using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using PTMedicalInsurance.Common; using PTMedicalInsurance.Helper; using PTMedicalInsurance.FormSetter; using PTMedicalInsurance.Business; using PTMedicalInsurance.Variables; using System.IO; using Newtonsoft.Json.Linq; using Newtonsoft.Json; using GMCrypto.Lib; namespace PTMedicalInsurance.Forms { /// /// 南昌双通道备案申请、查询和撤销 /// 查询时支持查询本地申请记录(用于撤销或查看历史)、查询中心记录并显示结果 /// 本地表结构与中心做了格式转换,用于表格显示 /// public partial class DualChannelRecordForm : Form { //设置业务实例 HisMainBusiness hBus = new HisMainBusiness(); MIIrisServices mIS = new MIIrisServices(); InvokeHelper invoker = new InvokeHelper(); public bool LocalQueryMode = true; private JObject joBasicInfo = null; DataTable dtApplyDrug = null; public DualChannelRecordForm() { InitializeComponent(); //asc.controllInitializeSize(this); //asc.controlAutoSize(this); this.StartPosition = FormStartPosition.CenterScreen; GridViewSetter grdSetter = new GridViewSetter(); grdSetter.SetHeaderTextOfChannelBasicInfo(dgv_BasicInfo); grdSetter.DatagridviewColumnWidthAdaptation(dgv_BasicInfo); grdSetter.SetHeaderTextOfChannelInsuInfo(dgv_DrugApply); grdSetter.DatagridviewColumnWidthAdaptation(dgv_DrugApply); grdSetter.SetHeaderTextOfChannelInsuInfo(dgv_DrugInfo); grdSetter.DatagridviewColumnWidthAdaptation(dgv_DrugInfo); grdSetter.SetHeaderTextOfChannelOrgInfo(dgv_OrgInfo); grdSetter.DatagridviewColumnWidthAdaptation(dgv_OrgInfo); } private void btnClose_Click(object sender, EventArgs e) { Close(); } private void DualChannelRecordForm_Load(object sender, EventArgs e) { this.Height = 600; this.Width = 1200; //asc.controllInitializeSize(this); //asc.controlAutoSize(this); } private void btnPresUpload_Click(object sender, EventArgs e) { if (joBasicInfo == null) { MessageBox.Show("请先读卡获取基本信息"); return; } if(dtApplyDrug == null || dtApplyDrug.Rows.Count < 1) { MessageBox.Show("请先增加药品信息"); return; } // 调用申请 string errMsg = string.Empty; JObject joRtn = invoker.invokeCenterService(TradeEnum.DualChannelApply, GetApplyParam()); if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg)!=0) { MessageBox.Show("申请失败:" + errMsg); return; } // 保存申请记录 if (SaveApply(joRtn)) { MessageBox.Show("申请成功!"); } } private JObject GetApplyParam() { JArray jaDrugs = new JArray(); foreach (DataRow row in dtApplyDrug.Rows) { dynamic obj = new JObject(); obj.med_list_codg = row["med_list_codg"].ToString(); obj.med_list_name = row["med_list_name"].ToString(); jaDrugs.Add(obj); } dynamic joOrg = new JObject(); joOrg.fixmedins_code = Global.inf.hospitalNO; joOrg.fixmedins_name = Global.inf.hospitalName; joOrg.poolarea_no = Global.inf.areaCode; if (joBasicInfo != null) { joBasicInfo["appy_type"] = "32"; joBasicInfo["begndate"] = dtpStart.Value.ToString("yyyy-MM-dd"); joBasicInfo["enddate"] = dtpEnd.Value.ToString("yyyy-MM-dd"); joBasicInfo["addr"] = txtAddress.Text.Trim(); joBasicInfo["cond_abst"] = txtDiag.Text.Trim(); } dynamic joInput = new JObject(); joInput.data = joBasicInfo; joInput.twopathdruglist = jaDrugs; joInput.twopathfixmedins = new JArray() { joOrg }; return joInput; } private bool SaveApply(JObject joRtn) { string errorMessage = string.Empty; string dcla = joRtn["two_path_reg_sn"].ToString(); JObject joParams = GetApplyParam(); // 兼容通用备案 JObject joInput = (JObject)joParams["data"].DeepClone(); joInput["trt_dcla_detl_sn"] = dcla; joInput["transCode"] = TradeEnum.DualChannelApply.GetCode(); joInput["transDesc"] = TradeEnum.DualChannelApply.GetName(); joInput["cond_abst_diag"] = joInput["cond_abst"]; joInput["cond_abst"].Remove(); joInput["drugs"] = joParams["twopathdruglist"]; joInput["fixmedins"] = joParams["twopathfixmedins"]; joInput["iresult"] = "0"; joInput["HospitalDr"] = Global.inf.hospitalDr; string outparam = string.Empty; int status = mIS.SaveReferralRecord(joInput, out outparam); if (status != 0) { MessageBox.Show("保存失败:" + outparam); return false; } return true; } private void btnReadCard_Click(object sender, EventArgs e) { CallResult ret = new ReadCardProcess().Process(new JObject()); if (ret.Success) { string outparam = string.Empty; string patInfo = ret.PureData?.ToString(); hBus.convertPatientInfo(patInfo, out outparam); if (string.IsNullOrEmpty(outparam)) { JObject joRtn = JObject.Parse(outparam); this.joBasicInfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.baseinfo")); joBasicInfo["emp_no"] = JsonHelper.getDestValue(joRtn, "selectedInsuInfo.emp_no"); joBasicInfo["emp_name"] = JsonHelper.getDestValue(joRtn, "selectedInsuInfo.emp_name"); joBasicInfo["insutype"] = JsonHelper.getDestValue(joRtn, "selectedInsuInfo.insutype"); txt_PsnName.Text = joBasicInfo["psn_name"].Text(); txtPsnNO.Text = joBasicInfo["psn_no"].Text(); txtInsuType.Text = joBasicInfo["insutype"].Text(); txtCertType.Text = joBasicInfo["psn_cert_type"].Text(); txtCertNo.Text = joBasicInfo["certno"].Text(); txtBirth.Text = joBasicInfo["brdy"].Text(); txtSex.Text = joBasicInfo["gend"].Text(); txtNation.Text = joBasicInfo["naty"].Text(); txtUnitNo.Text = joBasicInfo["emp_no"].Text(); txtUnitName.Text = joBasicInfo["emp_name"].Text(); } } else { MessageBox.Show(ret.Data); } } private void tc_Main_TabIndexChanged(object sender, EventArgs e) { } private void btnQuery_Click(object sender, EventArgs e) { if (this.joBasicInfo == null) { MessageBox.Show("请先读卡获取基本信息"); return; } dynamic joParam = new JObject(); JObject joRtn = new JObject(); string errMsg = string.Empty; JArray jaDrugs = new JArray(); JArray jaOrgs = new JArray(); JArray jaBasic = new JArray(); // 查询本院 if (LocalQueryMode) { joParam = new JObject(); joParam["CardID"] = joBasicInfo["certno"]; joParam["TransCode"] = TradeEnum.DualChannelApply.GetCode(); int status = mIS.QueryReferralRecord(joParam, out errMsg); if (status != 0) { MessageBox.Show("没有查询到申请记录!"); return; } joRtn = JObject.Parse(errMsg); jaBasic = JArray.Parse(joRtn["result"].Text()); } else { dynamic joInput = new JObject(); joParam.psn_no = this.joBasicInfo["psn_no"].Text(); joParam.begndate = dtpStart.Value.ToString("yyyy-MM-dd"); ; joParam.enddate = dtpEnd.Value.ToString("yyyy-MM-dd"); joInput.data = joParam; //查询中心 joRtn = invoker.invokeCenterService(TradeEnum.DualChannelQuery, joInput); if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0) { MessageBox.Show("查询失败:" + errMsg); return; } JObject joBasic = JObject.Parse(joRtn["result"].Text()); jaDrugs = JArray.Parse(joRtn["twopathdruglist"].Text()); jaOrgs = JArray.Parse(joRtn["twopathfixmedins"].Text()); // 转换为本地格式 jaBasic["PsnNo"] = jaBasic["psn_no"]; jaBasic["Name"] = jaBasic["psn_name"]; jaBasic["CardID"] = jaBasic["certno"]; jaBasic["CreateDate"] = jaBasic["apply_date"]; jaBasic["BegnDate"] = jaBasic["begndate"]; jaBasic["EndDate"] = jaBasic["enddate"]; jaBasic["iResult"] = "0"; jaBasic["begndate"].Remove(); jaBasic["enddate"].Remove(); jaBasic = new JArray() { joBasic }; jaDrugs.ToList().ForEach(drug => { drug["InsuCode"] = drug["med_list_codg"]; drug["InsuName"] = drug["med_list_name"]; }); jaOrgs.ToList().ForEach(org => { org["Code"] = org["fixmedins_code"]; org["Name"] = org["fixmedins_name"]; org["InsuranceArea"] = org["poolarea_no"]; }); } DataTable dtBasic = jaBasic.ToObject(); DataTable dtDrugs = jaDrugs.ToObject(); DataTable dtOrgs = jaOrgs.ToObject(); dgv_BasicInfo.DataSource = dtBasic; dgv_DrugInfo.DataSource = dtDrugs; dgv_OrgInfo.DataSource = dtOrgs; } private void btnCancel_Click(object sender, EventArgs e) { if (dgv_BasicInfo.SelectedIndex == -1) { MessageBox.Show("请先选择申请记录!"); return; } DataGridViewRow row = dgv_BasicInfo.Rows[dgv_BasicInfo.SelectedIndex]; string trt_id = row.Cells["InsuSerNo"].Value.ToString(); dynamic joInput = new JObject(); dynamic joParam = new JObject(); joParam.two_path_reg_sn_list = new List() { trt_id }; joInput.data = joParam; string errMsg = string.Empty; JObject joRtn = invoker.invokeCenterService(TradeEnum.DualChannelCancel, joInput); if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0) { MessageBox.Show("撤销失败:" + errMsg); return; } //修改iris状态 joParam = new JObject(); joParam["ID"] = row.Cells["ID"].Value; joParam["trtDclaDetlSn"] = trt_id; int status = mIS.CancelReferralRecord(joParam, out errMsg); if (status != 0) { MessageBox.Show("没有查询到申请记录!"); return; } MessageBox.Show("撤销成功!"); } } }