123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using PTMedicalInsurance.Common;
- using PTMedicalInsurance.Business;
- using System.Windows.Forms;
- using PTMedicalInsurance.Helper;
- using Newtonsoft.Json.Linq;
- using PTMedicalInsurance.Variables;
- using PTMedicalInsurance.Forms;
- using System.IO;
- using System.Reflection;
- using System.Data;
- using HuBeiMI.Forms;
- using System.Collections;
- using System.Data.SqlTypes;
- using Sunny.UI.Win32;
- using Sunny.UI;
- using PTMedicalInsurance.Forms.ElectronicSettlementCertificates;
- using System.Threading;
- namespace PTMedicalInsurance
- {
- public class InsuBusiness : IInsuBusiness
- {
- //定义相关的变量
- private Patients patient;
- private Fees fee;
- private Settlements settlement;
- //json对象属性
- private JObject joInParam;
- private JArray jaSession ;
- private JArray jaParams;
- private JObject joParam;
- private JObject joInterface;
- private JObject joInsuAdmObj;
- private JObject joParamA;//临时进销存使用
- JObject joParam992001;//临时进销存使用
- JObject joParam992002;//临时进销存使用
- JObject joParam992004;//临时进销存使用
- //设置业务实例
- CenterBusiness cBus = new CenterBusiness();
- HisMainBusiness hBus = new HisMainBusiness();
- HisIrisServices hIS = new HisIrisServices();
- MIIrisServices mIS= new MIIrisServices();
- InvokeHelper invoker = new InvokeHelper();
- //
- private string businessType;
- public InsuBusiness()
- {
- Global.curEvt.path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
- ComputerInfo comp = new ComputerInfo();
- Global.curEvt.mac = comp.GetMAC();
- Global.curEvt.ip = comp.GetIP(); //"10.1.4.100";
- Global.pat.insuplc_admdvs = ""; //如果是NULL中心会报错
- }
- private int parseInparam(string inParam,out string errMsg)
- {
- errMsg = "";
- try
- {
- joInParam = JObject.Parse(inParam);
- jaSession = JArray.Parse(JsonHelper.getDestValue(joInParam, "session"));
- Global.curEvt.jaSession = jaSession;
- jaParams = JArray.Parse(JsonHelper.getDestValue(joInParam, "params"));
- joParam = JObject.FromObject(jaParams[0]);
- if (JsonHelper.getDestValue(joInParam, "insuAdmObj") != "")
- joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInParam, "insuAdmObj"));
- joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
- Global.pat.insuplc_admdvs= JsonHelper.getDestValue(joInParam, "insuplc_admdvs");
- businessType = JsonHelper.getDestValue(joInParam, "businessType");
- return 0;
- }
- catch (Exception ex)
- {
- errMsg = "parseInparam 解析入参异常:" + errMsg;
- return -1;
- }
- }
-
- /// <summary>
- /// 签到
- /// </summary>
- /// <param name="InParam"></param>
- /// <returns></returns>
- public string Init(string InParam)
- {
- string errMsg, rtnResult ="";
- JObject joRtn = new JObject();
- try
- {
- if (hBus.initEnvironment(InParam, out errMsg) != 0)
- {
- return JsonHelper.setExceptionJson(-100, "initEnvironment 失败", errMsg).ToString();
- }
- else
- {
- //if (businessType != "BasicData") //医保对照不需要调用签到交易
- if ((businessType != "BasicData") && (businessType != "M6") && (businessType != "M6C") && (businessType != "M6Confirm") && (businessType != "M6CallBack"))
- {
- if (mIS.isSigned(ref Global.curEvt.signno) != true)
- {
- //签到
- if (cBus.signIn(out joRtn) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "签到异常", (string)joRtn["err_msg"]).ToString();
- return rtnResult;
- }
- else
- {
- Global.curEvt.signno = JsonHelper.getDestValue(joRtn, "output.signinoutb.sign_no");
- //插入签到表
- if (mIS.saveSignRecord(Global.curEvt.signno, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "中心签到成功但插入签到表失败:" + errMsg, null).ToString();
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "签到成功", joRtn).ToString();
- }
- }
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
- }
- }
- else
- {
- Global.curEvt.signno = "abc123";
- rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
- }
-
- return rtnResult;
- }
- }
- catch (Exception ex)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "Init 异常", ex.Message).ToString();
- return rtnResult;
- }
- finally
- {
- Global.writeLog("初始化结果:" + rtnResult);
- }
- }
- /// <summary>
- /// 初始化
- /// </summary>
- /// <param name="inParam"></param>
- /// <param name="outParam"></param>
- /// <returns></returns>
- private int init(string inParam, out string outParam)
- {
- string errMsg;
- outParam = "";
- try
- {
- //BS架构调用方式问题,每次调用都需要重新初始化
- JObject joInitRtn = JObject.Parse(Init(inParam));
- if (JsonHelper.parseIrisRtnValue(joInitRtn, out errMsg) != 0)
- {
- outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)", errMsg).ToString();
- return -1;
- }
- else
- {
- return 0;
- }
- }
- catch (Exception ex)
- {
- outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)异常", ex.Message).ToString();
- return -1;
- }
- }
- /// <summary>
- /// 获取患者信息
- /// </summary>
- /// <param name="InParam"></param>
- /// <returns></returns>
- public string GetPatientInfo(string InParam)
- {
- Global.writeLog("GetPatientInfo入参:" + JsonHelper.Compress(InParam));
- //设置返回值,错误信息
- int errCode;
- string errMsg, rtnResult = "",outParam;
- //BS架构调用方式问题,每次调用都需要重新初始化
- if (init(InParam,out outParam)!= 0)
- {
- rtnResult = outParam;
- return rtnResult;
- }
- JObject joInParam = JObject.Parse(InParam);
- string businessType = JsonHelper.getDestValue(joInParam,"businessType");
- try
- {
- switch (businessType)
- {
- case "M1"://门诊读卡
- {
- //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
- if (hBus.readCard(out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
- }
- else
- {
- //展示患者信息界面
- if (hBus.showPatInfo(outParam, out outParam) != 0)
- {
- rtnResult = outParam;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "", JObject.Parse(outParam)).ToString();
- }
- }
- break;
- }
- case "Z1"://住院读卡
- {
- //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
- if (hBus.readCard(out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
- }
- else
- {
- //住院提示特殊人员标识:JsonHelper.getDestValue(JObject.Parse(outParam), "output.exp_content.ectoken");
- string patInfo = outParam;
- //展示患者信息界面
- if (hBus.showPatInfo(patInfo, out outParam) != 0)
- {
- string idtype = JsonHelper.getDestValue(JObject.Parse(outParam), "output.selectedIdInfo.psn_idet_type");
- if (idtype != null)
- {
- string[] s1 = new string[8] { "9937", "230705", "211112", "236022", "230508", "236018", "2304", "2303" };//武汉乡村振兴人员身份类别
- if (s1.Contains(idtype))
- {
- MessageBox.Show("该人员存在特殊人员身份为" + idtype);
- }
- }
- rtnResult = outParam;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0,"",JObject.Parse(outParam)).ToString();
- }
- }
- break;
- }
- }
- return rtnResult;
- }
- catch (Exception ex)
- {
- rtnResult = JsonHelper.setIrisReturnValue(-1 , "GetPatientInfo发生异常;" + ex.Message,null).ToString();
- return rtnResult;
- }
- finally
- {
- Global.writeLog("GetPatientInfo出参:" + JsonHelper.Compress(rtnResult));
- }
- }
- /// <summary>
- /// 登记
- /// </summary>
- /// <param name="InParam"></param>
- /// <returns></returns>
- public string Register(string InParam)
- {
- Global.writeLog("Register 入参:" + JsonHelper.Compress(InParam));
- //设置返回值,错误信息
- string errMsg, rtnResult = "", outParam;
- try
- {
- //解析入参
- if (parseInparam(InParam, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
- return rtnResult;
- }
- //BS架构调用方式问题,每次调用都需要重新初始化
- if (init(InParam, out outParam) != 0)
- {
- rtnResult = outParam;
- return rtnResult;
- }
- //获取pat
- hBus.GetRegPatInfo(businessType, joInParam, out Global.pat);
- switch (businessType)
- {
- case "M2"://门诊登记
- {
- break;
- }
- case "M2C"://门诊登记撤销
- {
- break;
- }
- case "Z0"://住院修改
- {
- break;
- }
- case "Z2"://入院登记
- {
- Global.writeLog(Global.pat.insuType);
- string regInParam = "";
- //校验HIS姓名与医保姓名是否一致
- if (hBus.checkName(Global.pat.name, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
- return rtnResult;
- }
- //显示登记面板
- if (hBus.showInPatRegisterForm( out regInParam) == 0)
- {
- Global.writeLog(regInParam);
- JObject joRegIn_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2401", regInParam));
- JObject joRegIn = JObject.Parse(JsonHelper.setCenterInpar("2401", regInParam));
- //上传给中心
- JObject joRegOut = invoker.invokeCenterService("2401", joRegIn);
- //将中心返回的结果返回HIS,调用HIS服务进行保存
- if (JsonHelper.parseCenterRtnValue(joRegOut,out errMsg) == 0)
- {
- joRegOut.Add("validflag",1);
- joRegOut.Add("regstate", 1);
- joRegOut.Add("type", 1);
- Global.pat.mdtrtID = JsonHelper.getDestValue(joRegOut, "output.result.mdtrt_id");
- //插入患者本次就诊用的参保信息
- if (hBus.insertPatCurInsuInfo(JsonHelper.getDestValue(joParam, "patientInfo"), out outParam) != 0)
- {
- if (DialogResult.Yes == MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
- {
- }
- else
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!", outParam).ToString();
- return rtnResult;
- }
- }
- //插入医保平台
- if (mIS.saveInpatRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存登记信息", outParam).ToString();
- return rtnResult;
- }
- //返回登记信息,插入HIS
- if (hIS.returnRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
- return rtnResult;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
- return rtnResult;
- }
- }
- else
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", errMsg).ToString();
- return rtnResult;
- }
- }
- else
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", regInParam).ToString();
- return rtnResult;
- }
- }
- case "Z2C"://入院登记取消
- {
- //if (DialogResult.Yes == MessageBox.Show("即将进行取消中心医保登记,确定继续吗?", " 询问? ", MessageBoxButtons.YesNo))
- //{
- //}
- //else
- //{
- // rtnResult = JsonHelper.setExceptionJson(-1, "收费员撤销取消登记操作!", outParam).ToString();
- // return rtnResult;
- //}
- //取消中心登记
- if (cBus.cancleRegister("2404", out outParam) != 0)
- {
- //如果医保中心没有HIS所传的医保登记信息则默认撤销HIS登记信息
- int i = outParam.IndexOf("不存在有效的就诊登记信息");
- if (i != 0)
- {
- if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam+ ",是否强制撤销HIS医保登记信息?", "提示", MessageBoxButtons.YesNo))
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
- return rtnResult;
- } else
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
- return rtnResult;
- }
- }
- }
- //取消医保平台登记
- if (mIS.cancleRegister(1, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
- return rtnResult;
- }
- //取消HIS 登记
- if (hIS.cancleRegister( out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心和云医保平台取消登记成功,但HIS取消失败,", outParam).ToString();
- return rtnResult;
- }
- else
- {
- //CM 20230602 删除医保平台医保费用明细上传表数据
- mIS.deleteFee(out errMsg);
- rtnResult = JsonHelper.setIrisReturnValue(0, "取消医保登记成功", null).ToString();
- return rtnResult;
- }
- }
- case "Z6"://出院登记
- {
- break;
- }
- case "Z6C"://出院登记取消
- {
- if (cBus.cancleRegister("2405", out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消出院登记", errMsg).ToString();
- return rtnResult;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "取消出院登记成功", null).ToString();
- return rtnResult;
- }
- break;
- }
- default:
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "Register 交易", "传入的业务编码不对!").ToString();
- return rtnResult;
- }
- }
- }
- catch (Exception ex)
- {
- rtnResult = JsonHelper.setIrisReturnValue(-1, "Register 发生异常;" + ex.Message, null).ToString();
- return rtnResult;
- }
- finally
- {
- Global.writeLog("Register 出参:" + JsonHelper.Compress(rtnResult));
- }
- return "";
- }
- /// <summary>
- /// 费用上传
- /// </summary>
- /// <param name="InParam"></param>
- /// <returns></returns>
- public string FeeUpload(string InParam)
- {
- Global.writeLog("FeeUpload 入参:" + JsonHelper.Compress(InParam));
- //设置返回值,错误信息
- int errCode;
- string errMsg, rtnResult = "", outParam;
- try
- {
- //解析入参
- if (parseInparam(InParam, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
- return rtnResult;
- }
-
- //BS架构调用方式问题,每次调用都需要重新初始化
- if (init(InParam, out outParam) != 0)
- {
- rtnResult = outParam;
- return rtnResult;
- }
- //获取pat
- hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
- switch (businessType)
- {
- case "M3"://门诊费用上传
- {
- break;
- }
- case "M3C"://门诊费用撤销
- {
- break;
- }
- case "Z3"://入院费用上传
- {
- ////事前分析
- if (Global.curEvt.ext.isOpenAnalysis)
- {
- if (hBus.PreAnalysis("4", "", out errMsg) != 0)
- {
- //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
- //return rtnResult;
- DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
- return rtnResult;
- }
- }
- }
- //从医保平台获取患者详细的医保登记信息
- if (mIS.queryRegisterInfo(1, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
- return rtnResult;
- }
- JObject joReg = JObject.Parse(outParam);
- Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
- Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
- //先取消中心费用传送
- cBus.cancleFeeUpload("2302", out errMsg);
- //再删除医保传送表的数据
- mIS.deleteFee( out errMsg);
- #region【住院费用上传前调用3101事前服务】
- //1.获取3101入参报文
- /* 20221207 CM 朱鹏飞要求屏蔽调用事前事中服务交易
- if (hIS.GetInsuPatInfo("5", Global.pat, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "获取3101医保明细审核事前分析服务入参失败:", outParam).ToString();
- return rtnResult;
- }
- else
- {
- //2.调用医保3101明细审核事前分析服务
- JObject joInput = new JObject();
- joInput = JObject.Parse(outParam);
- JObject jo3101Rtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", joInput.ToString().Replace("\r\n", "")));
- if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
- {
- DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
- return rtnResult;
- }
- }
- }
- */
- #endregion
- //开始进行费用传送
- //调用HIS费用查询信息
- if (hIS.getHisFee(Global.pat, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "获取HIS费用", outParam).ToString();
- return rtnResult;
- }
- //调用医保平台转换
- JObject joHisFee = JObject.Parse(outParam);
- if (mIS.convertHisFeeWithInsuCode(joHisFee,out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "转换HIS费用", outParam).ToString();
- return rtnResult;
- }
- JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
- //按指定条数分割后上传,保存,更新
- if (hBus.uploadFeeToCenter("2301",10, jaFeeDetail, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "上传费用", outParam).ToString();
- return rtnResult;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传成功", null).ToString();
- return rtnResult;
- }
- }
- case "Z3C"://住院费用上传取消
- {
- if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
- return rtnResult;
- }
- if (mIS.deleteFee( out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
- return rtnResult;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传取消成功", null).ToString();
- return rtnResult;
- }
- }
- default:
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", "传入的业务编码不对!").ToString();
- return rtnResult;
- }
- }
- return rtnResult;
- }
- catch (Exception ex)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", ex.Message).ToString();
- return rtnResult;
- }
- finally
- {
- Global.writeLog("FeeUpload 出参:" + JsonHelper.Compress(rtnResult));
- }
- }
- /// <summary>
- /// 结算
- /// </summary>
- /// <param name="InParam"></param>
- /// <returns></returns>
- public string Settlement(string InParam)
- {
- Global.writeLog("Settlement 入参:" + JsonHelper.Compress(InParam));
- //设置返回值,错误信息
- string errMsg, rtnResult = "", outParam;
- try
- {
- //解析入参
- if (parseInparam(InParam, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
- return rtnResult;
- }
- //BS架构调用方式问题,每次调用都需要重新初始化
- if (init(InParam, out outParam) != 0)
- {
- rtnResult = outParam;
- return rtnResult;
- }
- //获取pat
- hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
- switch (businessType)
- {
- case "M4"://门诊预结算
- {
- OutpatientRegistration frmReg = new OutpatientRegistration();
- if (frmReg.ShowDialog() == DialogResult.OK)
- {
- rtnResult = "调用结束";
- }
- break;
- }
- case "M4C"://门诊预结算撤销
- {
- break;
- }
- case "M5"://门诊结算
- {
- Global.pat.admType = 1;
- string patInfo ="";
- //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
- if (hBus.readCard(out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
- return rtnResult;
- }
- else
- {
- patInfo = outParam;
- //展示患者信息界面
- if (hBus.showPatInfo(patInfo, out outParam) != 0)
- {
- rtnResult = outParam;
- return rtnResult;
- }
- }
- //患者信息赋值给全局变量
- patInfo = outParam;
-
- if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
- return rtnResult;
- }
- //校验HIS姓名与医保姓名是否一致
- if (hBus.checkName(Global.pat.name,out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
- return rtnResult;
- }
- //弹窗提示患者是否正常参保
- hBus.InsuMessage(out string InsuMess);
- MessageBox.Show(InsuMess,"参保信息提示");
-
- ////事前分析
- if (Global.curEvt.ext.isOpenAnalysis)
- {
- if (hBus.PreAnalysis("2", "", out errMsg) != 0) //事前事中:门诊挂号1 门诊收费登记2 住院登记3 住院收费登记4 住院执行医嘱5 门诊结算6 门诊预结算7 住院结算8 住院预结算9 购药划卡10
- {
- //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
- //return rtnResult;
- DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事前分析服务调用失败:", errMsg).ToString();
- return rtnResult;
- }
- }
- }
- //显示登记面板
- if (hBus.showOutPatRegisterForm(out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString();
- return rtnResult;
- }
- JObject joReg = JObject.Parse(outParam);
- //医保挂号
- JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
- JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
- jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
- jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2201", jo2201Inpar_plain));
- //此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
- JObject jo2203Inpar = new JObject();
- JObject jo2203Inpar_plain = new JObject();
- jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
- jo2203Inpar.Add("diseinfo",JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
- JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
- if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "医保挂号", errMsg).ToString();
- return rtnResult;
- }
- else
- {
- Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
- //插入患者本次就诊用的参保信息
- if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
- {
- if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam).ToString();
- return rtnResult;
- }
- }
- jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
- jo2203Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203", jo2203Inpar));
- jo2203Inpar = JObject.Parse(JsonHelper.setCenterInpar("2203", jo2203Inpar));
- //门诊登记信息,插入云医保平台
- jo2201Rtn.Add("validflag", 1);
- jo2201Rtn.Add("regstate", 1);
- jo2201Rtn.Add("type", 3);
- Global.writeLog(jo2201Inpar_plain.ToString());
- if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203Inpar_plain, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString();
- return rtnResult;
- }
- //返回登记信息,插入HIS
- /* if (hIS.returnRegisterInfo(jo2201Inpar_plain, jo2201Rtn, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
- return rtnResult;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
- return rtnResult;
- }*/
- }
- //门诊就诊信息上传
- JObject jo2203Rtn = invoker.invokeCenterService("2203",jo2203Inpar );
- if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
- return rtnResult;
- }
- #region【门诊就诊信息上传成功后调用3101事前服务】
- //1.获取3101入参报文
- /*
- if (hIS.GetInsuPatInfo("1", Global.pat, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "获取3101医保明细审核事前分析服务入参失败:", outParam).ToString();
- return rtnResult;
- }
- else
- {
- //2.调用医保3101明细审核事前分析服务
- JObject joInput = new JObject();
- //joInput.Add("data", JObject.Parse(outParam));
- joInput = JObject.Parse(outParam);
- JObject jo3101Rtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", joInput.ToString().Replace("\r\n", ""))); //.Replace(" ", "")
- if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
- {
- DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
- return rtnResult;
- }
- }
- }
- */
- #endregion
- //费用上传
- if (hBus.uploadFee("2204", 50, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
- return rtnResult;
- }
- #region【门诊预结算2206前调用3102医保明细审核事中服务】
- //1.获取3102入参报文
- /*
- if (hIS.GetInsuPatInfo("2", Global.pat, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
- return rtnResult;
- }
- else
- {
- //2.调用医保3102明细审核事前分析服务
- JObject joInput = new JObject();
- //joInput.Add("data", JObject.Parse(outParam));
- joInput = JObject.Parse(outParam);
- JObject jo3101Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
- if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
- {
- DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
- return rtnResult;
- }
- }
- }
- */
- #endregion
- ////事中分析
- if (Global.curEvt.ext.isOpenAnalysis)
- {
- if (hBus.PreAnalysis("7", "", out errMsg) != 0) //事前事中:门诊挂号1 门诊收费登记2 住院登记3 住院收费登记4 住院执行医嘱5 门诊结算6 门诊预结算7 住院结算8 住院预结算9 购药划卡10
- {
- //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
- //return rtnResult;
- DialogResult dr = MessageBox.Show("【3102】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
- return rtnResult;
- }
- }
- }
- //调用IRIS获取医保各项金额
- if (mIS.getSumFee(out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outParam).ToString();
- return rtnResult;
- }
- JObject joSumFee = JObject.Parse(outParam);
- JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joReg, "settlement"));
- //修改joSettlement的就诊ID ,总金额等
- joSettlement["mdtrt_id"] = Global.pat.mdtrtID;
- joSettlement["medfee_sumamt"] = JsonHelper.getDestValue(joSumFee, "data.Sumamt");
- //预结算2206
- if (hBus.preSettlement_OutPat(joSettlement, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
- return rtnResult;
- }
- //正式结算
- JObject joData = new JObject();
- joData.Add("data",joSettlement);
- JObject joRtn = invoker.invokeCenterService("2207", JsonHelper.setCenterInpar("2207", joData));
- if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
- return rtnResult;
- }
- else
- {
- //返回给云医保平台结算信息
- if (mIS.saveSettlement(joRtn, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
- return rtnResult;
- }
- //返回给云医保平台结算明细信息
- if (mIS.saveSettlementDetail(joRtn, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
- return rtnResult;
- }
- //返回给HIS
- JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo"));
- if (hIS.returnOutpatSettlementInfo(joSettlement, joSetlinfo, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
- return rtnResult;
- }
- else
- {
- JObject joHisServieRtn = JObject.Parse(outParam);
- hBus.returnToFrontEndAfterSettlement(joRtn, joHisServieRtn, out outParam);
- rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
- return rtnResult;
- }
- }
- }
- case "M5C"://门诊结算撤销
- {
- //查询HIS医保结算记录表获取该病人的参保地
- string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
- sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
- sqlStr = sqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
- JObject joSql = new JObject();
- joSql.Add("sqlStr", sqlStr);
- JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
- //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
- //{
- // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
- // return rtnResult;
- //}
- Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
- //退中心结算
- string newSettleID = "";
- if (cBus.cancleSettlement("2208", out outParam) != 0)
- {
- int i = outParam.IndexOf("获取到的就诊信息为无效状态,不能办理结算撤销业务");
- if (i != 0)
- {
- if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam + ",是否强制撤销HIS结算信息?", "提示", MessageBoxButtons.YesNo))
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心取消结算失败,", outParam).ToString();
- return rtnResult;
- }
- newSettleID = "YC";
- }
- else
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算", outParam).ToString();
- //查看是医保平台是否已经退费,如果是,则询问是否继续退费
- string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
- SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
- SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
- JObject joSqlStr = new JObject();
- joSqlStr.Add("sqlStr", SqlStr);
- JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
- JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
- if (jaCancleSettlInfo.Count == 1)
- {
- //询问收款员是否继续进行HIS退费
- if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
- {
- rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
- }
- }
- else
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
- }
- return rtnResult;
- }
- }
- else
- {
- newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
- }
-
- //string newSettleID = "10290453";
- //Global.pat.mdtrtID = "202210281547480034293700000000";
- //Global.pat.psn_no = "YX423049577";
- //Global.pat.settlID = "10290445";
- //退云医保平台结算
- if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消平台结算信息", outParam).ToString();
- //return rtnResult;
- }
-
- //中心取消传送
- if (cBus.cancleFeeUpload("2205", out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
- return rtnResult;
- }
-
- //云平台取消传送
- if (mIS.deleteFee(out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
- return rtnResult;
- }
- //取消中心登记
- if (cBus.cancleRegister("2202", out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
- return rtnResult;
- }
-
- //取消医保平台登记
- if (mIS.cancleRegister(3, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
- return rtnResult;
- }
- //退HIS结算
- if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消HIS结算信息", outParam).ToString();
- return rtnResult;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
- return rtnResult;
- }
- }
- case "M6"://门诊移动支付结算
- {
- MobilePay mp = new MobilePay(InParam, out errMsg);
- if (errMsg != "")
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易1", errMsg).ToString();
- return rtnResult;
- }
- if (mp.MobilePaySettlement(out outParam) != 0)
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易2", outParam).ToString();
- else
- rtnResult = outParam;
- return rtnResult;
- }
- case "M6C"://门诊移动支付结算撤销
- {
- string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
- MobilePay mp = new MobilePay(InParam, out errMsg);
- if (errMsg != "")
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易3", errMsg).ToString();
- return rtnResult;
- }
- if (String.IsNullOrEmpty(onlineYBFalg))
- mp.MSettl.onlineYBFalg = "N";
- else
- mp.MSettl.onlineYBFalg = onlineYBFalg;
- if (mp.MobilePayCancelSettlement(out outParam) != 0)
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易4", outParam).ToString();
- else
- rtnResult = JsonHelper.setExceptionJson(0, "Settlement 交易5", outParam).ToString();
- return rtnResult;
- }
- case "M6Confirm"://门诊移动支付确认
- {
- MobilePay mp = new MobilePay(InParam, out errMsg);
- if (errMsg != "")
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易6", errMsg).ToString();
- return rtnResult;
- }
- if (mp.MobilePayConfirmSettlement(out outParam) != 0)
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易7", outParam).ToString();
- else
- rtnResult = outParam;
- return rtnResult;
- }
- case "M6CallBack"://门诊移动支付回调
- {
- JObject jo = JObject.Parse(InParam);
- joInsuAdmObj = new JObject();
- joInsuAdmObj.Add("payOrdId", "");
- jo.Add("insuAdmObj", joInsuAdmObj);
- MobilePay mp = new MobilePay(jo.ToString(), out errMsg);
- if (errMsg != "")
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易8", errMsg).ToString();
- return rtnResult;
- }
- if (mp.MobilePayCallbackSettlement(out outParam) != 0)
- rtnResult = outParam;
- else
- rtnResult = outParam;
- return rtnResult;
- }
- case "Z4"://住院预结算
- {
- #region【住院预结算2303前调用3102医保明细审核事中服务】
- //1.获取3102入参报文
- /*
- if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
- return rtnResult;
- }
- else
- {
- //2.调用医保3102明细审核事前分析服务
- JObject joInput = new JObject();
- joInput = JObject.Parse(outParam);
- JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
- if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
- {
- DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果2:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
- return rtnResult;
- }
- }
- }
- */
- #endregion
- Global.pat.RYorCY = "2";
- Global.pat.admType = 2;
- JObject joSettle = new JObject();
- if (hBus.preSettlement("2303",out joSettle, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
- return rtnResult;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
- return rtnResult;
- }
- }
- case "Z4C"://住院预结算撤销
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
- return rtnResult;
- }
- case "Z5"://住院结算
- {
- #region【住院预结算2303前调用3102医保明细审核事中服务】
- //1.获取3102入参报文
- /*
- if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
- return rtnResult;
- }
- else
- {
- //2.调用医保3102明细审核事前分析服务
- JObject joInput = new JObject();
- joInput = JObject.Parse(outParam);
- JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
- if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
- {
- DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果1:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
- return rtnResult;
- }
- }
- }
- */
- #endregion
- #region【住院预结算2303前调用3102医保明细审核事中服务】
- ////事中分析
- if (Global.curEvt.ext.isOpenAnalysis)
- {
- if (hBus.PreAnalysis("9", "", out errMsg) != 0) //事前事中:门诊挂号1 门诊收费登记2 住院登记3 住院收费登记4 住院执行医嘱5 门诊结算6 门诊预结算7 住院结算8 住院预结算9 购药划卡10
- {
- //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
- //return rtnResult;
- DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
- return rtnResult;
- }
- }
- }
- #endregion
- Global.pat.admType = 2;
- Global.pat.RYorCY = "2";
- JObject joPreSetOutpar ;
-
- if (hBus.preSettlement("2303",out joPreSetOutpar, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
- return rtnResult;
- }
- else
- {
- JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "Settlement"));
- ////出院登记
- //JObject joDischargeRegister = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "DischargeRegister"));
- //JObject jo2402Rtn = invoker.invokeCenterService("2402", JsonHelper.setCenterInpar("2402", joDischargeRegister));
- //if (JsonHelper.parseCenterRtnValue(jo2402Rtn, out errMsg) != 0)
- //{
- // rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
- // return rtnResult;
- //}
- //正式结算
- joSettlement.Add("data", joSettlement);
- JObject jo2304Rtn = invoker.invokeCenterService("2304",JsonHelper.setCenterInpar("2304",joSettlement));
- if (JsonHelper.parseCenterRtnValue(jo2304Rtn, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
- cBus.cancleRegister("2405", out errMsg);
- return rtnResult;
- }
- else
- {
- //返回给云医保平台结算信息
- if (mIS.saveSettlement(jo2304Rtn, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
- return rtnResult;
- }
- //返回给云医保平台结算明细信息
- if (mIS.saveSettlementDetail(jo2304Rtn, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
- Global.writeLog(rtnResult);
- MessageBox.Show(errMsg);
- }
- //返回给HIS
- JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo"));
- if (hIS.returnInpatSettlementInfo(joParam, joSetlinfo, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
- return rtnResult;
- }
- else
- {
- //返回给前端
- JObject joHisServieRtn = JObject.Parse(outParam);
- hBus.returnToFrontEndAfterSettlement(jo2304Rtn, joHisServieRtn, out outParam);
- rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
- return rtnResult;
- }
- }
- }
- }
- case "Z5C"://住院结算撤销
- {
- //查询结算表
- string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and Hospital_Dr=" + Global.inf.hospitalDr
- + " and Adm_Dr='" + Global.pat.adm_Dr + "'"
- + " and MdtrtID='" + Global.pat.mdtrtID + "'"
- + " Order By ID DESC ";
- JObject joSql = new JObject();
- joSql.Add("sqlStr", sqlStr);
- JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
- //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
- //{
- // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
- // return rtnResult;
- //}
- //MessageBox.Show(joSettlInfo.ToString());
- Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
- Global.pat.SettID_YBJSB = JsonHelper.getDestValue(joSettlInfo, "result.data[0].SettlementID");
- if (Global.pat.settlID != Global.pat.SettID_YBJSB)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "通过09010059服务获取到的SettlementID<" + Global.pat.settlID + ">与DLL通过SQL语句" +
- joSql + ",获取到的SettlementID<" + Global.pat.SettID_YBJSB + ">不同,可能存在HIS单边账,请联系医保开发人员处理该笔结算记录!").ToString();
- //return rtnResult;
- }
- Global.pat.settlID = Global.pat.SettID_YBJSB;
- //取消中心结算信息
- if (cBus.cancleSettlement("2305", out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算信息失败!", outParam).ToString();
- //查看是医保平台是否已经退费,如果是,则询问是否继续退费
- string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
- SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
- SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
- JObject joSqlStr = new JObject();
- joSqlStr.Add("sqlStr", SqlStr);
- JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
- JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
- if (jaCancleSettlInfo.Count == 1)
- {
- //询问收款员是否继续进行HIS退费
- if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
- {
- rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
- }
- }
- else
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
- }
- return rtnResult;
- }
- else
- {
- //退结算会返一个新的ID
- string newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
- //取消平台结算信息
- if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心结算取消成功,医保平台结算信息取消失败!", outParam).ToString();
- return rtnResult;
- }
- //中心取消传送
- if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
- {
- //rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
- //return rtnResult;
- }
- //云平台取消传送
- if (mIS.deleteFee(out errMsg) != 0)
- {
- //rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
- //return rtnResult;
- }
- //取消HIS医保结算信息
- if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心跟医保平台结算取消成功, 取消HIS结算信息失败!", outParam).ToString();
- return rtnResult;
- }
- //取消出院登记
- if (cBus.cancleRegister("2405", out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(0, "中心,医保平台及HIS结算信息取消成功,取消出院登记失败!请手工取消出院登记!", outParam).ToString();
- return rtnResult;
- }
- rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
- return rtnResult;
- }
- }
- default:
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
- return rtnResult;
- }
- }
- return rtnResult;
- }
- catch (Exception ex)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
- return rtnResult;
- }
- finally
- {
- Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
- }
- }
- //[STAThread]
- //public void print(JObject joInParam)
- //{
- // //显示打印界面
- // SettlementChecklist frmSettlList;
- // string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
- // if (insuAdmObj == "")
- // {
- // frmSettlList = new SettlementChecklist();
- // }
- // else
- // {
- // JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
- // frmSettlList = new SettlementChecklist(joInsuAdmObj);
- // }
- // if (frmSettlList.ShowDialog() == DialogResult.OK)
- // {
- // };
- //}
- //[STAThread]
- /// <summary>
- /// 辅助交易
- /// </summary>
- /// <param name="InParam"></param>
- /// <returns></returns>
- public string AgentFun(string InParam)
- {
- Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
- //设置返回值,错误信息
- int errCode;
- string errMsg, rtnResult = "", outParam;
- try
- {
- //解析入参
- if (parseInparam(InParam, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
- return rtnResult;
- }
- //BS架构调用方式问题,每次调用都需要重新初始化
- if (init(InParam, out outParam) != 0)
- {
- rtnResult = outParam;
- return rtnResult;
- }
- //获取pat
- //hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
- switch (businessType)
- {
- case "BasicData"://基础数据维护
- {
- BasicData bd = new BasicData();
- if (bd.ShowDialog() != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出基础数据维护界面").ToString();
- return rtnResult;
- }
- break;
- }
- case "Exception"://异常处理
- {
- //显示异常处理界面
- HandleException frmEX = new HandleException();
- if (frmEX.ShowDialog() != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出异常处理界面").ToString();
- return rtnResult;
- }
- break;
- }
- case "CheckAndClearing"://对账清算
- {
- Clearing frmEX = new Clearing();
- if (frmEX.ShowDialog() != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出对账清算界面").ToString();
- return rtnResult;
- }
- break;
- }
- case "Print"://打印
- {
- //显示打印界面
- SettlementChecklist frmSettlList;
- string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
- if (insuAdmObj == "")
- {
- frmSettlList = new SettlementChecklist();
- if (frmSettlList.ShowDialog() != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出打印界面").ToString();
- return rtnResult;
- }
- }
- else
- {
- JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
- frmSettlList = new SettlementChecklist(joInsuAdmObj);
- string groupID = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "groupID");
- string userName = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "userName");
- DataTable dt = (DataTable)frmSettlList.dgvSettlRecord.DataSource;
- if (dt.Rows.Count != 1)
- {
- frmSettlList.ShowDialog();
- }
- else
- {
- frmSettlList.btnPrint_Click(null, null);
- }
- }
- return JsonHelper.setIrisReturnValue(0, "", null).ToString();
- break;
- }
- case "Log"://日志
- {
- MessageBox.Show(businessType);
- break;
- }
- case "RecordUpload"://上传记录
- {
- MessageBox.Show(businessType);
- break;
- }
- case "ToPutOnRecord"://医保备案相关
- {
- STA sta = new STA();
- Thread thread = new Thread(sta.ToPutOnRecord);
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- thread.Start();
- thread.Join();
- break;
- }
- case "MedInsuQuery"://医保查询
- {
- MedInsuQuery MedQuery = new MedInsuQuery();
- if (MedQuery.ShowDialog() != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保查询界面").ToString();
- return rtnResult;
- }
- break;
- }
- case "Appeal"://医保申诉
- {
- HopitalAppeal appeal = new HopitalAppeal();
- if (appeal.ShowDialog() != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保申诉界面").ToString();
- return rtnResult;
- }
- break;
- }
- case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
- {
- Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
- Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
- Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
- JObject joResult = new JObject();
- joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
- //事前分析
- if (Global.curEvt.ext.isOpenAnalysis)
- {
- if (hBus.PreAnalysis("5", joResult.ToString(), out errMsg) != 0)
- {
- MessageBox.Show(errMsg);
- break;
- }
- }
- break;
- }
- case "PrescribeCirculation"://医保处方流转
- {
- //显示医保处方流转界面
- PrescriptionCirculation PresCir = new PrescriptionCirculation("");
- if (PresCir.ShowDialog() != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保电子处方流转界面").ToString();
- return rtnResult;
- }
- break;
- }
- case "Special"://就医特殊属性上传
- {
- SpecialPsn spec = new SpecialPsn();
- if (spec.ShowDialog() != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出就医特殊属性上传界面").ToString();
- return rtnResult;
- }
- break;
- }
- case "ElectronicSettlementCertificate":// 电子结算凭证上传
- {
- EcSettlCertMainForm ecCert = new EcSettlCertMainForm();
- ecCert.ShowDialog();
- break;
- }
- default:
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对!").ToString();
- return rtnResult;
- }
- }
- return rtnResult;
- }
- catch (Exception ex)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
- return rtnResult;
- }
- finally
- {
- Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
- }
- }
- public string Download(string InParam)
- {
- Global.writeLog("Download 入参:" + JsonHelper.Compress(InParam));
- //设置返回值,错误信息
- int errCode;
- string errMsg, rtnResult = "", outParam;
- try
- {
- //解析入参
- if (parseInparam(InParam, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
- return rtnResult;
- }
- //BS架构调用方式问题,每次调用都需要重新初始化
- if (init(InParam, out outParam) != 0)
- {
- rtnResult = outParam;
- return rtnResult;
- }
- dynamic joData = new JObject();
- joData.data = joParam["data"];
- //string code = (string)joInParam["code"];
- string funNO = (string)joParam["funNO"];
- switch (businessType)
- {
- case "DirectoryDownload":
- {
- string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
- rtnResult = hBus.DownloadDirectory(funNO, downloadParam).ToString();
- break;
- }
- case "DictionayDownload":
- {
- string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
- rtnResult = hBus.downDictionary(downloadParam);
- break;
- }
- }
- return rtnResult;
- }
- catch (Exception ex)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "Download", ex.Message).ToString();
- return rtnResult;
- }
- finally
- {
- Global.writeLog("Download 出参:" + rtnResult);
- }
- }
-
- public string PlatformDirectConnect(string InParam)
- {
- //设置返回值,错误信息
- int errCode;
- string errMsg, rtnResult = "", outParam;
- try
- {
- Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
- //解析入参
- if (parseInparam(InParam, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
- return rtnResult;
- }
- Global.businessType = businessType;
- string funNO = JsonHelper.getDestValue(joInParam, "funNO");
- //BS架构调用方式问题,每次调用都需要重新初始化
- if (init(InParam, out outParam) != 0)
- {
- rtnResult = outParam;
- return rtnResult;
- }
- JObject joRtn;
- string[] strArr = { "3501", "3502", "3503", "3504", "3505", "3506", "3507" };//进销存交易
- bool exists = ((IList)strArr).Contains(funNO);
- if (exists)
- {
- //解析入参
- if (parsejoParam(joParam, funNO, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
- return rtnResult;
- }
-
- //if (funNO == "3505")
- //{
-
- // //解析入参
- // if (parsejoParamSet(joParam, funNO, out errMsg) != 0)
- // {
- // rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
- // return rtnResult;
- // }
- // invoker.invokeCenterServiceJXC("992001", JObject.Parse(JsonHelper.setCenterInpar("992001", joParam992001)));//结算信息上传
- // invoker.invokeCenterServiceJXC("992004", JObject.Parse(JsonHelper.setCenterInpar("992004", joParam992004)));//结算费用明细上传
- //}
- //if (funNO == "3506")
- //{
-
- // invoker.invokeCenterServiceJXC("992002", JObject.Parse(JsonHelper.setCenterInpar("992002", joParam992001)));//结算退费信息上传
- // invoker.invokeCenterServiceJXC("992004", JObject.Parse(JsonHelper.setCenterInpar("992004", joParam992004)));//结算退费费用明细上传
- //}
- joRtn = invoker.invokeCenterServiceJXC(funNO, JObject.Parse(JsonHelper.setCenterInpar(funNO, joParam)));
- string funNOA = funNO + 'A';
-
- joRtn = invoker.invokeCenterService(funNOA, JsonHelper.setCenterInpar(funNOA, joParamA));
- }
- else //非进销存交易
- {
- if (funNO== "I2002")
- {
- joRtn = invoker.invokeCenterServiceFZJK("I2002", joParam);//追溯码辅助接口
- }
- else {
-
- joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joParam));//正常交易走医保COM组件
- }
-
- }
- if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
- return rtnResult;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
- return rtnResult;
- }
- }
- catch (Exception ex)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
- return rtnResult;
- }
- finally
- {
- Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
- }
- }
- private int parsejoParam(JObject joParam,string funno,out string errMsg)
- {
- errMsg = "";
- try
- {
- if (funno == "3505"|| funno == "3506")
- {
- if (!string.IsNullOrEmpty(joParam["selinfo"]["setl_id"].ToString()))
- {
- if (joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4299" || joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4201")
- {
- joParam["selinfo"]["hi_feesetl_type"] = "1";
- }
- else
- {
- joParam["selinfo"]["hi_feesetl_type"] = "2";
- }
- }
- else
- {
- joParam["selinfo"]["hi_feesetl_type"] = "0";
- }
- JObject joRtn = JObject.Parse(joParam["selinfo"].ToString());
- //if (!string.IsNullOrEmpty(joParam["selinfo"]["drugtracinfo"].ToString()))
- //{
- // joRtn.Add("drug_trac_info", joParam["selinfo"]["drugtracinfo"]);
- // joParam["selinfo"] = joRtn;
- //}
- //MessageBox.Show("111");
- //MessageBox.Show(joParam.ToString());
- JArray selDtl = new JArray();
- selDtl.Add(JObject.Parse(joParam["selinfo"].ToString()));
- //MessageBox.Show(selDtl.ToString());
- joParamA = new JObject();
- joParamA.Add("selinfoDetail", selDtl);
- //MessageBox.Show(joParamA.ToString());
- return 0;
- }
- else if (funno == "3501")
- {
- JObject joRtn = JObject.Parse(joParam["invinfo"].ToString());
- //if (!string.IsNullOrEmpty(joParam["invinfo"]["drugtracinfo"].ToString()))
- //{
- // joRtn.Add("drug_trac_info", joParam["invinfo"]["drugtracinfo"]);
- // joParam["invinfo"] = joRtn;
- //}
- JArray selDtl = new JArray();
- selDtl.Add(JObject.Parse(joParam["invinfo"].ToString()));
- //MessageBox.Show(selDtl.ToString());
- joParamA = new JObject();
- joParamA.Add("invinfoDetail", selDtl);
- return 0;
- }
- else if (funno == "3502")
- {
- JObject joRtn = JObject.Parse(joParam["invinfo"].ToString());
- //if (!string.IsNullOrEmpty(joParam["invinfo"]["drugtracinfo"].ToString()))
- //{
- // joRtn.Add("drug_trac_info", joParam["invinfo"]["drugtracinfo"]);
- // joParam["invinfo"] = joRtn;
- //}
- JArray selDtl = new JArray();
- selDtl.Add(JObject.Parse(joParam["invinfo"].ToString()));
- //MessageBox.Show(selDtl.ToString());
- joParamA = new JObject();
- joParamA.Add("invinfoDetail", selDtl);
- return 0;
- }
- else if (funno == "3503")
- {
- JObject joRtn = JObject.Parse(joParam["purcinfo"].ToString());
- //if (!string.IsNullOrEmpty(joParam["purcinfo"]["drugtracinfo"].ToString()))
- //{
- // joRtn.Add("drug_trac_info", joParam["purcinfo"]["drugtracinfo"]);
- // joParam["purcinfo"] = joRtn;
- //}
- JArray selDtl = new JArray();
- selDtl.Add(JObject.Parse(joParam["purcinfo"].ToString()));
- //MessageBox.Show(selDtl.ToString());
- joParamA = new JObject();
- joParamA.Add("purcinfoDetail", selDtl);
- return 0;
- }
- else if ( funno == "3504")
- {
- JObject joRtn = JObject.Parse(joParam["purcinfo"].ToString());
- //if (!string.IsNullOrEmpty(joParam["purcinfo"]["drugtracinfo"].ToString()))
- //{
- // joRtn.Add("drug_trac_info", joParam["purcinfo"]["drugtracinfo"]);
- // joParam["purcinfo"] = joRtn;
- //}
- JArray selDtl = new JArray();
- selDtl.Add(JObject.Parse(joParam["purcinfo"].ToString()));
- //MessageBox.Show(selDtl.ToString());
- joParamA = new JObject();
- joParamA.Add("purcinfoDetail", selDtl);
- return 0;
- }
- else { return -1; }
-
- }
- catch (Exception ex)
- {
- errMsg = "parsejoParam 解析入参异常1:" + errMsg;
- return -1;
- }
- }
- private int parsejoParamSet(JObject joParam, string funno, out string errMsg)
- {
- errMsg = "";
- try
- {
- if (funno == "3505")
- {
- string setl_id = joParam["selinfo"]["setl_id"].ToString();
- string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 ";
- sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
- sqlStr = sqlStr + " AND SettlementID ='" + setl_id + "'";
- JObject joSql = new JObject();
- joSql.Add("sqlStr", sqlStr);
- JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
- //查询结算信息
- JObject Outpam = JObject.Parse(joSettlInfo["result"]["data"][0].ToString());
- dynamic setlinfo = new JObject();//结算信息节点
- setlinfo.setl_id = Outpam["SettlementID"];//结算ID
- setlinfo.mdtrt_id = Outpam["MdtrtID"];//就诊ID
- setlinfo.psn_no = Outpam["PersonnelNO"];//人员编号
- setlinfo.psn_name = Outpam["PatientName"];//人员姓名
- setlinfo.psn_cert_type = Outpam["MdtrtCertType"];//凭证类型
- setlinfo.certno = Outpam["CertificateNO"];//证件号码
- setlinfo.gend = Outpam["Gender"];//性别
- setlinfo.naty = Outpam["Nation"];//民族
- setlinfo.brdy = Outpam["BirthDay"];//出生日期
- setlinfo.age = Outpam["Age"];//年龄
- setlinfo.insutype = Outpam["InsuranceType"];//险种类型
- setlinfo.psn_type = Outpam["PersonType"];//人员类别
- setlinfo.cvlserv_flag = Outpam["CivilserviceFlag"];//公务员标志
- setlinfo.setl_time = Outpam["SettlementTime"];//结算时间
- setlinfo.mdtrt_cert_type = Outpam["MdtrtCertType"];//就诊凭证类型
- setlinfo.med_type = Outpam["MedicalType"];//医疗类别
- setlinfo.medfee_sumamt = Outpam["Sumamt"];//医疗费总额
- setlinfo.fulamt_ownpay_amt = Outpam["OwnPayAmount"];//全自费金额
- setlinfo.overlmt_selfpay = Outpam["OverLimitAmount"];//超限价自费费用
- setlinfo.preselfpay_amt = Outpam["PreSelfPayAmount"];//先行自付金额
- setlinfo.inscp_scp_amt = Outpam["InPolicyRangeAmount"];//符合政策范围金额
- setlinfo.act_pay_dedc = Outpam["ActualPayDeductible"];//实际支付起付线
- setlinfo.hifp_pay = Outpam["HealthInsurancePay"];//基本医疗保险统筹基金支出
- setlinfo.pool_prop_selfpay = Outpam["HealthInsuranceRatio"];//基本医疗保险统筹基金支付比例
- setlinfo.cvlserv_pay = Outpam["CivilserviceAllowancePay"];//公务员医疗补助资金支出
- setlinfo.hifes_pay = Outpam["EnterpriseSupplementPay"];//企业补充医疗保险基金支出
- setlinfo.hifmi_pay = Outpam["SeriousIllnessPay"];//居民大病保险资金支出
- setlinfo.hifob_pay = Outpam["LargeExpensesSupplementPay"];//职工大额医疗费用补助基金支出
- setlinfo.maf_pay = Outpam["MedicalAssistPay"];//医疗救助基金支出
- setlinfo.oth_pay = Outpam["OtherPay"];//结算ID
- setlinfo.fund_pay_sumamt = Outpam["FundPaySumamt"];//基金支付总额
- setlinfo.psn_part_amt = Outpam["PersonPaySumamt"];//个人负担总金额
- setlinfo.acct_pay = Outpam["AccountPaySumamt"];//个人账户支出
- setlinfo.psn_cash_pay = Outpam["PersonCashPay"];//个人现金支出
- setlinfo.balc = Outpam["Balance"];//余额
- setlinfo.acct_mulaid_pay = Outpam["AccountMutualAidAmount"];//个人账户共济支付金额
- setlinfo.medins_setl_id = Outpam["OrganSettlementID"];//医药机构结算结算ID
- setlinfo.clr_optins = Outpam["ClearingOrgan"];//clr_optins
- setlinfo.clr_way = Outpam["ClearingWay"];//clr_way
- setlinfo.clr_type = Outpam["ClearingType"];//clr_type
- setlinfo.exp_content = "";//exp_content
- setlinfo.hosp_part_amt = Outpam["HospitalPartAmount"];//医院负担金额
- setlinfo.hifdm_pay = 0;//伤残人员医疗保障基金支出
- dynamic setlinfo1 = new JObject();//结算信息节点
- setlinfo1.setl_id = Outpam["SettlementID"];//结算ID
- string outParam = "";
- string AdmID = Outpam["AdmID"].ToString();
- string billID = Outpam["BillID"].ToString();
- string recordID = Outpam["RecordID"].ToString();
-
- Global.pat.adm_Dr = int.Parse(AdmID);
- Global.pat.billID = billID;
- Global.pat.recordID = recordID;
- //获取IS费用
- if (hIS.getHisFee(Global.pat, out outParam) != 0)
- {
- MessageBox.Show("获取HIS费用失败");
- }
- //调用医保平台转换HIS费用(转换医保编码等)
- JObject joHisFee = JObject.Parse(outParam);
- if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0)
- {
- MessageBox.Show("获取HIS费用医保对照关系失败");
- }
- JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
- MessageBox.Show("11111");
- JObject jaFeeOne = new JObject();
- for (int i = 0; i < jaFeeDetail.Count; i++)
- {
- jaFeeOne.Add("feedetl_sn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
- jaFeeOne.Add("rxno", "");//处方号
- if (string.IsNullOrEmpty(jaFeeDetail[i]["rx_circ_flag"].ToString()))
- {
- jaFeeOne.Add("rx_circ_flag", "");//外购处方标志
- }
- else
- {
- jaFeeOne.Add("rx_circ_flag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
- }
- jaFeeOne.Add("fee_ocur_time", jaFeeDetail[i]["fee_ocur_time"]);
- jaFeeOne.Add("med_list_codg", jaFeeDetail[i]["med_list_codg"]);
- jaFeeOne.Add("medins_list_codg", jaFeeDetail[i]["medins_list_codg"]);
- jaFeeOne.Add("medins_list_name", jaFeeDetail[i]["medins_list_desc"]);
- jaFeeOne.Add("prodname", jaFeeDetail[i]["medins_list_desc"]);
- if (string.IsNullOrEmpty(jaFeeDetail[i]["spec"].ToString()))
- {
- jaFeeOne.Add("spec", "");
- }
- else
- {
- jaFeeOne.Add("spec", jaFeeDetail[i]["spec"]);
- }
- if (string.IsNullOrEmpty(jaFeeDetail[i]["doseForm"].ToString()))
- {
- jaFeeOne.Add("dosform_name", "");
- }
- else
- {
- jaFeeOne.Add("dosform_name", jaFeeDetail[i]["doseForm"]);
- }
- jaFeeOne.Add(" det_item_fee_sumamt", jaFeeDetail[i]["det_item_fee_sumamt"]);
- jaFeeOne.Add("cnt", jaFeeDetail[i]["cnt"]);
- jaFeeOne.Add("pric", jaFeeDetail[i]["pric"]);
- if (string.IsNullOrEmpty(jaFeeDetail[i]["sin_dos_dscr"].ToString()))
- {
- jaFeeOne.Add("sin_dos_dscr", "");
- }
- else
- {
- jaFeeOne.Add("sin_dos_dscr", jaFeeDetail[i]["sin_dos_dscr"]);
- }
- if (string.IsNullOrEmpty(jaFeeDetail[i]["used_frqu_dscr"].ToString()))
- {
- jaFeeOne.Add("used_frqu_dscr", "");
- }
- else
- {
- jaFeeOne.Add("used_frqu_dscr", jaFeeDetail[i]["used_frqu_dscr"]);
- }
- if (string.IsNullOrEmpty(jaFeeDetail[i]["prd_days"].ToString()))
- {
- jaFeeOne.Add("prd_days", "");
- }
- else
- {
- jaFeeOne.Add("prd_days", jaFeeDetail[i]["prd_days"]);
- }
- if (string.IsNullOrEmpty(jaFeeDetail[i]["medc_way_dscr"].ToString()))
- {
- jaFeeOne.Add("medc_way_dscr", "");
- }
- else
- {
- jaFeeOne.Add("medc_way_dscr", jaFeeDetail[i]["medc_way_dscr"]);
- }
- if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_codg"].ToString()))
- {
- jaFeeOne.Add("bilg_dr_codg", "");
- }
- else
- {
- jaFeeOne.Add("bilg_dr_codg", jaFeeDetail[i]["bilg_dr_codg"]);
- }
- if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_name"].ToString()))
- {
- jaFeeOne.Add("bilg_dr_name", "");
- }
- else
- {
- jaFeeOne.Add("bilg_dr_name", jaFeeDetail[i]["bilg_dr_name"]);
- }
- jaFeeOne.Add("phar_name", "");
- jaFeeOne.Add("phar_prac_cert_no", "");
- jaFeeOne.Add("tcmdrug_used_way", ""); //中药使用方式 1复方 2单方 必填
- jaFeeOne.Add("trdn_flag", "1");//拆零标志 必填 0否 1是
- jaFeeDetail.Add(jaFeeOne);
- jaFeeOne = new JObject();
- }
- MessageBox.Show("22222");
- joParam992001.Add("setlinfo", JObject.Parse(setlinfo));//结算信息节点
- joParam992004.Add("setlinfo", JObject.Parse(setlinfo1));
- joParam992004.Add("drugdetail", jaFeeDetail);//购药明细节点
- //JObject OutJo = invoker.invokeCenterServiceJXC("992001", JObject.Parse(JsonHelper.setCenterInpar("992001", Jo992001)));
- //MessageBox.Show("上传返回:" + OutJo.ToString());
- }
- if (funno == "3506")
- {
- string setl_id = joParam["selinfo"]["setl_id"].ToString();
- string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = -1 ";
- sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
- sqlStr = sqlStr + " AND SettlementID ='" + setl_id + "'";
- JObject joSql = new JObject();
- joSql.Add("sqlStr", sqlStr);
- JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
- //查询结算信息
- JObject Outpam = JObject.Parse(joSettlInfo["result"]["data"][0].ToString());
- string mdtrt_id = Outpam["MdtrtID"].ToString();//ADMID
- string sqlStr1 = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 ";
- sqlStr1 = sqlStr1 + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
- sqlStr1 = sqlStr1 + " AND MdtrtID ='" + mdtrt_id + "'";
- JObject joSql1 = new JObject();
- joSql1.Add("sqlStr1", sqlStr);
- JObject joSettlInfo1 = mIS.QuerySettlementInfo(joSql1);
- JObject Outpam1= JObject.Parse(joSettlInfo1["result"]["data"][0].ToString());
- dynamic setlinfo = new JObject();//结算信息节点
- setlinfo.setl_id = Outpam["SettlementID"];//结算ID
- setlinfo.init_setl_id = Outpam1["SettlementID"]; ;//结算ID
- setlinfo.setl_time = Outpam["SettlementTime"];//结算时间
- setlinfo.mdtrt_id = Outpam["MdtrtID"];//就诊ID
- setlinfo.psn_no = Outpam["PersonnelNO"];//人员编号
- setlinfo.exp_content = "";//人员姓名
- dynamic setlinfo1 = new JObject();//结算信息节点
- setlinfo1.setl_id = Outpam["SettlementID"];//结算ID
- joParam992002.Add("data", JObject.Parse(setlinfo));//结算信息节点
- string AdmID = Outpam["AdmID"].ToString();
- string billID = Outpam["BillID"].ToString();
- string recordID = Outpam["RecordID"].ToString();
- Global.pat.adm_Dr = int.Parse(AdmID);
- Global.pat.billID = billID;
- Global.pat.recordID = recordID;
- string outParam = "";
- //获取IS费用
- if (hIS.getHisFee(Global.pat, out outParam) != 0)
- {
- MessageBox.Show("获取HIS费用失败");
- }
- //调用医保平台转换HIS费用(转换医保编码等)
- JObject joHisFee = JObject.Parse(outParam);
- if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0)
- {
- MessageBox.Show("获取HIS费用医保对照关系失败");
- }
- JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
- JObject jaFeeOne = new JObject();
- for (int i = 0; i < jaFeeDetail.Count; i++)
- {
- jaFeeOne.Add("feedetl_sn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
- jaFeeOne.Add("rxno", "");//处方号
- if (string.IsNullOrEmpty(jaFeeDetail[i]["rx_circ_flag"].ToString()))
- {
- jaFeeOne.Add("rx_circ_flag", "");//外购处方标志
- }else {
- jaFeeOne.Add("rx_circ_flag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
- }
- jaFeeOne.Add("fee_ocur_time", jaFeeDetail[i]["fee_ocur_time"]);
- jaFeeOne.Add("med_list_codg", jaFeeDetail[i]["med_list_codg"]);
- jaFeeOne.Add("medins_list_codg", jaFeeDetail[i]["medins_list_codg"]);
- jaFeeOne.Add("medins_list_name", jaFeeDetail[i]["medins_list_desc"]);
- jaFeeOne.Add("prodname", jaFeeDetail[i]["medins_list_desc"]);
-
- if (string.IsNullOrEmpty(jaFeeDetail[i]["spec"].ToString()))
- {
- jaFeeOne.Add("spec", "");
- }
- else
- {
- jaFeeOne.Add("spec", jaFeeDetail[i]["spec"]);
- }
-
- if (string.IsNullOrEmpty(jaFeeDetail[i]["doseForm"].ToString()))
- {
- jaFeeOne.Add("dosform_name", "");
- }
-
- else
- {
- jaFeeOne.Add("dosform_name", jaFeeDetail[i]["doseForm"]);
- }
-
- jaFeeOne.Add(" det_item_fee_sumamt", jaFeeDetail[i]["det_item_fee_sumamt"]);
- jaFeeOne.Add("cnt", jaFeeDetail[i]["cnt"]);
- jaFeeOne.Add("pric", jaFeeDetail[i]["pric"]);
- if (string.IsNullOrEmpty(jaFeeDetail[i]["sin_dos_dscr"].ToString()))
- {
- jaFeeOne.Add("sin_dos_dscr", "");
- }
- else
- {
- jaFeeOne.Add("sin_dos_dscr", jaFeeDetail[i]["sin_dos_dscr"]);
- }
-
-
- if (string.IsNullOrEmpty(jaFeeDetail[i]["used_frqu_dscr"].ToString()))
- {
- jaFeeOne.Add("used_frqu_dscr", "");
- }
- else
- {
- jaFeeOne.Add("used_frqu_dscr", jaFeeDetail[i]["used_frqu_dscr"]);
- }
- if (string.IsNullOrEmpty(jaFeeDetail[i]["prd_days"].ToString()))
- {
- jaFeeOne.Add("prd_days", "");
- }
- else
- {
- jaFeeOne.Add("prd_days", jaFeeDetail[i]["prd_days"]);
- }
- if (string.IsNullOrEmpty(jaFeeDetail[i]["medc_way_dscr"].ToString()))
- {
- jaFeeOne.Add("medc_way_dscr", "");
- }
- else
- {
- jaFeeOne.Add("medc_way_dscr", jaFeeDetail[i]["medc_way_dscr"]);
- }
-
- if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_codg"].ToString()))
- {
- jaFeeOne.Add("bilg_dr_codg", "");
- }
- else
- {
- jaFeeOne.Add("bilg_dr_codg", jaFeeDetail[i]["bilg_dr_codg"]);
- }
- if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_name"].ToString()))
- {
- jaFeeOne.Add("bilg_dr_name", "");
- }
- else
- {
- jaFeeOne.Add("bilg_dr_name", jaFeeDetail[i]["bilg_dr_name"]);
- }
-
- jaFeeOne.Add("phar_name", "");
- jaFeeOne.Add("phar_prac_cert_no", "");
- jaFeeOne.Add("tcmdrug_used_way", ""); //中药使用方式 1复方 2单方 必填
- jaFeeOne.Add("trdn_flag", "1");//拆零标志 必填 0否 1是
- jaFeeDetail.Add(jaFeeOne);
- jaFeeOne = new JObject();
- }
- joParam992004.Add("setlinfo", JObject.Parse(setlinfo1));
- joParam992004.Add("drugdetail", jaFeeDetail);//购药明细节点
- }
- return 0;
- }
- catch (Exception ex)
- {
- errMsg = "parsejoParam 解析入参异常2:" + errMsg;
- return -1;
- }
- }
- }
- }
|