IPSettlementProcess.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.CardReaders;
  3. using PTMedicalInsurance.Common;
  4. using PTMedicalInsurance.Helper;
  5. using PTMedicalInsurance.Variables;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace PTMedicalInsurance.Business
  12. {
  13. class IPSettlementProcess : AbstractProcess
  14. {
  15. public IPSettlementProcess()
  16. {
  17. }
  18. public IPSettlementProcess(JObject orginal)
  19. {
  20. this.OrginalInput = orginal;
  21. }
  22. public override CallResult Process(JObject input)
  23. {
  24. string errMsg = "";
  25. #region 正式出院结算
  26. //在正式结算前读一次卡
  27. #region 异地患者结算前统一读卡核验身份
  28. if (Global.pat.insuplc_admdvs.Substring(0, 2) != Global.inf.areaCode.Substring(0, 2))
  29. {
  30. CallResult card = new ReadCardProcess().Process(input);
  31. if (card.Code != 0)
  32. {
  33. return Exception(-1, "读卡失败,请确认是否社保卡是否正常!", card.Data);
  34. }
  35. //读完卡后用新卡串
  36. input["Settlement"]["mdtrt_cert_type"] = Global.pat.mdtrtcertType;
  37. input["Settlement"]["mdtrt_cert_no"] = Global.pat.mdtrtcertNO;
  38. }
  39. #endregion
  40. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(input, "Settlement"));
  41. //基线版扩展
  42. JObject joDataExp = (JObject)joSettlement["exp_content"] ?? new JObject();
  43. //joDataExp.Add("cardtoken", Global.pat.card.Cardtoken);
  44. joDataExp.Add("elec_bill_code", "");
  45. joDataExp.Add("elec_billno_code", "");
  46. joDataExp.Add("elec_bill_chkcode", "");
  47. joSettlement["exp_content"] = joDataExp;
  48. JObject joInpar = new JObject();
  49. joInpar.Add("data", joSettlement);
  50. JObject jo2304Rtn = invoker.invokeCenterService(TradeEnum.InpatientSettlement, joInpar);
  51. if (JsonHelper.parseCenterRtnValue(jo2304Rtn, out errMsg) != 0)
  52. {
  53. //取消出院
  54. new InpatientExitCancelProcess().Process(input);
  55. return Exception(-1, "结算失败", errMsg);
  56. }
  57. else
  58. {
  59. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo"));
  60. //济南未返回基金分项,手工拆分
  61. //JArray fundArray = new LocalPayFundSplitService().Split(joSetlinfo);
  62. //if (fundArray?.Count > 0)
  63. //{
  64. // jo2304Rtn["output"]["setldetail"] = fundArray;
  65. //}
  66. Global.pat.admType = 2;
  67. //返回给云医保平台结算信息
  68. if (mIS.saveSettlement(jo2304Rtn, out errMsg) != 0)
  69. {
  70. return Exception(-1, "结算成功,但云医保平台保存失败", errMsg);
  71. }
  72. //返回给云医保平台结算明细信息
  73. if (mIS.saveSettlementDetail(jo2304Rtn, out errMsg) != 0)
  74. {
  75. return Exception(-1, "云医保平台保存结算明细失败", errMsg);
  76. }
  77. //返回给HIS
  78. if (hIS.returnInpatSettlementInfo(OrginalInput, joSetlinfo, out outParam) != 0)
  79. {
  80. return Exception(-1, "返回结算信息给HIS", outParam);
  81. }
  82. else
  83. {
  84. ////如果是通过人脸识别,需要发送到将结算结果发送到设备上去,流水号必须是全局
  85. //if (Global.pat.mdtrtcertType == "04")
  86. //{
  87. // CardReader cardReader = new CardReader();
  88. // if (cardReader.SettleNotify(cardReader.GetSettleNotifyData("", null), out outParam) != 0)
  89. // {
  90. // }
  91. //}
  92. //返回给前端
  93. JObject joHisServieRtn = JObject.Parse(outParam);
  94. hBus.returnToFrontEndAfterSettlement(jo2304Rtn, joHisServieRtn, out outParam);
  95. return IrisReturn("结算成功", JObject.Parse(outParam));
  96. }
  97. }
  98. #endregion
  99. }
  100. }
  101. }