/****************************************************************************** * 文件名称: 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.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Newtonsoft.Json.Linq; using PTMedicalInsurance.Common; using PTMedicalInsurance.Helper; using PTMedicalInsurance.Variables; using PTMedicalInsurance.Forms; using System.Data; using System.Reflection; using System.IO; using System.IO.Compression; using FastReport.DevComponents.Editors; 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"); } /// /// 获取Session信息(目前只获取操作员信息) /// /// public void getSessionInfo(JObject joSession) { Global.user.ID = JsonHelper.getDestValue(joSession, "userCode"); Global.user.name = JsonHelper.getDestValue(joSession, "userName"); Global.user.type = "3"; Global.user.officeID = JsonHelper.getDestValue(joSession, "locID"); Global.user.officeName = JsonHelper.getDestValue(joSession, "locDesc"); } /// /// 根据壳程序传入的入参设置全局接口变量 /// /// /// 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.ecURL = JsonHelper.getDestValue(joInpar, "CenterURL2"); inf.areaCode = JsonHelper.getDestValue(joInpar, "AreaCode"); inf.dllName = JsonHelper.getDestValue(joInpar, "DLLName"); inf.hospitalNO = JsonHelper.getDestValue(joInpar, "HospitalNO"); inf.version = "v1.0"; inf.signatureType = "SM3"; inf.recivedSystem = "YBXT"; inf.AK = ""; inf.SK = ""; inf.dev_safe_info = ""; inf.dev_no = Global.curEvt.mac; inf.cardURL = inf.centerURL; 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.ecURL = JsonHelper.getDestValue(joInpar, "centerURL2"); inf.areaCode = JsonHelper.getDestValue(joInpar, "areaCode"); inf.dllName = JsonHelper.getDestValue(joInpar, "dLLName"); inf.hospitalNO = JsonHelper.getDestValue(joInpar, "hospitalNO"); inf.version = "v1.0"; inf.signatureType = "SM3"; inf.recivedSystem = "YBXT"; inf.AK = ""; inf.SK = ""; inf.dev_safe_info = ""; inf.dev_no = Global.curEvt.mac; inf.cardURL = inf.centerURL; 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); 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 = ""; string errorMsg = ""; string sInput = ""; string sOutPar; JObject joCardInfo = new JObject(); ChooseCard cc = new ChooseCard(); CardReader_HN CardRead = new CardReader_HN(); try { #region【湖北省基线版医保接口直接调用1101参数传空调用银海COM进行读卡弹框选项】 /* if (cc.ShowDialog() == DialogResult.OK) { #region【电子凭证】 if (cc.sP_CertType == "01") { Global.pat.mdtrtcertType = "01"; Global.pat.certType = "01"; Random rd = new Random(); int iNum = rd.Next(); string sLSH = DateTime.Now.ToString("YYYYMMDDHHNNSS") + Global.inf.hospitalNO + iNum.ToString().Substring(0, 5); joCardInfo.Add("operatorId", Global.user.ID); joCardInfo.Add("operatorName", Global.user.name); joCardInfo.Add("officeId", Global.user.officeID); joCardInfo.Add("officeName", Global.user.officeName); joCardInfo.Add("orgId", Global.inf.hospitalNO); joCardInfo.Add("businessType", cc.sL_CertCodeType); //认证方式 //二维码 if (cc.EcCertDecodeType == "0") { joCardInfo.Add("deviceType", cc.sL_CertCodeType); } //电子凭证 else if (cc.EcCertDecodeType == "1") { joCardInfo.Add("outBizNo", sLSH); joCardInfo.Add("extData", ""); } //刷脸、先授权后解码 else if (cc.EcCertDecodeType == "2") //刷脸 { JObject JoGetAuthInfo = new JObject(); JoGetAuthInfo.Add("outBizNo", sLSH); JoGetAuthInfo.Add("extData", ""); JObject JoInputAuth = new JObject(); JoInputAuth.Add("orgId", Global.inf.hospitalNO); JoInputAuth.Add("transType", "cn.nhsa.ec.auth"); JoInputAuth.Add("data", JoGetAuthInfo); JoInputAuth.Add("extra", ""); //调用刷脸认证接口cn.nhsa.ec.auth返回授权信息authNo CardRead.NationEcTrans(Global.inf.ecURL, JoInputAuth.ToString(), out sOutPar); if (JsonHelper.getDestValue(JObject.Parse(sOutPar), "code") != "0") { outParam = "调用刷脸认证接口cn.nhsa.ec.auth失败:" + sOutPar; return -1; } //成功返回授权信息 string auth = sOutPar; JObject JoAuthOut = new JObject(); JoAuthOut.Add("outBizNo", DateTime.Now.ToString("YYYYMMDDHHNNSS") + Global.inf.hospitalNO + iNum.ToString().Substring(0, 5)); JoAuthOut.Add("authNo", auth); JoAuthOut.Add("extData", ""); joCardInfo = (JObject)JoAuthOut.DeepClone(); } //调用电子凭证动态库NationECCode.dll获取身份信息 JObject JoInput = new JObject(); JoInput.Add("orgId", Global.inf.hospitalNO); JoInput.Add("transType",cc.sL_EcCertDecodeTradeNO); JoInput.Add("data", joCardInfo); JoInput.Add("extra", ""); //MessageBox.Show("电子凭证解码地址:" + Global.inf.ecURL + ",入参:" + JoInput.ToString()); CardRead.NationEcTrans(Global.inf.ecURL, JoInput.ToString(), out sOutPar); if (JsonHelper.getDestValue(JObject.Parse(sOutPar), "code") != "0") { outParam = "调用电子凭证失败:" + sOutPar; return -1; } Global.pat.ecToken = JsonHelper.getDestValue(JObject.Parse(sOutPar), "data.ecToken"); Global.pat.name = JsonHelper.getDestValue(JObject.Parse(sOutPar), "data.userName"); Global.pat.IDType = JsonHelper.getDestValue(JObject.Parse(sOutPar), "data.idType"); Global.pat.IDNO = JsonHelper.getDestValue(JObject.Parse(sOutPar), "data.idNo"); Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(sOutPar), "data.insuOrg"); Global.pat.mdtrtcertNO = Global.pat.ecToken; Global.pat.certType = Global.pat.IDType; Global.pat.certNO = Global.pat.IDNO; } #endregion #region【身份证】 if (cc.sP_CertType == "02") { Global.pat.mdtrtcertType = "02"; Global.pat.mdtrtcertNO = cc.sP_CertNO; Global.pat.certType = "01"; Global.pat.certNO = cc.sP_IDNO; Global.pat.name = cc.PatName; Global.pat.card.SN = ""; } #endregion #region【社保卡】 if (cc.sP_CertType == "03") { //【社保卡-异地】 if (cc.bOtherProvLocal) { Global.pat.bOtherProvLocal = true; Global.pat.insuplc_admdvs = Global.pat.card.SearchAdmCode; if (CardRead.ReadCardBas_HSM_Step1(cc.sL_CardType, Global.inf.hospitalNO, out sOutPar) != 0) { outParam = "社保卡读卡异常ReadCardBas_HSM_Step1:" + sOutPar; return -1; } else { //【9201卡内部认证】 JObject joData9201 = new JObject(); joData9201.Add("mac", sOutPar); //Global.pat.insuplc_admdvs = tools.getDestPosStrBySpliter(sOutPar, 1); //参保地 InvokeHelper invoker9201 = new InvokeHelper(); JObject joRtn9201 = invoker9201.invokeCenterService("9201", JsonHelper.setCenterInpar("9201", joData9201)); if (JsonHelper.parseCenterRtnValue(joRtn9201, out errorMsg) != 0) { outParam = "卡内部认证9201交易失败:" + errorMsg; return -1; } else { outParam = joRtn9201.ToString(); Global.pat.card.pKey = JsonHelper.getDestValue(JObject.Parse(outParam), "output.crtf_ide_data"); //认证鉴别数据 } if (CardRead.ReadCardBas_HSM_Step2(Global.pat.card.pKey,out sOutPar) != 0) { outParam = "社保卡读卡异常ReadCardBas_HSM_Step2:" + errorMsg; return -1; } } } else //【社保卡-本地】 { if (CardRead.ReadCardBas(cc.sL_CardType,Global.inf.hospitalNO,out sOutPar) != 0) { outParam = "社保卡读卡异常ReadCardBas:" + sOutPar; return -1; } } //【社保卡读卡成功返回】 Global.pat.insuplc_admdvs = tools.getDestPosStrBySpliter(sOutPar, 1); //参保地 Global.pat.card.NO = tools.getDestPosStrBySpliter(sOutPar, 2); //社会保障号码 Global.pat.certNO = tools.getDestPosStrBySpliter(sOutPar, 3); //卡号 Global.pat.card.SN = tools.getDestPosStrBySpliter(sOutPar, 4); //卡识别码 Global.pat.name = tools.getDestPosStrBySpliter(sOutPar, 5); //姓名 Global.pat.certType = "90"; Global.pat.mdtrtcertType = "03"; Global.pat.mdtrtcertNO = Global.pat.certNO; Global.pat.certNO = Global.pat.card.NO; } #endregion //是否异地 Global.pat.bOtherProvLocal = cc.bOtherProvLocal; } else { outParam = "收款员取消读卡!"; return -1; } */ #endregion #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); joData.Add("begntime", ""); joData.Add("psn_cert_type", Global.pat.certType); joData.Add("certno", Global.pat.certNO); //证件号码 joData.Add("psn_name", Global.pat.name); JObject joInput = new JObject(); joInput.Add("data",joData); InvokeHelper invoker = new InvokeHelper(); JObject 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.insuplc_admdvs"); //参保地 //Global.pat.card.NO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.insuplc_admdvs"); //社会保障号码 Global.pat.certNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.certno"); //证件号码 Global.pat.card.SN = ""; //卡识别码 Global.pat.name = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.psn_name"); //姓名 Global.pat.certType = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.psn_cert_type"); //人员证件类型 Global.pat.mdtrtcertType = "02"; //就诊凭证类型 Global.pat.mdtrtcertNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.certno"); //就诊凭证编号 Global.pat.certNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.certno"); //证件号码 Global.pat.psn_no = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.psn_no"); //人员编号 Global.pat.emp_name = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.emp_name"); //单位名称 Global.pat.insuType = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.insutype"); //险种类型 //Global.pat.psn_type = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.psn_type"); //人员类别 Global.pat.ecToken = JsonHelper.getDestValue(JObject.Parse(outParam), "output.exp_content.ectoken"); //电子令牌 //if (Global.pat.ecToken != "") //{ // Global.pat.mdtrtcertType = "01"; // Global.pat.mdtrtcertNO = Global.pat.ecToken; //} outParam = outParam.Replace(@"\", "").Replace("\"{", "{").Replace("}\"", "}"); return 0; } #endregion } catch (Exception ex) { outParam = "异常:" + ex.Message; return -1; } } /// /// 展示患者信息界面,转换相关编码为中文,并获取操作员选中的信息 /// /// /// /// public int showPatInfo(String patInfo,out string outparam ) { outparam = ""; //展示信息界面 JObject joOutparam = JObject.Parse(patInfo); JObject joOutput = JObject.Parse(JsonHelper.getDestValue(joOutparam, "output")); //编码转换 JArray jaConvertCode = new JArray(); JObject joConvertCodeParam = new JObject(); joConvertCodeParam.Add("hospitalDr", Global.inf.hospitalDr); joConvertCodeParam.Add("interfaceDr", Global.inf.interfaceDr); joConvertCodeParam.Add("output", joOutput); jaConvertCode.Add(joConvertCodeParam); JObject joConvertCode = new JObject(); joConvertCode.Add("code", "09010054"); joConvertCode.Add("params", jaConvertCode); InvokeHelper invoker = new InvokeHelper(); JObject joConvertCodeRtn = invoker.invokeInsuService(joConvertCode.ToString(), "患者信息编码转换"); PatientInsuInfo frmPatientInfo = new PatientInsuInfo(joConvertCodeRtn); //相关信息转换到登记面板 try { if (frmPatientInfo.ShowDialog() == DialogResult.OK) { //原来用的是转换后的 //frmPatientInfo.joSelectedInsuInfo.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); //frmPatientInfo.joSelectedInsuInfo.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); //joOutparam.Property("output").AddBeforeSelf(new JProperty("selectedInsuInfo", frmPatientInfo.joSelectedInsuInfo)); //现在用转换之前的 JArray jaInsuInfo = JArray.Parse(JsonHelper.getDestValue(joOutput, "insuinfo")); JArray jaIdInfo = JArray.Parse(JsonHelper.getDestValue(joOutput, "idetinfo")); JObject joSelectedInsuInfo = (JObject)jaInsuInfo[frmPatientInfo.insuInfoIndex]; JObject joSelectedIdInfo; if (jaIdInfo.Count != 0) { joSelectedIdInfo = (JObject)jaIdInfo[frmPatientInfo.idInfoIndex]; } else { joSelectedIdInfo = new JObject(); } joSelectedInsuInfo.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); joSelectedInsuInfo.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); joOutparam.Property("output").AddBeforeSelf(new JProperty("selectedInsuInfo", joSelectedInsuInfo)); //joOutparam.Property("output").AddBeforeSelf(new JProperty("selectedIdInfo", joSelectedInsuInfo)); joOutparam.Property("output").AddBeforeSelf(new JProperty("selectedIdInfo", joSelectedIdInfo));//特殊身份标识患者信息组织 outparam = joOutparam.ToString(); return 0; } else { outparam = JsonHelper.setExceptionJson(-1, "门诊读卡", "收款员取消读卡").ToString(); return -1; } } catch (Exception e) { outparam = JsonHelper.setExceptionJson(-1, "患者参保信息展示", e.Message).ToString(); 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 InsuMessage(out string InMeage) { //弹窗提示患者信息 String T_message = ""; //湖北省基线版武汉市判断医保类型 if (Global.pat.insuplc_admdvs.Substring(0, 4) == "4201") { T_message = "武汉市医保"; } else if (Global.pat.insuplc_admdvs.Substring(0, 4) == "4299") { T_message = "湖北省医保"; } else if (Global.pat.insuplc_admdvs.Substring(0, 2) == "42" && Global.pat.insuplc_admdvs.Substring(0, 4) != "4201" && Global.pat.insuplc_admdvs.Substring(0, 4) != "4299") { T_message = "省内异地"; } else if (Global.pat.insuplc_admdvs.Substring(0, 2) != "42") { T_message = "跨省异地"; } if (Global.pat.insuType.ToString() == "310") { T_message = T_message + "职工"; } if (Global.pat.insuType.ToString() == "390") { T_message = T_message + "居民"; } if (string.IsNullOrEmpty(Global.pat.paus_insu_date)) { T_message = T_message + "/"+"正常参保"; } else { T_message = T_message + "/" + "暂停参保"; } InMeage = "当前选择参保信息:"+T_message; return 0; } /// /// 患者读卡并获取中心信息(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; } } /// /// 显示住院患者登记面板,返回登记入参 /// /// /// public int showInPatRegisterForm(out string regInfo) { //调用服务获取门诊诊断信息 string diagnoses; if (hIS.getPatDiagnoses(Global.pat, out diagnoses) != 0) { regInfo = JsonHelper.setExceptionJson(-1, "getPatDiagnoses", diagnoses).ToString(); return -1; } JObject joHisRtnInfo = JObject.Parse(diagnoses); //组织登记入参 JObject joReg = new JObject(); try { JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joHisRtnInfo, "diseinfo")); string dscg_maindiag_code = "",dscg_maindiag_name = ""; // 对诊断数组进行转换 转换下主要诊断 JArray jaConvertedDiagnoses = new JArray(); JArray jaInPatDiagnoses = new JArray(); JArray jaOutPatDiagnoses = new JArray(); 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() == "ADD") //ADD 入院 OPD 门诊 //{ // jaConvertedDiagnoses.Add(jaDiagnoses[i]); //} if (jaDiagnoses[i]["diaTypeCode"].ToString() == "ADD") //ADD 入院 OPD 门诊 { jaInPatDiagnoses.Add(jaDiagnoses[i]); } if (jaDiagnoses[i]["diaTypeCode"].ToString() == "OPD") //ADD 入院 OPD 门诊 { jaOutPatDiagnoses.Add(jaDiagnoses[i]); } } if (jaInPatDiagnoses.Count > 0) { jaConvertedDiagnoses = (JArray)jaInPatDiagnoses.DeepClone(); } else { jaConvertedDiagnoses = (JArray)jaOutPatDiagnoses.DeepClone(); } 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(); } } //登记面板实例 OutpatientRegistration frmReg = new OutpatientRegistration(); frmReg.dblkcbxSettelmentWay.Enabled = false; 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(); } } 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(); } } frmReg.DtDiagnose = (DataTable)jaConvertedDiagnoses.ToObject(typeof(DataTable)); //展示登记面板 if (frmReg.ShowDialog() == DialogResult.OK) { string diseCodg ="",diseName = ""; diseCodg = frmReg.diseCodg; diseName = frmReg.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"); //} JObject joMdtrtinfo = new JObject(); joMdtrtinfo.Add("psn_no", Global.pat.psn_no); //人员编号 joMdtrtinfo.Add("insutype", Global.pat.insuType); //险种类型 joMdtrtinfo.Add("coner_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.coner_name")); //联系人姓名 joMdtrtinfo.Add("tel", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.tel")); //联系电话 joMdtrtinfo.Add("begntime", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.begntime")); //开始时间 joMdtrtinfo.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); //就诊凭证类型 joMdtrtinfo.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); //就诊凭证编号 joMdtrtinfo.Add("med_type", frmReg.med_type); //医疗类别 //joMdtrtinfo.Add("ipt_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.ipt_no")); //住院号 joMdtrtinfo.Add("ipt_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.medrcdno")); //住院号//根据武汉要求改为病案号 joMdtrtinfo.Add("medrcdno", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.medrcdno")); //病历号 joMdtrtinfo.Add("atddr_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.atddr_no")); //主治医生编码 joMdtrtinfo.Add("chfpdr_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.chfpdr_name")); //主诊医师姓名 joMdtrtinfo.Add("adm_diag_dscr", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_diag_dscr")); //入院诊断描述 joMdtrtinfo.Add("adm_dept_codg", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_codg")); //入院科室编码 joMdtrtinfo.Add("adm_dept_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name")); //入院科室名称 joMdtrtinfo.Add("adm_bed", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_bed")); //入院床位 joMdtrtinfo.Add("dscg_maindiag_code", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_code")); //住院主诊断代码 joMdtrtinfo.Add("dscg_maindiag_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_name")); //住院主诊断名称 //joMdtrtinfo.Add("dscg_maindiag_code", dscg_maindiag_code); //住院主诊断代码 //joMdtrtinfo.Add("dscg_maindiag_name", dscg_maindiag_name); //住院主诊断名称 joMdtrtinfo.Add("main_cond_dscr", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.main_cond_dscr")); //主要病情描述 joMdtrtinfo.Add("dise_codg", diseCodg); //病种编码 joMdtrtinfo.Add("dise_name", diseName); //病种名称 joMdtrtinfo.Add("oprn_oprt_code", frmReg.oprn_oprt_code); //手术操作代码 joMdtrtinfo.Add("oprn_oprt_name", frmReg.oprn_oprt_name); //手术操作名称 joMdtrtinfo.Add("fpsc_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fpsc_no")); //计划生育服务证号 joMdtrtinfo.Add("matn_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.matn_type")); //生育类别 joMdtrtinfo.Add("birctrl_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_type")); //计划生育手术类别 joMdtrtinfo.Add("latechb_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.latechb_flag")); //晚育标志 joMdtrtinfo.Add("geso_val", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.geso_val")); //孕周数 joMdtrtinfo.Add("fetts", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fetts")); //胎次 joMdtrtinfo.Add("fetus_cnt", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fetus_cnt")); //胎儿数 joMdtrtinfo.Add("pret_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.pret_flag")); //早产标志 joMdtrtinfo.Add("birctrl_matn_date", ""); //计划生育手术或生育日期 JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_matn_date") 20230228医保中心校验传正确时间或空 joMdtrtinfo.Add("dise_type_code", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dise_type_code")); //病种类型 joMdtrtinfo.Add("exp_content", Global.pat.ExpContent); //字段扩展 joMdtrtinfo.Add("insuplc_admdvs", Global.pat.insuplc_admdvs); //参保地医保区划 joMdtrtinfo.Add("mdtrtarea_admvs", Global.inf.areaCode); //就医地医保区划 joReg.Add("mdtrtinfo", joMdtrtinfo); joReg.Add("diseinfo", jaConvertedDiagnoses); Global.pat.disCode = diseCodg; Global.pat.disName = diseName; Global.pat.medType = frmReg.med_type; regInfo = joReg.ToString(); return 0; } else { regInfo = "收费员取消操作!"; return -1; } } catch (Exception ex) { regInfo = "登记界面显示异常:" + ex.Message; return -1; } } /// /// 显示出院登记界面,返回出院登记和结算的入参 /// /// /// /// public int showDischargeRegisterForm(string funNO, JObject joSumFee, JObject joHisRtnInfo, out string outParam) { outParam = ""; string errMsg; 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 (Global.pat.RYorCY == "1") { if (jaDiagnoses[i]["diaTypeCode"].ToString() == "ADD") //ADD 入院 OPD 门诊 { jaConvertedDiagnoses.Add(jaDiagnoses[i]); } } else if (Global.pat.RYorCY == "2") { if (jaDiagnoses[i]["diaTypeCode"].ToString() == "DIS") //ADD 入院 OPD 门诊 { jaConvertedDiagnoses.Add(jaDiagnoses[i]); } } else { if (jaDiagnoses[i]["diaTypeCode"].ToString() == "OPD") //ADD 入院 OPD 门诊 { 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; } 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 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", Global.pat.ExpContent); //字段扩展 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")); JObject joDataExp = new JObject(); joDataExp.Add("acct_payamt", "0.00"); joDataExp.Add("cla_trt_flag", ""); joSetlInpar.Add("exp_content", Global.pat.ExpContent); //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) { //调用服务获取门诊诊断信息 string diagnoses; if (hIS.getPatDiagnoses(Global.pat, out diagnoses) != 0) { regInfo = JsonHelper.setExceptionJson(-1, "getPatDiagnoses", diagnoses).ToString(); return -1; } JObject joHisRtnInfo = JObject.Parse(diagnoses); //组织入参 JObject joReg = new JObject(); try { JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joHisRtnInfo, "diseinfo")); //登记面板实例 OutpatientRegistration frmReg = new OutpatientRegistration(); //frmReg.dblkcbxSettelmentWay.Enabled = false; //险种类型 DataTable dtInsuType = (DataTable)frmReg.dblkcbxInsuranceType.DataSource; for (int i = 0; i < dtInsuType.Rows.Count; i++) { if (dtInsuType.Rows[i]["Code"].ToString() == Global.pat.insuType) { frmReg.dblkcbxInsuranceType.Text = dtInsuType.Rows[i]["Name"].ToString(); frmReg.insuType = dtInsuType.Rows[i]["Code"].ToString(); } } //医疗类别 DataTable dtMedType = (DataTable)frmReg.dblkcbxMedicalType.DataSource; for (int i = 0; i < dtMedType.Rows.Count; i++) { if (Global.pat.insuType == "390") //湖北居民默认 110104 门诊统筹 { if (dtMedType.Rows[i]["Code"].ToString() == "110104") { frmReg.dblkcbxMedicalType.Text = dtMedType.Rows[i]["Name"].ToString(); frmReg.med_type = dtMedType.Rows[i]["Code"].ToString(); } } else { if (dtMedType.Rows[i]["Code"].ToString() == "11") { 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(); } } //转换下主要诊断 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; } } } frmReg.DtDiagnose = (DataTable)jaDiagnoses.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"); }; //组织挂号入参 JObject joRegInpar = new JObject(); string occurTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); joRegInpar.Add("psn_no", Global.pat.psn_no); joRegInpar.Add("insutype", frmReg.insuType); joRegInpar.Add("begntime", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.begntime"));//挂号时间 这里之所以不取当前时间是因为就诊信息上传会关联判断挂号的时间DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") joRegInpar.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); joRegInpar.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); joRegInpar.Add("ipt_otp_no", Global.pat.adm_Dr); joRegInpar.Add("atddr_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.atddr_no")); joRegInpar.Add("dr_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.chfpdr_name")); joRegInpar.Add("dept_code", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_codg")); joRegInpar.Add("dept_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name")); joRegInpar.Add("exp_content", Global.pat.ExpContent); joRegInpar.Add("caty", "72"); joReg.Add("data", joRegInpar); //组织就诊信息入参 JObject joMdtrtinfo = new JObject(); for (int i = 0; i < jaDiagnoses.Count; i++) { jaDiagnoses[i]["vali_flag"] = new JObject(); jaDiagnoses[i]["vali_flag"] = "1"; } joMdtrtinfo.Add("mdtrt_id", Global.pat.mdtrtID); joMdtrtinfo.Add("psn_no", Global.pat.psn_no); //人员编号 Global.pat.medType = frmReg.med_type; joMdtrtinfo.Add("med_type", frmReg.med_type); //医疗类别 joMdtrtinfo.Add("begntime", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.begntime")); //开始时间 joMdtrtinfo.Add("main_cond_dscr", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.main_cond_dscr")); //主要病情描述 joMdtrtinfo.Add("dise_codg", diseCodg); //病种编码 joMdtrtinfo.Add("dise_name", diseName); //病种名称 joMdtrtinfo.Add("birctrl_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_type")); //计划生育手术类别 joMdtrtinfo.Add("birctrl_matn_date", ""); //计划生育手术或生育日期 JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_matn_date") 20230228医保中心校验传正确时间或空 joMdtrtinfo.Add("matn_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.matn_type")); //生育类别 joMdtrtinfo.Add("geso_val", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.geso_val")); //孕周数 joMdtrtinfo.Add("exp_content", ""); //字段扩展 //组织结算入参 JObject joSetlInpar = new JObject(); joSetlInpar.Add("psn_no", Global.pat.psn_no); 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", ""); joSetlInpar.Add("psn_setlway", frmReg.psn_setlway); //结算方式 joSetlInpar.Add("mdtrt_id", Global.pat.mdtrtID); joSetlInpar.Add("chrg_bchno", Global.pat.adm_Dr.ToString()); joSetlInpar.Add("acct_used_flag", frmReg.personAccountUsedFlag);//个人账户使用标志 joSetlInpar.Add("insutype", frmReg.insuType);//险种类型 joSetlInpar.Add("pub_hosp_rfom_flag", ""); joSetlInpar.Add("exp_content", Global.pat.ExpContent); joReg.Add("mdtrtinfo", joMdtrtinfo); joReg.Add("diseinfo", jaDiagnoses); joReg.Add("settlement", joSetlInpar); regInfo = joReg.ToString(); return 0; } else { regInfo = "收费员取消操作!"; return -1; } } catch (Exception ex) { regInfo = "登记界面显示异常:" + ex.Message; return -1; } } /// /// 上传费用到中心 /// /// /// public int uploadFee(string funNO,int singleCount,out string outParam) { outParam = ""; //获取IS费用 if (hIS.getHisFee(Global.pat, out outParam) != 0) { return -1; } //调用医保平台转换HIS费用(转换医保编码等) JObject joHisFee = JObject.Parse(outParam); if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0) { return -2; } JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data")); //按指定条数分割后上传,保存,更新 if (uploadFeeToCenter(funNO, singleCount, jaFeeDetail, out outParam) != 0) { return -3; } else { outParam = "成功"; return 0; } } 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 (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.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; } } //如果患者异地的则就医地需要该为419900 if (Global.pat.insuplc_admdvs != "") { if (Global.pat.insuplc_admdvs.Substring(0, 4) != Global.inf.areaCode.Substring(0, 4)) { Global.inf.areaCode = "419900"; } } } 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.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"); 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"); 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"; // } //} } ///对目录下载业务的封装 /// public JObject DownloadDirectory(string funNO,string inParam) { string errorMessage = "", sRtn = ""; 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); if (JsonHelper.parseIrisRtnValue(jo9102Rtn,out errorMessage) != 0) { joRtn = JsonHelper.setExceptionJson(-100, "保存文件异常", errorMessage); return joRtn; } //解压缩 string zipFilePath = jo9102Rtn["filePath"].ToString(); string txtFileDir = System.Environment.CurrentDirectory + "\\Download"; string txtFilePath = txtFileDir + "\\" + filename.Substring(0, filename.Length - 4); //string txtFilePath = Global.curEvt.path + "\\Download\\" + filename; //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 ex) { 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 = ""; string errMsg; try { SettlementInfo frmSettlment = new SettlementInfo(joSettlement); //相关信息转换到结算信息面板 if (frmSettlment.ShowDialog() == DialogResult.OK) { return 0; } else { outParam = "收款员取消"; return -1; } } catch (Exception ex) { outParam = "showSettlementForm 异常:" + 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 = ""; //调用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; //后面再改 if ((Global.pat.RYorCY == "2") && (Global.pat.medType == "26")) { Global.pat.DiseasecCode = JsonHelper.getDestValue(joReg, "data.DiseasecCode"); Global.pat.DiseasecName = JsonHelper.getDestValue(joReg, "data.DiseasecName"); } //昆明结算前读卡核验身份 //string patInfo = ""; //if (readCard(out patInfo) != 0) //{ // outParam = JsonHelper.setExceptionJson(-1, "readCard", patInfo).ToString(); // return -1; //} //调用服务获取门诊诊断信息 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); JObject jo2303Inpar = JObject.Parse(JsonHelper.getDestValue(joRtn, "Settlement")); JObject jo2402Inpar = JObject.Parse(JsonHelper.getDestValue(joRtn, "DischargeRegister")); //昆明出院登记放再预结算之前 JObject jo2402Rtn = invoker.invokeCenterService("2402", JsonHelper.setCenterInpar("2402", jo2402Inpar)); string errMsg; if (JsonHelper.parseCenterRtnValue(jo2402Rtn, out errMsg) != 0) { outParam = JsonHelper.setExceptionJson(-1, "预结算失败:出院登记失败", errMsg).ToString(); return -1; } //预结算 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; } } 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 void getLocalConfingue() { IniFile ini = new IniFile(Global.curEvt.path + @"\INSUConfigure.ini"); Global.curEvt.ext.isOpenAnalysis = (ini.ReadValue("PreAndInProcessAnalysis", "isOpenAnalysis") == "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; } } } }