123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- using Newtonsoft.Json.Linq;
- using PTMedicalInsurance.Helper;
- using PTMedicalInsurance.Variables;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PTMedicalInsurance.Business.Core.SelfServiceMachine.Process.InPat
- {
- class OrganizeIPPatientInparam : AbstractProcess
- {
- public override CallResult Process(JObject input)
- {
-
- if (mIS.getSumFee(out errMsg) != 0)
- {
- outParam = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", errMsg).ToString();
- return Exception(outParam);
- }
- JObject joSumFee = JObject.Parse(errMsg);
- if ((JsonHelper.getDestValue(joSumFee, "data.Sumamt") == "") || (JsonHelper.getDestValue(joSumFee, "data.Sumamt") == "0"))
- {
- outParam = "未检测到上传费用!";
- return Exception(outParam);
- }
- if (mIS.queryRegisterInfo(1, out outParam) != 0)
- {
- outParam = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
- return Exception(outParam);
- }
- JObject joReg = JObject.Parse(outParam);
- Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
- Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
- if ((Global.pat.mdtrtcertType == "") || (Global.pat.mdtrtcertNO == ""))
- {
- 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.medType == "2101") && (JsonHelper.getDestValue(joReg, "data.DiseasecCode") == "") && (Global.pat.RYorCY == "2"))
- {
- Global.pat.DiseasecCode = JsonHelper.getDestValue(joReg, "data.MainDiagCode");
- Global.pat.DiseasecName = JsonHelper.getDestValue(joReg, "data.MainDiagName");
- }
-
- string diagnoses;
- if (hIS.getPatDiagnoses(Global.pat, out diagnoses) != 0)
- {
- outParam = JsonHelper.setExceptionJson(-1, "getPatDiagnoses", diagnoses).ToString();
- return Exception(outParam);
- }
- JObject joDiagnoses = JObject.Parse(diagnoses);
- JObject joHisRtnInfo = (JObject)joDiagnoses.DeepClone();
- JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joHisRtnInfo, "diseinfo"));
-
-
- JArray jaConvertedDiagnoses = new JArray();
- string dscg_maindiag_code = "", dscg_maindiag_name = "";
- for (int i = 0; i < jaDiagnoses.Count; i++)
- {
- string diag_type = JsonHelper.getDestValue((JObject)jaDiagnoses[i], "diag_type");
- switch (diag_type)
- {
- case "1":
- {
- jaDiagnoses[i]["diag_type_name"] = new JObject();
- jaDiagnoses[i]["diag_type_name"] = "西医主要诊断";
- break;
- }
- case "2":
- {
- jaDiagnoses[i]["diag_type_name"] = new JObject();
- jaDiagnoses[i]["diag_type_name"] = "西医其他诊断";
- break;
- }
- case "3":
- {
- jaDiagnoses[i]["diag_type_name"] = new JObject();
- jaDiagnoses[i]["diag_type_name"] = "中医主病诊断";
- break;
- }
- case "4":
- {
- jaDiagnoses[i]["diag_type_name"] = new JObject();
- jaDiagnoses[i]["diag_type_name"] = "中医主证诊断";
- break;
- }
- }
-
- if (Global.pat.RYorCY == "2")
- {
- if (jaDiagnoses[i]["diaTypeCode"].ToString() == "DIS")
- {
- jaConvertedDiagnoses.Add(jaDiagnoses[i]);
- }
- }
- else
- {
- if (jaDiagnoses[i]["diaTypeCode"].ToString() == "ADD")
- {
- jaConvertedDiagnoses.Add(jaDiagnoses[i]);
- }
- }
- }
- for (int i = 0; i < jaConvertedDiagnoses.Count; i++)
- {
- jaConvertedDiagnoses[i]["diag_srt_no"] = i + 1;
- if (jaConvertedDiagnoses[i]["maindiag_flag"].ToString() == "1")
- {
- dscg_maindiag_code = jaConvertedDiagnoses[i]["diag_code"].ToString();
- dscg_maindiag_name = jaConvertedDiagnoses[i]["diag_name"].ToString();
- }
-
- jaConvertedDiagnoses[i]["mdtrt_id"] = new JObject();
- jaConvertedDiagnoses[i]["mdtrt_id"] = Global.pat.mdtrtID;
- }
-
-
- JArray jaDisRegAuditDetail;
- int disRegAuditDetailCount =0;
- JObject joAuditInfo;
- if (mIS.queryDischargeAuditInfo(out errMsg) != 0)
- {
- return Exception(errMsg) ;
- }
- else
- {
- JObject joRtn = JObject.Parse(errMsg);
- joAuditInfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "result.AuditInfo"));
-
- jaDisRegAuditDetail = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.DisReg"));
-
-
- disRegAuditDetailCount = int.Parse(JsonHelper.getDestValue(joRtn, "result.DisRegCount"));
-
- }
- int auditStatus = int.Parse(JsonHelper.getDestValue(joAuditInfo, "AuditStatus"));
- string memo = JsonHelper.getDestValue(joAuditInfo, "Memo");
- if (auditStatus == 0)
- {
- return Exception("本次就诊未进行出院审核,请联系服务人员处理!");
- }
- if (auditStatus == -1)
- {
- return Exception($"本次就诊未通过出院审核,原因为{memo},请联系服务人员处理!");
- }
- string personSettlementWay = "";
- string halfwaySettlementFlag = "";
- string personAccountUsedFlag = "";
- foreach (JObject jo in jaDisRegAuditDetail)
- {
-
-
-
-
- if (jo["DetailCode"].ToString() == "med_type")
- {
- Global.pat.medType = jo["Value"].ToString();
- }
- if (jo["DetailCode"].ToString() == "dise_codg")
- {
- Global.pat.DiseasecCode = jo["Value"].ToString();
- }
- if (jo["DetailCode"].ToString() == "dise_name")
- {
- Global.pat.discDiagName = jo["Value"].ToString();
- }
- if (jo["DetailCode"].ToString() == "oprn_oprt_code")
- {
- Global.pat.operCode = jo["Value"].ToString();
- }
- if (jo["DetailCode"].ToString() == "oprn_oprt_name")
- {
- Global.pat.operName = jo["Value"].ToString();
- }
- if (jo["DetailCode"].ToString() == "dise_type_code")
- {
- Global.pat.DiseasecType = jo["Value"].ToString();
- }
- if (jo["DetailCode"].ToString() == "mid_setl_flag")
- {
- halfwaySettlementFlag = jo["Value"].ToString();
- }
- if (jo["DetailCode"].ToString() == "acct_used_flag")
- {
- personAccountUsedFlag = jo["Value"].ToString();
- }
- if (jo["DetailCode"].ToString() == "psn_setlway")
- {
- personSettlementWay = jo["Value"].ToString();
- }
- }
- if (string.IsNullOrEmpty(personSettlementWay))
- {
- return Exception("出院审核未设置个人结算方式");
- }
- if (string.IsNullOrEmpty(halfwaySettlementFlag))
- {
- return Exception("出院审核未设置中途结算方式");
- }
- if (string.IsNullOrEmpty(personAccountUsedFlag))
- {
- return Exception("出院审核未设置账户支付方式");
- }
- if (string.IsNullOrEmpty(Global.pat.medType))
- {
- return Exception("出院审核未设置医疗类别");
- }
- JObject joDscgInfo = new JObject();
- joDscgInfo.Add("mdtrt_id", Global.pat.mdtrtID);
- joDscgInfo.Add("psn_no", Global.pat.psn_no);
- joDscgInfo.Add("insutype", Global.pat.insuType);
-
-
- joDscgInfo.Add("endtime", Global.Set.hisDischargeTime);
- joDscgInfo.Add("dise_codg", Global.pat.disCode);
- joDscgInfo.Add("dise_name", Global.pat.disName);
- joDscgInfo.Add("oprn_oprt_code", Global.pat.operCode);
- joDscgInfo.Add("oprn_oprt_name", Global.pat.operName);
- 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", "");
- 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("chrg_bchno", Global.pat.adm_Dr.ToString());
- joSetlInpar.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
- joSetlInpar.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO);
- joSetlInpar.Add("med_type", Global.pat.medType);
- joSetlInpar.Add("medfee_sumamt", JsonHelper.getDestValue(joSumFee, "data.Sumamt"));
- joSetlInpar.Add("psn_setlway", personSettlementWay);
- joSetlInpar.Add("mdtrt_id", Global.pat.mdtrtID);
- joSetlInpar.Add("acct_used_flag", personAccountUsedFlag);
- joSetlInpar.Add("insutype", Global.pat.insuType);
- joSetlInpar.Add("insuplc_admdvs", Global.pat.insuplc_admdvs);
- joSetlInpar.Add("mdtrtarea_admvs", Global.inf.areaCode);
- joSetlInpar.Add("invono", "");
- joSetlInpar.Add("mid_setl_flag", halfwaySettlementFlag);
- 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", Global.Set.hisDischargeTime);
- JObject joDataExp = new JObject();
- joDataExp.Add("acct_payamt", "0.00");
- joDataExp.Add("cla_trt_flag", "");
- joSetlInpar.Add("exp_content", joDataExp);
- JObject joOut = new JObject();
- joOut.Add("DischargeRegister", joRegInpar);
- joOut.Add("Settlement", joSetlInpar);
- joOut.Add("errorCode", 0);
- outParam = joOut.ToString();
- return Success();
- }
- }
- }
|