AbstractProcess.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. using MedicalInsurance.Forms;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using PTMedicalInsurance.Helper;
  5. using PTMedicalInsurance.Variables;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. namespace PTMedicalInsurance.Business
  14. {
  15. abstract class AbstractProcess
  16. {
  17. protected CenterBusiness cBus = new CenterBusiness();
  18. protected HisMainBusiness hBus = new HisMainBusiness();
  19. protected HisIrisServices hIS = new HisIrisServices();
  20. protected MIIrisServices mIS = new MIIrisServices();
  21. protected InvokeHelper invoker = new InvokeHelper();
  22. protected string outParam = "";
  23. public JObject OrginalInput { set; get; }
  24. /// <summary>
  25. /// 使用原始参数
  26. /// </summary>
  27. public bool UseOrginal {
  28. get;set;
  29. }
  30. /// <summary>
  31. /// 返回成功信息
  32. /// </summary>
  33. /// <returns></returns>
  34. protected CallResult Success()
  35. {
  36. return Success("成功");
  37. }
  38. protected CallResult Success(string msg)
  39. {
  40. return new CallResult(0, msg, outParam);
  41. }
  42. /// <summary>
  43. /// 返回失败信息
  44. /// </summary>
  45. /// <param name="code"></param>
  46. /// <param name="errMsg"></param>
  47. /// <returns></returns>
  48. protected CallResult Error(int code, string errMsg)
  49. {
  50. return Exception(code, errMsg, outParam);
  51. }
  52. protected CallResult Exception(int code, string errMsg,string param)
  53. {
  54. outParam = JsonHelper.setExceptionJson(code, errMsg, param).ToString();
  55. return new CallResult(code, errMsg, outParam,param);
  56. }
  57. protected CallResult Exception(string errMsg, string param)
  58. {
  59. return Exception(-1, errMsg, param);
  60. }
  61. protected CallResult IrisReturn(string msg,JObject obj)
  62. {
  63. outParam = JsonHelper.setIrisReturnValue(0, msg, obj).ToString();
  64. return new CallResult(0, msg, outParam,obj);
  65. }
  66. /// <summary>
  67. /// 返回失败信息
  68. /// </summary>
  69. /// <param name="errMsg"></param>
  70. /// <returns></returns>
  71. protected CallResult Error(string errMsg)
  72. {
  73. return new CallResult(-1, errMsg, outParam);
  74. }
  75. /// <summary>
  76. /// 业务过程
  77. /// </summary>
  78. /// <param name="input"></param>
  79. /// <returns></returns>
  80. public abstract CallResult Process(JObject input);
  81. /// <summary>
  82. /// 根据是否需要使用共济支付重新计算结算数据
  83. /// </summary>
  84. /// <param name="setlInfo"></param>
  85. /// <returns></returns>
  86. protected JObject MutualAidPay(string setlInfo)
  87. {
  88. JObject joRtn = JObject.Parse(setlInfo);
  89. if (Global.pat.mutualAidFlag)
  90. {
  91. try
  92. {
  93. decimal psnCashPay = decimal.Parse(JsonHelper.getDestValue(joRtn, "psn_cash_pay"));
  94. if (psnCashPay == 0)
  95. {
  96. MessageBox.Show("该患者自付金额为0,不需要进行共济支付!");
  97. }
  98. else
  99. {
  100. //开启自付界面,因涉及到多次自付
  101. MutualAid frmMA = new MutualAid(joRtn);
  102. if (frmMA.dtSettlInfo.Rows.Count != 0)
  103. {
  104. frmMA.WindowState = FormWindowState.Maximized;
  105. if (frmMA.ShowDialog() == DialogResult.OK)
  106. {
  107. joRtn = JObject.Parse(frmMA.finalSettlementInfo);
  108. }
  109. else
  110. {
  111. MessageBox.Show("开启共济支付失败,原因为收款员取消共济支付!");
  112. }
  113. }
  114. else
  115. {
  116. MessageBox.Show("开启共济支付失败,原因为未检测到有效的被共济人的医保结算数据!");
  117. }
  118. }
  119. }
  120. catch (Exception ex)
  121. {
  122. MessageBox.Show("共济支付失败:" + ex.Message);
  123. }
  124. }
  125. return joRtn;
  126. }
  127. protected JObject CancelMutualAidPay(JObject joRtn)
  128. {
  129. DataTable dtSettlInfo = (DataTable)JsonConvert.DeserializeObject(joRtn["result"]["data"].ToString(), (typeof(DataTable)));
  130. if (dtSettlInfo.Rows.Count != 1)
  131. {
  132. Global.writeLog("无共济支付信息!");
  133. return JsonHelper.setExceptionJson(-1, "未查询到相关结算信息!", "");
  134. }
  135. int mutualAidFlag = 0;
  136. if (!string.IsNullOrEmpty(dtSettlInfo.Rows[0]["MutualAidFlag"].ToString()))
  137. {
  138. mutualAidFlag = Convert.ToInt32(dtSettlInfo.Rows[0]["MutualAidFlag"].ToString());
  139. }
  140. Global.writeLog("共济支付标志:" + mutualAidFlag);
  141. if (mutualAidFlag > 0)
  142. {
  143. //开启自付界面,因涉及到多次自付
  144. MutualAid frmMA = new MutualAid(Global.pat.settlID);
  145. if (frmMA.dtSettlInfo.Rows.Count != 0)
  146. {
  147. frmMA.WindowState = FormWindowState.Maximized;
  148. if (frmMA.ShowDialog() == DialogResult.OK)
  149. {
  150. }
  151. else
  152. {
  153. return JsonHelper.setExceptionJson(-1, "收款员取消共济支付撤销!", null);
  154. }
  155. }
  156. else
  157. {
  158. return JsonHelper.setExceptionJson(-1, "开启共济支付失败,原因为未检测到有效的被共济人的医保结算数据!", null);
  159. }
  160. }
  161. return joRtn;
  162. }
  163. }
  164. }