|
@@ -0,0 +1,240 @@
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
+using PTMedicalInsurance.Common;
|
|
|
+using PTMedicalInsurance.Entity;
|
|
|
+using PTMedicalInsurance.Forms;
|
|
|
+using PTMedicalInsurance.Helper;
|
|
|
+using PTMedicalInsurance.Variables;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows.Forms;
|
|
|
+
|
|
|
+namespace PTMedicalInsurance.Business
|
|
|
+{
|
|
|
+ class ReadCardProcess : AbstractProcess
|
|
|
+ {
|
|
|
+ public override CallResult Process(JObject input)
|
|
|
+ {
|
|
|
+ JObject joCardInfo = new JObject();
|
|
|
+ ChooseCard cc = new ChooseCard();
|
|
|
+ JObject joRtn = new JObject();
|
|
|
+ JObject joInput = new JObject();
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (cc.ShowDialog() == DialogResult.OK)
|
|
|
+ {
|
|
|
+ Global.businessType = "";
|
|
|
+ Utils.GetInsuCode();
|
|
|
+ Global.pat.certType = "01";
|
|
|
+
|
|
|
+ //电子凭证
|
|
|
+ if (cc.cardType == "01")
|
|
|
+ {
|
|
|
+
|
|
|
+ Global.pat.mdtrtcertType = "01";
|
|
|
+ Global.businessType = cc.businessType;
|
|
|
+ tradeEcToken(out outParam);
|
|
|
+ //return trade1161(out outParam);
|
|
|
+ return Success();
|
|
|
+
|
|
|
+ }
|
|
|
+ //身份证
|
|
|
+ if (cc.cardType == "02")
|
|
|
+ {
|
|
|
+ if (cc.ID == "")
|
|
|
+ {
|
|
|
+ Global.pat.mdtrtcertType = "02";
|
|
|
+ Global.pat.name = "";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Global.pat.mdtrtcertType = "02";
|
|
|
+ //读身份证
|
|
|
+ CardReader reader = new CardReader();
|
|
|
+ int rtn = reader.ReadSFZ(out outParam);
|
|
|
+ if (rtn == 0)
|
|
|
+ {
|
|
|
+ trade1101(out outParam);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return Success();
|
|
|
+ }
|
|
|
+ //社保卡
|
|
|
+ if (cc.cardType == "03")
|
|
|
+ {
|
|
|
+ #region 调用读卡接口信息
|
|
|
+
|
|
|
+ Global.pat.mdtrtcertType = "03";
|
|
|
+
|
|
|
+ //return trade1161(out outParam);
|
|
|
+ int rtn = 0;
|
|
|
+ if (!Global.curEvt.enabledDebug)
|
|
|
+ {
|
|
|
+ CardReader reader = new CardReader();
|
|
|
+ rtn = reader.ReadCardBas(out outParam);
|
|
|
+ }
|
|
|
+ if (rtn == 0)
|
|
|
+ {
|
|
|
+ //清除原数据
|
|
|
+ trade1101(out outParam);
|
|
|
+ }
|
|
|
+ return Success();
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //outParam = JsonHelper.setExceptionJson().ToString();
|
|
|
+ return Exception(-1, "读卡", "取消读卡");
|
|
|
+ }
|
|
|
+ return Success();
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Error("异常:" + ex.Message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 通过证件号获取基本信息(无卡)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="cardNo"></param>
|
|
|
+ /// <param name="outParam"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public int trade1101(out string outParam)
|
|
|
+ {
|
|
|
+ outParam = "";
|
|
|
+ string errorMsg = "";
|
|
|
+ JObject joInput = new JObject();
|
|
|
+
|
|
|
+ JObject joData = new JObject();
|
|
|
+ joData.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
|
|
|
+ joData.Add("mdtrt_cert_no", Utils.ConvertMdtrtcertNo());
|
|
|
+ joData.Add("card_sn", Global.pat.card.SN);
|
|
|
+ joData.Add("begntime", Utils.GetDateTimeNow());
|
|
|
+ joData.Add("psn_cert_type", Global.pat.certType);
|
|
|
+ joData.Add("certno", Global.pat.certNO); //证件号码
|
|
|
+ joData.Add("psn_name", Global.pat.name);
|
|
|
+
|
|
|
+ joInput.Add("data", joData);
|
|
|
+ InvokeHelper invoker = new InvokeHelper();
|
|
|
+ JObject joRtn = invoker.invokeCenterService(TradeEnum.PatientInfo, joInput);
|
|
|
+
|
|
|
+ if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
|
|
|
+ {
|
|
|
+ outParam = "获取病人信息失败:" + errorMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //手动增加业务码(沈阳)
|
|
|
+ joRtn["output"]["baseinfo"]["bizCode"] = Global.pat.card.BusinessCode;
|
|
|
+ outParam = joRtn.ToString();
|
|
|
+ parsePatient(joRtn);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 读卡并获取基本信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="outParam"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public int trade1161(out string outParam)
|
|
|
+ {
|
|
|
+ outParam = "";
|
|
|
+ string errorMsg = "";
|
|
|
+
|
|
|
+ JObject joInput = new JObject();
|
|
|
+ joInput.Add("begntime", Utils.GetDateTimeNow());
|
|
|
+
|
|
|
+ JObject joRtn = new JObject();
|
|
|
+ joRtn = invoker.invokeCenterService(TradeEnum.ReadCardInfo, joInput);
|
|
|
+ if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
|
|
|
+ {
|
|
|
+ outParam = "读卡失败:" + errorMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ parsePatient(joRtn);
|
|
|
+ outParam = joRtn.ToString();
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 解析人员基本信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="joRtn"></param>
|
|
|
+ public void parsePatient(JObject joRtn)
|
|
|
+ {
|
|
|
+ // 基线版
|
|
|
+ PersonCardInfo info = JsonHelper.getOutput<PersonCardInfo>(joRtn);
|
|
|
+ if (info.cardInfo != null)
|
|
|
+ {
|
|
|
+ Global.pat.card.NO = info.cardInfo.cardno;
|
|
|
+ Global.pat.card.SN = info.cardInfo.card_sn;
|
|
|
+ Global.pat.card.Cardtoken = info.cardInfo.ecToken;
|
|
|
+ Global.pat.ecToken = info.cardInfo.ecToken;
|
|
|
+ }
|
|
|
+
|
|
|
+ //Global.writeLog("病人信息:"+joRtn.ToString());
|
|
|
+
|
|
|
+ if (info.insuInfo != null && info.insuInfo.Length > 0)
|
|
|
+ {
|
|
|
+ //参保地
|
|
|
+ Global.pat.insuplc_admdvs = info.insuInfo[0].insuplc_admdvs;
|
|
|
+ Global.pat.insuplc_name = info.insuInfo[0].insuplc_name;
|
|
|
+ Global.pat.medType = info.insuInfo[0].med_type ?? "C";
|
|
|
+ }
|
|
|
+ //证件号
|
|
|
+ Global.pat.certNO = info.baseInfo?.certno;
|
|
|
+ // 人员证件类型
|
|
|
+ Global.pat.certType = info.baseInfo?.psn_cert_type;
|
|
|
+ // 就诊类型
|
|
|
+ if (string.IsNullOrEmpty(Global.pat.mdtrtcertType))
|
|
|
+ {
|
|
|
+ Global.pat.mdtrtcertType = "03";
|
|
|
+ }
|
|
|
+ // 就诊凭证号
|
|
|
+ if (!string.IsNullOrEmpty(Global.pat.card.NO))
|
|
|
+ {
|
|
|
+ Global.pat.mdtrtcertNO = Global.pat.card.NO;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(Global.pat.mdtrtcertNO))
|
|
|
+ {
|
|
|
+ Global.pat.mdtrtcertNO = Global.pat.certNO;
|
|
|
+ }
|
|
|
+
|
|
|
+ Global.pat.payOrdId = info.platformOrderNo;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 通过电子凭证获取基本信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="outParam"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public int tradeEcToken(out string outParam)
|
|
|
+ {
|
|
|
+ //cardInfo
|
|
|
+ outParam = ECTokenReader.ECQuery("1");
|
|
|
+
|
|
|
+ trade1101(out outParam);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|