1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861 |
- using Newtonsoft.Json.Linq;
- using PTMedicalInsurance.Common;
- using PTMedicalInsurance.Helper;
- using PTMedicalInsurance.Variables;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace PTMedicalInsurance.Business
- {
- class MobilePay
- {
- private HisIrisServices hIS = new HisIrisServices();
- private MIIrisServices mIS = new MIIrisServices();
- private CenterBusiness cBus = new CenterBusiness();
- private InvokeHelper invoker = new InvokeHelper();
- private Patients MPat;
- public Settlements MSettl;
- private JArray jaFee;
- //
- private string fixmedins_code;//定点医疗服务机构编码
- private string yhappid;//渠道ID
- private string orgId;//电子凭证机构号
- //前端传过来的入参,从这里面取值
- private JObject joParam;
- private JObject joInsuAdmObj;
-
- public MobilePay(string inpar,out string errMsg)
- {
- errMsg = "";
- try
- {
- //西安普瑞眼视光医院测试环境
- Global.curEvt.URL = Global.inf.MobilePay.url;
- Global.inf.AK = Global.inf.MobilePay.secretKey;
- Global.inf.SK = Global.inf.MobilePay.privateKey;
- Global.inf.appId = Global.inf.MobilePay.appid;
- Global.inf.Secret = Global.inf.MobilePay.secretKey;
- Global.inf.privateKey = Global.inf.MobilePay.privateKey;
- Global.inf.publicKey = Global.inf.MobilePay.publicKey;
- Global.inf.devSafeInfo = Global.inf.MobilePay.devSafeInfo;
- JObject joInpar = JObject.Parse(inpar);
- joParam = JObject.Parse(JsonHelper.getDestValue(joInpar,"params[0]"));
- joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInpar, "insuAdmObj"));
- setPatientByInPar();
- setSettlementsByInPar();
- }
- catch (Exception ex)
- {
- errMsg = "MobilePay异常:" + ex.Message;
- }
- }
- public int MobilePaySettlement(out string outPar)
- {
- string errMsg,patInfo,YH6201Inpar,YH6201Rtn, YH6202Inpar, YH6202Rtn,YH6301Inpar,YH6301Rtn;
- outPar = "";
- try
- {
- EncryptHelper eh = new EncryptHelper();
- if (GetPatientInfo(out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- patInfo = errMsg;
- if (string.IsNullOrEmpty(Global.pat.insuplc_admdvs)) { Global.pat.insuplc_admdvs = "610100"; }
- JObject jo1101Rtn = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", patInfo));
- if (JsonHelper.parseCenterRtnValue(jo1101Rtn, out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- setPatientInsuInfo(jo1101Rtn);
- if (GetYH6201Inpar(out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- Global.writeLog("8888:-1"+errMsg);
- YH6201Inpar = errMsg;
- //JObject joYH6201Rtn = invoker.invokeMPService("6201", eh.encrypt(errMsg));
- JObject joYH6201Rtn = invoker.invokeMPService("6201", errMsg);
- if (JsonHelper.parseMPRtnValue(joYH6201Rtn, out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- //JObject joEncData = JObject.Parse(eh.decrypt(errMsg));
- JObject joEncData = JObject.Parse(errMsg);
- Global.writeLog(JsonHelper.Compress("8888:-2" + joEncData));
- //设置
- setPatientBy6201Rtn(joEncData);
- //存入MI 患者表,登记表,费用表
- if (saveToMi(out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- //YH6202
- if (GetYH6202Inpar(JObject.Parse(YH6201Inpar), out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- YH6202Inpar = errMsg;
- JObject joYH6202Rtn = invoker.invokeMPService("6202", YH6202Inpar);
- //JObject joYH6202Rtn = invoker.invokeMPService("6202", eh.encrypt(YH6202Inpar));
- if (JsonHelper.parseMPRtnValue(joYH6202Rtn, out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- //joEncData = JObject.Parse(eh.decrypt(errMsg));
- joEncData = JObject.Parse(errMsg);
- Global.writeLog(JsonHelper.Compress(joEncData));
- //设置
- setSettlementsBy6202Rtn(joEncData);
- MSettl.confirmFlag = 0;
- //存入MI 结算表
- if (saveSettlement (out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- //6301查询具体明细信息
- //if (GetYH6301Inpar(out errMsg) != 0)
- //{
- // outPar = errMsg;
- // return -1;
- //}
- //YH6301Inpar = errMsg;
- //JObject joYH6301Rtn = invoker.invokeMPService("6301", eh.encrypt(YH6301Inpar));
- //if (JsonHelper.parseMPRtnValue(joYH6301Rtn, out errMsg) != 0)
- //{
- // outPar = errMsg;
- // return -1;
- //}
- //joEncData = JObject.Parse(eh.decrypt(errMsg));
- //JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
- //Global.writeLog(JsonHelper.Compress(joEncData));
- ////设置
- //setSettlementsBy6301Rtn(joSettlInfo);
- ////存入MI 结算表
- //if (saveSettlement(out errMsg) != 0)
- //{
- // outPar = errMsg;
- //}
- //返回给HIS后端
- JObject joPreSettl = JObject.Parse(JsonHelper.getDestValue(joEncData, "data.extData.preSetl"));
- //JObject joTmp = JObject.Parse(JsonHelper.getDestValue(joYH6201Rtn, "encData"));
- JObject joTmp = new JObject();
- joTmp.Add("insutype", MPat.insuType);
- joTmp.Add("psn_no", MPat.psn_no);
- joTmp.Add("insuplc_admdvs", MPat.insuplc_admdvs);
- joTmp.Add("mdtrtId", MPat.mdtrtID);
- joTmp.Add("mdtrt_id", MPat.mdtrtID);
- joPreSettl.Add("setl_id", MPat.payOrdId);
- joTmp.Add("mdtrt_cert_type", JsonHelper.getDestValue(joPreSettl, "mdtrt_cert_type"));
- joTmp.Add("mdtrt_cert_no", JsonHelper.getDestValue(joPreSettl, "certno"));
- joTmp.Add("med_type", JsonHelper.getDestValue(joPreSettl, "med_type"));
- if (returnMPSettlementInfo(joTmp, joPreSettl, out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- //返回给HIS前端
- outPar = errMsg;
- return 0;
- }
- catch (Exception ex)
- {
- outPar = ex.Message;
- return -1;
- }
- }
- public int MobilePayConfirmSettlement(out string outPar)
- {
- string errMsg, M6301Inpar;
- outPar = "";
- try
- {
- //EncryptHelper eh = new EncryptHelper();
- //6301查询具体明细信息
- if (Get6301Inpar(out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- M6301Inpar = errMsg;
- JObject joM6301Rtn = invoker.invokeMPService("6301", M6301Inpar);
- if (JsonHelper.parseMPRtnValue(joM6301Rtn, out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- JObject joEncData = JObject.Parse(errMsg);
- //JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "data.extData.SETLINFO"));
- //设置
- setSettlementsBy6301Rtn(joEncData);
- MSettl.confirmFlag = 1;
- //存入MI 结算表
- if (updateSettlement(out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- else
- {
- //返回给HIS前端
- outPar = JsonHelper.setExceptionJson(0, "云医保平台", "确认成功!").ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- outPar = ex.Message;
- return -1;
- }
- }
- public int MobilePayCancelSettlement(out string outPar)
- {
- string errMsg, YH6203Inpar, YH6203Rtn;
- outPar = "";
- try
- {
- EncryptHelper eh = new EncryptHelper();
- if (MSettl.onlineYBFalg != "Y")
- {
- //读电子凭证
- //if (ReadEc(out errMsg) != 0)
- //{
- // outPar = errMsg;
- // return -1;
- //}
- //测试环境地址
- //Global.inf.ecURL = "http://10.126.40.13:8080/localcfc/api/hsecfc/localQrCodeQuery";
- HisMainBusiness hBus = new HisMainBusiness();
- if (hBus.readCard(out errMsg) != 0)
- {
- outPar = JsonHelper.setExceptionJson(-100, "读卡失败!", errMsg).ToString();
- return -1;
- }
- MPat.token = Global.pat.mdtrtcertNO;
- }
- //获取6203入参
- if (Get6203Inpar(out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- YH6203Inpar = errMsg;
- JObject jo6203Rtn = invoker.invokeMPService("6203", YH6203Inpar);
- //YH6202
- if (JsonHelper.parseMPRtnValue(jo6203Rtn, out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- else
- {
- JObject joEncData = JObject.Parse(errMsg);
- string newSettlID = JsonHelper.getDestValue(joEncData, "data.extData.setlInfo.setl_id");
- if (newSettlID == "")
- newSettlID = "LZTF001";
- //处理撤销数据
- if (cancleSettlement(MPat.settlID, out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- //joParam.Add("mdtrt_id", MPat.mdtrtID);
- //joParam.Add("insuplc_admdvs", MPat.insuplc_admdvs);
- //joParam.Add("setl_id", MPat.settlID);
- joParam.Add("middleSettleFlag", "");
- //退HIS结算
- if (hIS.cancleSettlementInfo(joParam, out errMsg) != 0)
- {
- outPar = errMsg;
- return -1;
- }
- else
- {
- outPar = errMsg;
- return 0;
- }
- }
- }
- catch (Exception ex)
- {
- Global.writeLog("MobilePayCancelSettlement:" + ex.Message);
- outPar = ex.Message;
- return -1;
- }
- }
- public int MobilePayCallbackSettlement(out string outPar)
- {
- string errMsg;
- outPar = "";
- try
- {
- if (Get6302Result(out errMsg) != 0)
- {
- JObject joResult = new JObject();
- JObject joData = new JObject();
- joData.Add("success", "false");
- joData.Add("message", errMsg);
- joResult.Add("data", joData);
- joResult.Add("errorCode", -1);
- joResult.Add("result", joData);
- outPar = joResult.ToString();
- return -1;
- }
- else
- {
- JObject joResult = new JObject();
- JObject joData = new JObject();
- joData.Add("success", "true");
- joData.Add("message", errMsg);
- joResult.Add("data", joData);
- joResult.Add("errorCode", 0);
- joResult.Add("result", joData);
- outPar = joResult.ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- outPar = "MobilePayCallbackSettlement:" + ex.Message;
- return -1;
- }
- finally
- {
- Global.writeLog("MobilePayCallbackSettlement", "", outPar);
- }
- }
- //组织M6203入参
- public int Get6203Inpar(out string outparam)
- {
- string errMsg = "";
- outparam = "";
- try
- {
- JObject joInpar = new JObject();
- //获取医保平台结算信息
- if (QuerySettleInfo(out errMsg) != 0)
- {
- outparam = errMsg;
- return -1;
- }
- JObject joRtn = JObject.Parse(errMsg);
- JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "result.data[0]"));
- MPat.settlID = JsonHelper.getDestValue(joSettl, "SettlementID");
- //MPat.mdtrtID = JsonHelper.getDestValue(joSettl, "MdtrtID");
- //入参
- joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "PayOrdID"));//支付订单号
- joInpar.Add("appRefdSn", MPat.recordID);//应用退款流水号
- joInpar.Add("appRefdTime", DateTime.Now.ToString("yyyyMMddHHmmss"));//应用退费时间
- joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
- joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
- joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
- joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joSettl, "PersonCashPay"));//现金退费金额
- joInpar.Add("ecToken", MPat.token);//电子凭证授权Token 前端传入
- joInpar.Add("refdType", "HI");//退费类型 前端传入
- joInpar.Add("expContent", "");//扩展数据 前端传入
- joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
- //JObject joData = new JObject();
- //joData.Add("data", joInpar);
- outparam = joInpar.ToString();
- return 0;
- }
- catch (Exception ex)
- {
- outparam = "GetYH6203Inpar:" + ex.Message;
- return -1;
- }
- finally
- {
- Global.writeLog("GetYH6203Inpar", "", outparam);
- }
- }
- public int Get6302Result(out string outparam)
- {
- string errMsg = "";
- outparam = "";
- try
- {
- JObject joInpar = new JObject();
- //获取医保平台结算信息
- if (QuerySettleInfoBy6302(out errMsg) != 0)
- {
- outparam = errMsg;
- return -1;
- }
- JObject joRtn = JObject.Parse(errMsg);
- JArray jaSettl = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.data"));
- if (jaSettl.Count != 1)
- {
- outparam = "该订单数据不唯一!";
- return -1;
- }
- else
- {
- //if (jaSettl[0]["ConfirmFlag"].ToString() != "1")
- //{
- // outparam = "确认标志不为1!";
- // return -1;
- //}
- //else
- {
- outparam = "回调成功!查询正确!";
- return 0;
- }
- }
- }
- catch (Exception ex)
- {
- outparam = "Get6302Result:" + ex.Message;
- return -1;
- }
- finally
- {
- Global.writeLog("Get6302Result", "", outparam);
- }
- }
- public int QuerySettleInfoBy6302(out string errMsg)
- {
- errMsg = "";
- try
- {
- string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr= " + Global.inf.hospitalDr;
- sqlStr = sqlStr + " and AdmType = 3 and PayOrdID= '" + MPat.payOrdId + "'";
- JObject joSqlstr = new JObject();
- joSqlstr.Add("sqlStr", sqlStr);
- JObject joRtn = mIS.DynamicQuerySettlInfo(joSqlstr);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- errMsg = joRtn.ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- errMsg = ex.Message;
- return -1;
- }
- }
- #region 读卡
- public int ReadEc(out string outParam)
- {
- outParam = "";
- JObject joInput = new JObject();
- try
- {
- STA sta = new STA();
- object[] o = new object[2];
- sta.ReadCard(o);
- if (int.Parse(o[0].ToString()) != 0)
- {
- outParam = o[1].ToString();
- return -1;
- }
- else
- {
- outParam = o[1].ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- outParam = "异常:" + ex.Message;
- return -1;
- }
- }
- #endregion
- #region 赋值MPat,Msettle结构体
- public void setPatientByInPar()
- {
- MPat.adm_Dr = int.Parse(JsonHelper.getDestValue(joParam, "admID"));
- Global.pat.adm_Dr = MPat.adm_Dr;
- MPat.recordID = JsonHelper.getDestValue(joParam, "recordID");
- MPat.billID = JsonHelper.getDestValue(joParam, "billID");
- MPat.medType = JsonHelper.getDestValue(joInsuAdmObj, "medType");
- MPat.certType = JsonHelper.getDestValue(joInsuAdmObj, "mdtrtCertType");
- MPat.token = JsonHelper.getDestValue(joInsuAdmObj, "ecToken");
- MPat.payAuthNo = JsonHelper.getDestValue(joInsuAdmObj, "payAuthNo");
- MPat.uldLatlnt = JsonHelper.getDestValue(joInsuAdmObj, "uldLatlnt");
- MPat.payOrdId = JsonHelper.getDestValue(joInsuAdmObj, "payOrdId");
- MPat.mdtrtID = JsonHelper.getDestValue(joInsuAdmObj, "mdtrt_id");
- Global.pat.mdtrtID = MPat.mdtrtID;
- }
- public void setPatientByEc(JObject jo)
- {
- MPat.name = JsonHelper.getDestValue(jo, "userName");
- MPat.IDNO = JsonHelper.getDestValue(jo, "idNo");
- MPat.certType = JsonHelper.getDestValue(jo, "idType");
- MPat.token = JsonHelper.getDestValue(jo, "ecToken");
- MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuOrg");
- MPat.payAuthNo = JsonHelper.getDestValue(jo, "authNo");
- MPat.gend = JsonHelper.getDestValue(jo, "gender");
- MPat.brdy = JsonHelper.getDestValue(jo, "birthday");
- MPat.naty = JsonHelper.getDestValue(jo, "nationality");
- MPat.payOrdId = "";
- }
- public void setPatientBy6201Rtn(JObject jo)
- {
- MPat.payOrdId = JsonHelper.getDestValue(jo, "data.payOrdId");
- MPat.payToken = JsonHelper.getDestValue(jo, "data.payToken");
- //MPat.psn_no = JsonHelper.getDestValue(jo, "psn_no");
- //MPat.insuType = JsonHelper.getDestValue(jo, "insutype");
- //MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuplc_admdvs");
- MPat.mdtrtID = JsonHelper.getDestValue(jo, "data.extData.mdtrtId");
- }
- //{"errorCode":0,"errorMessage":"","result":{"patName":"张振","patBirthdate":"1993-02-07","patSex":"男","credCode":"01","credNo":"522226199302073619"}}
- public void setPatientByHisBaseInfo(JObject jo)
- {
- MPat.name = JsonHelper.getDestValue(jo, "result.patName");
- MPat.brdy = JsonHelper.getDestValue(jo, "result.patBirthdate");
- MPat.gend = JsonHelper.getDestValue(jo, "result.patSex");
- MPat.age = JsonHelper.getDestValue(jo, "result.age");
- MPat.naty = JsonHelper.getDestValue(jo, "result.naty");
- MPat.certNO = JsonHelper.getDestValue(jo, "result.credNo");
- MPat.IDNO = MPat.certNO;
- MPat.certType = JsonHelper.getDestValue(jo, "result.credCode");
- }
- public void setPatientByMiRegInfo(JObject jo)
- {
- MPat.name = JsonHelper.getDestValue(jo, "data.PatientName");
- MPat.psn_no = JsonHelper.getDestValue(jo, "data.PersonalNO");
- MPat.certNO = JsonHelper.getDestValue(jo, "data.CertificateNO");
- MPat.IDNO = MPat.certNO;
- MPat.certType = JsonHelper.getDestValue(jo, "data.CertificateType");
- MPat.payToken = JsonHelper.getDestValue(jo, "data.payToken");
- MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "data.InsuranceAreaCode");
- }
- public void setPatientInsuInfo(JObject jo)
- {
- MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "output.insuinfo[0].insuplc_admdvs");
- MPat.psn_no = JsonHelper.getDestValue(jo, "output.baseinfo.psn_no");
- MPat.insuType = JsonHelper.getDestValue(jo, "output.insuinfo[0].insutype");
- Global.pat.insuplc_admdvs = MPat.insuplc_admdvs;
- Global.pat.psn_no = MPat.psn_no;
- Global.pat.insuType = MPat.insuType;
- }
- public void setPatientByDiagnoseInfo(JObject jo)
- {
- MPat.admAttendDoctorNO = JsonHelper.getDestValue(jo, "atddr_no");
- MPat.admDiagCode = JsonHelper.getDestValue(jo, "dscg_maindiag_code");
- MPat.admDiagName = JsonHelper.getDestValue(jo, "dscg_maindiag_name");
- MPat.AdmInDepCode = JsonHelper.getDestValue(jo, "adm_dept_codg");
- }
- public void setSettlementsBy6202Rtn(JObject jo)
- {
- MSettl.settlID = JsonHelper.getDestValue(jo, "data.payOrdId");
- MPat.payOrdId = JsonHelper.getDestValue(jo, "data.payOrdId");
- MSettl.payOrdId = JsonHelper.getDestValue(jo, "data.payOrdId");
- MSettl.ordStas = JsonHelper.getDestValue(jo, "data.ordStas");
- MSettl.sumamt = getDecimalFee(jo, "data.feeSumamt");
- MSettl.personCashPay = getDecimalFee(jo, "data.ownPayAmt");
- MSettl.accountPaySumamt = getDecimalFee(jo, "data.psnAcctPay");
- MSettl.fundPaySumamt = getDecimalFee(jo, "data.fundPay");
- MSettl.deposit = getDecimalFee(jo, "data.deposit");
- MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "data.extData.preSetl.clr_optins");
- MSettl.clearingType = JsonHelper.getDestValue(jo, "data.extData.preSetl.clr_type");
- MSettl.clearingWay = JsonHelper.getDestValue(jo, "data.extData.preSetl.clr_way");
- MSettl.civilserviceAllowancePay = getDecimalFee(jo, "data.extData.preSetl.cvlserv_pay");
- MSettl.ownPayAmount = getDecimalFee(jo, "data.extData.preSetl.fulamt_ownpay_amt");
- MSettl.overLimitAmountmt = getDecimalFee(jo, "data.extData.preSetl.overlmt_selfpay");
- MSettl.preSelfPayAmount = getDecimalFee(jo, "data.extData.preSetl.preselfpay_amt");
- MSettl.inPolicyRangeAmount = getDecimalFee(jo, "data.extData.preSetl.inscp_scp_amt");
- MSettl.actualPayDeductible = getDecimalFee(jo, "data.extData.preSetl.act_pay_dedc");
- MSettl.healthInsurancePay = getDecimalFee(jo, "data.extData.preSetl.hifp_pay");
- MSettl.healthInsuranceRatio = getDecimalFee(jo, "data.extData.preSetl.pool_prop_selfpay");
- MSettl.enterpriseSupplementPay = getDecimalFee(jo, "data.extData.preSetl.hifes_pay");
- MSettl.seriousIllnessPay = getDecimalFee(jo, "data.extData.preSetl.hifmi_pay");
- MSettl.largeExpensesSupplementPay = getDecimalFee(jo, "data.extData.preSetl.hifob_pay");
- MSettl.medicalAssistPay = getDecimalFee(jo, "data.extData.preSetl.maf_pay");
- MSettl.hospitalPartAmount = getDecimalFee(jo, "data.extData.preSetl.hosp_part_amt");
- MSettl.otherPay = getDecimalFee(jo, "data.extData.preSetl.oth_pay");
- MSettl.personPaySumamt = getDecimalFee(jo, "data.extData.preSetl.psn_part_amt");
- MSettl.balance = getDecimalFee(jo, "data.extData.preSetl.balc");
- MSettl.accountMutualAidAmount = getDecimalFee(jo, "data.extData.preSetl.acct_mulaid_pay");
- }
- public void setSettlementsBy6301Rtn(JObject jo)
- {
- MSettl.settlID = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.setl_id");
- MPat.psn_no = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.psn_no");
- MPat.naty = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.naty");
- //MPat.name = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.name");
- MPat.age = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.age");
- MPat.gend = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.gend");
- MPat.certNO = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.certno");
- MPat.brdy = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.brdy");
- MPat.insuType = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.insutype");
- MPat.psn_type = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.psn_type");
- MPat.mdtrtcertType = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.mdtrt_cert_type");
- MPat.medType = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.med_type");
- //MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuplc_admdvs");
- //MPat.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
- MSettl.ordStas = JsonHelper.getDestValue(jo, "data.ordStas");
- MSettl.sumamt = getDecimalFee(jo, "data.extData.SETLINFO.medfee_sumamt");
- MSettl.personCashPay = getDecimalFee(jo, "data.extData.SETLINFO.psn_cash_pay");
- MSettl.accountPaySumamt = getDecimalFee(jo, "data.extData.SETLINFO.acct_pay");
- MSettl.fundPaySumamt = getDecimalFee(jo, "data.extData.SETLINFO.fund_pay_sumamt");
- //MSettl.deposit = getDecimalFee(jo, "deposit");
- MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.clr_optins");
- MSettl.clearingType = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.clr_type");
- MSettl.clearingWay = JsonHelper.getDestValue(jo, "data.extData.SETLINFO.clr_way");
- MSettl.civilserviceAllowancePay = getDecimalFee(jo, "data.extData.SETLINFO.cvlserv_pay");
- MSettl.ownPayAmount = getDecimalFee(jo, "data.extData.SETLINFO.fulamt_ownpay_amt");
- MSettl.overLimitAmountmt = getDecimalFee(jo, "data.extData.SETLINFO.overlmt_selfpay");
- MSettl.preSelfPayAmount = getDecimalFee(jo, "data.extData.SETLINFO.preselfpay_amt");
- MSettl.inPolicyRangeAmount = getDecimalFee(jo, "data.extData.SETLINFO.inscp_scp_amt");
- MSettl.actualPayDeductible = getDecimalFee(jo, "data.extData.SETLINFO.act_pay_dedc");
- MSettl.healthInsurancePay = getDecimalFee(jo, "data.extData.SETLINFO.hifp_pay");
- MSettl.healthInsuranceRatio = getDecimalFee(jo, "data.extData.SETLINFO.pool_prop_selfpay");
- MSettl.enterpriseSupplementPay = getDecimalFee(jo, "data.extData.SETLINFO.hifes_pay");
- MSettl.seriousIllnessPay = getDecimalFee(jo, "data.extData.SETLINFO.hifmi_pay");
- MSettl.largeExpensesSupplementPay = getDecimalFee(jo, "data.extData.SETLINFO.hifob_pay");
- MSettl.medicalAssistPay = getDecimalFee(jo, "data.extData.SETLINFO.maf_pay");
- MSettl.hospitalPartAmount = getDecimalFee(jo, "data.extData.SETLINFO.hosp_part_amt");
- MSettl.otherPay = getDecimalFee(jo, "data.extData.SETLINFO.oth_pay");
- MSettl.personPaySumamt = getDecimalFee(jo, "data.extData.SETLINFO.psn_part_amt");
- MSettl.balance = getDecimalFee(jo, "data.extData.SETLINFO.balc");
- MSettl.accountMutualAidAmount = getDecimalFee(jo, "data.extData.SETLINFO.acct_mulaid_pay");
- }
- public void setSettlementsByInPar()
- {
- MSettl.clearingWay = JsonHelper.getDestValue(joInsuAdmObj, "psnSetlway");
- MSettl.settlID = JsonHelper.getDestValue(joInsuAdmObj, "payOrdId");
- MSettl.payOrdId = JsonHelper.getDestValue(joInsuAdmObj, "payOrdId");
- }
- #endregion
- #region 组织入参
- public int GetPatientInfo(out string outparam)
- {
- string errMsg = "";
- outparam = "";
- try
- {
- JObject joInpar = new JObject();
- //查询患者基本信息
- if (hIS.GetHisPatBaseInfo(out errMsg) != 0)
- {
- outparam = errMsg;
- return -1;
- }
- setPatientByHisBaseInfo(JObject.Parse(errMsg));
- //入参
- joInpar.Add("mdtrt_cert_type", "02");//就诊凭证类型
- joInpar.Add("mdtrt_cert_no", MPat.certNO);//就诊凭证编号
- joInpar.Add("card_sn", "");//卡识别码
- joInpar.Add("begntime", "");//开始时间 获取历史参保信息时传入
- joInpar.Add("psn_cert_type", "01");//就诊凭证类型为“ 02” 时默认传 01 代表身份 证,其他证件类型按实际上传
- joInpar.Add("certno", MPat.certNO);//证件号码
- joInpar.Add("psn_name", MPat.name);//姓名
- JObject joData = new JObject();
- joData.Add("data", joInpar);
- outparam = joData.ToString();
- return 0;
- }
- catch (Exception ex)
- {
- outparam = "GetPatientInfo:" + ex.Message;
- return -1;
- }
- finally
- {
- Global.writeLog("GetPatientInfo", "", outparam);
- }
- }
- //组织YH6201入参
- public int GetYH6201Inpar(out string outparam)
- {
- string errMsg = "";
- outparam = "";
- try
- {
- JObject joInpar = new JObject();
- //查询患者基本信息
- if (hIS.GetHisPatBaseInfo(out errMsg) != 0)
- {
- outparam = errMsg;
- return -1;
- }
- setPatientByHisBaseInfo(JObject.Parse(errMsg));
- JObject joPatBaseInfo = JObject.Parse(JsonHelper.getDestValue(JObject.Parse(errMsg),"result"));
- //获取诊断
- if (getDiagnoses(out errMsg) != 0)
- {
- outparam = errMsg;
- return -1;
- }
- JObject joDiagnoses = JObject.Parse(errMsg);
- JArray jaDiseinfoList = JArray.Parse(JsonHelper.getDestValue(joDiagnoses, "diseinfoList"));
- JObject joMdtrtinfo = JObject.Parse(JsonHelper.getDestValue(joDiagnoses, "mdtrtinfo"));
- setPatientByDiagnoseInfo(joMdtrtinfo);
- //获取费用
- if (GetFee(out errMsg) != 0)
- {
- outparam = errMsg;
- return -1;
- }
- JObject joFee = JObject.Parse(errMsg);
- JArray jaFeedetailList = JArray.Parse(JsonHelper.getDestValue(joFee, "feedetailList"));
- for (int i = 0; i < jaFeedetailList.Count; i++)
- {
- JObject joTmp = new JObject();
- joTmp.Add("act_purc_pric", jaFeedetailList[i]["pric"]);
- joTmp.Add("sin_dos", jaFeedetailList[i]["sinDosDscr"]);
- joTmp.Add("medins_list_name", jaFeedetailList[i]["medListName"]);
- ((JObject)jaFeedetailList[i]).Property("chrgBchno").Remove();
- ((JObject)jaFeedetailList[i]).Property("diseCodg").Remove();
- ((JObject)jaFeedetailList[i]).Property("rxno").Remove();
- ((JObject)jaFeedetailList[i]).Property("feeOcurTime").Remove();
- ((JObject)jaFeedetailList[i]).Property("sinDosDscr").Remove();
- ((JObject)jaFeedetailList[i]).Property("usedFrquDscr").Remove();
- ((JObject)jaFeedetailList[i]).Property("prdDays").Remove();
- ((JObject)jaFeedetailList[i]).Property("medcWayDscr").Remove();
- ((JObject)jaFeedetailList[i]).Property("bilgDeptCodg").Remove();
- //jaFeedetailList[i]["bilgDeptCodg"] = "100106";
- ((JObject)jaFeedetailList[i]).Property("acordDeptCodg").Remove();
- ((JObject)jaFeedetailList[i]).Property("acordDeptName").Remove();
- ((JObject)jaFeedetailList[i]).Property("ordersDrCode").Remove();
- ((JObject)jaFeedetailList[i]).Property("ordersDrName").Remove();
- ((JObject)jaFeedetailList[i]).Property("tcmdrugUsedWay").Remove();
- ((JObject)jaFeedetailList[i]).Property("etipFlag").Remove();
- ((JObject)jaFeedetailList[i]).Property("etipHospCode").Remove();
- ((JObject)jaFeedetailList[i]).Property("dscgTkdrugFlag").Remove();
- ((JObject)jaFeedetailList[i]).Property("matnFeeFlag").Remove();
- ((JObject)jaFeedetailList[i]).Property("initFeedetlSn").Remove();
- ((JObject)jaFeedetailList[i]).Property("medType").Remove();
- ((JObject)jaFeedetailList[i]).Property("memo").Remove();
- //((JObject)jaFeedetailList[i]).Property("expContent").Remove();
- ((JObject)jaFeedetailList[i]).Property("medListName").Remove();
- ((JObject)jaFeedetailList[i]).Property("medListSpc").Remove();
- ((JObject)jaFeedetailList[i]).Property("combNo").Remove();
- //jaFeedetailList[i]["chrgBchno"] = MPat.adm_Dr.ToString();
- jaFeedetailList[i]["expContent"] = joTmp.ToString().Replace("\r\n","");
- jaFeedetailList[i]["medType"] = JsonHelper.getDestValue(joInsuAdmObj, "medType");
- jaFeedetailList[i]["psnNo"] = new JObject();
- jaFeedetailList[i]["psnNo"] = MPat.psn_no;
- }
- //入参
- joInpar.Add("orgCodg", Global.inf.hospitalNO);//机构编码
- //joInpar.Add("orgId", "");//电子凭证机构号
- joInpar.Add("psnNo", MPat.psn_no);//人员编号
- joInpar.Add("insutype", MPat.insuType);//险种类型
- joInpar.Add("medOrgOrd", MPat.recordID);//医疗机构订单号 前端传入
- //joInpar.Add("initRxOrd", JsonHelper.getDestValue(joInsuAdmObj, "initRxOrd"));//要续方的原处方流水 前端传入
- //joInpar.Add("rxCircFlag", JsonHelper.getDestValue(joInsuAdmObj, "rxCircFlag"));//电子处方流转标志 前端传入
- MSettl.settlTime = Convert.ToDateTime(JsonHelper.getDestValue(joMdtrtinfo, "begntime"));
- //joInpar.Add("begntime", JsonHelper.getDestValue(joMdtrtinfo, "begntime"));//开始时间
- joInpar.Add("idNo", JsonHelper.getDestValue(joPatBaseInfo, "credNo"));//证件号码
- joInpar.Add("userName", JsonHelper.getDestValue(joPatBaseInfo, "patName"));//用户姓名
- joInpar.Add("idType", JsonHelper.getDestValue(joPatBaseInfo, "credCode"));//证件类别
- joInpar.Add("ecToken", JsonHelper.getDestValue(joInsuAdmObj, "ecToken"));//电子凭证授权ecToken 前端传入
- joInpar.Add("insuCode", Global.inf.areaCode);//就诊参保地行政区划
- joInpar.Add("insuplcAdmdvs", Global.pat.insuplc_admdvs);//
- joInpar.Add("iptOtpNo", JsonHelper.getDestValue(joMdtrtinfo, "ipt_no"));//住院/门诊号
- joInpar.Add("atddrNo", JsonHelper.getDestValue(joMdtrtinfo, "atddr_no"));//医师编码
- joInpar.Add("drName", JsonHelper.getDestValue(joMdtrtinfo, "chfpdr_name"));//医师姓名
- joInpar.Add("deptCode", JsonHelper.getDestValue(joMdtrtinfo, "adm_dept_codg"));//科室编码100106
- joInpar.Add("deptName", JsonHelper.getDestValue(joMdtrtinfo, "adm_dept_name"));//科室名称
- joInpar.Add("caty", "A10");//科别
- joInpar.Add("mdtrtId", JsonHelper.getDestValue(joMdtrtinfo, "mdtrtId"));//就诊ID
- joInpar.Add("medType", MPat.medType);//医疗类别 前端传入
- joInpar.Add("feeType", JsonHelper.getDestValue(joInsuAdmObj, "feeType"));//费用类型 前端传入
- joInpar.Add("medfeeSumamt", JsonHelper.getDestValue(joFee, "medfeeSumamt"));//医疗费总额
- //joInpar.Add("acctUsedFlag", JsonHelper.getDestValue(joInsuAdmObj, "acctUsedFlag"));//个人账户使用标志 前端传入
- //joInpar.Add("mainCondDscr", JsonHelper.getDestValue(joMdtrtinfo, "mainCondDscr"));//主要病情描述
- //joInpar.Add("diseCodg", JsonHelper.getDestValue(joMdtrtinfo, "diseCodg"));//病种编码
- //joInpar.Add("diseName", JsonHelper.getDestValue(joMdtrtinfo, "diseName"));//病种名称
- //joInpar.Add("psnSetlway", JsonHelper.getDestValue(joInsuAdmObj, "psnSetlway"));//个人结算方式 前端传入
- joInpar.Add("chrgBchno", JsonHelper.getDestValue(joFee, "chrgBchno"));//收费批次号
- //joInpar.Add("pubHospRfomFlag", JsonHelper.getDestValue(joInsuAdmObj, "pubHospRfomFlag"));//公立医院改革标志
- //joInpar.Add("invono", JsonHelper.getDestValue(joMdtrtinfo, "invono"));//发票号
- //joInpar.Add("endtime", JsonHelper.getDestValue(joMdtrtinfo, "endtime"));//出院时间
- //joInpar.Add("fulamtOwnpayAmt", JsonHelper.getDestValue(joMdtrtinfo, "fulamtOwnpayAmt"));//全自费金额
- //joInpar.Add("overlmtSelfpay", JsonHelper.getDestValue(joMdtrtinfo, "overlmtSelfpay"));//超限价金额
- //joInpar.Add("preselfpayAmt", JsonHelper.getDestValue(joMdtrtinfo, "preselfpayAmt"));//先行自付金额
- //joInpar.Add("inscpScpAmt", JsonHelper.getDestValue(joMdtrtinfo, "inscpScpAmt"));//符合政策范围金额
- //joInpar.Add("oprnOprtCode", JsonHelper.getDestValue(joMdtrtinfo, "oprnOprtCode"));//手术操作代码
- //joInpar.Add("oprnOprtName", JsonHelper.getDestValue(joMdtrtinfo, "oprnOprtName"));//手术操作名称
- //joInpar.Add("fpscNo", JsonHelper.getDestValue(joMdtrtinfo, "fpscNo"));//计划生育服务证号
- //joInpar.Add("latechbFlag", JsonHelper.getDestValue(joMdtrtinfo, "latechbFlag"));//晚育标志
- joInpar.Add("gesoVal", JsonHelper.getDestValue(joMdtrtinfo, "gesoVal"));//孕周数
- joInpar.Add("fetts", JsonHelper.getDestValue(joMdtrtinfo, "fetts"));//胎次
- joInpar.Add("fetusCnt", JsonHelper.getDestValue(joMdtrtinfo, "fetusCnt"));//胎儿数
- //joInpar.Add("pretFlag", JsonHelper.getDestValue(joMdtrtinfo, "pretFlag"));//早产标志
- //joInpar.Add("birctrlType", JsonHelper.getDestValue(joMdtrtinfo, "birctrlType"));//计划生育手术类别
- //joInpar.Add("birctrlMatnDate", JsonHelper.getDestValue(joMdtrtinfo, "birctrlMatnDate"));//计划生育手术或生育日期
- //joInpar.Add("copFlag", JsonHelper.getDestValue(joMdtrtinfo, "copFlag"));//伴有并发症标志
- //joInpar.Add("dscgDeptCodg", JsonHelper.getDestValue(joMdtrtinfo, "dscgDeptCodg"));//出院科室编码
- //joInpar.Add("dscgDeptName", JsonHelper.getDestValue(joMdtrtinfo, "dscgDeptName"));//出院科室名称
- //joInpar.Add("dscgDed", JsonHelper.getDestValue(joMdtrtinfo, "dscgDed"));//出院床位
- //joInpar.Add("dscgWay", JsonHelper.getDestValue(joMdtrtinfo, "dscgWay"));//离院方式
- //joInpar.Add("dieDate", JsonHelper.getDestValue(joMdtrtinfo, "dieDate"));//死亡日期
- //joInpar.Add("matnType", JsonHelper.getDestValue(joMdtrtinfo, "matnType"));//生育类别
- //joInpar.Add("expContent", JsonHelper.getDestValue(joInsuAdmObj, "expContent"));//扩展参数 前端传入
- //joInpar.Add("midSetlFlag", JsonHelper.getDestValue(joInsuAdmObj, "midSetlFlag"));//中途结算标志 前端传入
- joInpar.Add("diseinfoList", jaDiseinfoList);//诊断或症状明细
- joInpar.Add("feedetailList", jaFeedetailList);//费用明细
- joInpar.Add("devSafeInfo", Global.inf.devSafeInfo);//设备安全信息
- //joInpar.Add("admDiagDscr", JsonHelper.getDestValue(joMdtrtinfo, "admDiagDscr"));//入院诊断描述
- //joInpar.Add("admDeptCodg", JsonHelper.getDestValue(joMdtrtinfo, "admDeptCodg"));//入院科室编码
- //joInpar.Add("admDeptName", JsonHelper.getDestValue(joMdtrtinfo, "admDeptName"));//入院科室名称
- //joInpar.Add("admBed", JsonHelper.getDestValue(joMdtrtinfo, "admBed"));//入院床位
- joInpar.Add("payAuthNo", JsonHelper.getDestValue(joInsuAdmObj, "payAuthNo"));//支付授权码 前端传入
- joInpar.Add("uldLatlnt", JsonHelper.getDestValue(joInsuAdmObj, "uldLatlnt"));//经纬度 前端传入
- joInpar.Add("mdtrtCertType", JsonHelper.getDestValue(joInsuAdmObj, "mdtrtCertType"));//就诊凭证类型 前端传入
- //joInpar.Add("insuplcAdmdvs", MPat.insuplc_admdvs);//用户参保地行政区划
- JObject joData = new JObject();
- joData.Add("data",joInpar);
- outparam = joInpar.ToString();
- return 0;
- }
- catch (Exception ex)
- {
- outparam = "GetYH6201Inpar:" + ex.Message;
- return -1;
- }
- finally
- {
- Global.writeLog("GetYH6201Inpar","",outparam);
- }
- }
- //获取入参,入参基本为类局部变量
- public int GetYH6202Inpar(JObject joYH6201Inpar, out string outparam)
- {
- outparam = "";
- try
- {
- //获取其他入参
- JObject joInpar = new JObject();
- joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
- joInpar.Add("payOrdId", MPat.payOrdId);//待支付订单号
- joInpar.Add("payToken", MPat.payToken);//支付订单对应的token
- joInpar.Add("orgCodg", Global.inf.hospitalNO);//定点机构编码
- joInpar.Add("orgBizSer", DateTime.Now.ToString("yyyyMMddHHmmssffff"));//业务流水号 前端传入
- joInpar.Add("ecAuthCode", "");
- joInpar.Add("ecChnlAppId", "");
- joInpar.Add("ecChnlUserId", "");
- joInpar.Add("mdtrtId", MPat.mdtrtID);
- joInpar.Add("chrgBchno", JsonHelper.getDestValue(joYH6201Inpar, "chrgBchno"));//收费批次号
- joInpar.Add("feeType", JsonHelper.getDestValue(joYH6201Inpar, "feeType"));//费用类别
- //joInpar.Add("deposit", JsonHelper.getDestValue(joInsuAdmObj, "deposit"));//住院押金
- joInpar.Add("expContent", "");//扩展数据
- //joInpar.Add("acctUsedFlag", "");//个账使用标识
- //JObject joData = new JObject();
- //joData.Add("data",joInpar);
- outparam = joInpar.ToString();
- return 0;
- }
- catch (Exception ex)
- {
- outparam = "GetYH6202Inpar:" + ex.Message;
- return -1;
- }
- finally
- {
- Global.writeLog("GetYH6202Inpar", "", outparam);
- }
- }
- //组织YH6203入参
- public int GetYH6203Inpar(out string outparam)
- {
- string errMsg = "";
- outparam = "";
- try
- {
- JObject joInpar = new JObject();
- //获取医保平台结算信息
- if (QuerySettleInfo(out errMsg) != 0)
- {
- outparam = errMsg;
- return -1;
- }
- JObject joRtn = JObject.Parse(errMsg);
- JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "result.data[0]"));
- MPat.settlID = JsonHelper.getDestValue(joSettl, "SettlementID");
- //MPat.mdtrtID = JsonHelper.getDestValue(joSettl, "MdtrtID");
- //入参
- joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "PayOrdID"));//支付订单号
- joInpar.Add("appRefdSn", MPat.recordID);//应用退款流水号
- joInpar.Add("appRefdTime", DateTime.Now.ToString("yyyyMMddHHmmss"));//应用退费时间
- joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
- joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
- joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
- joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joSettl, "PersonCashPay"));//现金退费金额
- joInpar.Add("ecToken", MPat.token);//电子凭证授权Token 前端传入
- joInpar.Add("refdType", "HI");//退费类型 前端传入
- joInpar.Add("expContent", "");//扩展数据 前端传入
- joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
- //JObject joData = new JObject();
- //joData.Add("data", joInpar);
- outparam = joInpar.ToString();
- return 0;
- }
- catch (Exception ex)
- {
- outparam = "GetYH6203Inpar:" + ex.Message;
- return -1;
- }
- finally
- {
- Global.writeLog("GetYH6203Inpar", "", outparam);
- }
- }
- //获取入参,入参基本为类局部变量
- public int GetYH6301Inpar(out string outparam)
- {
- outparam = "";
- try
- {
- string errMsg;
- //查询登记信息
- if (mIS.queryRegisterInfo(4,out errMsg) != 0)
- {
- outparam = errMsg;
- return -1;
- }
- setPatientByMiRegInfo(JObject.Parse(errMsg));
- //获取其他入参
- JObject joInpar = new JObject();
- joInpar.Add("payOrdId", MPat.payOrdId);//待支付订单号
- joInpar.Add("payToken", MPat.payToken);//支付订单对应的token
- joInpar.Add("orgCodg", Global.inf.hospitalNO);//定点机构编码
- joInpar.Add("idNo", MPat.IDNO);//业务流水号 前端传入
- joInpar.Add("userName", MPat.name);
- joInpar.Add("idType", "01");
- joInpar.Add("expContent", "");
- outparam = joInpar.ToString();
- return 0;
- }
- catch (Exception ex)
- {
- outparam = "GetYH6301Inpar:" + ex.Message;
- return -1;
- }
- finally
- {
- Global.writeLog("GetYH6301Inpar", "", outparam);
- }
- }
- public int GetYH6401Inpar(out string outparam)
- {
- string errMsg = "";
- outparam = "";
- try
- {
- JObject joInpar = new JObject();
- //获取医保平台结算信息
- if (QuerySettleInfo(out errMsg) != 0)
- {
- outparam = errMsg;
- return -1;
- }
- JObject joRtn = JObject.Parse(errMsg);
- JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "data"));
- //入参
- joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "SettlementID"));//支付订单号
- joInpar.Add("appRefdSn", JsonHelper.getDestValue(joSettl, ""));//应用退款流水号
- joInpar.Add("appRefdTime", JsonHelper.getDestValue(joSettl, ""));//应用退费时间
- joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
- joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
- joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
- joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joInsuAdmObj, "PersonCashPay"));//现金退费金额
- joInpar.Add("ecToken", MPat.token);//电子凭证授权Token 前端传入
- joInpar.Add("refdType", "ALL");//退费类型 前端传入
- joInpar.Add("expContent", "");//扩展数据 前端传入
- joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
- outparam = joInpar.ToString();
- return 0;
- }
- catch (Exception ex)
- {
- outparam = "GetYH6203Inpar:" + ex.Message;
- return -1;
- }
- finally
- {
- Global.writeLog("GetYH6203Inpar", "", outparam);
- }
- }
- //获取入参,入参基本为类局部变量
- public int Get6301Inpar(out string outparam)
- {
- outparam = "";
- try
- {
- string errMsg;
- //查询登记信息
- if (mIS.queryRegisterInfo(4, out errMsg) != 0)
- {
- outparam = errMsg;
- return -1;
- }
- setPatientByMiRegInfo(JObject.Parse(errMsg));
- //获取其他入参
- JObject joInpar = new JObject();
- joInpar.Add("payOrdId", MPat.payOrdId);//待支付订单号
- joInpar.Add("payToken", MPat.payToken);//支付订单对应的token
- joInpar.Add("orgCodg", Global.inf.hospitalNO);//定点机构编码
- joInpar.Add("idNo", MPat.IDNO);//业务流水号 前端传入
- joInpar.Add("userName", MPat.name);
- joInpar.Add("idType", "01");
- joInpar.Add("expData", "");
- //JObject joData = new JObject();
- //joData.Add("data", joInpar);
- outparam = joInpar.ToString();
- return 0;
- }
- catch (Exception ex)
- {
- outparam = "Get6301Inpar:" + ex.Message;
- return -1;
- }
- finally
- {
- Global.writeLog("Get6301Inpar", "", outparam);
- }
- }
- #endregion
- #region 诊断
- //获取诊断信息
- public int getDiagnoses(out string errMsg)
- {
- errMsg = "";
- try
- {
- //调用服务获取门诊诊断信息
- string outparam = "";
- if (hIS.getPatDiagnoses(MPat, out outparam) != 0)
- {
- return -1;
- }
- JObject joRtn = JObject.Parse(outparam);
- JObject joMdtrtInfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "mdtrtinfo"));
- JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joRtn, "diseinfo"));
- //组织门诊结算诊断入参
- JArray jaRow = new JArray();
- for (int i = 0; i < jaDiagnoses.Count; i++)
- {
- JObject joTmp = new JObject();
- joTmp.Add("diagType", jaDiagnoses[i]["diag_type"]);//
- joTmp.Add("diagSrtNo", jaDiagnoses[i]["diag_srt_no"]);//
- joTmp.Add("diagCode", jaDiagnoses[i]["diag_code"]);//
- joTmp.Add("diagName", jaDiagnoses[i]["diag_name"]);//
- joTmp.Add("diagDept", "综合眼病专科");//jaDiagnoses[i]["diag_dept"]
- joTmp.Add("diseDorNo", jaDiagnoses[i]["dise_dor_no"]);//
- joTmp.Add("diseDorName", jaDiagnoses[i]["dise_dor_name"]);//
- joTmp.Add("diagTime", jaDiagnoses[i]["diag_time"]);//
- joTmp.Add("valiFlag", "1");//
- jaRow.Add(joTmp);
- }
- JObject joDiagRow = new JObject();
- joDiagRow.Add("diseinfoList", jaRow);
- joDiagRow.Add("mdtrtinfo", joMdtrtInfo);
- outparam = joDiagRow.ToString();
- errMsg = outparam;
- return 0;
- }
- catch (Exception ex)
- {
- errMsg = "getDiagnoses:" + ex.Message;
- return -1;
- }
- }
- #endregion
- #region 费用
- private int GetFee(out string outparam)
- {
- string hisFee, chrgBchno ="";
- JObject jo = new JObject();
- JObject joRow = new JObject();
- JArray jaRow = new JArray();
- try
- {
- //获取HIS费用
- if (hIS.getHisFee(MPat, out hisFee) != 0)
- {
- outparam = hisFee;
- return -1;
- }
- JObject joFee = JObject.Parse(hisFee);
- //处理
- //调用医保平台转换HIS费用(转换医保编码等)
- JObject joHisFee = JObject.Parse(hisFee);
- if (mIS.convertHisFeeWithInsuCodeOfMobilePay(MPat,joHisFee, out outparam) != 0)
- {
- return -1;
- }
-
- JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outparam), "data"));
- jaFee = (JArray)jaFeeDetail.DeepClone();
- decimal sumFee = 0;
- //转换
- for (int i = 0; i < jaFeeDetail.Count; i++)
- {
- decimal cnt = decimal.Parse(jaFeeDetail[i]["cnt"].ToString());
- decimal pric = decimal.Parse(jaFeeDetail[i]["pric"].ToString());
- decimal sumamt = decimal.Parse(jaFeeDetail[i]["det_item_fee_sumamt"].ToString());
- sumFee = sumFee + sumamt;
- JObject joTmp = new JObject();
- joTmp.Add("feedetlSn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
- joTmp.Add("mdtrtId", jaFeeDetail[i]["mdtrt_id"]);//就诊ID
- //joTmp.Add("psnNo", jaFeeDetail[i]["psnNo"]);//人员编号
- chrgBchno = jaFeeDetail[i]["chrg_bchno"].ToString();
- joTmp.Add("chrgBchno", jaFeeDetail[i]["chrg_bchno"]);//收费批次号
- joTmp.Add("diseCodg", "");//病种编码
- joTmp.Add("rxno", jaFeeDetail[i]["rxno"]);//处方号
- joTmp.Add("rxCircFlag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
- joTmp.Add("feeOcurTime", jaFeeDetail[i]["fee_ocur_time"]);//费用发生时间
- joTmp.Add("medListCodg", jaFeeDetail[i]["med_list_codg"]);//医疗目录编码
- joTmp.Add("medinsListCodg", jaFeeDetail[i]["medins_list_codg"]);//医药机构目录编码
- joTmp.Add("detItemFeeSumamt", sumamt.ToString("#0.00"));//明细项目费用总额
- joTmp.Add("cnt", cnt.ToString("#0.0000"));//数量
- joTmp.Add("pric", pric.ToString("#0.000000"));//单价
- joTmp.Add("sinDosDscr", jaFeeDetail[i]["sin_dos_dscr"]);//单次剂量描述
- joTmp.Add("usedFrquDscr", jaFeeDetail[i]["used_frqu_dscr"]);//使用频次描述
- joTmp.Add("prdDays", jaFeeDetail[i]["prd_days"]);//周期天数
- joTmp.Add("medcWayDscr", jaFeeDetail[i]["medc_way_dscr"]);//用药途径描述
- joTmp.Add("bilgDeptCodg", jaFeeDetail[i]["bilg_dept_codg"]);//开单科室编码
- joTmp.Add("bilgDeptName", jaFeeDetail[i]["bilg_dept_name"]);//开单科室名称
- joTmp.Add("bilgDrCodg", jaFeeDetail[i]["bilg_dr_codg"]);//开单医生编码
- joTmp.Add("bilgDrName", jaFeeDetail[i]["bilg_dr_name"]);//开单医师姓名
- joTmp.Add("acordDeptCodg", jaFeeDetail[i]["acord_dept_codg"]);//受单科室编码
- joTmp.Add("acordDeptName", jaFeeDetail[i]["acord_dept_name"]);//受单科室名称
- joTmp.Add("ordersDrCode", jaFeeDetail[i]["orders_dr_code"]);//受单医生编码
- joTmp.Add("ordersDrName", jaFeeDetail[i]["orders_dr_name"]);//受单医生姓名
- joTmp.Add("hospApprFlag", jaFeeDetail[i]["hosp_appr_flag"]);//医院审批标志
- joTmp.Add("tcmdrugUsedWay", jaFeeDetail[i]["tcmdrug_used_way"]);//中药使用方式
- joTmp.Add("etipFlag", jaFeeDetail[i]["etip_flag"]);//外检标志
- joTmp.Add("etipHospCode", jaFeeDetail[i]["etip_hosp_code"]);//外检医院编码
- joTmp.Add("dscgTkdrugFlag", jaFeeDetail[i]["dscg_tkdrug_flag"]);//出院带药标志
- joTmp.Add("matnFeeFlag", jaFeeDetail[i]["matn_fee_flag"]);//生育费用标志
- joTmp.Add("initFeedetlSn", jaFeeDetail[i]["init_feedetl_sn"]);//原费用流水号
- joTmp.Add("drordNo", jaFeeDetail[i]["drord_no"]);//医嘱号
- joTmp.Add("medType", jaFeeDetail[i]["med_type"]);//医疗类别
- joTmp.Add("memo", "");//备注
- joTmp.Add("expContent", jaFeeDetail[i]["expContent"]);//扩展字段
- joTmp.Add("medListName", jaFeeDetail[i]["medins_list_name"]);//医疗目录名称
- joTmp.Add("medListSpc", jaFeeDetail[i]["med_list_spc"]);//医疗目录规格
- joTmp.Add("combNo", jaFeeDetail[i]["comb_no"]);//组套编号
- jaRow.Add(joTmp);
- }
- jo.Add("medfeeSumamt", sumFee.ToString("#0.00"));
- jo.Add("chrgBchno", chrgBchno);
- jo.Add("feedetailList", jaRow);
- outparam = jo.ToString();
- return 0;
- }
- catch (Exception ex)
- {
- outparam = "获取费用异常:" + ex.Message;
- Global.writeLog("GetFee", jo.ToString(), "获取费用异常:" + ex.Message);
- return -1;
- }
- }
- /// <summary>
- /// 汇总医保返回的结算金额(按照HIS的原则汇总,后期HIS按照这个来进行勾稽关系判断)
- /// </summary>
- /// <param name="jo"></param>
- /// <returns></returns>
- public int sumInsuRtnSettlInfo(JObject jo, out JObject joSumFee, out string errMsg)
- {
- // 医疗费总额是患者在医药机构花费的所有诊疗、药品、耗材、服务设施等项目费用的总和 = 基金支付总额 + 个人负担总金额 + 其他(如医院负担金额);
- //3、基金支付总额 = 基本医保统筹基金支出(含职工基本医疗保险、居民基本医疗保险)+补充医疗保险基金支出 (含覆盖全体参保人的居民大病保险和大额医疗费用补助、覆盖部分参保人的企业职工大额医疗费用补助和公务员医疗补助等)+医疗救助基金支出 + 其他支出(如伤残人员医疗保障基金支出);
- //5、个人账户支出中包含账户共济支付金额
- joSumFee = new JObject();
- errMsg = "";
- decimal ybAmt, psnAcctAmt, hospAmt, psnCashAmt, medFee;
- try
- {
- ybAmt = 0; psnAcctAmt = 0; hospAmt = 0; psnCashAmt = 0; medFee = 0;
- ybAmt = MSettl.fundPaySumamt;
- psnAcctAmt = MSettl.accountPaySumamt;
- psnCashAmt =MSettl.personCashPay;
- hospAmt = MSettl.hospitalPartAmount;
- medFee = MSettl.sumamt;
- joSumFee.Add("sumamt", medFee);
- joSumFee.Add("ybAmt", ybAmt);
- joSumFee.Add("psnAcctAmt", psnAcctAmt);
- joSumFee.Add("hospAmt", hospAmt);
- joSumFee.Add("psnCashAmt", psnCashAmt);
- if (medFee != (ybAmt + psnAcctAmt + psnCashAmt + hospAmt))
- {
- errMsg = "ybAmt(" + ybAmt.ToString() + ")+" + "psnAcctAmt(" + psnAcctAmt.ToString() + ")+" + "psnCashAmt(" + psnCashAmt.ToString() + ")+" + "hospAmt(" + hospAmt.ToString() + ")" + "!=medFee(" + medFee.ToString() + ")";
- return -1;
- }
- return 0;
- }
- catch (Exception ex)
- {
- errMsg = ex.Message;
- return 1;
- }
- }
- /// <summary>
- /// 获取结算费用的封装
- /// </summary>
- /// <param name="jo"></param>
- /// <param name="path"></param>
- /// <returns></returns>
- private decimal getDecimalFee(JObject jo, string path)
- {
- try
- {
- string temp = JsonHelper.getDestValue(jo, path);
- if (temp == "")
- {
- return 0;
- }
- else
- {
- return decimal.Parse(temp);
- }
- }
- catch (Exception ex)
- {
- Global.writeLog("getFee异常:" + ex.Message);
- return 0;
- }
- }
- #endregion
- #region 结算
- /// <summary>
- /// 返回移动支付结算信息给HIS
- /// </summary>
- /// <param name="joSetlInpar"></param>
- /// <param name="joSetlinfo"></param>中心返回的信息
- /// <param name="outParam"></param>
- /// <returns></returns>
- public int returnMPSettlementInfo(JObject joReg, JObject joSettl, out string outParam)
- {
- string errMsg;
- try
- {
- JObject joSumFee = new JObject();
- if (sumInsuRtnSettlInfo(joSettl, out joSumFee, out errMsg) != 0)
- {
- outParam = "返回结算结果给HIS失败,请联系管理员!" + errMsg;
- return -1;
- }
- dynamic joTmp = new JObject();
- joTmp.settleInfo = joSettl;
- joTmp.updateUserID = Global.user.ID;
- joTmp.regInfo = joReg;
- joTmp.middleSettleFlag = "";
- joTmp.interfaceDr = Global.inf.interfaceDr;
- dynamic joHisInfo = new JObject();
- joHisInfo.admID = MPat.adm_Dr;
- joHisInfo.billID = MPat.billID;
- joHisInfo.recordID = MPat.recordID;
- joTmp.hisInfo = joHisInfo;
- joTmp.psn_type = MPat.psn_type;
- joTmp.mobilePayFlag = "Y";
- joTmp.sumFeeObj = joSumFee;
- joTmp.mdtrtinfo = MPat.mdtrtID;
- JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110018", joTmp).ToString(), "返回移动支付结算结果给HIS");
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- outParam = "返回移动支付结算结果给HIS失败,请联系管理员!" + errMsg;
- return -1;
- }
- else
- {
- joSumFee.Add("payAuthNo",MPat.payAuthNo);
- joSumFee.Add("payOrdId", MPat.payOrdId);
- joSumFee.Add("setlLatlnt", MPat.uldLatlnt);
- joSumFee.Add("org_no", Global.inf.hospitalNO);
- joSumFee.Add("medOrgOrd", MPat.recordID);
- joSumFee.Add("mdtrtId", MPat.mdtrtID);
- joSumFee.Add("gmt_out_create", MSettl.settlTime.ToString("yyyy-MM-dd HH:mm:ss"));
- joRtn["result"]= joSumFee;
- outParam = joRtn.ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- outParam = "返回移动支付结算结果给HIS出现异常:!" + ex.Message;
- return -1;
- }
- }
- //查询结算信息
- public int QuerySettleInfo(out string errMsg)
- {
- errMsg = "";
- try
- {
- string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr= " + Global.inf.hospitalDr;
- sqlStr = sqlStr + " and AdmType = 3 and Adm_Dr= " + MPat.adm_Dr + " and PayOrdID= '" + MPat.payOrdId + "'";
- JObject joSqlstr = new JObject();
- joSqlstr.Add("sqlStr", sqlStr);
- JObject joRtn = mIS.DynamicQuerySettlInfo(joSqlstr);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- errMsg = joRtn.ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- errMsg = ex.Message;
- return -1;
- }
- }
- #endregion
- #region 存入MI
- /// <summary>
- /// 插入患者该次就诊参保信息
- /// </summary>
- /// <param name="joBaseInfo"></param>
- /// <param name="joInsuInfo"></param>
- /// <param name="joIdetInfo"></param>
- /// <param name="outParam"></param>
- /// <returns></returns>
- private int insertPatCurInsuInfo( out string outParam)
- {
- JObject joTmp = new JObject();
- string errMsg = "";
- try
- {
- joTmp.Add("HospitalDr", Global.inf.hospitalDr);
- joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
- joTmp.Add("AdmID", MPat.adm_Dr);
- joTmp.Add("PatientName", MPat.name);
- joTmp.Add("PersonalNO", MPat.psn_no);
- joTmp.Add("MdtrtID", MPat.mdtrtID);
- joTmp.Add("PsnCertType", "");
- joTmp.Add("PsnCertNO", MPat.certNO);
- joTmp.Add("Gend", MPat.gend);
- joTmp.Add("Naty", "");
- joTmp.Add("Brdy", MPat.brdy);
- joTmp.Add("Age", MPat.age);
- joTmp.Add("Balc", MPat.balc);
- joTmp.Add("Insutype", MPat.insuType);
- joTmp.Add("PsnType", MPat.psn_type);
- joTmp.Add("PsnInsuStas", "");
- joTmp.Add("PsnInsuDate", "");
- joTmp.Add("PausInsuDate", "");
- joTmp.Add("Cvlservflag", "");
- joTmp.Add("insuplcAdmdvs", MPat.insuplc_admdvs);
- joTmp.Add("EmpName", MPat.emp_name);
- joTmp.Add("PsnIdettype", "");
- joTmp.Add("PsnTypeLv", "");
- joTmp.Add("IdetBegntime", "");
- joTmp.Add("IdetEndtime", "");
- if (string.IsNullOrEmpty(Global.user.ID)) Global.user.ID = "0";
- joTmp.Add("updateUserID", Global.user.ID);
- string serviceCode = "09010070";
- string inpar = JsonHelper.setIrisInpar(serviceCode, joTmp).ToString();
- JObject joRtn = invoker.invokeInsuService(inpar, "插入患者该次就诊参保信息");
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- outParam = errMsg;
- return -1;
- }
- else
- {
- outParam = joRtn.ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- outParam = "医保平台插入患者该次就诊参保信息:" + ex.Message;
- return -1;
- }
- }
- /// <summary>
- /// 插入登记信息
- /// </summary>
- /// <param name="joInpar"></param> 48交易入参
- /// <param name="joOutpar"></param>48交易出参
- /// <param name="outParam"></param>
- /// <returns></returns>
- private int saveRegisterInfo(out string outParam)
- {
- //插入云医保平台
- JObject joTmp = new JObject();
- string errMsg = "";
- try
- {
- joTmp.Add("HospitalDr", Global.inf.hospitalDr);
- joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
- joTmp.Add("AdmDr", MPat.adm_Dr);
- joTmp.Add("PatientName", MPat.name);
- joTmp.Add("PersonalNO", MPat.psn_no);
- joTmp.Add("InsuRegID", MPat.mdtrtID);
- joTmp.Add("RegDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- joTmp.Add("InsuType", MPat.insuType);
- joTmp.Add("CertificateType", MPat.certType);
- joTmp.Add("CertificateNO", MPat.certNO);
- joTmp.Add("MedicalType", MPat.medType);
- joTmp.Add("AttendDoctorNO",MPat.admAttendDoctorNO);
- joTmp.Add("ChiefPhyDocName", "");
- joTmp.Add("AdmInDiagDesc", "");
- joTmp.Add("AdmInDepCode", MPat.AdmInDepCode);
- joTmp.Add("AdmInDepName", "");
- joTmp.Add("AdmBed", "");
- joTmp.Add("MainDiagCode", MPat.admDiagCode);
- joTmp.Add("MainDiagName", MPat.admDiagName);
- joTmp.Add("MainConditionDesc", "");
- joTmp.Add("DiseasecCode", "");
- joTmp.Add("DiseasecName", "");
- joTmp.Add("OperationCode", "");
- joTmp.Add("OperationName", "");
- joTmp.Add("DiseasecTypeCode", "");
- joTmp.Add("InsuranceAreaCode", MPat.insuplc_admdvs);
- joTmp.Add("TreatmentAreaCode", Global.inf.areaCode);
- joTmp.Add("payOrdId", MPat.payOrdId);
- joTmp.Add("payToken", MPat.payToken);
- joTmp.Add("RegState", "1");
- joTmp.Add("ValidFlag", "1");
- joTmp.Add("Type", "4");//线上支付门诊
- joTmp.Add("updateUserID", Global.user.ID);
- joTmp.Add("msgid", Global.curEvt.msgid);
- joTmp.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- string serviceCode = "09010044";
- string inpar = JsonHelper.setIrisInpar(serviceCode, joTmp).ToString();
- JObject joRtn = invoker.invokeInsuService(inpar, "新增门诊登记信息");
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- outParam = joRtn.ToString();
- return -1;
- }
- else
- {
- outParam = joRtn.ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- outParam = "保存门诊登记信息异常:" + ex.Message;
- return -1;
- }
- }
- /// <summary>
- /// 插入结算信息
- /// </summary>
- /// <param name="joSettlement"></param>
- /// <param name="outParam"></param>
- /// <returns></returns>
- public int saveSettlement(out string outParam)
- {
- JObject joTmp = new JObject();
- string errMsg = "";
- try
- {
- JObject joSetlinfo = new JObject();
- joSetlinfo.Add("HospitalDr", Global.inf.hospitalDr);
- joSetlinfo.Add("admID", MPat.adm_Dr);
- joSetlinfo.Add("mdtrt_id", MPat.mdtrtID);
- joSetlinfo.Add("setl_id", MSettl.settlID);//
- joSetlinfo.Add("pay_ord_id", MSettl.payOrdId);
- joSetlinfo.Add("psn_no", MPat.psn_no);
- joSetlinfo.Add("psn_name", MPat.name);
- //joSetlinfo.Add("mdtrt_cert_type", JsonHelper.getDestValue(joRtnSetlinfo, "mdtrt_cert_type"));
- joSetlinfo.Add("certno", MPat.certNO);
- joSetlinfo.Add("gend", MPat.gend);
- joSetlinfo.Add("naty", MPat.naty);
- joSetlinfo.Add("brdy", MPat.brdy);
- joSetlinfo.Add("age", MPat.age);
- joSetlinfo.Add("insutype", MPat.insuType);
- joSetlinfo.Add("psn_type", MPat.psn_type);
- joSetlinfo.Add("cvlserv_flag", "");
- joSetlinfo.Add("setl_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- joSetlinfo.Add("mdtrt_cert_type", MPat.mdtrtcertType);
- joSetlinfo.Add("med_type", MPat.medType);
- joSetlinfo.Add("medfee_sumamt", MSettl.sumamt);//总费用
- joSetlinfo.Add("fulamt_ownpay_amt", MSettl.ownPayAmount);//全自费金额
- joSetlinfo.Add("overlmt_selfpay", MSettl.overLimitAmountmt);//超限价自费费用
- joSetlinfo.Add("preselfpay_amt", MSettl.preSelfPayAmount);//先行自付金额
- joSetlinfo.Add("inscp_scp_amt", MSettl.inPolicyRangeAmount);//符合政策范围金额
- joSetlinfo.Add("act_pay_dedc", MSettl.actualPayDeductible);//实际支付起付线
- joSetlinfo.Add("hifp_pay", MSettl.healthInsurancePay);//基本医疗保险统筹基金支出
- joSetlinfo.Add("pool_prop_selfpay", MSettl.healthInsuranceRatio);//基本医疗保险统筹基金支付比例
- joSetlinfo.Add("cvlserv_pay", MSettl.civilserviceAllowancePay);//公务员医疗补助资金支出
- joSetlinfo.Add("hifes_pay", MSettl.enterpriseSupplementPay);//企业支付 占用 大病报销金额
- joSetlinfo.Add("hifmi_pay", MSettl.seriousIllnessPay);// 居民大病保险资金支出
- joSetlinfo.Add("hifob_pay", MSettl.largeExpensesSupplementPay);//职工大额医疗费用补助基金支出
- joSetlinfo.Add("maf_pay", MSettl.medicalAssistPay);//医疗救助基金支出
- joSetlinfo.Add("hosp_part_amt", MSettl.hospitalPartAmount);//医院负担金额
- joSetlinfo.Add("oth_pay", MSettl.otherPay);//其他支出
- joSetlinfo.Add("fund_pay_sumamt", MSettl.fundPaySumamt);//基金支付总额
- joSetlinfo.Add("psn_part_amt", MSettl.personPaySumamt);//个人负担总金额
- joSetlinfo.Add("acct_pay", MSettl.accountPaySumamt);//个人账户支出
- joSetlinfo.Add("psn_cash_pay", MSettl.personCashPay);//个人现金支出
- joSetlinfo.Add("balc", MSettl.balance);// 余额
- joSetlinfo.Add("acct_mulaid_pay", "");//个人账户共济支付金额
- joSetlinfo.Add("medins_setl_id", "");//医药机构结算ID
- joSetlinfo.Add("clr_optins", MSettl.clearingOrgan);//清算经办机构
- joSetlinfo.Add("clr_way", MSettl.clearingWay);//清算方式
- joSetlinfo.Add("clr_type", MSettl.clearingType);//清算类别
- joSetlinfo.Add("ValidFlag", 1);
- joSetlinfo.Add("BillType", 1);
- joSetlinfo.Add("msgid", Global.curEvt.msgid);
- joSetlinfo.Add("admType", "3");
- joSetlinfo.Add("billID", MPat.billID);
- joSetlinfo.Add("recordID", MPat.recordID);
- joSetlinfo.Add("interfaceDr", Global.inf.interfaceDr);
- joSetlinfo.Add("insuplc_admdvs", MPat.insuplc_admdvs);
- joSetlinfo.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- joSetlinfo.Add("HospitalizationsDays", MSettl.hospitalizationsDays);
- joSetlinfo.Add("HospitalizationsTimes", MSettl.hospitalizationsTimes);
- joSetlinfo.Add("HISAdmTime", MSettl.hisAdmTime);
- joSetlinfo.Add("HISDischargeTime", MSettl.hisDischargeTime);
- joSetlinfo.Add("updateUserID", Global.user.ID);
- joSetlinfo.Add("ConfirmFlag", MSettl.confirmFlag);
- JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010051", joSetlinfo).ToString(), "插入结算信息");
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- outParam = errMsg;
- return -1;
- }
- else
- {
- outParam = joSetlinfo.ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- outParam = "插入结算信息:" + ex.Message;
- return -1;
- }
- }
- public int updateSettlement(out string outParam)
- {
- JObject joTmp = new JObject();
- string errMsg = "";
- try
- {
- JObject joSetlinfo = new JObject();
- joSetlinfo.Add("HospitalDr", Global.inf.hospitalDr);
- joSetlinfo.Add("AdmDr", MPat.adm_Dr);
- joSetlinfo.Add("MdtrtID", MPat.mdtrtID);
- joSetlinfo.Add("SettlementID", MSettl.settlID);//
- joSetlinfo.Add("PayOrdID", MSettl.payOrdId);
- joSetlinfo.Add("PersonnelNO", MPat.psn_no);
- joSetlinfo.Add("PatientName", MPat.name);
- //joSetlinfo.Add("CertificateType", JsonHelper.getDestValue(joRtnSetlinfo, "mdtrt_cert_type"));
- joSetlinfo.Add("CertificateNO", MPat.certNO);
- joSetlinfo.Add("Gender", MPat.gend);
- joSetlinfo.Add("Nation", MPat.naty);
- joSetlinfo.Add("BirthDay", MPat.brdy);
- joSetlinfo.Add("Age", MPat.age);
- joSetlinfo.Add("InsuranceType", MPat.insuType);
- joSetlinfo.Add("PersonType", MPat.psn_type);
- joSetlinfo.Add("CivilserviceFlag", "");
- joSetlinfo.Add("SettlementDateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- joSetlinfo.Add("MdtrtCertType", MPat.mdtrtcertType);
- joSetlinfo.Add("MedicalType", MPat.medType);
- joSetlinfo.Add("Sumamt", MSettl.sumamt);//总费用
- joSetlinfo.Add("OwnPayAmount", MSettl.ownPayAmount);//全自费金额
- joSetlinfo.Add("OverLimitAmount", MSettl.overLimitAmountmt);//超限价自费费用
- joSetlinfo.Add("PreSelfPayAmount", MSettl.preSelfPayAmount);//先行自付金额
- joSetlinfo.Add("InPolicyRangeAmount", MSettl.inPolicyRangeAmount);//符合政策范围金额
- joSetlinfo.Add("ActualPayDeductible", MSettl.actualPayDeductible);//实际支付起付线
- joSetlinfo.Add("HealthInsurancePay", MSettl.healthInsurancePay);//基本医疗保险统筹基金支出
- joSetlinfo.Add("HealthInsuranceRatio", MSettl.healthInsuranceRatio);//基本医疗保险统筹基金支付比例
- joSetlinfo.Add("CivilserviceAllowancePay", MSettl.civilserviceAllowancePay);//公务员医疗补助资金支出
- joSetlinfo.Add("EnterpriseSupplementPay", MSettl.enterpriseSupplementPay);//企业支付
- joSetlinfo.Add("SeriousIllnessPay", MSettl.seriousIllnessPay);// 居民大病保险资金支出
- joSetlinfo.Add("LargeExpensesSupplementPay", MSettl.largeExpensesSupplementPay);//职工大额医疗费用补助基金支出
- joSetlinfo.Add("MedicalAssistPay", MSettl.medicalAssistPay);//医疗救助基金支出
- joSetlinfo.Add("HospitalPartAmount", MSettl.hospitalPartAmount);//医院负担金额
- joSetlinfo.Add("OtherPay", MSettl.otherPay);//其他支出
- joSetlinfo.Add("FundPaySumamt", MSettl.fundPaySumamt);//基金支付总额
- joSetlinfo.Add("PersonPaySumamt", MSettl.personPaySumamt);//个人负担总金额
- joSetlinfo.Add("AccountPaySumamt", MSettl.accountPaySumamt);//个人账户支出
- joSetlinfo.Add("PersonCashPay", MSettl.personCashPay);//个人现金支出
- joSetlinfo.Add("Balance", MSettl.balance);// 余额
- joSetlinfo.Add("AccountMutualAidAmount", "");//个人账户共济支付金额
- joSetlinfo.Add("OrganSettlementID", "");//医药机构结算ID
- joSetlinfo.Add("ClearingOrgan", MSettl.clearingOrgan);//清算经办机构
- joSetlinfo.Add("ClearingWay", MSettl.clearingWay);//清算方式
- joSetlinfo.Add("ClearingType", MSettl.clearingType);//清算类别
- joSetlinfo.Add("ValidFlag", 1);
- joSetlinfo.Add("BillType", 1);
- joSetlinfo.Add("ConfirmFlag", MSettl.confirmFlag);
- joSetlinfo.Add("MSGID", Global.curEvt.msgid);
- joSetlinfo.Add("AdmType", "3");
- joSetlinfo.Add("BillID", MPat.billID);
- joSetlinfo.Add("RecordID", MPat.recordID);
- joSetlinfo.Add("InterfaceDr", Global.inf.interfaceDr);
- joSetlinfo.Add("InsuranceAreaCode", MPat.insuplc_admdvs);
- joSetlinfo.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- joSetlinfo.Add("HospitalizationsDays", MSettl.hospitalizationsDays);
- joSetlinfo.Add("HospitalizationsTimes", MSettl.hospitalizationsTimes);
- joSetlinfo.Add("HISAdmTime", MSettl.hisAdmTime);
- joSetlinfo.Add("HISDischargeTime", MSettl.hisDischargeTime);
- joSetlinfo.Add("updateUserID", Global.user.ID);
- JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010089", joSetlinfo).ToString(), "通过订单号更新结算信息");
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- outParam = errMsg;
- return -1;
- }
- else
- {
- outParam = joSetlinfo.ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- outParam = "插入结算信息:" + ex.Message;
- return -1;
- }
- }
- /// <summary>
- /// 取消结算
- /// </summary>
- /// <param name="outParam"></param>
- /// <returns></returns>
- public int cancleSettlement(string newSettlID, out string outParam)
- {
- JObject joTmp = new JObject();
- string errMsg = "";
- try
- {
- joTmp.Add("HospitalDr", Global.inf.hospitalDr);
- joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
- joTmp.Add("admID", MPat.adm_Dr);
- joTmp.Add("mdtrt_id", MPat.mdtrtID);
- joTmp.Add("setl_id", MPat.settlID);
- joTmp.Add("new_setl_id", newSettlID);
- joTmp.Add("updateUserID", Global.user.ID);
- joTmp.Add("msgid", Global.curEvt.msgid);
- joTmp.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
- JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010052", joTmp).ToString(), "取消结算信息");
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- outParam = errMsg;
- return -1;
- }
- else
- {
- outParam = JsonHelper.setExceptionJson(0, "云医保平台","取消结算成功").ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- outParam = "取消结算信息:" + ex.Message;
- return -1;
- }
- }
- /// <summary>
- /// 插入医保费用
- /// </summary>
- /// <param name="jaTmp"></param>
- /// <param name="outParam"></param>
- /// <returns></returns>
- public int insertFee(JArray jaTmp, out string outParam)
- {
- try
- {
- outParam = "";
- string errMsg;
- dynamic joTmp = new JObject();
- joTmp = new JObject();
- joTmp.code = "09010046";
- joTmp.HospitalDr = Global.inf.hospitalDr;
- joTmp.admID = MPat.adm_Dr;
- joTmp.mdtrt_id = MPat.mdtrtID;
- joTmp.updateUserID = Global.user.ID;
- joTmp.Add("params", jaTmp);
- ;
- JObject joRtn = invoker.invokeInsuService(joTmp.ToString(), "插入2301明细");
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- outParam = errMsg;
- return -1;
- }
- else
- {
- outParam = joRtn.ToString();
- return 0;
- }
- }
- catch (Exception ex)
- {
- outParam = "insertFee 异常:" + ex.Message;
- return -1;
- }
- }
- private int saveToMi( out string errMsg)
- {
- errMsg = "";
- try
- {
- //存储参保信息
- if (insertPatCurInsuInfo( out errMsg) != 0)
- {
- return -1;
- }
- //存储登记信息
- if (saveRegisterInfo( out errMsg) != 0)
- {
- return -1;
- }
- //处理jaFee
- foreach (var jo in jaFee)
- {
- jo["mdtrt_id"] = MPat.mdtrtID;
- jo["psn_no"] = MPat.psn_no;
- }
- //存储费用信息
- if (insertFee(jaFee, out errMsg) != 0)
- {
- return -1;
- }
- return 0;
- }
- catch (Exception ex)
- {
- errMsg = "saveToMi:" + ex.Message;
- return -1;
- }
- }
- #endregion
- #region 解析中心返回
- /// <summary>
- /// 解析银海移动支付返参
- /// </summary>
- /// <param name="joRtn"></param>
- /// <param name="errorMsg"></param>
- /// <returns></returns>
- public int ParseCenterRtnValue(JObject joRtn, out string errorMsg)
- {
- try
- {
- errorMsg =JsonHelper.getDestValue(joRtn, "message");
- return int.Parse(JsonHelper.getDestValue(joRtn, "code")); //0 成功-1 失败
- }
- catch (Exception ex)
- {
- errorMsg = "解析移动支付返参发生异常:" + ex.Message;
- return -1;
- }
- }
- #endregion
- }
- }
|