/****************************************************************************** * 文件名称: 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 Newtonsoft.Json; using Newtonsoft.Json.Linq; using Org.BouncyCastle.Utilities.Encoders; using PTMedicalInsurance.Common; using PTMedicalInsurance.Entity.Settlement.PortalPay; using PTMedicalInsurance.Forms; using PTMedicalInsurance.Helper; using PTMedicalInsurance.Variables; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; 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"; } /// /// 根据壳程序传入的入参设置全局接口变量 /// /// /// 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 = "BObOUSG1z1FXOGn3SkJ0FchX+8ftm9+RYqfVWLqdyVL2srAevCusk7ZZTSR3BQRcYe4bMq85MYmYGzz90UATaC8="; inf.SK = "AKPGR6SIzhJUe8kdIgHmAgIAKjQQl3s4TqoSTbJ7Sc9H"; inf.dev_safe_info = ""; inf.dev_no = Global.curEvt.mac; inf.cardURL = inf.centerURL; //inf.ecURL = JsonHelper.getDestValue(joInpar, "CenterURL2"); inf.BusinessID = "41a8514ba8ed429eb4dde381eda02fe0"; //商务ID码 inf.CreditID = "91530112MA6Q3GGC1E"; //服务商统一社会信用代码 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.ecURL = JsonHelper.getDestValue(joCenterURL2, "core.ecURL"); inf.downURL = JsonHelper.getDestValue(joCenterURL2, "core.downURL"); inf.PortalAmp.url = JsonHelper.getDestValue(joCenterURL2, "portalAmp.url"); inf.PortalAmp.appid = JsonHelper.getDestValue(joCenterURL2, "portalAmp.appid"); inf.PortalAmp.secretKey = JsonHelper.getDestValue(joCenterURL2, "portalAmp.secretKey"); inf.PortalAmp.privateKey = JsonHelper.getDestValue(joCenterURL2, "portalAmp.privateKey"); inf.PortalAmp.publicKey = JsonHelper.getDestValue(joCenterURL2, "portalAmp.publicKey"); inf.PortalOrg.url = JsonHelper.getDestValue(joCenterURL2, "portalOrg.url"); inf.PortalOrg.appid = JsonHelper.getDestValue(joCenterURL2, "portalOrg.appid"); inf.PortalOrg.secretKey = JsonHelper.getDestValue(joCenterURL2, "portalOrg.secretKey"); inf.PortalOrg.privateKey = JsonHelper.getDestValue(joCenterURL2, "portalOrg.privateKey"); inf.PortalOrg.publicKey = JsonHelper.getDestValue(joCenterURL2, "portalOrg.publicKey"); inf.MobilePay.url = JsonHelper.getDestValue(joCenterURL2, "mobilePay.url"); inf.MobilePay.appid = JsonHelper.getDestValue(joCenterURL2, "mobilePay.appid"); inf.MobilePay.secretKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.secretKey"); inf.MobilePay.privateKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.privateKey"); inf.MobilePay.publicKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.publicKey"); inf.PresCir.url = JsonHelper.getDestValue(joCenterURL2, "mobilePay.url"); inf.PresCir.appid = JsonHelper.getDestValue(joCenterURL2, "mobilePay.appid"); inf.PresCir.secretKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.secretKey"); inf.PresCir.privateKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.privateKey"); inf.PresCir.publicKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.publicKey"); 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 = "BObOUSG1z1FXOGn3SkJ0FchX+8ftm9+RYqfVWLqdyVL2srAevCusk7ZZTSR3BQRcYe4bMq85MYmYGzz90UATaC8="; inf.SK = "AKPGR6SIzhJUe8kdIgHmAgIAKjQQl3s4TqoSTbJ7Sc9H"; inf.dev_safe_info = ""; inf.dev_no = Global.curEvt.mac; inf.cardURL = inf.centerURL; //inf.ecURL = JsonHelper.getDestValue(joInpar, "CenterURL2"); inf.BusinessID = "41a8514ba8ed429eb4dde381eda02fe0"; //商务ID码 inf.CreditID = "91530112MA6Q3GGC1E"; //服务商统一社会信用代码 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.ecURL = JsonHelper.getDestValue(joCenterURL2, "core.ecURL"); inf.downURL = JsonHelper.getDestValue(joCenterURL2, "core.downURL"); inf.PortalAmp.url = JsonHelper.getDestValue(joCenterURL2, "portalAmp.url"); inf.PortalAmp.appid = JsonHelper.getDestValue(joCenterURL2, "portalAmp.appid"); inf.PortalAmp.secretKey = JsonHelper.getDestValue(joCenterURL2, "portalAmp.secretKey"); inf.PortalAmp.privateKey = JsonHelper.getDestValue(joCenterURL2, "portalAmp.privateKey"); inf.PortalAmp.publicKey = JsonHelper.getDestValue(joCenterURL2, "portalAmp.publicKey"); inf.PortalOrg.url = JsonHelper.getDestValue(joCenterURL2, "portalOrg.url"); inf.PortalOrg.appid = JsonHelper.getDestValue(joCenterURL2, "portalOrg.appid"); inf.PortalOrg.secretKey = JsonHelper.getDestValue(joCenterURL2, "portalOrg.secretKey"); inf.PortalOrg.privateKey = JsonHelper.getDestValue(joCenterURL2, "portalOrg.privateKey"); inf.PortalOrg.publicKey = JsonHelper.getDestValue(joCenterURL2, "portalOrg.publicKey"); inf.MobilePay.url = JsonHelper.getDestValue(joCenterURL2, "mobilePay.url"); inf.MobilePay.appid = JsonHelper.getDestValue(joCenterURL2, "mobilePay.appid"); inf.MobilePay.secretKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.secretKey"); inf.MobilePay.privateKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.privateKey"); inf.MobilePay.publicKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.publicKey"); inf.PresCir.url = JsonHelper.getDestValue(joCenterURL2, "mobilePay.url"); inf.PresCir.appid = JsonHelper.getDestValue(joCenterURL2, "mobilePay.appid"); inf.PresCir.secretKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.secretKey"); inf.PresCir.privateKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.privateKey"); inf.PresCir.publicKey = JsonHelper.getDestValue(joCenterURL2, "mobilePay.publicKey"); inf.cainfo = ""; } /// /// 初始化环境 /// /// /// public int initEnvironment(string inParam,out string error) { error = string.Empty; try { //获取HIS和医保平台的IRIS配置信息 getHisConfingue(out Global.hisConfig); getInsuConfingue(out Global.insuConfig); 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); } string session = JsonHelper.getDestValue(joInparam, "session[0]"); JObject joSession = (session !="")? JObject.Parse(session):null; 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 sOutPar; string pCardinfo = ""; string pBusCardinfo = ""; JObject joCardInfo = new JObject(); ChooseCard cc = new ChooseCard(); CardReader_JIL CardRead = new CardReader_JIL(); try { //#region【调用银海COM组件读卡弹框-1401交易】 ////调用银海com组件读卡弹框 1401交易 //InvokeHelper yinhaiCom = new InvokeHelper(); //JObject joInput1401 = new JObject(); //dynamic joData1401 = new JObject(); //joData1401.fixmedinsCode = Global.inf.hospitalNO; //joData1401.psnNo = ""; ////交易输入报文格式 //joInput1401["transNo"] = "1401"; //joInput1401["transType"] = "passwordCheck"; //joInput1401["timestamp"] = DateTime.Now.ToString("YYYYMMDDHH24MISS"); //joInput1401.Add("data", JObject.FromObject(joData1401)); //string sRtnValue1401 = string.Empty; //yinhaiCom.Call("1401", joInput1401.ToString(), out sRtnValue1401); //JObject joRtn1401 = new JObject(); //joRtn1401 = JObject.Parse(sRtnValue1401); //if (JsonHelper.parseCenterRtnValue(joRtn1401, out errorMsg) != 0) //{ // outParam = "调用银海控件失败:" + errorMsg; // return -1; //} //else //{ // outParam = joRtn1401.ToString(); // Global.pat.certNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.certno"); //证件号码 // Global.pat.name = JsonHelper.getDestValue(JObject.Parse(outParam), "output.psn_name"); //姓名 // Global.pat.card.NO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.card_no"); //社会保障卡号 // Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuplc_admdvs"); //参保地 // Global.pat.card.SN = JsonHelper.getDestValue(JObject.Parse(outParam), "output.card_sn"); //卡识别码 // Global.pat.certType = JsonHelper.getDestValue(JObject.Parse(outParam), "output.psn_cert_type"); //证件类别 // Global.pat.mdtrtcertNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.mdtrt_cert_no"); //就诊凭证编号 // Global.pat.mdtrtcertType = JsonHelper.getDestValue(JObject.Parse(outParam), "output.mdtrt_cert_type"); //就诊凭证类型 // Global.pat.IDNO = Global.pat.certNO; //} //#endregion #region【调用自定义读卡窗口读卡】 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("yyyyMMddHHmmss") + 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") //刷脸 { joCardInfo.Add("outBizNo", sLSH); joCardInfo.Add("extData", ""); JObject JoInputAuth = new JObject(); JoInputAuth.Add("orgId", Global.inf.hospitalNO); JoInputAuth.Add("transType", "cn.nhsa.ec.auth"); JoInputAuth.Add("data", joCardInfo); JoInputAuth.Add("extra", ""); //调用刷脸认证接口cn.nhsa.ec.auth返回授权信息authNo CardRead.InsuQRCodeQuery(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("yyyyMMddHHmmss") + 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.InsuQRCodeQuery(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 = ""; //长春身份证调用动态库读卡 if (CardRead.readSFZ(out pCardinfo, out pBusCardinfo) != 0) { outParam = "社保卡读卡异常ReadCardBas:" + pCardinfo; return -1; } //} Global.writeLog("医保读卡" + "(" + Global.curEvt.URL + ")", pCardinfo, pBusCardinfo);//医保读卡日志输出 //【社保卡读卡成功返回】 Global.pat.mdtrtcertType = "02"; Global.pat.mdtrtcertNO = pBusCardinfo.Replace('\u0000', ' ').Trim(); //Global.pat.mdtrtcertNO = tools.getDestPosStrBySpliter(pCardinfo, 1);//获取身份证号 Global.pat.certType = "01"; Global.pat.certNO = tools.getDestPosStrBySpliter(pCardinfo, 1);//获取身份证号 Global.pat.name = tools.getDestPosStrBySpliter(pCardinfo, 2);//姓名 Global.pat.card.SN = ""; Global.pat.insuplc_admdvs = tools.getDestPosStrBySpliter(pCardinfo, 1).ToString().Substring(0,6); //Global.pat.insuplc_admdvs = "220581"; } #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.readCard( out pCardinfo, out pBusCardinfo) != 0) { outParam = "社保卡读卡异常ReadCardBas:" + pCardinfo; return -1; } //} Global.writeLog("医保读卡" + "(" + Global.curEvt.URL + ")", pCardinfo, pBusCardinfo);//医保读卡日志输出 //【社保卡读卡成功返回】 Global.pat.insuplc_admdvs = tools.getDestPosStrBySpliter(pCardinfo, 1); //参保地 Global.pat.card.NO = tools.getDestPosStrBySpliter(pCardinfo, 2); //社会保障号码 Global.pat.certNO = tools.getDestPosStrBySpliter(pCardinfo, 3); //卡号 Global.pat.card.SN = tools.getDestPosStrBySpliter(pCardinfo, 4); //卡识别码 Global.pat.name = tools.getDestPosStrBySpliter(pCardinfo, 5); //姓名 //Global.pat.certType = "90"; Global.pat.certType = "01"; Global.pat.mdtrtcertType = "03"; //Global.pat.mdtrtcertNO = Global.pat.certNO; Global.pat.mdtrtcertNO = pBusCardinfo.Replace('\u0000',' ').Trim();//长春医保卡卡凭证所有涉及凭证,传参需传医保读卡第二个返参 Global.pat.certNO = Global.pat.card.NO; } #endregion } else { outParam = "收款员取消读卡!"; return -1; } #endregion #region【1101获取身份信息】 JObject joData1101 = new JObject(); joData1101.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); //就诊凭证类型 joData1101.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); //就诊凭证编码 joData1101.Add("card_sn", Global.pat.card.SN); //卡识别码 joData1101.Add("begntime", DateTime.Now.ToString("yyyy-MM-dd")); joData1101.Add("psn_cert_type", Global.pat.certType); //证件类别 joData1101.Add("certno", Global.pat.certNO); //证件号码 joData1101.Add("psn_name", Global.pat.name); //姓名 JObject joExpContent= new JObject(); joExpContent.Add("credit_flag", Global.pat.creditFlag); joData1101.Add("exp_content", joExpContent); JObject joInput1101 = new JObject(); joInput1101.Add("data", joData1101); InvokeHelper invoker = new InvokeHelper(); JObject joRtn1101 = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", joInput1101)); if (JsonHelper.parseCenterRtnValue(joRtn1101, out errorMsg) != 0) { outParam = "读卡失败:" + errorMsg; return -1; } else { outParam = joRtn1101.ToString(); Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.insuplc_admdvs"); //参保地 Global.pat.psn_no = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.psn_no"); //参保地 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)); 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; } } /// /// 患者读卡并获取中心信息(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")); //开始时间 "2023-02-28 14:26:29" 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("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_stand_code")); //入院科室编码 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")); //计划生育手术或生育日期 joMdtrtinfo.Add("dise_type_code", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dise_type_code")); //病种类型 JObject joTrum = new JObject(); JObject joDataExp = new JObject(); //外伤节点 trum_content //joDataExp.Add("acct_payamt", "0.00"); //joDataExp.Add("cla_trt_flag", ""); joDataExp.Add("trum_flag", frmReg.traumaFlag);//外伤标志 0 否 1是 joDataExp.Add("rel_ttp_flag", frmReg.relTtpFlag);//涉及第三方标志 0 否 1是 //JObject joMdtPep = new JObject();//就诊人群类型 mdtrt_grp_content //joMdtPep.Add("mdtrt_grp_type", "");//1新冠肺炎确诊患者 2其他国家突发公共事件 3新冠肺炎疑似患者 4无症状感染者 joTrum.Add("trum_content", joDataExp);//外伤节点 trum_content //joTrum.Add("mdtrt_grp_content", joMdtPep);//就诊人群类型 trum_content joMdtrtinfo.Add("exp_content", joTrum); //字段扩展 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 (jaDiagnoses[i]["diaTypeCode"].ToString() == "DIS") //ADD 入院 OPD 门诊 DIS出院诊断 { 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")); //计划生育手术或生育日期 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", ""); //字段扩展 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("mdtrt_cert_type", Global.pat.mdtrtcertType); joSetlInpar.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); 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("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")); joSetlInpar.Add("dscgTime", Global.pat.hisDischargeTime); //joSetlInpar.Add("chrg_bchno", Global.pat.adm_Dr.ToString()); joSetlInpar.Add("med_type", Global.pat.medType); joSetlInpar.Add("exp_content", ""); // joSetlInpar.Add("minpacunt_drug_trac_cnt", Global.Set.minpacunt_drug_trac_cnt); joSetlInpar.Add("mcs_trac_cnt", Global.Set.mcs_trac_cnt); //joSetlInpar.Add("invono", ""); //JObject joDataExp = new JObject(); //joDataExp.Add("acct_payamt", "0.00"); //joDataExp.Add("cla_trt_flag", ""); //joSetlInpar.Add("exp_content", joDataExp); //11111 AmpHos001 ampHos001 = new AmpHos001(); // 院内证件类型,和 ORG_001 的his_cust_list 内的his_cust_type 是同样的意思 ampHos001.hisCustType = Global.pat.mdtrtcertType; // 院内证件类型 // 院内证件号,和 ORG_001 的his_cust_list 内的his_cust_id 是同样的意思 ampHos001.hisCustId = Global.pat.certNO; // 院内证件号 // 应用类型 ampHos001.appType = "02"; // 应用类型应用类型 01 门诊02 住院03 挂号04 线上 // 医疗机构订单号 ampHos001.medOrgOrd = Global.inf.hospitalNO + Global.pat.settlID; // 医疗机构订单号 ,必填,通过这个单号来回查推送的详情数据\norgCode+subOrgCode+medOrgOrd 不超过47位。\nmedOrgOrd 和 ORG_002 返回的org_trace_no 需要一致 // 分院编号 ampHos001.subOrgCode = ""; // 分院编号 // 订单状态 ampHos001.orderStatus = ""; // 订单状态 "pushType 类型为 HOSPITAL_PAYMENT 时必填\nMERCHANT_WAIT_PAY 待支付\nMERCHANT_PAID 已支付\nMERCHANT_PART_REFUNDED 已部分退款\nMERCHANT_REFUNDED 已全额退款\nMERCHANT_CLOSED 已取消") // 机构代码 ampHos001.orgCode = Global.inf.hospitalNO; // 机构代码 // 用户名 ampHos001.patientName = Global.pat.name; // 用户名 // 证件类型 ampHos001.idType = Global.pat.certType; // 证件类型 // 证件号 ampHos001.idNo = Global.pat.certNO; // 证件号 // 推送类型 ampHos001.pushType = "HOSPITAL_PAYMENT"; // 推送类型HOSPITAL_APPOINTMENT 挂号单 HOSPITAL_PAYMENT 支付单 // 子订单类型 ampHos001.subOrderType = ""; // 子订单类型 只有当 pushType 为挂号单时必填 APPOINTMENT_WAIT_PA // 是否本人挂号 ampHos001.isDoneBySelf = ""; // 是否本人挂号 只有当 pushType 为挂号单时必填YES 是NO 否NULL 未知 // 下一步就医指引 ampHos001.nextStepTips = ""; // 下一步就医指引 一、当 pushType 为挂号单时必填a)当 subOrderType 为预约成功待⽀付,并且承接⻚⽀持在线医保⽀付的时候,建议传⼊⽂案:“⽀持在线医保⽀付,⽆需取号,直接前往就诊科室”b)当 subOrderType 为其他 类型(非待支付)时,建 议传⼊⽂案“请前往 3 楼302 室内科签到就诊”,或 者自定义⽂案;二、当 pushType 为支付单 时必填a)医保订单待支付提醒中, 请传入支付相关提示,如 “点击在线医保支付,无 需前往窗口/ 自助机排队”b)医保订单支付完成提醒中,请传入取药、检查检验的指引,如“请前往 3 楼⻄药房 5 号窗⼝取药。” // 预约时间 ampHos001.scheduledTime = ""; // 预约时间 当推送类型为“挂号单 ”时 必填。格式:yyyy-MM-dd HH:mm:ss // 重定向地址 ampHos001.redirectUrl = ""; // 重定向地址 // 科室名称 ampHos001.deptName = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name"); // 科室名称 // 科室编码 ampHos001.deptCode = "A10"; // 科室编码 // 科室地址 ampHos001.deptLoc = ""; // 科室地址 // 医生姓名 ampHos001.drName = ""; // 医生姓名 // 医生职级 ampHos001.drLvName = ""; // 医生职级 // 医生编码 ampHos001.drNo = ""; // 医生编码 // 订单创建时间 ampHos001.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // 订单创建时间 // 订单修改时间 ampHos001.updateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // 订单修改时间 // 扩展参数 ampHos001.extData = null; // 扩展参数 JObject joOut = new JObject(); joOut.Add("DischargeRegister", joRegInpar); joOut.Add("Settlement", joSetlInpar); joOut.Add("ampHos001", ampHos001.ToJson()); 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 (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++) { jaDiagnoses[i]["diag_dept"] = "A10"; 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", 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_code", "A10"); joRegInpar.Add("dept_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name")); joRegInpar.Add("caty", "A10"); joRegInpar.Add("exp_content", ""); 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")); //计划生育手术或生育日期 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", ""); JObject joExpContent = new JObject(); JObject joTrum = new JObject(); joTrum.Add("trum_flag", frmReg.traumaFlag);//外伤标志 0 否 1是 joTrum.Add("rel_ttp_flag", frmReg.relTtpFlag);//涉及第三方标志 0 否 1是 //JObject joMdtPep = new JObject();//就诊人群类型 mdtrt_grp_content //joMdtPep.Add("mdtrt_grp_type", "");//1新冠肺炎确诊患者 2其他国家突发公共事件 3新冠肺炎疑似患者 4无症状感染者 joExpContent.Add("trum_content", joTrum);//外伤节点 trum_content //信用支付 //dynamic joCredit = new { bank_code = "", pay_fee = 0}; //joExpContent.Add("credit_info",JObject.FromObject(joCredit)); //joExpContent.Add("credit_flag", frmReg.creditFlag); joSetlInpar.Add("exp_content", joExpContent); //字段扩展 joSetlInpar.Add("minpacunt_drug_trac_cnt", Global.Set.minpacunt_drug_trac_cnt); joSetlInpar.Add("mcs_trac_cnt", Global.Set.mcs_trac_cnt); joReg.Add("mdtrtinfo", joMdtrtinfo); joReg.Add("diseinfo", jaDiagnoses); joReg.Add("settlement", joSetlInpar); // AmpHos001 ampHos001 = new AmpHos001(); // 院内证件类型,和 ORG_001 的his_cust_list 内的his_cust_type 是同样的意思 ampHos001.hisCustType = Global.pat.mdtrtcertType; // 院内证件类型 // 院内证件号,和 ORG_001 的his_cust_list 内的his_cust_id 是同样的意思 ampHos001.hisCustId = Global.pat.certNO; // 院内证件号 // 应用类型 ampHos001.appType = "01"; // 应用类型应用类型 01 门诊02 住院03 挂号04 线上 // 医疗机构订单号 ampHos001.medOrgOrd = Global.inf.hospitalNO + Global.pat.settlID; // 医疗机构订单号 ,必填,通过这个单号来回查推送的详情数据\norgCode+subOrgCode+medOrgOrd 不超过47位。\nmedOrgOrd 和 ORG_002 返回的org_trace_no 需要一致 // 分院编号 ampHos001.subOrgCode = ""; // 分院编号 // 订单状态 ampHos001.orderStatus = ""; // 订单状态 "pushType 类型为 HOSPITAL_PAYMENT 时必填\nMERCHANT_WAIT_PAY 待支付\nMERCHANT_PAID 已支付\nMERCHANT_PART_REFUNDED 已部分退款\nMERCHANT_REFUNDED 已全额退款\nMERCHANT_CLOSED 已取消") // 机构代码 ampHos001.orgCode =Global.inf.hospitalNO; // 机构代码 // 用户名 ampHos001.patientName = Global.pat.name; // 用户名 // 证件类型 ampHos001.idType = Global.pat.certType; // 证件类型 // 证件号 ampHos001.idNo = Global.pat.certNO; // 证件号 // 推送类型 ampHos001.pushType = "HOSPITAL_PAYMENT"; // 推送类型HOSPITAL_APPOINTMENT 挂号单 HOSPITAL_PAYMENT 支付单 // 子订单类型 ampHos001.subOrderType = ""; // 子订单类型 只有当 pushType 为挂号单时必填 APPOINTMENT_WAIT_PA // 是否本人挂号 ampHos001.isDoneBySelf = ""; // 是否本人挂号 只有当 pushType 为挂号单时必填YES 是NO 否NULL 未知 // 下一步就医指引 ampHos001.nextStepTips = ""; // 下一步就医指引 一、当 pushType 为挂号单时必填a)当 subOrderType 为预约成功待⽀付,并且承接⻚⽀持在线医保⽀付的时候,建议传⼊⽂案:“⽀持在线医保⽀付,⽆需取号,直接前往就诊科室”b)当 subOrderType 为其他 类型(非待支付)时,建 议传⼊⽂案“请前往 3 楼302 室内科签到就诊”,或 者自定义⽂案;二、当 pushType 为支付单 时必填a)医保订单待支付提醒中, 请传入支付相关提示,如 “点击在线医保支付,无 需前往窗口/ 自助机排队”b)医保订单支付完成提醒中,请传入取药、检查检验的指引,如“请前往 3 楼⻄药房 5 号窗⼝取药。” // 预约时间 ampHos001.scheduledTime = ""; // 预约时间 当推送类型为“挂号单 ”时 必填。格式:yyyy-MM-dd HH:mm:ss // 重定向地址 ampHos001.redirectUrl = ""; // 重定向地址 // 科室名称 ampHos001.deptName = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name"); // 科室名称 // 科室编码 ampHos001.deptCode = "A10"; // 科室编码 // 科室地址 ampHos001.deptLoc = ""; // 科室地址 // 医生姓名 ampHos001.drName = ""; // 医生姓名 // 医生职级 ampHos001.drLvName = ""; // 医生职级 // 医生编码 ampHos001.drNo = ""; // 医生编码 // 订单创建时间 ampHos001.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // 订单创建时间 // 订单修改时间 ampHos001.updateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // 订单修改时间 // 扩展参数 ampHos001.extData = null; // 扩展参数 joReg.Add("ampHos001", ampHos001.ToJson()); regInfo = joReg.ToString(); return 0; } else { regInfo = "收费员取消操作!"; return -1; } } catch (Exception ex) { regInfo = "登记界面显示异常:" + ex.Message; return -1; } } public int showOutPatRegisterForm(string patInfo, out string regInfo) { //登记面板实例 OutpatientRegistration frmReg = new OutpatientRegistration(); //如果是慢性病患者,查询慢病信息 string chronicDieseaseInfo = ""; if (Global.pat.medType == "14") { if (QueryOPChronicDisease(out chronicDieseaseInfo) != 0) { regInfo = "检测到患者为慢病患者,但查询中心的慢病信息出错!"; return -1; } DataTable dtChronicDiesease = JsonConvert.DeserializeObject(chronicDieseaseInfo); // 获取当前日期 DateTime today = DateTime.Today; // 先筛选出符合条件的 DataRow(不投影) IEnumerable filteredRows = dtChronicDiesease.AsEnumerable() .Where(row => { var endDateObj = row["enddate"]; if (endDateObj == null || endDateObj == DBNull.Value) return false; if (endDateObj is DateTime endDate) return endDate.Date < today; if (endDateObj is string endDateStr && DateTime.TryParse(endDateStr, out var endDate2)) return endDate2.Date < today; return false; }); // 如果结果为空,避免 CopyToDataTable 抛异常 DataTable resultTable; if (filteredRows.Any()) { // 复制成一个新的 DataTable(包含原表所有列) DataTable filteredTable = filteredRows.CopyToDataTable(); // 创建目标 DataTable resultTable = new DataTable(""); resultTable.Columns.Add("Code", typeof(string)); resultTable.Columns.Add("Name", typeof(string)); resultTable.Columns.Add("SearchCode", typeof(string)); // 投影每一行数据到新结构 foreach (DataRow sourceRow in filteredTable.Rows) { resultTable.Rows.Add( sourceRow["opsp_dise_code"], sourceRow["opsp_dise_name"], sourceRow["opsp_dise_name"] ); } // 现在 resultTable 就是你需要的 DataTable } else { // 处理空集合情况 resultTable = new DataTable(""); resultTable.Columns.Add("Code", typeof(string)); resultTable.Columns.Add("Name", typeof(string)); resultTable.Columns.Add("SearchCode", typeof(string)); // 返回空表 } } //调用服务获取门诊诊断信息 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")); //frmReg.initBaseInfo(JObject.Parse(patInfo)); //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; string defaultMedType = string.IsNullOrEmpty(Global.pat.medType) ? "9901" : Global.pat.medType; for (int i = 0; i < dtMedType.Rows.Count; i++) { if (dtMedType.Rows[i]["Code"].ToString() == defaultMedType) { 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 (tools.ShowAppDiaglog(frmReg) == DialogResult.OK) { string diseCodg = frmReg.diseCodg, diseName = frmReg.diseName; #region 组织挂号入参 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); Global.pat.insuType = frmReg.insuType; joRegInpar.Add("begntime", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.begntime"));//挂号时间 occurTime joRegInpar.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); joRegInpar.Add("mdtrt_cert_no", Global.pat.certNO); string admDr = Utils.convertAdmDr(Global.pat.adm_Dr.ToString()); joRegInpar.Add("ipt_otp_no", admDr); 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", ""); joRegInpar.Add("caty", "A10"); string dscg_maindiag_code = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_code"); string dscg_maindiag_name = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_name"); List lstDiag = new List { "H52.300x002", "H52.701", "Z46.000", "Z97.300", "Z97.300x002" }; if (lstDiag.Contains(dscg_maindiag_code)) { regInfo = $"请检查主诊断【{dscg_maindiag_name}】!该诊断不允许进行医保结算!"; return -1; } #endregion #region 组织就诊信息入参 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")); //孕周数 // 特殊2203A需要exp_content字段 JObject ExportObj = new JObject(); ExportObj.Add("dise_reim_mon", ""); ExportObj.Add("deve_flag", ""); ExportObj.Add("otp_reim_flag", ""); ExportObj.Add("local_dise", ""); //单病种编码 ExportObj.Add("ifen_flag", ""); //传染性标志 //ExportObj.Add("cla_trt_flag", frmReg.claTrtFlag); //分级诊疗标志 ExportObj.Add("trum_flag", frmReg.traumaFlag); //外伤标志 //ExportObj.Add("ipt_type", frmReg.iptTypeCode); //住院类型(离院) ExportObj.Add("rel_ttp_flag", frmReg.relTtpFlag); //涉及第三方标志 ExportObj.Add("mdtrt_grp_type", ""); //就诊人群类型 ExportObj.Add("elec_bill_code", ""); //电子票据代码 ExportObj.Add("elec billno_code", ""); //电子票据号码 ExportObj.Add("otp_er_refl_flag", ""); //门诊转急诊 joMdtrtinfo.Add("exp_content", ExportObj); //字段扩展 #endregion #region 组织结算入参 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", ""); joSetlInpar.Add("mdtrt_mode", "0"); joSetlInpar.Add("minpacunt_drug_trac_cnt", Global.Set.minpacunt_drug_trac_cnt); joSetlInpar.Add("mcs_trac_cnt", Global.Set.mcs_trac_cnt); #endregion joReg.Add("data", joRegInpar); 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 QueryOPChronicDisease(out string chronicDiseaseInfo) { TradeEnum trade; if (Global.pat.insuplc_admdvs.Substring(0, 4) != Global.inf.areaCode.Substring(0, 4)) { trade = TradeEnum.QueryChronicDiseaseRecord; } else { trade = TradeEnum.QueryChronicDiseaseRecordLocal; } JObject joTmp = new JObject(); joTmp.Add("psn_no", Global.pat.psn_no); JObject joData = new JObject(); joData.Add("data", joTmp); //5301 也可以 JObject joRtn = invoker.invokeCenterService(trade.GetCode(), joData); string err; if (JsonHelper.parseCenterRtnValue(joRtn, out chronicDiseaseInfo) != 0) { return -1; } else { if (trade == TradeEnum.QueryChronicDiseaseRecord) { chronicDiseaseInfo = JsonHelper.getDestValue(joRtn, "output.feedetail"); } else { chronicDiseaseInfo = JsonHelper.getDestValue(joRtn, "output.result"); } return 0; } } /// /// 获取门诊患者的各入参 /// /// /// public int getOutPatientInparamForPayAfterTreatment(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")); //转换下主要诊断 for (int i = 0; i < jaDiagnoses.Count; i++) { jaDiagnoses[i]["diag_dept"] = "A10"; 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; } } } string diseCodg = "", diseName = ""; diseCodg = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_code"); 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", Global.pat.insuType); joRegInpar.Add("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_code", "A10"); joRegInpar.Add("dept_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name")); joRegInpar.Add("caty", "A10"); joRegInpar.Add("exp_content", ""); 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); //人员编号 joMdtrtinfo.Add("med_type", Global.pat.medType); //医疗类别 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")); //计划生育手术或生育日期 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", "01"); //结算方式 写死 joSetlInpar.Add("mdtrt_id", Global.pat.mdtrtID); joSetlInpar.Add("chrg_bchno", Global.pat.adm_Dr.ToString()); joSetlInpar.Add("acct_used_flag", Global.Set.acctUsedFlag);//个人账户使用标志 joSetlInpar.Add("insutype", Global.pat.insuType);//险种类型 joSetlInpar.Add("pub_hosp_rfom_flag", ""); JObject joExpContent = new JObject(); JObject joTrum = new JObject(); joTrum.Add("trum_flag", "");//外伤标志 0 否 1是 joTrum.Add("rel_ttp_flag", "");//涉及第三方标志 0 否 1是 //JObject joMdtPep = new JObject();//就诊人群类型 mdtrt_grp_content //joMdtPep.Add("mdtrt_grp_type", "");//1新冠肺炎确诊患者 2其他国家突发公共事件 3新冠肺炎疑似患者 4无症状感染者 joExpContent.Add("trum_content", joTrum);//外伤节点 trum_content //信用支付 //dynamic joCredit = new { bank_code = "", pay_fee = 0}; //joExpContent.Add("credit_info",JObject.FromObject(joCredit)); //joExpContent.Add("credit_flag", frmReg.creditFlag); joSetlInpar.Add("exp_content", joExpContent); //字段扩展 joReg.Add("mdtrtinfo", joMdtrtinfo); joReg.Add("diseinfo", jaDiagnoses); joReg.Add("settlement", joSetlInpar); regInfo = joReg.ToString(); return 0; } 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]["rxno"] = ""; //临时改,后面处理 jaFeeDetail[i]["chrg_bchno"] = Global.pat.adm_Dr.ToString(); jaFeeDetail[i]["med_type"] = Global.pat.medType; jaFeeDetail[i]["bilg_dept_codg"] = "A10"; jaFeeDetail[i]["acord_dept_codg"] = "A10"; if (jaFeeDetail[i]["med_list_codg"].ToString().Substring(0, 1) == "C") { jaFeeDetail[i]["medins_list_codg"] = jaFeeDetail[i]["med_list_codg"].ToString();//耗材院内医疗机构编码传医保目录27位 jaFeeDetail[i]["med_list_codg"] = jaFeeDetail[i]["med_list_codg"].ToString().Substring(0, 15);//耗材医保目录传15位 } 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; } } //如果患者异地的则就医地需要该为369900 if (Global.pat.insuplc_admdvs != "") { if (Global.pat.insuplc_admdvs.Substring(0, 4) != Global.inf.areaCode.Substring(0, 4)) { Global.inf.areaCode = "459900"; } } } catch (Exception ex) { Global.writeLog("GetRegPatInfo(" + businessType + ")", JsonHelper.Compress(joInparam),"PAT结构体设置异常:" + ex.Message); } } /// /// 获取就诊费用明细 /// /// /// public CallResult getFeeDetail() { string outParam = ""; //获取IS费用 if (hIS.getHisFee(Global.pat, out outParam) != 0) { return new CallResult(-1, "获取His费用失败!", outParam); } //调用医保平台转换HIS费用(转换医保编码等) JObject joHisFee = JObject.Parse(outParam); if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0) { return new CallResult(-2, "转换社保费用失败", outParam); } return new CallResult(0, "成功", JsonHelper.getDestValue(JObject.Parse(outParam), "data")); } /// /// 获取费用上传时前端传入的信息,并赋值给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 = "229900"; } } } 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 = ""; 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"); 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 "M6C"://移动支付门诊结算撤销,长春移动支付退费走线下模式,从核心接口退费 { 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"); 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"); 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; } case "M7": case "M8":// 长春先医后付挂号 { 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"); Global.Set.acctUsedFlag = JsonHelper.getDestValue(joInparam, "insuAdmObj.acct_used_flag"); 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.medType = JsonHelper.getDestValue(joInparam, "insuAdmObj.med_type"); 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.Set.operationType = (OperationType)Enum.Parse(typeof(OperationType), JsonHelper.getDestValue(joInparam, "operationType")); 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.Set.operationType = (OperationType)Enum.Parse(typeof(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.Set.operationType = (OperationType)Enum.Parse(typeof(OperationType), JsonHelper.getDestValue(joInparam, "operationType")); break; } case "IPInReg"://入院登记 { Global.ssmp.cardType = JsonHelper.getDestValue(joInparam, "params[0].cardType"); //Global.operationType = JsonHelper.getDestValue(joInparam, "operationType") + "-" + businessType; Global.Set.operationType = (OperationType)Enum.Parse(typeof(OperationType), JsonHelper.getDestValue(joInparam, "operationType")); 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 = "", 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 JObject DownloadDirectory(TradeEnum trade, string inParam) { string errorMessage = "", sRtn = ""; JObject joRtn = new JObject(); try { JObject joCenterRtn = cBus.DownDirecotry(trade, 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); if (File.Exists(txtFilePath)) { //询问收款员是否继续进行HIS退费 if (DialogResult.Yes == MessageBox.Show("下载的文件已存在,是否覆盖? ", "提示", MessageBoxButtons.YesNo)) { File.Delete(txtFilePath); } else { joRtn = (JObject)jo9102Rtn.DeepClone(); joRtn["filePath"] = txtFilePath; return joRtn; } } //昆明下载下来的文件是解压后的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 (Global.pat.creditArray != null) { frmSettlment.dtCreditInfo = (DataTable)Global.pat.creditArray.ToObject(typeof(DataTable)); } //相关信息转换到结算信息面板 if (frmSettlment.ShowDialog() == DialogResult.OK) { //信用支付 dynamic joCredit = new { bank_code = frmSettlment.bankCode, pay_fee = frmSettlment.payFee }; JObject joExpContent = new JObject(); joExpContent.Add("credit_info", JObject.FromObject(joCredit)); joExpContent.Add("credit_flag", frmSettlment.creditFlag); Global.writeLog("joExpContent" + joExpContent.ToString()); outParam = joExpContent.ToString(); 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 preSettlementForPayAfterTreatment(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; } 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; } 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); //从云医保平台获取患者详细的医保登记信息 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")); // MessageBox.Show("读卡获取参保地1:" + Global.pat.insuplc_admdvs); //出院登记放再预结算之前 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(); if (Global.Set.creditFlag == "1") { Global.writeLog($"OUT:{outParam}"); JObject joTmp = JObject.Parse(outParam); Global.writeLog($"joTmp:{joTmp}"); Global.writeLog("joSettlement" + joSettlement.ToString()); //信用支付 JObject joExpContent = new JObject(); if (JsonHelper.getDestValue(joSettlement, "Settlement.exp_content") != "") { joExpContent = JObject.Parse(JsonHelper.getDestValue(joSettlement, "exp_content")); } else { joSettlement["Settlement"]["exp_content"] = new JObject(); } joExpContent.Add("credit_info", JObject.Parse(JsonHelper.getDestValue(joTmp, "credit_info"))); joExpContent.Add("credit_flag", JsonHelper.getDestValue(joTmp, "credit_flag")); joSettlement["Settlement"]["exp_content"] = joExpContent; } 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")); JObject joExpContent = new JObject(); if (JsonHelper.getDestValue(joPatInfo, "output.exp_content") != "") { joExpContent = JObject.Parse(JsonHelper.getDestValue(joPatInfo, "output.exp_content")); } else { joExpContent = null; } if (mIS.insertPatCurInsuInfo(joBaseInfo, joInsuInfo, joIdetInfo,joExpContent, out outparam) != 0) { return -1; } else { return 0; } } catch (Exception e) { outparam = "插入患者该次就诊参保信息失败:" + e.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; } } #region【事前事中服务】 /// /// 事前分析 /// /// /// 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")); string HasValues = JsonHelper.getDestValue(joRtn, "output.result[0].HasValues").ToString(); if (jaResult.HasValues) { PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(joRtn); if (paipaForm.ShowDialog() == DialogResult.OK) { //【3103】事前事中服务反馈服务 if (PreAnalysisFeedBack("3101", paipaForm.JrID, out outparam) != 0) { outparam = "【3103】事前事中服务反馈服务" + outparam; return -1; } else { return 0; } } else { outparam = "事前事中审核不通过,操作员取消!"; return -1; } } else { return 0; } if (HasValues == "") { outparam = "事前事中审核服务未返回详细说明!"; return -1; } } } 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 int PreAnalysisFeedBack(string funNo, string jrId, out string outparam) { outparam = ""; try { outparam = ""; string WarnType = ""; //【3103】事前事中服务反馈服务 if (funNo == "3101") WarnType = "1"; else if (funNo == "3102") WarnType = "2"; JObject joInput3103Warns = new JObject(); joInput3103Warns.Add("warn_rslt_id", jrId); joInput3103Warns.Add("dspo_way", Global.Set.dspoWay); joInput3103Warns.Add("dspo_way_rea", Global.Set.dspoWayRea); JArray ja3103Warns = new JArray(); ja3103Warns.Add(joInput3103Warns); JObject joInput3103 = new JObject(); joInput3103.Add("warn_type", WarnType); //反馈类型 1.事前 2.事中 joInput3103.Add("warns", ja3103Warns); JObject joInput = new JObject(); joInput.Add("data", joInput3103); JObject jo3103Rtn = invoker.invokeCenterService("3103", JsonHelper.setCenterInpar("3103", joInput.ToString())); if (JsonHelper.parseCenterRtnValue(jo3103Rtn, out string errMsg) != 0) { outparam = JsonHelper.setExceptionJson(-1, "【3103】事前事中服务反馈服务调用失败:", errMsg).ToString(); return -1; } return 0; } catch (Exception ex) { outparam = ex.Message; return -1; } finally { Global.writeLog("PreAnalysisFeedBack", "", outparam); } } #endregion } }