OrganizeIPPatientInparam.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.Helper;
  3. using PTMedicalInsurance.Variables;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PTMedicalInsurance.Business.Core.SelfServiceMachine.Process.InPat
  10. {
  11. class OrganizeIPPatientInparam : AbstractProcess
  12. {
  13. public override CallResult Process(JObject input)
  14. {
  15. //调用IRIS获取医保各项金额
  16. if (mIS.getSumFee(out errMsg) != 0)
  17. {
  18. outParam = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", errMsg).ToString();
  19. return Exception(outParam);
  20. }
  21. JObject joSumFee = JObject.Parse(errMsg);
  22. if ((JsonHelper.getDestValue(joSumFee, "data.Sumamt") == "") || (JsonHelper.getDestValue(joSumFee, "data.Sumamt") == "0"))
  23. {
  24. outParam = "未检测到上传费用!";
  25. return Exception(outParam);
  26. }
  27. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  28. {
  29. outParam = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  30. return Exception(outParam);
  31. }
  32. JObject joReg = JObject.Parse(outParam);
  33. Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
  34. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  35. if ((Global.pat.mdtrtcertType == "") || (Global.pat.mdtrtcertNO == ""))
  36. {
  37. Global.pat.mdtrtcertType = JsonHelper.getDestValue(joReg, "data.CertificateType");
  38. Global.pat.mdtrtcertNO = JsonHelper.getDestValue(joReg, "data.CertificateNO");
  39. }
  40. //Global.pat.mdtrtcertType = JsonHelper.getDestValue(joReg, "data.CertificateType");
  41. //Global.pat.mdtrtcertNO = JsonHelper.getDestValue(joReg, "data.CertificateNO");
  42. Global.pat.certType = JsonHelper.getDestValue(joReg, "data.CertificateType");
  43. Global.pat.certNO = JsonHelper.getDestValue(joReg, "data.CertificateNO"); //影响后面的验密 ,
  44. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode");
  45. Global.pat.psn_type = Global.pat.insuType; //后面再改
  46. //if (Global.pat.RYorCY == "2")
  47. //{
  48. // Global.pat.DiseasecCode = JsonHelper.getDestValue(joReg, "data.DiseasecCode");
  49. // Global.pat.DiseasecName = JsonHelper.getDestValue(joReg, "data.DiseasecName");
  50. //}
  51. if ((Global.pat.medType == "2101") && (JsonHelper.getDestValue(joReg, "data.DiseasecCode") == "") && (Global.pat.RYorCY == "2"))
  52. {
  53. Global.pat.DiseasecCode = JsonHelper.getDestValue(joReg, "data.MainDiagCode");
  54. Global.pat.DiseasecName = JsonHelper.getDestValue(joReg, "data.MainDiagName");
  55. }
  56. //调用服务获取门诊诊断信息
  57. string diagnoses;
  58. if (hIS.getPatDiagnoses(Global.pat, out diagnoses) != 0)
  59. {
  60. outParam = JsonHelper.setExceptionJson(-1, "getPatDiagnoses", diagnoses).ToString();
  61. return Exception(outParam);
  62. }
  63. JObject joDiagnoses = JObject.Parse(diagnoses);
  64. JObject joHisRtnInfo = (JObject)joDiagnoses.DeepClone();
  65. JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joHisRtnInfo, "diseinfo"));
  66. //从费用核查获取,可以先按照默认走一遍试试
  67. // 对诊断数组进行转换 转换下主要诊断
  68. JArray jaConvertedDiagnoses = new JArray();
  69. string dscg_maindiag_code = "", dscg_maindiag_name = "";
  70. for (int i = 0; i < jaDiagnoses.Count; i++)
  71. {
  72. string diag_type = JsonHelper.getDestValue((JObject)jaDiagnoses[i], "diag_type");
  73. switch (diag_type)
  74. {
  75. case "1":
  76. {
  77. jaDiagnoses[i]["diag_type_name"] = new JObject();
  78. jaDiagnoses[i]["diag_type_name"] = "西医主要诊断";
  79. break;
  80. }
  81. case "2":
  82. {
  83. jaDiagnoses[i]["diag_type_name"] = new JObject();
  84. jaDiagnoses[i]["diag_type_name"] = "西医其他诊断";
  85. break;
  86. }
  87. case "3":
  88. {
  89. jaDiagnoses[i]["diag_type_name"] = new JObject();
  90. jaDiagnoses[i]["diag_type_name"] = "中医主病诊断";
  91. break;
  92. }
  93. case "4":
  94. {
  95. jaDiagnoses[i]["diag_type_name"] = new JObject();
  96. jaDiagnoses[i]["diag_type_name"] = "中医主证诊断";
  97. break;
  98. }
  99. }
  100. //出院登记 取出院诊断信息
  101. if (Global.pat.RYorCY == "2")
  102. {
  103. if (jaDiagnoses[i]["diaTypeCode"].ToString() == "DIS") //ADD 入院 OPD 门诊 DIS 出院
  104. {
  105. jaConvertedDiagnoses.Add(jaDiagnoses[i]);
  106. }
  107. }
  108. else
  109. {
  110. if (jaDiagnoses[i]["diaTypeCode"].ToString() == "ADD") //ADD 入院 OPD 门诊 DIS 出院
  111. {
  112. jaConvertedDiagnoses.Add(jaDiagnoses[i]);
  113. }
  114. }
  115. }
  116. for (int i = 0; i < jaConvertedDiagnoses.Count; i++)
  117. {
  118. jaConvertedDiagnoses[i]["diag_srt_no"] = i + 1;
  119. if (jaConvertedDiagnoses[i]["maindiag_flag"].ToString() == "1")
  120. {
  121. dscg_maindiag_code = jaConvertedDiagnoses[i]["diag_code"].ToString();
  122. dscg_maindiag_name = jaConvertedDiagnoses[i]["diag_name"].ToString();
  123. }
  124. //增加就诊ID
  125. jaConvertedDiagnoses[i]["mdtrt_id"] = new JObject();
  126. jaConvertedDiagnoses[i]["mdtrt_id"] = Global.pat.mdtrtID;
  127. }
  128. //费用核查
  129. //查询费用核查信息 regType -1表示查询全部明细
  130. JArray jaDisRegAuditDetail;
  131. int disRegAuditDetailCount =0;
  132. JObject joAuditInfo;
  133. if (mIS.queryDischargeAuditInfo(out errMsg) != 0)
  134. {
  135. return Exception(errMsg) ;
  136. }
  137. else
  138. {
  139. JObject joRtn = JObject.Parse(errMsg);
  140. joAuditInfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "result.AuditInfo"));
  141. //jaAdmRegAuditDetail = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.AdmReg"));
  142. jaDisRegAuditDetail = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.DisReg"));
  143. //jaOutpatRegAuditDetail = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.OutpatReg"));
  144. //admRegAuditDetailCount = int.Parse(JsonHelper.getDestValue(joRtn, "result.AdmRegCount"));
  145. disRegAuditDetailCount = int.Parse(JsonHelper.getDestValue(joRtn, "result.DisRegCount"));
  146. //outpatRegAuditDetailCount = int.Parse(JsonHelper.getDestValue(joRtn, "result.OutpatRegCount"));
  147. }
  148. int auditStatus = int.Parse(JsonHelper.getDestValue(joAuditInfo, "AuditStatus"));
  149. string memo = JsonHelper.getDestValue(joAuditInfo, "Memo");
  150. if (auditStatus == 0)
  151. {
  152. return Exception("本次就诊未进行出院审核,请联系服务人员处理!");
  153. }
  154. if (auditStatus == -1)
  155. {
  156. return Exception($"本次就诊未通过出院审核,原因为{memo},请联系服务人员处理!");
  157. }
  158. string personSettlementWay = "";
  159. string halfwaySettlementFlag = "";
  160. string personAccountUsedFlag = "";
  161. foreach (JObject jo in jaDisRegAuditDetail)
  162. {
  163. //if (jo["DetailCode"].ToString() == "insutype")
  164. //{
  165. // Global.pat.insuType = jo["Value"].ToString();
  166. //}
  167. if (jo["DetailCode"].ToString() == "med_type")
  168. {
  169. Global.pat.medType = jo["Value"].ToString();
  170. }
  171. if (jo["DetailCode"].ToString() == "dise_codg")
  172. {
  173. Global.pat.DiseasecCode = jo["Value"].ToString();
  174. }
  175. if (jo["DetailCode"].ToString() == "dise_name")
  176. {
  177. Global.pat.discDiagName = jo["Value"].ToString();
  178. }
  179. if (jo["DetailCode"].ToString() == "oprn_oprt_code")
  180. {
  181. Global.pat.operCode = jo["Value"].ToString();
  182. }
  183. if (jo["DetailCode"].ToString() == "oprn_oprt_name")
  184. {
  185. Global.pat.operName = jo["Value"].ToString();
  186. }
  187. if (jo["DetailCode"].ToString() == "dise_type_code")
  188. {
  189. Global.pat.DiseasecType = jo["Value"].ToString();
  190. }
  191. if (jo["DetailCode"].ToString() == "mid_setl_flag")
  192. {
  193. halfwaySettlementFlag = jo["Value"].ToString();
  194. }
  195. if (jo["DetailCode"].ToString() == "acct_used_flag")
  196. {
  197. personAccountUsedFlag = jo["Value"].ToString();
  198. }
  199. if (jo["DetailCode"].ToString() == "psn_setlway")
  200. {
  201. personSettlementWay = jo["Value"].ToString();
  202. }
  203. }
  204. if (string.IsNullOrEmpty(personSettlementWay))
  205. {
  206. return Exception("出院审核未设置个人结算方式");
  207. }
  208. if (string.IsNullOrEmpty(halfwaySettlementFlag))
  209. {
  210. return Exception("出院审核未设置中途结算方式");
  211. }
  212. if (string.IsNullOrEmpty(personAccountUsedFlag))
  213. {
  214. return Exception("出院审核未设置账户支付方式");
  215. }
  216. if (string.IsNullOrEmpty(Global.pat.medType))
  217. {
  218. return Exception("出院审核未设置医疗类别");
  219. }
  220. JObject joDscgInfo = new JObject();
  221. joDscgInfo.Add("mdtrt_id", Global.pat.mdtrtID);
  222. joDscgInfo.Add("psn_no", Global.pat.psn_no); //人员编号
  223. joDscgInfo.Add("insutype", Global.pat.insuType); //险种类型
  224. //joDscgInfo.Add("coner_name", JsonHelper.getJsonValue(joHisPatInfo, "coner_name")); //联系人姓名
  225. //joDscgInfo.Add("tel", JsonHelper.getJsonValue(joHisPatInfo, "tel")); //联系电话
  226. joDscgInfo.Add("endtime", Global.Set.hisDischargeTime); //结束时间DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  227. joDscgInfo.Add("dise_codg", Global.pat.disCode); //病种编码
  228. joDscgInfo.Add("dise_name", Global.pat.disName); //病种名称
  229. joDscgInfo.Add("oprn_oprt_code", Global.pat.operCode); //手术操作代码
  230. joDscgInfo.Add("oprn_oprt_name", Global.pat.operName); //手术操作名称
  231. joDscgInfo.Add("fpsc_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fpsc_no")); //计划生育服务证号
  232. joDscgInfo.Add("matn_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.matn_type")); //生育类别
  233. joDscgInfo.Add("birctrl_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_type")); //计划生育手术类别
  234. joDscgInfo.Add("latechb_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.latechb_flag")); //晚育标志
  235. joDscgInfo.Add("geso_val", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.geso_val")); //孕周数
  236. joDscgInfo.Add("fetts", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fetts")); //胎次
  237. joDscgInfo.Add("fetus_cnt", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fetus_cnt")); //胎儿数
  238. joDscgInfo.Add("pret_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.pret_flag")); //早产标志
  239. joDscgInfo.Add("birctrl_matn_date", ""); //计划生育手术或生育日期 JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_matn_date") 20230228医保中心校验传正确时间或空
  240. joDscgInfo.Add("cop_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dise_type_code")); //伴有并发症标志
  241. joDscgInfo.Add("dscg_dept_codg", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_codg")); //出院科室编码
  242. joDscgInfo.Add("dscg_dept_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name")); //出院科室名称
  243. joDscgInfo.Add("dscg_bed", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_bed")); //出院床位
  244. joDscgInfo.Add("dscg_way", "1"); //离院方式
  245. joDscgInfo.Add("die_date", ""); //死亡日期
  246. joDscgInfo.Add("exp_content", ""); //字段扩展
  247. joDscgInfo.Add("insuplc_admdvs", Global.pat.insuplc_admdvs); //参保地医保区划
  248. joDscgInfo.Add("mdtrtarea_admvs", Global.inf.areaCode); //就医地医保区划
  249. JObject joRegInpar = new JObject();
  250. joRegInpar.Add("dscginfo", joDscgInfo);
  251. joRegInpar.Add("diseinfo", jaConvertedDiagnoses);
  252. //结算入参
  253. JObject joSetlInpar = new JObject();
  254. joSetlInpar.Add("psn_no", Global.pat.psn_no);
  255. joSetlInpar.Add("chrg_bchno", Global.pat.adm_Dr.ToString());
  256. joSetlInpar.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
  257. joSetlInpar.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO);
  258. joSetlInpar.Add("med_type", Global.pat.medType);
  259. joSetlInpar.Add("medfee_sumamt", JsonHelper.getDestValue(joSumFee, "data.Sumamt"));
  260. joSetlInpar.Add("psn_setlway", personSettlementWay); //结算方式
  261. joSetlInpar.Add("mdtrt_id", Global.pat.mdtrtID);
  262. joSetlInpar.Add("acct_used_flag", personAccountUsedFlag);//个人账户使用标志
  263. joSetlInpar.Add("insutype", Global.pat.insuType);//险种类型
  264. joSetlInpar.Add("insuplc_admdvs", Global.pat.insuplc_admdvs);
  265. joSetlInpar.Add("mdtrtarea_admvs", Global.inf.areaCode);
  266. joSetlInpar.Add("invono", "");
  267. joSetlInpar.Add("mid_setl_flag", halfwaySettlementFlag);
  268. joSetlInpar.Add("fulamt_ownpay_amt", JsonHelper.getDestValue(joSumFee, "data.FullOwnPayAmount"));
  269. joSetlInpar.Add("overlmt_selfpay", JsonHelper.getDestValue(joSumFee, "data.OverLimitAmount"));
  270. joSetlInpar.Add("preselfpay_amt", JsonHelper.getDestValue(joSumFee, "data.PreSelfPayAmount"));
  271. joSetlInpar.Add("dscgTime", Global.Set.hisDischargeTime);
  272. JObject joDataExp = new JObject();
  273. joDataExp.Add("acct_payamt", "0.00");
  274. joDataExp.Add("cla_trt_flag", "");
  275. joSetlInpar.Add("exp_content", joDataExp); //11111
  276. JObject joOut = new JObject();
  277. joOut.Add("DischargeRegister", joRegInpar);
  278. joOut.Add("Settlement", joSetlInpar);
  279. joOut.Add("errorCode", 0);
  280. outParam = joOut.ToString();
  281. return Success();
  282. }
  283. }
  284. }