123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- 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
- {
- string safeNo = Global.pat.admType == 1 ? "2207A" : "1101";
- //string safeNo = "1101";
- DialogResult dialog = tools.ShowAppDiaglog(cc);
- if (dialog == DialogResult.OK)
- {
- Global.businessType = "";
- Global.pat.certType = "01";
- //电子凭证
- if (cc.cardType == "01")
- {
- Global.pat.mdtrtcertType = "01";
- Global.businessType = cc.businessType;
- }
- //身份证
- if (cc.cardType == "02")
- {
- Global.pat.mdtrtcertType = "02";
- }
- //社保卡
- if (cc.cardType == "03")
- {
- Global.pat.mdtrtcertType = "03";
- }
- #region 调用读卡接口信息
- // 全部都采用银海
- int rtn = 0;
- //if (!Global.curEvt.enabledDebug)
- //{
- // YinHaiSafeCtrl safeCtrl = new YinHaiSafeCtrl();
- // rtn = safeCtrl.Prepare(safeNo, out outParam);
- // if (rtn != 0)
- // {
- // return Exception("调用安全控件", outParam);
- // }
- //}
- //else
- //{
- // YinHaiSafeCtrl safeCtrl = new YinHaiSafeCtrl();
- // rtn = safeCtrl.Prepare(cc.cardType,safeNo, out outParam);
- // if (rtn != 0)
- // {
- // return Exception("调用安全控件", outParam);
- // }
- //}
- YinHaiSafeCtrl safeCtrl = new YinHaiSafeCtrl();
- if (Global.pat.admType == 1)
- {
- if (Global.pat.mdtrtcertType == "03")
- {
- rtn = safeCtrl.Prepare(Global.pat.mdtrtcertType, "1101", out outParam);
- if (rtn != 0)
- {
- return Exception("调用安全控件", outParam);
- }
- //重定向
- if (hBus.Redirect(Global.inf.originalInterfaceDr, out outParam) != 0)
- {
- return Exception(-2, "Redirect", outParam);
- }
- //再次调用门诊2207A,否则后面无法结算
- rtn = safeCtrl.Prepare(Global.pat.mdtrtcertType, "2207A", out outParam);
- if (rtn != 0)
- {
- return Exception("调用安全控件", outParam);
- }
- }
- else
- //if (Global.pat.mdtrtcertType == "01")
- {
- rtn = safeCtrl.Prepare(Global.pat.mdtrtcertType, "2207A", out outParam);
- if (rtn != 0)
- {
- return Exception("调用安全控件", outParam);
- }
- //重定向
- if (hBus.Redirect(Global.inf.originalInterfaceDr, out outParam) != 0)
- {
- return Exception(-2, "Redirect", outParam);
- }
- }
- }
- else
- {
- rtn = safeCtrl.Prepare(Global.pat.mdtrtcertType, "1101", out outParam);
- if (hBus.Redirect(Global.inf.originalInterfaceDr, out outParam) != 0)
- {
- return Exception(-2, "Redirect", outParam);
- }
- if (Global.pat.mdtrtcertType == "03")
- {
- //再次调用门诊1101,否则后面无法结算
- rtn = safeCtrl.Prepare(Global.pat.mdtrtcertType, "1101", out outParam);
- if (rtn != 0)
- {
- return Exception("调用安全控件", outParam);
- }
- }
- if (rtn != 0)
- {
- return Exception("调用安全控件", outParam);
- }
- }
- if (rtn == 0)
- {
- rtn = trade1101(out outParam);
- }
- if (rtn == 0)
- {
- return Success();
- }
-
- #endregion
- }
- else
- {
- return Exception(-1, "读卡", "取消读卡");
- }
- return Exception(-1, "读卡", outParam);
- }
- 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)
- {
- Utils.GetInsuCode();
- 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);
- dynamic joExpContent = new JObject();
- joExpContent.card_token = Global.pat.card.Cardtoken;
- joData.Add("expContent", joExpContent);
- 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 = "";
- int ret = ECTokenReader.ECQuery("1",out outParam);
- return ret;
- }
- }
- }
|