ReadCardProcess.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.Common;
  3. using PTMedicalInsurance.Entity;
  4. using PTMedicalInsurance.Forms;
  5. using PTMedicalInsurance.Helper;
  6. using PTMedicalInsurance.Variables;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. namespace PTMedicalInsurance.Business
  14. {
  15. class ReadCardProcess : AbstractProcess
  16. {
  17. public override CallResult Process(JObject input)
  18. {
  19. JObject joCardInfo = new JObject();
  20. ChooseCard cc = new ChooseCard();
  21. JObject joRtn = new JObject();
  22. JObject joInput = new JObject();
  23. try
  24. {
  25. string safeNo = Global.pat.admType == 1 ? "2207A" : "1101";
  26. DialogResult dialog = tools.ShowAppDiaglog(cc);
  27. if (dialog == DialogResult.OK)
  28. {
  29. Global.businessType = "";
  30. Global.pat.certType = "01";
  31. //电子凭证
  32. if (cc.cardType == "01")
  33. {
  34. Global.pat.mdtrtcertType = "01";
  35. Global.businessType = cc.businessType;
  36. }
  37. //身份证
  38. if (cc.cardType == "02")
  39. {
  40. Global.pat.mdtrtcertType = "02";
  41. }
  42. //社保卡
  43. if (cc.cardType == "03")
  44. {
  45. Global.pat.mdtrtcertType = "03";
  46. }
  47. #region 调用读卡接口信息
  48. // 全部都采用银海
  49. int rtn = 0;
  50. if (!Global.curEvt.enabledDebug)
  51. {
  52. YinHaiSafeCtrl safeCtrl = new YinHaiSafeCtrl();
  53. rtn = safeCtrl.Prepare(safeNo, out outParam);
  54. if (rtn != 0)
  55. {
  56. return Exception("调用安全控件", outParam);
  57. }
  58. }
  59. if (rtn == 0)
  60. {
  61. rtn = trade1101(out outParam);
  62. }
  63. if (rtn == 0)
  64. {
  65. return Success();
  66. }
  67. #endregion
  68. }
  69. else
  70. {
  71. return Exception(-1, "读卡", "取消读卡");
  72. }
  73. return Exception(-1, "读卡", outParam);
  74. }
  75. catch (Exception ex)
  76. {
  77. return Error("异常:" + ex.Message);
  78. }
  79. }
  80. /// <summary>
  81. /// 通过证件号获取基本信息(无卡)
  82. /// </summary>
  83. /// <param name="cardNo"></param>
  84. /// <param name="outParam"></param>
  85. /// <returns></returns>
  86. public int trade1101(out string outParam)
  87. {
  88. Utils.GetInsuCode();
  89. outParam = "";
  90. string errorMsg = "";
  91. JObject joInput = new JObject();
  92. JObject joData = new JObject();
  93. joData.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
  94. joData.Add("mdtrt_cert_no", Utils.ConvertMdtrtcertNo());
  95. joData.Add("card_sn", Global.pat.card.SN);
  96. joData.Add("begntime", Utils.GetDateTimeNow());
  97. joData.Add("psn_cert_type", Global.pat.certType);
  98. joData.Add("certno", Global.pat.certNO); //证件号码
  99. joData.Add("psn_name", Global.pat.name);
  100. dynamic joExpContent = new JObject();
  101. joExpContent.card_token = Global.pat.card.Cardtoken;
  102. joData.Add("expContent", joExpContent);
  103. joInput.Add("data", joData);
  104. InvokeHelper invoker = new InvokeHelper();
  105. JObject joRtn = invoker.invokeCenterService(TradeEnum.PatientInfo, joInput);
  106. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  107. {
  108. outParam = "获取病人信息失败:" + errorMsg;
  109. return -1;
  110. }
  111. else
  112. {
  113. //joRtn["output"]["baseinfo"]["bizCode"] = Global.pat.card.BusinessCode;
  114. outParam = joRtn.ToString();
  115. parsePatient(joRtn);
  116. return 0;
  117. }
  118. }
  119. /// <summary>
  120. /// 读卡并获取基本信息
  121. /// </summary>
  122. /// <param name="outParam"></param>
  123. /// <returns></returns>
  124. public int trade1161(out string outParam)
  125. {
  126. outParam = "";
  127. string errorMsg = "";
  128. JObject joInput = new JObject();
  129. joInput.Add("begntime", Utils.GetDateTimeNow());
  130. JObject joRtn = new JObject();
  131. joRtn = invoker.invokeCenterService(TradeEnum.ReadCardInfo, joInput);
  132. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  133. {
  134. outParam = "读卡失败:" + errorMsg;
  135. return -1;
  136. }
  137. else
  138. {
  139. parsePatient(joRtn);
  140. outParam = joRtn.ToString();
  141. }
  142. return 0;
  143. }
  144. /// <summary>
  145. /// 解析人员基本信息
  146. /// </summary>
  147. /// <param name="joRtn"></param>
  148. public void parsePatient(JObject joRtn)
  149. {
  150. // 基线版
  151. PersonCardInfo info = JsonHelper.getOutput<PersonCardInfo>(joRtn);
  152. if (info.cardInfo != null)
  153. {
  154. Global.pat.card.NO = info.cardInfo.cardno;
  155. Global.pat.card.SN = info.cardInfo.card_sn;
  156. Global.pat.card.Cardtoken = info.cardInfo.ecToken;
  157. Global.pat.ecToken = info.cardInfo.ecToken;
  158. }
  159. //Global.writeLog("病人信息:"+joRtn.ToString());
  160. if (info.insuInfo != null && info.insuInfo.Length > 0)
  161. {
  162. //参保地
  163. Global.pat.insuplc_admdvs = info.insuInfo[0].insuplc_admdvs;
  164. Global.pat.insuplc_name = info.insuInfo[0].insuplc_name;
  165. Global.pat.medType = info.insuInfo[0].med_type ?? "C";
  166. }
  167. //证件号
  168. Global.pat.certNO = info.baseInfo?.certno;
  169. // 人员证件类型
  170. Global.pat.certType = info.baseInfo?.psn_cert_type;
  171. // 就诊类型
  172. if (string.IsNullOrEmpty(Global.pat.mdtrtcertType))
  173. {
  174. Global.pat.mdtrtcertType = "03";
  175. }
  176. // 就诊凭证号
  177. if (!string.IsNullOrEmpty(Global.pat.card.NO))
  178. {
  179. Global.pat.mdtrtcertNO = Global.pat.card.NO;
  180. }
  181. // 没有卡号用证件号
  182. if (string.IsNullOrEmpty(Global.pat.mdtrtcertNO))
  183. {
  184. Global.pat.mdtrtcertNO = Global.pat.certNO;
  185. }
  186. Global.pat.payOrdId = info.platformOrderNo;
  187. }
  188. /// <summary>
  189. /// 通过电子凭证获取基本信息
  190. /// </summary>
  191. /// <param name="outParam"></param>
  192. /// <returns></returns>
  193. public int tradeEcToken(out string outParam)
  194. {
  195. //cardInfo
  196. outParam = "";
  197. int ret = ECTokenReader.ECQuery("1",out outParam);
  198. return ret;
  199. }
  200. }
  201. }