/****************************************************************************** * 文件名称: HisMainBusiness.cs * 文件说明: HIS主体交易的封装 * 当前版本: V1.0 * 创建日期: 2022-06-20 * * * 2020-06-20: 增加 HisMainBusiness 类 * ***** 2020-06-20: 增加 CardReader 方法,获取URL地址,USER信息,地方版SSCard.dll使用 * ***** 2020-06-20: 增加 CardReader 方法重载,国家版电子凭证使用 * ***** 2020-06-20: 增加 Init 方法,SSCard环境初始化 * ***** 2020-06-20: 增加 ReadCardBas 方法,读社保卡 * ***** 2020-06-20: 增加 VerifyPIN 方法,验证密码 * ***** 2020-06-20: 增加 ChangePIN 方法,修改密码 * ***** 2020-06-20: 增加 ReadSFZ 方法,读身份证 * ***** 2020-06-20: 增加 GetQRBase 方法,读二维码 * ***** 2020-06-20: 增加 NationEcTrans 方法,读电子凭证(国家版) ******************************************************************************/ using System; using System.Windows.Forms; using Newtonsoft.Json.Linq; using PTMedicalInsurance.Common; using PTMedicalInsurance.Helper; using PTMedicalInsurance.Variables; using PTMedicalInsurance.Forms; using System.Data; using Org.BouncyCastle.Utilities.Encoders; namespace PTMedicalInsurance.Business { class HisMainBusiness { private InvokeHelper invoker = new InvokeHelper(); private HisIrisServices hIS = new HisIrisServices(); private MIIrisServices mIS = new MIIrisServices(); private CenterBusiness cBus = new CenterBusiness(); /// /// 获取HIS的IRIS配置信息 /// /// public void getHisConfingue(out IrisConfigue con) { IniFile ini = new IniFile(Global.curEvt.path + @"\INSUConfigure.ini"); con.ip = ini.ReadValue("HIS", "ip"); con.url = ini.ReadValue("HIS", "url"); con.authorization = ini.ReadValue("HIS", "authorization"); } /// /// 获取医保平台的iris配置信息 /// /// public void getInsuConfingue(out IrisConfigue con) { IniFile ini = new IniFile(Global.curEvt.path + @"\INSUConfigure.ini"); con.ip = ini.ReadValue("INSU", "ip"); con.url = ini.ReadValue("INSU", "url"); con.authorization = ini.ReadValue("INSU", "authorization"); } public void getLocalConfingue() { IniFile ini = new IniFile(Global.curEvt.path + @"\INSUConfigure.ini"); Global.curEvt.ext.isOpenAnalysis = (ini.ReadValue("PreAndInProcessAnalysis", "isOpenAnalysis") == "1"); Global.curEvt.ext.centerMode = ini.ReadValue("YB", "mode"); } /// /// 获取主目录 /// public void getMainInterface() { string errMsg; Global.inf.mainInterfaceDr = Global.inf.interfaceDr; JObject joRtn = mIS.getInterface(Global.inf.interfaceDr.ToString()); string specialInterfaceDr = JsonHelper.getDestValue(joRtn, "InsuCurrencyCataLogue"); if (!string.IsNullOrEmpty(specialInterfaceDr)) { Global.inf.mainInterfaceDr = int.Parse(specialInterfaceDr); } else { joRtn = mIS.getMainInterface(Global.inf.interfaceDr.ToString()); if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0) { return; } string mainInterfaceDr = JsonHelper.getDestValue(joRtn, "result.data[0].MainInterfaceDr"); if (!string.IsNullOrEmpty(mainInterfaceDr)) { Global.inf.mainInterfaceDr = int.Parse(mainInterfaceDr); return; } } } /// /// 获取Session信息(目前只获取操作员信息) /// /// public void getSessionInfo(JObject joSession) { if (string.IsNullOrEmpty(Global.user.ID)) { Global.user.ID = JsonHelper.getDestValue(joSession, "userCode"); } Global.user.name = JsonHelper.getDestValue(joSession, "userName"); Global.user.type = "1"; } /// /// 根据壳程序传入的入参设置全局接口变量 /// /// /// public void setGlobalInterface(JObject joInpar,out InterfaceInfo inf) { inf = new InterfaceInfo(); inf.hospitalDr = int.Parse(JsonHelper.getDestValue(joInpar, "HospitalDr")); inf.hisHospitalDr = int.Parse(JsonHelper.getDestValue(joInpar, "hisHospitalDr")); inf.hospitalName = JsonHelper.getDestValue(joInpar, "HospitalName"); inf.interfaceDr = int.Parse(JsonHelper.getDestValue(joInpar, "ID")); inf.interfaceID = JsonHelper.getDestValue(joInpar, "InterfaceID"); //inf.oper = "3"; inf.centerURL = JsonHelper.getDestValue(joInpar, "CenterURL"); inf.areaCode = JsonHelper.getDestValue(joInpar, "AreaCode"); inf.dllName = JsonHelper.getDestValue(joInpar, "DLLName"); inf.hospitalNO = JsonHelper.getDestValue(joInpar, "HospitalNO"); inf.version = "v1.0"; inf.signatureType = "SM2"; inf.recivedSystem = "YBXT"; //inf.AK = "583ebd87f99f4be19a6c425d5ecb89fc"; //inf.SK = "m9pKPKPnlfMcpJNtSjtvRCN2Rgg="; inf.dev_safe_info = ""; inf.dev_no = Global.curEvt.mac; inf.cardURL = inf.centerURL; inf.ecURL = "http://ec.yn.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"; inf.centerURL2 = JsonHelper.getDestValue(joInpar, "CenterURL2"); byte[] b = Base64.Decode(inf.centerURL2); string centerURL2 = System.Text.Encoding.UTF8.GetString(b); JObject joCenterURL2 = JObject.Parse(centerURL2); inf.MobilePay.url = JsonHelper.getDestValue(joCenterURL2, "mobilePayURL"); inf.MobilePay.appid = JsonHelper.getDestValue(joCenterURL2, "mobilePayAppId"); inf.MobilePay.secretKey = JsonHelper.getDestValue(joCenterURL2, "mobilePaySecretKey"); inf.MobilePay.privateKey = JsonHelper.getDestValue(joCenterURL2, "mobilePayPrivateKey"); inf.MobilePay.publicKey = JsonHelper.getDestValue(joCenterURL2, "mobilePayPublicKey"); inf.PresCir.url = JsonHelper.getDestValue(joCenterURL2, "presCirURL"); inf.PresCir.appid = JsonHelper.getDestValue(joCenterURL2, "presCirAppId"); inf.PresCir.secretKey = JsonHelper.getDestValue(joCenterURL2, "presCirSecretKey"); inf.PresCir.privateKey = JsonHelper.getDestValue(joCenterURL2, "presCirPrivateKey"); inf.PresCir.publicKey = JsonHelper.getDestValue(joCenterURL2, "presCirPublicKey"); inf.cainfo = ""; } /// /// 根据壳程序传入的入参设置全局接口变量 /// /// /// public void setGlobalInterface_Plat(JObject joInpar, out InterfaceInfo inf) { inf = new InterfaceInfo(); inf.hospitalDr = int.Parse(JsonHelper.getDestValue(joInpar, "hospitalID")); inf.hisHospitalDr = int.Parse(JsonHelper.getDestValue(joInpar, "hisHospitalDr")); inf.hospitalName = JsonHelper.getDestValue(joInpar, "hospitalName"); inf.interfaceDr = int.Parse(JsonHelper.getDestValue(joInpar, "medInsuInterfaceID")); inf.interfaceID = JsonHelper.getDestValue(joInpar, "interfaceNO"); //inf.oper = "3"; inf.centerURL = JsonHelper.getDestValue(joInpar, "centerURL"); inf.areaCode = JsonHelper.getDestValue(joInpar, "areaCode"); inf.dllName = JsonHelper.getDestValue(joInpar, "dLLName"); inf.hospitalNO = JsonHelper.getDestValue(joInpar, "hospitalNO"); inf.version = "v1.0"; inf.signatureType = "SM2"; inf.recivedSystem = "YBXT"; //inf.AK = "583ebd87f99f4be19a6c425d5ecb89fc"; //inf.SK = "m9pKPKPnlfMcpJNtSjtvRCN2Rgg="; inf.dev_safe_info = ""; inf.dev_no = Global.curEvt.mac; inf.cardURL = inf.centerURL; //inf.ecURL = "http://ec.yn.hsip.gov.cn/localcfc/api/hsecfc/localQrCodeQuery"; inf.centerURL2 = JsonHelper.getDestValue(joInpar, "centerURL2"); byte[] b = Base64.Decode(inf.centerURL2); string centerURL2 = System.Text.Encoding.UTF8.GetString(b); JObject joCenterURL2 = JObject.Parse(centerURL2); inf.MobilePay.url = JsonHelper.getDestValue(joCenterURL2, "mobilePayURL"); inf.MobilePay.appid = JsonHelper.getDestValue(joCenterURL2, "mobilePayAppId"); inf.MobilePay.secretKey = JsonHelper.getDestValue(joCenterURL2, "mobilePaySecretKey"); inf.MobilePay.privateKey = JsonHelper.getDestValue(joCenterURL2, "mobilePayPrivateKey"); inf.MobilePay.publicKey = JsonHelper.getDestValue(joCenterURL2, "mobilePayPublicKey"); inf.PresCir.url = JsonHelper.getDestValue(joCenterURL2, "presCirURL"); inf.PresCir.appid = JsonHelper.getDestValue(joCenterURL2, "presCirAppId"); inf.PresCir.secretKey = JsonHelper.getDestValue(joCenterURL2, "presCirSecretKey"); inf.PresCir.privateKey = JsonHelper.getDestValue(joCenterURL2, "presCirPrivateKey"); inf.PresCir.publicKey = JsonHelper.getDestValue(joCenterURL2, "presCirPublicKey"); inf.cainfo = ""; } /// /// 初始化环境 /// /// /// public int initEnvironment(string inParam,out string error) { error = string.Empty; try { //获取HIS和医保平台的IRIS配置信息 getHisConfingue(out Global.hisConfig); getInsuConfingue(out Global.insuConfig); getLocalConfingue(); JObject joInparam = JObject.Parse(inParam); JObject JoSession = JObject.Parse(JsonHelper.getDestValue(joInparam, "session[0]")); string hisHospitalDr = JsonHelper.getDestValue(JoSession, "hospID"); JObject joInterface = JObject.Parse(JsonHelper.getDestValue(joInparam, "interfaceinfo")); joInterface.Add("hisHospitalDr", hisHospitalDr); if (joInterface != null) { //获取当前接口详细信息 if (Global.businessType == "P1") { setGlobalInterface_Plat(joInterface, out Global.inf); } else { setGlobalInterface(joInterface, out Global.inf); } JObject joSession = JObject.Parse(JsonHelper.getDestValue(joInparam, "session[0]")); if (joSession != null) { //获取当前用户信息 getSessionInfo(joSession); //获取主目录 getMainInterface(); return 0; } else { error = "初始化环境失败:session获取失败!"; return -1; } } else { error = "初始化环境失败:interfaceinfo获取失败!"; return -1; } } catch (Exception ex) { error ="初始化环境失败:" + ex.Message; return -1; } } /// /// 读卡 /// /// public int readCard(out string outParam) { outParam = ""; JObject joInput = new JObject(); try { STA sta = new STA(); object[] o = new object[2]; sta.ReadCard(o); if (int.Parse(o[0].ToString()) != 0) { outParam = o[1].ToString(); return -1; } else { if (Global.pat.isWorkInjury) { if (trade1101(out outParam) != 0) { return -1; } else { JObject joRtn = JObject.Parse(outParam); Global.pat.psn_no = JsonHelper.getDestValue(joRtn, "output.baseinfo.psn_no"); if (tradeQ002(out outParam) != 0) { return -1; } else { joRtn["output"]["workinjury"] = new JArray(); joRtn["output"]["workinjury"] = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "output.gsxx")); outParam = joRtn.ToString(); return 0; } } } else { return this.trade1101(out outParam); } } } catch (Exception ex) { outParam = "异常:" + ex.Message; return -1; } } private int trade1101(out string outParam) { outParam = ""; string errorMsg = ""; JObject joInput = new JObject(); JObject joRtn = new JObject(); #region【1101获取身份信息】 JObject joData = new JObject(); joData.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); joData.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); joData.Add("card_sn", Global.pat.card.SN); //开始时间 if (string.IsNullOrEmpty(Global.pat.begntime)) { Global.pat.begntime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } joData.Add("begntime", Global.pat.begntime); joData.Add("psn_cert_type", Global.pat.certType); joData.Add("certno", Global.pat.certNO); //证件号码 joData.Add("psn_name", Global.pat.name); joInput.Add("data", joData); joRtn = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", joInput)); if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0) { outParam = "获取病人信息失败:" + errorMsg; return -1; } else { //joRtn.Add("cardinfo",joCardInfo); outParam = joRtn.ToString(); Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo[0].insuplc_admdvs"); //参保地 return 0; } #endregion } private int tradeQ002(out string outParam) { outParam = ""; string errorMsg = ""; JObject joInput = new JObject(); JObject joRtn = new JObject(); JObject joData = new JObject(); joData.Add("psn_no", Global.pat.psn_no); joInput.Add("data", joData); joRtn = invoker.invokeCenterService("Q002", JsonHelper.setCenterInpar("Q002", joInput)); if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0) { outParam = "获取病人信息失败:" + errorMsg; return -1; } else { outParam = joRtn.ToString(); return 0; } } /// /// 展示患者信息界面,转换相关编码为中文,并获取操作员选中的信息 /// /// /// /// public int showPatInfo(String patInfo,out string outParam) { try { STA sta = new STA(); object[] o = new object[3]; o[0] = 0; o[1] = patInfo; sta.showPatInfo(o); outParam = o[2].ToString(); return (int)o[0]; } catch (Exception ex) { outParam = "异常:" + ex.Message; return -1; } } /// /// 患者读卡并获取中心信息(1101)后设置PAT结构体 /// /// /// /// public int setGlobalPatAfaterShowPatInfo(string patInfo,out string errMsg) { JObject joPatInfo; errMsg = ""; try { joPatInfo = JObject.Parse(patInfo); //基本信息 Global.pat.certNO = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.certno"); Global.pat.psn_no = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.psn_no"); Global.pat.gend = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.gend"); Global.pat.brdy = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.brdy"); Global.pat.naty = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.naty"); Global.pat.age = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.age"); Global.pat.certType = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.psn_cert_type"); //if (Global.pat.name != JsonHelper.getDestValue(joPatInfo, "output.baseinfo.psn_name")) //{ // errMsg = "患者姓名(" + Global.pat.name + ")与参保人姓名(" + JsonHelper.getDestValue(joPatInfo, "output.baseinfo.psn_name") + ")不一致,请检查!"; // return -1; //} Global.pat.name = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.psn_name"); //选中的参保信息 Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.insuplc_admdvs"); Global.pat.psn_insu_date = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.psn_insu_date"); Global.pat.cvlserv_flag = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.cvlserv_flag"); Global.pat.balc = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.balc"); Global.pat.emp_name = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.emp_name"); Global.pat.psn_type = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.psn_type"); Global.pat.psn_insu_stas = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.psn_insu_stas"); Global.pat.insuType = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.insutype"); Global.pat.paus_insu_date = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.paus_insu_date"); //卡片信息 //Global.pat.cardSN = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.paus_insu_date"); //选中的身份信息 return 0; } catch (Exception ex) { errMsg = "获取患者信息发生异常:" + ex.Message; return -1; } } /// /// 校验HIS信息与医保参保信息姓名是否一致 /// /// /// /// public int checkName(string insuName, out string errMsg) { try { errMsg = ""; string hisPatBaseInfo = ""; if (hIS.GetHisPatBaseInfo(out hisPatBaseInfo) != 0) { errMsg = hisPatBaseInfo; return -1; } string hisPatName = JsonHelper.getDestValue(JObject.Parse(hisPatBaseInfo), "result.patName"); if (hisPatName != insuName) { errMsg = "患者姓名(" + hisPatName + ")与参保人姓名(" + insuName + ")不一致,请检查!"; return -1; } else { return 0; } } catch (Exception ex) { errMsg = "核对HIS与医保平台姓名一致性发生异常:" + ex.Message; return -1; } } /// /// 显示住院患者登记面板,返回登记入参 /// /// /// public int showInPatRegisterForm(out string regInfo) { regInfo = ""; try { STA sta = new STA(); object[] o = new object[2]; sta.showInPatRegisterForm(o); regInfo = o[1].ToString(); return (int)o[0]; } catch (Exception ex) { regInfo = "异常:" + ex.Message; return -1; } } /// /// 显示出院登记界面,返回出院登记和结算的入参 /// /// /// /// public int showDischargeRegisterForm(string funNO, JObject joSumFee, JObject joHisRtnInfo, out string outParam) { outParam = ""; try { JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joHisRtnInfo, "diseinfo")); //选择结算方式等 OutpatientRegistration frmReg = new OutpatientRegistration(); frmReg.dblkcbxInsuranceType.Enabled = true; DataTable dt = (DataTable)frmReg.dblkcbxInsuranceType.DataSource; int selectedIndex = 0; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["Code"].ToString() == Global.pat.insuType) { selectedIndex = i; frmReg.dblkcbxInsuranceType.Text = dt.Rows[i]["Name"].ToString(); frmReg.insuType = dt.Rows[i]["Code"].ToString(); } } dt = (DataTable)frmReg.dblkcbxMedicalType.DataSource; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["Code"].ToString() == Global.pat.medType) { frmReg.dblkcbxMedicalType.Text = dt.Rows[i]["Name"].ToString(); frmReg.med_type = dt.Rows[i]["Code"].ToString(); } } if (Global.pat.RYorCY == "1") { DataTable dtMedType = (DataTable)frmReg.dblkcbxMedicalType.DataSource; for (int i = 0; i < dtMedType.Rows.Count; i++) { if (dtMedType.Rows[i]["Code"].ToString() == "21") { frmReg.dblkcbxMedicalType.Text = dtMedType.Rows[i]["Name"].ToString(); frmReg.med_type = dtMedType.Rows[i]["Code"].ToString(); } } } DataTable dtSettlWay = (DataTable)frmReg.dblkcbxSettelmentWay.DataSource; for (int i = 0; i < dtSettlWay.Rows.Count; i++) { if (dtSettlWay.Rows[i]["Code"].ToString() == "01") { frmReg.dblkcbxSettelmentWay.Text = dtSettlWay.Rows[i]["Name"].ToString(); frmReg.psn_setlway = dtSettlWay.Rows[i]["Code"].ToString(); } } DataTable DTdiseCodg = (DataTable)frmReg.dblkcbxDisease.DataSource; for (int i = 0; i < DTdiseCodg.Rows.Count; i++) { if (DTdiseCodg.Rows[i]["Code"].ToString() == Global.pat.DiseasecCode) { frmReg.dblkcbxDisease.Text = DTdiseCodg.Rows[i]["Name"].ToString(); frmReg.diseCodg = DTdiseCodg.Rows[i]["Code"].ToString(); } } if (frmReg.dblkcbxInsuranceType.Text != "") frmReg.dblkcbxInsuranceType.Enabled = false; if (frmReg.dblkcbxMedicalType.Text != "") frmReg.dblkcbxMedicalType.Enabled = false; //if (frmReg.dblkcbxDisease.Text != "") // frmReg.dblkcbxDisease.Enabled = false; // 对诊断数组进行转换 转换下主要诊断 JArray jaConvertedDiagnoses = new JArray(); string dscg_maindiag_code = "", dscg_maindiag_name = ""; for (int i = 0; i < jaDiagnoses.Count; i++) { string diag_type = JsonHelper.getDestValue((JObject)jaDiagnoses[i], "diag_type"); switch (diag_type) { case "1": { jaDiagnoses[i]["diag_type_name"] = new JObject(); jaDiagnoses[i]["diag_type_name"] = "西医主要诊断"; break; } case "2": { jaDiagnoses[i]["diag_type_name"] = new JObject(); jaDiagnoses[i]["diag_type_name"] = "西医其他诊断"; break; } case "3": { jaDiagnoses[i]["diag_type_name"] = new JObject(); jaDiagnoses[i]["diag_type_name"] = "中医主病诊断"; break; } case "4": { jaDiagnoses[i]["diag_type_name"] = new JObject(); jaDiagnoses[i]["diag_type_name"] = "中医主证诊断"; break; } } if (jaDiagnoses[i]["diaTypeCode"].ToString() == "DIS") //出院 { jaConvertedDiagnoses.Add(jaDiagnoses[i]); } } if (jaConvertedDiagnoses.Count == 0) { //outParam = "出院诊断为空!"; //return -1; for (int i = 0; i < jaDiagnoses.Count; i++) { if (jaDiagnoses[i]["diaTypeCode"].ToString() == "ADD") //出院 { jaConvertedDiagnoses.Add(jaDiagnoses[i]); } } } for (int i = 0; i < jaConvertedDiagnoses.Count; i++) { jaConvertedDiagnoses[i]["diag_srt_no"] = i + 1; if (jaConvertedDiagnoses[i]["maindiag_flag"].ToString() == "1") { dscg_maindiag_code = jaConvertedDiagnoses[i]["diag_code"].ToString(); dscg_maindiag_name = jaConvertedDiagnoses[i]["diag_name"].ToString(); } //增加就诊ID jaConvertedDiagnoses[i]["mdtrt_id"] = new JObject(); jaConvertedDiagnoses[i]["mdtrt_id"] = Global.pat.mdtrtID; } //出院登记扩展字段值解析,弹框展示 if ((Global.pat.ExpContent != "") && (Global.pat.RYorCY == "2")) { //JObject ExpContentObj = JObject.Parse(Global.pat.ExpContent); //frmReg.claTrtFlag = JsonHelper.getDestValue(ExpContentObj, "cla_trt_flag"); //frmReg.unifPayStdType = JsonHelper.getDestValue(ExpContentObj, "unif_pay_std_type"); //frmReg.traumaFlag = JsonHelper.getDestValue(ExpContentObj, "trum_flag"); //frmReg.iptTypeCode = JsonHelper.getDestValue(ExpContentObj, "ipt_type"); //frmReg.relTtpFlag = JsonHelper.getDestValue(ExpContentObj, "rel_ttp_flag"); //frmReg.mdtrtGrpType = JsonHelper.getDestValue(ExpContentObj, "mdtrt_grp_type"); if (frmReg.claTrtFlag == "1") frmReg.chk_claTrtFlag.Checked = true; if (frmReg.traumaFlag == "1") frmReg.Chk_TraumaFlag.Checked = true; if (frmReg.relTtpFlag == "1") frmReg.Chk_RelTtpFlag.Checked = true; } frmReg.DtDiagnose = (DataTable)jaConvertedDiagnoses.ToObject(typeof(DataTable)); if (frmReg.ShowDialog() == DialogResult.OK) { string diseCodg = "", diseName = ""; //哈尔滨要求必须传病种。普通疾病传主诊断 if (string.IsNullOrEmpty(frmReg.diseCodg)) { diseCodg = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_code"); }; if (string.IsNullOrEmpty(frmReg.diseName)) { diseName = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_name"); }; //出院登记入参 //单病种出院登记 病种信息取入院登记入参 if (Global.pat.RYorCY == "2") { // 单病种? if (Global.pat.medType == "26") { diseCodg = Global.pat.DiseasecCode; diseName = Global.pat.DiseasecName; } else { frmReg.insuType = Global.pat.insuType; } } //JObject ExportObj = new JObject(); ////出院登记扩展参数用入院登记时保存的 //if ((Global.pat.ExpContent != "") && (Global.pat.RYorCY == "2")) //{ // ExportObj = JObject.Parse(Global.pat.ExpContent); //} //else //{ // ExportObj.Add("sin_dise_codg", ""); //单病种编码 // ExportObj.Add("cla_trt_flag", frmReg.claTrtFlag); //分级诊疗标志 // ExportObj.Add("unif_pay_std_typ", frmReg.unifPayStdType); //包干标准类型 // ExportObj.Add("bydise_setl_disediag_codg", ""); //按病种付费疾病诊断代码 // ExportObj.Add("bydise_setl_oprn_oprt_code", ""); //按病种付费手册操作代码 // ExportObj.Add("trum_flag", frmReg.traumaFlag); //外伤标志 // ExportObj.Add("medcasno", ""); //病案号 // ExportObj.Add("ipt_type", frmReg.iptTypeCode); //住院类型 // ExportObj.Add("rel_ttp_flag", frmReg.relTtpFlag); //涉及第三方标志 // ExportObj.Add("mdtrt_grp_type", frmReg.mdtrtGrpType); //就诊人群类型 //} JObject joDscgInfo = new JObject(); joDscgInfo.Add("mdtrt_id", Global.pat.mdtrtID); joDscgInfo.Add("psn_no", Global.pat.psn_no); //人员编号 joDscgInfo.Add("insutype", frmReg.insuType); //险种类型 //joDscgInfo.Add("coner_name", JsonHelper.getJsonValue(joHisPatInfo, "coner_name")); //联系人姓名 //joDscgInfo.Add("tel", JsonHelper.getJsonValue(joHisPatInfo, "tel")); //联系电话 joDscgInfo.Add("endtime", Global.pat.hisDischargeTime); //结束时间DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") joDscgInfo.Add("dise_codg", diseCodg); //病种编码 joDscgInfo.Add("dise_name", diseName); //病种名称 joDscgInfo.Add("oprn_oprt_code", frmReg.oprn_oprt_code); //手术操作代码 joDscgInfo.Add("oprn_oprt_name", frmReg.oprn_oprt_name); //手术操作名称 joDscgInfo.Add("fpsc_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fpsc_no")); //计划生育服务证号 joDscgInfo.Add("matn_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.matn_type")); //生育类别 joDscgInfo.Add("birctrl_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_type")); //计划生育手术类别 joDscgInfo.Add("latechb_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.latechb_flag")); //晚育标志 //joDscgInfo.Add("geso_val", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.geso_val")); //孕周数 //joDscgInfo.Add("fetts", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fetts")); //胎次 //joDscgInfo.Add("fetus_cnt", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fetus_cnt")); //胎儿数 joDscgInfo.Add("pret_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.pret_flag")); //早产标志 //joDscgInfo.Add("birctrl_matn_date", ""); //计划生育手术或生育日期 JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_matn_date") 20230228医保中心校验传正确时间或空 joDscgInfo.Add("cop_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dise_type_code")); //伴有并发症标志 joDscgInfo.Add("dscg_dept_codg", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_codg")); //出院科室编码 joDscgInfo.Add("dscg_dept_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name")); //出院科室名称 joDscgInfo.Add("dscg_bed", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_bed")); //出院床位 joDscgInfo.Add("dscg_way", "1"); //离院方式 //joDscgInfo.Add("die_date", ""); //死亡日期 //joDscgInfo.Add("exp_content", ExportObj); //字段扩展 joDscgInfo.Add("insuplc_admdvs", Global.pat.insuplc_admdvs); //参保地医保区划 joDscgInfo.Add("mdtrtarea_admvs", Global.inf.areaCode); //就医地医保区划 JObject joRegInpar = new JObject(); joRegInpar.Add("dscginfo", joDscgInfo); joRegInpar.Add("diseinfo", jaConvertedDiagnoses); //结算入参 JObject joSetlInpar = new JObject(); joSetlInpar.Add("psn_no", Global.pat.psn_no); joSetlInpar.Add("chrg_bchno", Global.pat.adm_Dr.ToString()); joSetlInpar.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); joSetlInpar.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); joSetlInpar.Add("med_type", Global.pat.medType); joSetlInpar.Add("medfee_sumamt", JsonHelper.getDestValue(joSumFee, "data.Sumamt")); joSetlInpar.Add("psn_setlway", frmReg.psn_setlway); //结算方式 joSetlInpar.Add("mdtrt_id", Global.pat.mdtrtID); joSetlInpar.Add("acct_used_flag", frmReg.personAccountUsedFlag);//个人账户使用标志 joSetlInpar.Add("insutype", frmReg.insuType);//险种类型 //joSetlInpar.Add("insuplc_admdvs", Global.pat.insuplc_admdvs); //joSetlInpar.Add("mdtrtarea_admvs", Global.inf.areaCode); joSetlInpar.Add("invono", ""); joSetlInpar.Add("mid_setl_flag", "0"); joSetlInpar.Add("fulamt_ownpay_amt", JsonHelper.getDestValue(joSumFee, "data.FullOwnPayAmount")); joSetlInpar.Add("overlmt_selfpay", JsonHelper.getDestValue(joSumFee, "data.OverLimitAmount")); joSetlInpar.Add("preselfpay_amt", JsonHelper.getDestValue(joSumFee, "data.PreSelfPayAmount")); joSetlInpar.Add("dscgTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); if (Global.pat.isWorkInjury) { joSetlInpar.Add("SpecialType", "GGS");//险种类型 } joSetlInpar.Add("minpacunt_drug_trac_cnt", Global.Set.minpacunt_drug_trac_cnt); //本次结算应上传最小包装追溯码数量 joSetlInpar.Add("mcs_trac_cnt", Global.Set.mcs_trac_cnt); //本次结算应上传耗材追溯码数量 //JObject joDataExp = new JObject(); //joDataExp.Add("acct_payamt", "0.00"); //joDataExp.Add("cla_trt_flag", ""); //joSetlInpar.Add("exp_content", joDataExp); //11111 JObject joOut = new JObject(); joOut.Add("DischargeRegister", joRegInpar); joOut.Add("Settlement", joSetlInpar); joOut.Add("errorCode", 0); outParam = joOut.ToString(); return 0; } else { outParam = "收款员取消结算"; return -1; } } catch (Exception ex) { outParam = "showDischargeRegisterForm 异常:" + ex.Message; return -1; } } public int showOutPatRegisterForm(out string regInfo) { regInfo = ""; try { STA sta = new STA(); object[] o = new object[2]; sta.showOutPatRegisterForm(o); regInfo = o[1].ToString(); return (int)o[0]; } catch (Exception ex) { regInfo = "异常:" + ex.Message; return -1; } } /// /// 上传费用到中心 /// /// /// public int uploadFee(string funNO, int singleCount, out string outParam) { outParam = ""; try { STA sta = new STA(); object[] o = new object[4]; o[0] = 0; o[1] = funNO; o[2] = singleCount; o[3] = ""; sta.uploadFee(o); outParam = o[3].ToString(); return (int)o[0]; } catch (Exception ex) { outParam = "uploadFee 异常:" + ex.Message; return -1; } } public int uploadFeeToCenter(string funNO,int singleCount,JArray jaFeeDetail, out string outParam) { outParam = ""; string errMsg; try { JArray jaTmp = new JArray(); for (int i = 0; i < jaFeeDetail.Count; i++) { jaFeeDetail[i]["chrg_bchno"] = Global.pat.adm_Dr.ToString(); jaFeeDetail[i]["med_type"] = Global.pat.medType; if (Global.pat.isWorkInjury) { jaFeeDetail[i]["dise_codg"] = new JObject(); jaFeeDetail[i]["dise_codg"] = Global.pat.disCode; } if (jaFeeDetail[i]["validFlag"].ToString() == "N") continue; jaTmp.Add(jaFeeDetail[i]); if (((i + 1) % singleCount == 0) || ((i + 1) == jaFeeDetail.Count)) { JObject joFeeDetail = new JObject(); joFeeDetail.Add("feedetail", jaTmp); JObject joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joFeeDetail.ToString())); if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0) { outParam = errMsg; return -1; } else { //成功后插入医保平台 if (mIS.insertFee(jaTmp, out errMsg) != 0) { outParam = outParam + errMsg; return -1; } //更新2301返回的数据 if (mIS.updateFee(JArray.Parse(JsonHelper.getDestValue(joRtn, "output.result")), out errMsg) != 0) { outParam = outParam + errMsg; return -1; } } jaTmp = new JArray(); } } return 0; } catch (Exception ex) { outParam = "uploadFee 异常:" + ex.Message; return -1; } } /// /// 获取登记时候传入的信息,并赋值给patients结构体 /// /// /// /// public void GetRegPatInfo(string businessType, JObject joInparam,out Patients pat) { pat = new Patients(); try { switch (businessType) { case "M2"://门诊登记 { break; } case "M2C"://门诊登记撤销 { break; } case "Z0"://住院修改 { break; } case "Z2"://入院登记 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID")); pat.psn_no = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.output.baseinfo.psn_no"); pat.insuType = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.selectedInsuInfo.insutype"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.selectedInsuInfo.insuplc_admdvs"); pat.mdtrtcertType = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.selectedInsuInfo.mdtrt_cert_type"); pat.mdtrtcertNO = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.selectedInsuInfo.mdtrt_cert_no"); pat.name = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.output.baseinfo.psn_name"); pat.psn_type = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.selectedInsuInfo.psn_type"); pat.certType = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.output.baseinfo.psn_cert_type"); pat.certNO = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.output.baseinfo.certno"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); pat.card.SN = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.cardinfo.card_sn"); break; } case "Z2C"://入院登记取消 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID")); pat.psn_no = JsonHelper.getDestValue(joInparam, "params[0].psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "params[0].mdtrt_id"); //pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "params[0].insuplc_admdvs"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); break; } case "Z6"://出院登记 { pat.hisDischargeTime = Convert.ToDateTime(JsonHelper.getDestValue(joInparam, "insuAdmObj.disDateTime")).ToString("yyyy-MM-dd HH:mm:ss"); break; } case "Z6C"://出院登记取消 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID")); pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); break; } default: { break; } } } catch (Exception ex) { Global.writeLog("GetRegPatInfo(" + businessType + ")", JsonHelper.Compress(joInparam),"PAT结构体设置异常:" + ex.Message); } } /// /// 获取费用上传时前端传入的信息,并赋值给patients结构体 /// /// /// /// public void GetFeeHisInfo(string businessType, JObject joInparam, out Patients pat) { pat = new Patients(); try { switch (businessType) { case "M3"://门诊费用上传 { break; } case "M3C"://门诊费用撤销 { break; } case "Z3"://入院费用上传 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID")); pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); pat.name = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_name"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); pat.recordID = ""; break; } case "Z3C"://住院费用上传取消 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID")); pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); break; } default: { break; } } //如果患者异地的则就医地需要该为369900 //if (Global.pat.insuplc_admdvs != "") //{ // if (Global.pat.insuplc_admdvs.Substring(0, 4) != Global.inf.areaCode.Substring(0, 4)) // { // Global.inf.areaCode = "369900"; // } //} } catch (Exception ex) { Global.writeLog("GetFeeHisInfo(" + businessType + ")", JsonHelper.Compress(joInparam), "PAT结构体设置异常:" + ex.Message); } } /// /// 获取结算时前端传入的信息,并赋值给patients结构体 /// /// /// /// public void GetSettlementHisInfo(string businessType, JObject joInparam, out Patients pat) { pat = new Patients(); switch (businessType) { case "M4"://门诊预结算 { break; } case "M4C"://门诊预结算撤销 { break; } case "M5"://门诊结算 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID")); pat.recordID = JsonHelper.getDestValue(joInparam, "params[0].recordID"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); Global.Set.minpacunt_drug_trac_cnt = JsonHelper.getDestValue(joInparam, "insuAdmObj.minpacunt_drug_trac_cnt"); Global.Set.mcs_trac_cnt = JsonHelper.getDestValue(joInparam, "insuAdmObj.mcs_trac_cnt"); Global.pat.insuplc_admdvs = ""; break; } case "M5C"://门诊结算撤销 { pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id"); pat.settlID = JsonHelper.getDestValue(joInparam, "insuAdmObj.setl_id"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID")); pat.recordID = JsonHelper.getDestValue(joInparam, "params[0].recordID"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); break; } case "Z4"://住院预结算 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID")); pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); pat.name = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_name"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); pat.hisDischargeTime = Convert.ToDateTime(JsonHelper.getDestValue(joInparam, "insuAdmObj.disDateTime")).ToString("yyyy-MM-dd HH:mm:ss"); break; } case "Z4C"://住院预结算撤销 { pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id"); pat.settlID = JsonHelper.getDestValue(joInparam, "insuAdmObj.setl_id"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID")); pat.recordID = JsonHelper.getDestValue(joInparam, "params[0].recordID"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); break; } case "Z5"://住院结算 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID")); pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); pat.name = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_name"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); pat.hisDischargeTime = Convert.ToDateTime(JsonHelper.getDestValue(joInparam, "insuAdmObj.disDateTime")).ToString("yyyy-MM-dd HH:mm:ss"); Global.Set.minpacunt_drug_trac_cnt = JsonHelper.getDestValue(joInparam, "insuAdmObj.minpacunt_drug_trac_cnt"); Global.Set.mcs_trac_cnt = JsonHelper.getDestValue(joInparam, "insuAdmObj.mcs_trac_cnt"); if (string.IsNullOrEmpty(JsonHelper.getDestValue(joInparam, "insuAdmObj.inDays"))) { Global.Set.hospitalizationsDays = 0; } else { Global.Set.hospitalizationsDays = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.inDays")); } if (string.IsNullOrEmpty(JsonHelper.getDestValue(joInparam, "insuAdmObj.inTimes"))) { Global.Set.hospitalizationsTimes = 0; } else { Global.Set.hospitalizationsTimes = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.inTimes")); } if (string.IsNullOrEmpty(JsonHelper.getDestValue(joInparam, "insuAdmObj.admDateTime"))) { Global.Set.hisAdmTime = ""; } else { Global.Set.hisAdmTime = Convert.ToDateTime(JsonHelper.getDestValue(joInparam, "insuAdmObj.admDateTime")).ToString("yyyy-MM-dd HH:mm:ss"); } if (string.IsNullOrEmpty(pat.hisDischargeTime)) { Global.Set.hisDischargeTime = ""; } else { Global.Set.hisDischargeTime = pat.hisDischargeTime; } break; } case "Z5C"://住院结算撤销 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID")); pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); pat.name = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_name"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); pat.settlID = JsonHelper.getDestValue(joInparam, "insuAdmObj.setl_id"); pat.SettID_HISJSB = pat.settlID; //这里是通过09010059交易获取到的结算ID break; } default: { break; } } //如果患者异地的则就医地需要该为369900 //if (Global.pat.insuplc_admdvs != "") //{ // if (Global.pat.insuplc_admdvs.Substring(0, 4) != Global.inf.areaCode.Substring(0, 4)) // { // Global.inf.areaCode = "369900"; // } //} } /// /// 获取自助机调用时前端传入的信息,并赋值给patients结构体 /// /// /// /// public void GetSelfServiceMachineInfo(string businessType, JObject joInparam, out Patients pat) { pat = new Patients(); switch (businessType) { case "GetPatientInfo"://读取患者信息 { Global.ssmp.cardType = JsonHelper.getDestValue(joInparam, "params[0].cardType"); Global.operationType = JsonHelper.getDestValue(joInparam, "operationType") + "-" + businessType; Global.pat.businessType = businessType; break; } case "OPReg"://门诊挂号 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID")); pat.recordID = JsonHelper.getDestValue(joInparam, "params[0].recordID"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); Global.ssmp.cardType = JsonHelper.getDestValue(joInparam, "params[0].cardType"); Global.pat.insuplc_admdvs = ""; Global.operationType = JsonHelper.getDestValue(joInparam, "operationType"); break; } case "OPSettl"://门诊结算 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID")); pat.recordID = JsonHelper.getDestValue(joInparam, "params[0].recordID"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); pat.insuplc_admdvs = ""; Global.ssmp.cardType = JsonHelper.getDestValue(joInparam, "params[0].cardType"); Global.operationType = JsonHelper.getDestValue(joInparam, "operationType"); break; } case "IPInReg"://入院登记 { Global.ssmp.cardType = JsonHelper.getDestValue(joInparam, "params[0].cardType"); Global.operationType = JsonHelper.getDestValue(joInparam, "operationType") + "-" + businessType; pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID")); break; } case "IPSettl"://住院结算 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID")); pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id"); pat.name = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_name"); pat.recordID = JsonHelper.getDestValue(joInparam, "params[0].recordID"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); pat.recordID = JsonHelper.getDestValue(joInparam, "params[0].recordID"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); Global.ssmp.cardType = JsonHelper.getDestValue(joInparam, "params[0].cardType"); if (string.IsNullOrEmpty(JsonHelper.getDestValue(joInparam, "insuAdmObj.inDays"))) { Global.Set.hospitalizationsDays = 0; } else { Global.Set.hospitalizationsDays = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.inDays")); } if (string.IsNullOrEmpty(JsonHelper.getDestValue(joInparam, "insuAdmObj.inTimes"))) { Global.Set.hospitalizationsTimes = 0; } else { Global.Set.hospitalizationsTimes = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.inTimes")); } if (string.IsNullOrEmpty(JsonHelper.getDestValue(joInparam, "insuAdmObj.admDateTime"))) { Global.Set.hisAdmTime = ""; } else { Global.Set.hisAdmTime = Convert.ToDateTime(JsonHelper.getDestValue(joInparam, "insuAdmObj.admDateTime")).ToString("yyyy-MM-dd HH:mm:ss"); } if (string.IsNullOrEmpty(JsonHelper.getDestValue(joInparam, "insuAdmObj.disDateTime"))) { Global.Set.hisDischargeTime = ""; } else { Global.Set.hisDischargeTime = Convert.ToDateTime(JsonHelper.getDestValue(joInparam, "insuAdmObj.disDateTime")).ToString("yyyy-MM-dd HH:mm:ss"); } break; } case "DischargeAudit"://出院核查 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID")); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); break; } default: { break; } } } ///对目录下载业务的封装 /// public JObject DownloadDirectory(string funNO,string inParam) { string errorMessage = ""; JObject joRtn = new JObject(); try { JObject joCenterRtn = cBus.DownDirecotry(funNO,inParam); if (JsonHelper.parseCenterRtnValue(joCenterRtn,out errorMessage) != 0) { joRtn = JsonHelper.setExceptionJson(-100, "下载异常", errorMessage); return joRtn; } string filename = JsonHelper.getDestValue(joCenterRtn, "output.filename"); //MessageBox.Show("1306查询目录文件号返回:"+ joCenterRtn.ToString()); JObject jo9102Rtn = cBus.SaveFile(joCenterRtn,inParam); if (JsonHelper.parseIrisRtnValue(jo9102Rtn,out errorMessage) != 0) { joRtn = JsonHelper.setExceptionJson(-100, "保存文件异常", errorMessage); return joRtn; } //解压缩 string zipFilePath = jo9102Rtn["filePath"].ToString(); string txtFileDir = System.Environment.CurrentDirectory + "\\YBDLOAD"; string txtFilePath = txtFileDir + "\\" + filename.Substring(0, filename.Length - 4); //MessageBox.Show("解压缩的txtFilePath:"+ zipFilePath+"|解压到目标路径:"+ txtFileDir+"|文件解析路径:"+ txtFilePath); //昆明下载下来的文件是解压后的TXT if (tools.ExtractFile(zipFilePath, txtFileDir, out errorMessage) != 0) { joRtn = JsonHelper.setExceptionJson(-100, "提取文件", errorMessage); return joRtn; } joRtn = (JObject)jo9102Rtn.DeepClone(); joRtn["filePath"] = txtFilePath; return joRtn; } catch (Exception ) { joRtn = JsonHelper.setExceptionJson(-100, "下载中心目录", errorMessage); return joRtn; } finally { Global.writeLog("HisMainBusiness.DownloadDirectory", inParam, joRtn.ToString()); } } /// /// 字典下载 /// /// /// public string downDictionary(string inParam) { JObject joCenterRtn = invoker.invokeCenterService("1901", inParam); return joCenterRtn.ToString(); } /// /// 展示结算信息界面 /// /// /// /// public int showSettlementForm(JObject joSettlement, out string outParam) { outParam = ""; try { STA sta = new STA(); object[] o = new object[2]; o[1] = joSettlement.ToString(); sta.showSettlementForm(o); outParam = o[1].ToString(); return (int)o[0]; } catch (Exception ex) { outParam = "异常:" + ex.Message; return -1; } } /// /// 门诊预结算封装,返回正式结算的入参 /// /// /// /// public int preSettlement_OutPat( JObject joSettlement, out string outParam) { outParam = ""; //预结算 JObject jo2206Data = new JObject(); jo2206Data.Add("data", joSettlement); JObject jo2206Rtn = invoker.invokeCenterService("2206", JsonHelper.setCenterInpar("2206", jo2206Data)); if (JsonHelper.parseCenterRtnValue(jo2206Rtn, out outParam) != 0) { outParam = JsonHelper.setExceptionJson(-1, "出院预结算", outParam).ToString(); return -1; } //返回给HIS进行预结算判断 JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2206Rtn, "output.setlinfo")); if (hIS.preSettlement(joSettlement, joSetlinfo, out outParam) != 0) { outParam = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString(); return -1; } //编码转换 if (mIS.convertSettlementWithInsuCode(jo2206Rtn, out outParam) != 0) { outParam = JsonHelper.setExceptionJson(-1, "结算信息转换", outParam).ToString(); return -1; } JObject joSumFee = new JObject(); string errMsg = ""; //判断勾稽关系是否平 if (hIS.sumInsuRtnSettlInfo(JObject.Parse(JsonHelper.getDestValue(jo2206Rtn, "output.setlinfo")), out joSumFee, out errMsg) != 0) { outParam = "勾稽关系不符合标准,请联系管理员!" + errMsg; return -1; } //展示结算信息 JObject joConverted = JObject.Parse(outParam); if (showSettlementForm(joConverted, out outParam) != 0) { outParam = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString(); return -1; } else { return 0; } } /// /// 预结算封装,返回正式结算的入参 /// /// /// /// public int preSettlement(string funNO,out JObject joSettlement, out string outParam) { joSettlement = new JObject(); outParam = ""; string outPar = ""; #region 调用IRIS获取医保各项金额 if (mIS.getSumFee(out outPar) != 0) { outParam = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outPar).ToString(); return -1; } JObject joSumFee = JObject.Parse(outPar); if ((JsonHelper.getDestValue(joSumFee, "data.Sumamt") == "") || (JsonHelper.getDestValue(joSumFee, "data.Sumamt") == "0")) { outParam = "请先右击选择【医保费用上传】!"; return -1; } //从云医保平台获取患者详细的医保登记信息 int type; if (funNO == "2206") { type = 3; //门诊预结算 } else { type = 1; //住院预结算 } if (mIS.queryRegisterInfo(type, out outParam) != 0) { outParam = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString(); return -1; } JObject joReg = JObject.Parse(outParam); Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType"); Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType"); Global.pat.mdtrtcertType = JsonHelper.getDestValue(joReg, "data.CertificateType"); Global.pat.mdtrtcertNO = JsonHelper.getDestValue(joReg, "data.CertificateNO"); Global.pat.certType = JsonHelper.getDestValue(joReg, "data.CertificateType"); Global.pat.certNO = JsonHelper.getDestValue(joReg, "data.CertificateNO"); Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode"); Global.pat.psn_type = Global.pat.insuType; //后面再改 Global.pat.ExpContent = JsonHelper.getDestValue(joReg, "data.ExpContent"); if ((Global.pat.RYorCY == "2")) { Global.pat.DiseasecCode = JsonHelper.getDestValue(joReg, "data.DiseasecCode"); Global.pat.DiseasecName = JsonHelper.getDestValue(joReg, "data.DiseasecName"); } #endregion #region 事中分析 string errMsg; if (Global.curEvt.ext.isOpenAnalysis) { if (InProcessAnalysis(out errMsg) != 0) { outParam = JsonHelper.setExceptionJson(-1, "InProcessAnalysis", errMsg).ToString(); return -1; } } #endregion #region 出院登记 //调用服务获取门诊诊断信息 string diagnoses; if (hIS.getPatDiagnoses(Global.pat, out diagnoses) != 0) { outParam = JsonHelper.setExceptionJson(-1, "getPatDiagnoses", diagnoses).ToString(); return -1; } JObject joDiagnoses = JObject.Parse(diagnoses); //展示出院登记界面,选择结算方式等 if (showDischargeRegisterForm(funNO, joSumFee, joDiagnoses, out outParam) != 0) { outParam = JsonHelper.setExceptionJson(-1, "展示出院预结算界面", outParam).ToString(); return -1; } JObject joRtn = JObject.Parse(outParam); #endregion #region 预结算 JObject jo2303Inpar = JObject.Parse(JsonHelper.getDestValue(joRtn, "Settlement")); JObject jo2303Data = new JObject(); jo2303Data.Add("data", jo2303Inpar); JObject jo2303Rtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, jo2303Data)); if (JsonHelper.parseCenterRtnValue(jo2303Rtn, out outParam) != 0) { outParam = JsonHelper.setExceptionJson(-1, "出院预结算", outParam).ToString(); return -1; } //预结算结果传给HIS进行HIS判断 if (funNO == "2303") { //返回给HIS JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2303Rtn, "output.setlinfo")); JObject joParam = new JObject(); joParam.Add("admID", Global.pat.adm_Dr); joParam.Add("recordID", Global.pat.recordID); joParam.Add("billID", Global.pat.billID); if (hIS.preSettlementInfo(joParam, joSetlinfo, out outParam) != 0) { outParam = JsonHelper.setExceptionJson(-1, "出院预结算", outParam).ToString(); return -1; } } //编码转换 if (mIS.convertSettlementWithInsuCode(jo2303Rtn, out outParam) != 0) { outParam = JsonHelper.setExceptionJson(-1, "结算信息转换", outParam).ToString(); return -1; } //展示结算信息 JObject joConverted = JObject.Parse(outParam); if (showSettlementForm(joConverted, out outParam) != 0) { outParam = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString(); return -1; } else { joSettlement = (JObject)joRtn.DeepClone(); return 0; } #endregion } public int returnToFrontEndAfterSettlement(JObject joCenterRtn,JObject joHisServieRtn, out string outParam) { outParam = ""; try { JObject johisInsuInfo = JObject.Parse(JsonHelper.getDestValue(joHisServieRtn, "result")); johisInsuInfo.Add("setl_id", JsonHelper.getDestValue(joCenterRtn, "output.setlinfo.setl_id")); JObject joTmp = (JObject)joCenterRtn.DeepClone(); joTmp.Add("hisInsuInfo", johisInsuInfo); outParam = joTmp.ToString(); return 0; } catch (Exception ex) { outParam = "returnToFrontEndAfterSettlement:" + ex.Message; return -1; } } /// /// 插入患者该次就诊参保信息 /// /// /// /// /// public int insertPatCurInsuInfo(String patInfo, out string outparam) { Global.writeLog(" " + patInfo); outparam = ""; try { JObject joPatInfo = JObject.Parse(patInfo); JObject joBaseInfo = JObject.Parse(JsonHelper.getDestValue(joPatInfo, "output.baseinfo")); JObject joInsuInfo = JObject.Parse(JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo")); JObject joIdetInfo = JObject.Parse(JsonHelper.getDestValue(joPatInfo, "selectedIdInfo")); if (mIS.insertPatCurInsuInfo(joBaseInfo, joInsuInfo, joIdetInfo, out outparam) != 0) { return -1; } else { return 0; } } catch (Exception e) { outparam = "插入患者该次就诊参保信息失败:" + e.Message; return -1; } } /// /// 事前分析 /// /// /// public int PreAnalysis(string trig_scen, string inparam, out string outparam) { outparam = ""; try { ////先签到 //JObject jo9001Rtn = new JObject(); //cBus.signIn(out jo9001Rtn); if (trig_scen == "5") { outparam = inparam; } else { //获取HIS返回的内容 if (hIS.PreAnalysis(out outparam) != 0) { return -1; } } PreAndInProcessAnalysis preAnalysis = new PreAndInProcessAnalysis(outparam); if (preAnalysis.setPatientByHisBaseInfo(out outparam) != 0) { return -1; } outparam = preAnalysis.Get3101Inpar(trig_scen, Global.pat).ToString(); JObject joRtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", outparam)); if (JsonHelper.parseCenterRtnValue(joRtn, out outparam) != 0) { return -1; } else { JArray jaResult = JArray.Parse(JsonHelper.getDestValue(joRtn, "output.result")); if (jaResult.HasValues) { PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(joRtn); if (paipaForm.ShowDialog() == DialogResult.OK) { return 0; } else { outparam = "事前事中审核不通过,操作员取消!"; return -1; } } else return 0; } } catch (Exception ex) { outparam = ex.Message; return -1; } } /// /// 事中分析 /// /// /// public int InProcessAnalysis(out string outparam) { outparam = ""; try { //获取HIS返回的内容 if (hIS.PreAnalysis(out outparam) != 0) { return -1; } PreAndInProcessAnalysis preAnalysis = new PreAndInProcessAnalysis(outparam); if (preAnalysis.setPatientByHisBaseInfo(out outparam) != 0) { return -1; } outparam = preAnalysis.Get3101Inpar("5", Global.pat).ToString(); JObject joRtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", outparam)); return JsonHelper.parseCenterRtnValue(joRtn, out outparam); } catch (Exception ex) { outparam = ex.Message; return -1; } finally { Global.writeLog("InProcessAnalysis", "", outparam); } } public void GetAgentFunHisInfo(string businessType, JObject joInparam, out Patients pat) { pat = new Patients(); switch (businessType) { case "PreAndInProcessAnalysis"://事前事中 { pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID")); pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no"); pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id"); pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs"); pat.name = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_name"); pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID"); Global.pat.insuType = JsonHelper.getDestValue(joInparam, "insuAdmObj.insutype"); break; } default: { break; } } } } }