| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564 |
- 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 System.Xml.Linq;
- using Newtonsoft.Json;
- using System.Xml;
- using System.Threading;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using PTMedicalInsurance.Forms.SettlementWithNopwdApplys;
- namespace PTMedicalInsurance
- {
-
- public class InsuBusiness : IInsuBusiness
- {
- public enum ShowCommands : int
- {
- SW_HIDE = 0,
- SW_SHOWNORMAL = 1,
- SW_NORMAL = 1,
- SW_SHOWMINIMIZED = 2,
- SW_SHOWMAXIMIZED = 3,
- SW_MAXIMIZE = 3,
- SW_SHOWNOACTIVATE = 4,
- SW_SHOW = 5,
- SW_MINIMIZE = 6,
- SW_SHOWMINNOACTIVE = 7,
- SW_SHOWNA = 8,
- SW_RESTORE = 9,
- SW_SHOWDEFAULT = 10,
- SW_FORCEMINIMIZE = 11,
- SW_MAX = 11
- };
- [DllImport("shell32.dll")]
- public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);
- //json对象属性
- private JObject joInParam;
- private JArray jaSession ;
- private JArray jaParams;
- private JObject joParam;
- private JObject joInterface;
- private JObject joInsuAdmObj;
- //设置业务实例
- CenterBusiness cBus = new CenterBusiness();
- HisMainBusiness hBus = new HisMainBusiness();
- HisIrisServices hIS = new HisIrisServices();
- MIIrisServices mIS= new MIIrisServices();
- InvokeHelper invoker = new InvokeHelper();
- private XmlHelper xmler = new XmlHelper();
- //
- 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();
- Global.pat.insuplc_admdvs = "";//如果是NULL中心会报错
- }
- #region 内部私有方法封装
- 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]);
- joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
- if (JsonHelper.getDestValue(joInParam, "insuAdmObj") !="")
- joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInParam, "insuAdmObj"));
- businessType = JsonHelper.getDestValue(joInParam, "businessType");
- if (JsonHelper.getDestValue(joInParam, "operationType") != "")
- {
- Global.operationType = (OperationType)Enum.Parse(typeof(OperationType), JsonHelper.getDestValue(joInParam, "operationType"));
- }
- Global.curEvt.businessType = businessType;
- return 0;
- }
- catch (Exception ex)
- {
- errMsg = "parseInparam 解析入参异常:" + errMsg;
- return -1;
- }
- }
- 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;
- }
- }
- #endregion
- #region 核心业务
- /// <summary>
- /// 初始化
- /// </summary>
- /// <param name="InParam"></param>
- /// <returns></returns>
- public string Init(string InParam)
- {
- string errMsg, rtnResult ="";
- JObject joRtn = new JObject();
- try
- {
- //解析入参
- if (parseInparam(InParam, out errMsg) != 0)
- {
- return JsonHelper.setExceptionJson(-100, "initEnvironment解析入参失败", errMsg).ToString();
- }
- if (hBus.initEnvironment(InParam, out errMsg) != 0)
- {
- return JsonHelper.setExceptionJson(-100, "initEnvironment(获取HIS及医保平台配置信息,当前登录用户信息,当前接口的详细信息) 失败", errMsg).ToString();
- }
- else
- {
- //签到
- 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();
- }
- }
- }
- InvokeHelper.yhCom = new YinHaiCom();
- if (InvokeHelper.initYHCom(out errMsg) != 0)
- {
- return JsonHelper.setExceptionJson(-100, "初始化银海COM组件失败", errMsg).ToString();
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
- }
- return rtnResult;
- }
- }
- catch (Exception ex)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "初始化异常", ex.Message).ToString();
- return rtnResult;
- }
- finally
- {
- Global.writeLog("初始化结果:" + rtnResult);
- }
- }
- /// <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;
- }
- 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 = outParam;
- }
- }
- break;
- }
- case "Z1"://住院读卡
- {
- //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
- if (hBus.readCard(out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
- }
- else
- {
- string patInfo = outParam;
- //展示患者信息界面
- if (hBus.showPatInfo(patInfo, out outParam) != 0)
- {
- 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
- {
-
- //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"://入院登记
- {
- string regInParam = "";
- errMsg = "";
- if (hBus.checkName(Global.pat.name, out errMsg) != 0)
- {
- rtnResult = errMsg;
- return rtnResult;
- }
- //显示登记面板
- if (hBus.showInPatRegisterForm( out regInParam) == 0)
- {
- JObject joReg = JObject.Parse(regInParam);
- JObject joRegIn = JObject.Parse(JsonHelper.getDestValue(joReg, "input"));
- //将中心返回的结果返回HIS,调用HIS服务进行保存
- if (invoker.invokeYHCom("21", joRegIn, out outParam)== 0)
- {
- string outPut = xmler.ToJSON(outParam);
- JObject joRegOut = JObject.Parse(outPut);
- Global.pat.mdtrtID = JsonHelper.getDestValue(joRegOut, "output.prm_akc190");
- Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joRegOut, "output.prm_yab003");
- //插入患者本次就诊用的参保信息
- if (hBus.insertPatCurInsuInfo(JsonHelper.getDestValue(joParam, "patientInfo"), out outParam) != 0)
- {
- if (DialogResult.Yes == MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
- {
- }
- else
- {
- invoker.cancleYHCom(out errMsg);
- rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!", outParam).ToString();
- return rtnResult;
- }
- }
- //插入医保平台
- joRegOut.Add("validflag", 1);
- joRegOut.Add("regstate", 1);
- joRegOut.Add("type", 1);
- if (mIS.saveInpatRegisterInfo(joRegIn, joRegOut, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存登记信息", outParam).ToString();
- invoker.cancleYHCom(out errMsg);
- return rtnResult;
- }
- //返回登记信息,插入HIS
- if (hIS.returnRegisterInfo(joRegIn, joRegOut, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
- invoker.cancleYHCom(out errMsg);
- return rtnResult;
- }
- else
- {
- //确认中心结算
- if (invoker.confirmYHCom(out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心确认失败", errMsg).ToString();
- invoker.cancleYHCom(out errMsg);
- return rtnResult;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
- return rtnResult;
- }
- }
- }
- else
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", outParam).ToString();
- invoker.cancleYHCom(out errMsg);
- return rtnResult;
- }
- }
- else
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", regInParam).ToString();
- invoker.cancleYHCom(out errMsg);
- return rtnResult;
- }
- }
- case "Z2C"://入院登记取消
- {
- string sqlStr = "SELECT * FROM BS_MedInsuRegisterInfo WHERE Type=1 and Interface_Dr=" + Global.inf.interfaceDr;
- sqlStr = sqlStr + " AND InsuRegID='" + Global.pat.mdtrtID + "'";
- sqlStr = sqlStr + " AND Adm_Dr='" + Global.pat.adm_Dr + "'";
- JObject joSqlstr = new JObject();
- joSqlstr.Add("sqlStr", sqlStr);
- JArray jaParam = new JArray();
- jaParam.Add(joSqlstr);
- JObject joSettlQuery = new JObject();
- joSettlQuery.Add("params", jaParam);
- joSettlQuery.Add("code", "09010062");
- JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询住院登记信息");
-
- JArray jaRegInfo = JArray.Parse(JsonHelper.getDestValue(joRtn,"result.data"));
- if (jaRegInfo.Count != 1)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "云平台:", "未查询到或查询到多条住院登记信息").ToString();
- return rtnResult;
- }
- else
- {
- Global.pat.medType = jaRegInfo[0]["med_type"].ToString();
- Global.pat.insuplc_admdvs = jaRegInfo[0]["insuplc_admdvs"].ToString();
- Global.pat.insuType = jaRegInfo[0]["InsuType"].ToString();
- hBus.setPrmBatch();
- }
-
-
- //取消中心登记
- if (cBus.cancleRegister(out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
- ////询问收款员是否继续进行HIS退费
- //if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 是否强制取消HIS登记 ", MessageBoxButtons.YesNo))
- //{
- // //取消HIS 登记
- // if (hIS.cancleRegister(out outParam) != 0)
- // {
- // rtnResult = JsonHelper.setExceptionJson(-1, "强制取消HIS登记失败,", outParam).ToString();
- // }
- // else
- // {
- // rtnResult = JsonHelper.setExceptionJson(0, "强制取消HIS登记成功", 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
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "取消医保登记成功", null).ToString();
- return rtnResult;
- }
- }
- case "Z6"://出院登记
- {
- break;
- }
- case "Z6C"://出院登记取消
- {
- //从医保平台获取患者详细的医保登记信息
- 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");
- Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode");
- hBus.setPrmBatch();
- if (cBus.cancleDisRegister(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 (hBus.PreAnalysis("5", out errMsg) != 0)
- //{
- // rtnResult = JsonHelper.setExceptionJson(-1, "事前提示:" , errMsg).ToString();
- // return rtnResult;
- //}
- //解析入参
- 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 (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");
- Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode");
- hBus.setPrmBatch();
- if (Global.pat.medType != "G31")
- {
- Global.pat.patExtend.prm_yabtch = Global.pat.insuplc_admdvs;
- ////事前分析
- if (Global.curEvt.ext.isOpenAnalysis)
- {
- if (hBus.PreAnalysis("4","", out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
- return rtnResult;
- }
- }
- }
-
- ////先取消中心费用传送
- //cBus.cancleFeeUpload("2302", out errMsg);
- ////再删除医保传送表的数据
- //mIS.deleteFee(out errMsg);
- //费用上传
- if (hBus.uploadFee("2301", 50, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
- return rtnResult;
- }
- else
- {
- rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传成功", null).ToString();
- return rtnResult;
- }
- }
- case "Z3C"://住院费用上传取消
- {
- //从医保平台获取患者详细的医保登记信息
- 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");
- Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode");
- hBus.setPrmBatch();
- 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"://门诊结算
- {
- STA sta = new STA();
- Thread thread = new Thread(new ParameterizedThreadStart(sta.showOutPatientIntegratedServicesForm));
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- object[] o = new object[3];
- o[0] = "-1";
- thread.Start(o);
- thread.Join();
- if ((int)o[0] != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-100, "门诊结算失败!", (string)o[2]).ToString();
- return rtnResult;
- }
- else
- {
- rtnResult = (string)o[2];
- return rtnResult;
- }
- }
- case "M5C"://门诊结算撤销
- {
- string setl_id = JsonHelper.getDestValue(joParam, "setl_id");
- //查询结算表
- string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag =1 and billType = 1 and Hospital_Dr=" + Global.inf.hospitalDr
- + " and Adm_Dr=" + Global.pat.adm_Dr
- + " and MdtrtID='" + Global.pat.mdtrtID + "'"
- + " AND SettlementID='" + setl_id + "'";
- JObject joSql = new JObject();
- joSql.Add("sqlStr", sqlStr);
- JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
- Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
- Global.pat.medType = JsonHelper.getDestValue(joSettlInfo, "result.data[0].MedicalType");
- Global.pat.insuType = JsonHelper.getDestValue(joSettlInfo, "result.data[0].InsuranceType");
- hBus.setPrmBatch();
- //共济
- DataTable dtSettlInfo = (DataTable)JsonConvert.DeserializeObject(joSettlInfo["result"]["data"].ToString(), (typeof(DataTable)));
- if (dtSettlInfo.Rows.Count != 1)
- {
- rtnResult = JsonHelper.setIrisReturnValue(-1, "未查询到相关结算信息!", joSettlInfo).ToString();
- return rtnResult;
- }
- int mutualAidFlag = 0;
- if (!string.IsNullOrEmpty(dtSettlInfo.Rows[0]["MutualAidFlag"].ToString()))
- {
- mutualAidFlag = Convert.ToInt32(dtSettlInfo.Rows[0]["MutualAidFlag"].ToString());
- }
- if (mutualAidFlag > 0)
- {
- STA sta = new STA();
- Thread thread = new Thread(sta.MutualAid);
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- object[] o = new object[2];
- o[0] = setl_id;
- thread.Start(o);
- thread.Join();
- //重新赋值
- hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
- Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
- Global.pat.patExtend.prm_yabtch = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
- Global.pat.medType = JsonHelper.getDestValue(joSettlInfo, "result.data[0].MedicalType");
- Global.pat.insuType = JsonHelper.getDestValue(joSettlInfo, "result.data[0].InsuranceType");
- }
- //退中心结算
- if (cBus.cancleSettlement( out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算", outParam).ToString();
- //查看是医保平台是否已经退费,如果是,则询问是否继续退费
- //string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
- ////sqlStr = sqlStr + " AND SettlementID ='" + Global.pat.settlID + "'"; // 广州本地门诊退结算ID 跟结算ID 一致,但异地门诊不一致
- //sqlStr = sqlStr + " AND RecordID ='" + Global.pat.recordID + "'";
- //sqlStr = sqlStr + " AND ValidFlag = 0 AND BillType = -1";
- //string sqlStr = "SELECT RecordID FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
- //sqlStr = sqlStr + " AND SettlementID ='" + Global.pat.settlID + "'" + " AND BillType = 1 ";
- //sqlStr = "(" + sqlStr + ")";
- //sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr
- // + " AND BillType = -1 and RecordID=" + sqlStr;
- sqlStr = "SELECT A.* FROM BS_MedInsuSettlement A LEFT JOIN BS_MedInsuSettlement B ON A.RecordID = b.RecordID";
- sqlStr = sqlStr + " AND A.BillType = -1 AND B.BillType = 1 ";
- sqlStr = sqlStr + " where B.SettlementID ='" + Global.pat.settlID + "'";
- sqlStr = sqlStr + " AND A.Interface_Dr=" + Global.inf.interfaceDr;
- 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 == 0)
- {
- //询问收款员是否继续进行HIS退费
- //if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
- //{
- // rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
- //}
- }
- else 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;
- }
- //确认中心结算
- if (invoker.confirmYHCom(out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心确认失败", outParam).ToString();
- return rtnResult;
- }
- string newSettleID = JsonHelper.getDestValue(JObject.Parse(xmler.ToJSON(outParam)), "output.prm_yka198");
- //退云医保平台结算
- if (mIS.cancleSettlement(newSettleID,out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消平台结算信息", outParam).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;
- }
- 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 交易", errMsg).ToString();
- return rtnResult;
- }
- if (mp.MobilePaySettlement(out outParam) != 0)
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
- else
- rtnResult = outParam;
- return rtnResult;
- }
- case "M6C"://门诊移动支付结算撤销
- {
- string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
- //if (onlineYBFalg == "Y")
- //{
- // rtnResult = JsonHelper.setExceptionJson(-1, "门诊移动支付撤销交易", "不支持线上退费").ToString();
- // return rtnResult;
- //}
- MobilePay mp = new MobilePay(InParam, out errMsg);
- if (errMsg != "")
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", 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 交易", outParam).ToString();
- else
- rtnResult = JsonHelper.setExceptionJson(0, "Settlement 交易", outParam).ToString();
- return rtnResult;
- }
- case "M6Confirm"://门诊移动支付确认
- {
- MobilePay mp = new MobilePay(InParam, out errMsg);
- if (errMsg != "")
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
- return rtnResult;
- }
- if (mp.MobilePayConfirmSettlement(out outParam) != 0)
- rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
- else
- rtnResult = outParam;
- return rtnResult;
- }
- case "Z4"://住院预结算
- {
- JObject joSettle = new JObject();
- if (hBus.preSettlement(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"://住院结算
- {
- JObject joPreSetOutpar ;
- if (hBus.preSettlement(out joPreSetOutpar, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
- return rtnResult;
- }
- else
- {
- if (Global.pat.patExtend.isMutualAid && Global.pat.patExtend.isSettlementWithNopwd)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "无密码结算和共济结算只能选择一个", "").ToString();
- return rtnResult;
- }
-
- if (Global.pat.patExtend.prm_yabtch != "GS01")
- {
- ////事中分析
- if (Global.curEvt.ext.isOpenAnalysis)
- {
- if (hBus.InProcessAnalysis("8", out errMsg) != 0)
- {
- outParam = JsonHelper.setExceptionJson(-1, "InProcessAnalysis", errMsg).ToString();
- return outParam;
- }
- }
- }
- string sqlStr = "SELECT * FROM SQLUser.BS_MIPatCurrentInsuInfo WHERE Interface_Dr =" + Global.inf.interfaceDr
- + " AND AdmID = '" + Global.pat.adm_Dr + "'"
- + " AND MdtrtID = '" + Global.pat.mdtrtID + "'";
- JObject joSqlStr = new JObject();
- joSqlStr.Add("sqlStr", sqlStr);
- JObject joCurrentInsuInfo = mIS.DynamicQueryPatCurrentInsuInfo(joSqlStr);
- if (JsonHelper.parseIrisRtnValue(joCurrentInsuInfo, out errMsg) != 0)
- {
- }
- else
- {
- Global.pat.patExtend.prm_auther_certno = JsonHelper.getDestValue(joCurrentInsuInfo, "result.rows[0].extField1");
- Global.pat.patExtend.prm_auther_insu_admdvs = JsonHelper.getDestValue(joCurrentInsuInfo, "result.rows[0].extField2");
- Global.pat.patExtend.prm_auther_name = JsonHelper.getDestValue(joCurrentInsuInfo, "result.rows[0].extField3");
- Global.pat.patExtend.prm_auther_no = JsonHelper.getDestValue(joCurrentInsuInfo, "result.rows[0].extField4");
- }
- if (Global.pat.patExtend.isMutualAid && (string.IsNullOrEmpty(Global.pat.patExtend.prm_auther_certno) || string.IsNullOrEmpty(Global.pat.patExtend.prm_auther_no)))
- {
- outParam = ("未检测到该患者有共济授权人,请取消勾选共济结算!!");
- rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
- return rtnResult;
- }
- JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "Settlement"));
- //出院登记
- //invoker.invokeYHCom
- JObject joDischargeRegister = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "DischargeRegister"));
- if (invoker.invokeYHCom("25",joDischargeRegister, out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
- return rtnResult;
- }
- string settlementFunNO = "41";
- if (Global.pat.patExtend.isSettlementWithNopwd)
- {
- ApplyReason frm = new ApplyReason();
- frm.StartPosition = FormStartPosition.CenterParent;
- if (frm.ShowDialog() != DialogResult.OK)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "无密码结算必须输入原因", "").ToString();
- return rtnResult;
- }
- if (string.IsNullOrEmpty(frm.reason))
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "无密码结算必须输入原因", "").ToString();
- return rtnResult;
- }
- joSettlement["prm_aae013"] = frm.reason;
- joSettlement.Remove("businessType");
- joSettlement.Remove("officeId");
- joSettlement.Remove("officeName");
- joSettlement.Remove("operatorId");
- joSettlement.Remove("operatorName");
- joSettlement.Remove("orgId");
- joSettlement.Remove("deviceType");
- joSettlement.Remove("cardtype");
- joSettlement.Remove("cardid");
- joSettlement.Remove("cardname");
- settlementFunNO = "41d";
- }
- //正式结算
- if (invoker.invokeYHCom(settlementFunNO,joSettlement, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", outParam).ToString();
- cBus.cancleDisRegister( out errMsg);
- return rtnResult;
- }
- else
- {
-
- Global.pat.admType = 2;
- JObject joSettlRtn = JObject.Parse(xmler.ToJSON(outParam));
- //返回给云医保平台结算信息
- if (mIS.saveSettlement(joSettlRtn, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", outParam).ToString();
- return rtnResult;
- }
- //共济支付
- if (Global.pat.patExtend.isMutualAid)
- {
- decimal psnCashPay = decimal.Parse(JsonHelper.getDestValue(joSettlRtn, "output.psn_cash_pay"));
- if (psnCashPay == 0)
- {
- MessageBox.Show("该患者自付金额为0,不需要进行共济支付!");
- }
- else
- {
- //开启自付界面,因涉及到多次自付
- JObject joMa = new JObject();
- joMa.Add("setl_id", JsonHelper.getDestValue(joSettlRtn, "output.prm_yka103"));
- joMa.Add("MainSettlInfo", joSettlRtn);
- joMa.Add("psnCashPay", psnCashPay);
- //MutualAid frmMA = new MutualAid(joMa);
- //if (frmMA.dtSumumt.Rows.Count != 0)
- //{
- // frmMA.WindowState = FormWindowState.Maximized;
- // if (frmMA.ShowDialog() == DialogResult.OK)
- // {
- // outParam = frmMA.finalSettlementInfo;
- // joSettlRtn = frmMA.joMainSettlInfo;
- // }
- // else
- // {
- // MessageBox.Show("开启共济支付失败,原因为收款员取消共济支付!");
- // }
- //}
- //else
- //{
- // MessageBox.Show("开启共济支付失败,原因为未检测到有效的被共济人的医保结算数据!");
- //}
- STA sta = new STA();
- Thread thread = new Thread(new ParameterizedThreadStart(sta.MutualAid_));
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- object[] o = new object[2];
- o[0] = joMa;
- thread.Start(o);
- thread.Join();
- rtnResult = (string)o[1];
- JObject joMutualAidRtn = JObject.Parse(rtnResult);
- if (JsonHelper.parseIrisRtnValue(joMutualAidRtn, out errMsg) != 0)
- {
- return rtnResult;
- }
- else
- {
- outParam = JsonHelper.getDestValue(joMutualAidRtn, "result.settlInfo");
- joSettlRtn = JObject.Parse(JsonHelper.getDestValue(joMutualAidRtn, "result.settlRtn"));
- }
- }
- }
- //返回给HIS
- JObject joSetlinfo = JObject.Parse(outParam);
- if (hIS.returnInpatSettlementInfo(joSettlRtn, joSetlinfo, out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
- return rtnResult;
- }
- //确认中心结算
- if (invoker.confirmYHCom(out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心确认失败", errMsg).ToString();
- invoker.cancleYHCom(out errMsg);
- return rtnResult;
- }
- else
- {
- //返回给前端
- JObject joHisServieRtn = JObject.Parse(outParam);
- hBus.returnToFrontEndAfterSettlement(joSettlRtn, 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 + "'"
- + " 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");
- Global.pat.insuType = JsonHelper.getDestValue(joSettlInfo, "result.data[0].InsuranceType");
- Global.pat.medType = JsonHelper.getDestValue(joSettlInfo, "result.data[0].MedicalType");
- hBus.setPrmBatch();
- //共济
- DataTable dtSettlInfo = (DataTable)JsonConvert.DeserializeObject(joSettlInfo["result"]["data"].ToString(), (typeof(DataTable)));
- int mutualAidFlag = 0;
- if (!string.IsNullOrEmpty(dtSettlInfo.Rows[0]["MutualAidFlag"].ToString()))
- {
- mutualAidFlag = Convert.ToInt32(dtSettlInfo.Rows[0]["MutualAidFlag"].ToString());
- }
- if (mutualAidFlag > 0)
- {
- //开启自付界面,因涉及到多次自付
- //MutualAid frmMA = new MutualAid(setl_id);
- //if (frmMA.dtSettlInfo.Rows.Count != 0)
- //{
- // frmMA.WindowState = FormWindowState.Maximized;
- // if (frmMA.ShowDialog() == DialogResult.OK)
- // {
- // }
- // else
- // {
- // rtnResult = JsonHelper.setIrisReturnValue(-1, "收款员取消共济支付撤销!", null).ToString();
- // return rtnResult;
- // }
- //}
- //else
- //{
- // rtnResult = JsonHelper.setIrisReturnValue(-1, "开启共济支付失败,原因为未检测到有效的被共济人的医保结算数据!", null).ToString();
- // return rtnResult;
- //}
- STA sta = new STA();
- Thread thread = new Thread(sta.MutualAid);
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- object[] o = new object[2];
- o[0] = Global.pat.settlID;
- thread.Start(o);
- thread.Join();
- //重新赋值
- hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
- Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
- Global.pat.patExtend.prm_yabtch = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
- Global.pat.medType = JsonHelper.getDestValue(joSettlInfo, "result.data[0].MedicalType");
- Global.pat.insuType = JsonHelper.getDestValue(joSettlInfo, "result.data[0].InsuranceType");
- hBus.setPrmBatch();
- }
- //取消中心结算信息
- if (cBus.cancleSettlement(out outParam) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算信息失败!", outParam).ToString();
- ////询问收款员是否继续进行HIS退费
- //if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 是否强制退HIS费用? ", MessageBoxButtons.YesNo))
- //{
- // rtnResult = JsonHelper.setExceptionJson(0, "收款员选择强制退HIS费用!", outParam).ToString();
- //}
- return rtnResult;
- }
- else
- {
- //确认中心结算
- if (invoker.confirmYHCom(out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "中心确认失败", outParam).ToString();
- return rtnResult;
- }
- string rtn = xmler.ToJSON(outParam);
- //退结算会返一个新的ID
- string newSettleID = JsonHelper.getDestValue(JObject.Parse(rtn), "output.prm_yka198");
- if (string.IsNullOrEmpty(newSettleID)) newSettleID = Global.pat.settlID;
- //取消平台结算信息
- if (mIS.cancleSettlement(newSettleID,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;
- }
- //取消出院登记
- if (cBus.cancleDisRegister( 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));
- }
- }
- /// <summary>
- /// 辅助交易
- /// </summary>
- /// <param name="InParam"></param>
- /// <returns></returns>
- public string AgentFun(string InParam)
- {
- Global.writeLog("AgentFun 入参:" + 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.GetAgentFunHisInfo(businessType, joInParam, out Global.pat);
- switch (businessType)
- {
- case "BasicData"://基础数据维护
- {
- STA sta = new STA();
- Thread thread = new Thread(sta.BasicData);
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- thread.Start();
- thread.Join();
- break;
- }
- case "Exception"://异常处理
- {
- STA sta = new STA();
- Thread thread = new Thread(sta.Exception);
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- thread.Start();
- thread.Join();
- break;
- }
- case "CheckAndClearing"://对账清算
- {
- STA sta = new STA();
- Thread thread = new Thread(sta.CheckAndClearing);
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- thread.Start();
- thread.Join();
- break;
- }
- case "Print"://打印
- {
- //Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInsuAdmObj, "admID"));
- //Global.pat.mdtrtID = JsonHelper.getDestValue(joInsuAdmObj, "mdtrt_id");
- //Global.pat.settlID = JsonHelper.getDestValue(joInsuAdmObj, "setl_id");
- //Thread thread = new Thread(print);
- //callBack cb = new callBack(CallBack);
- //thread.SetApartmentState(ApartmentState.STA); //重点
- //thread.IsBackground = true;
- //thread.Start();
- //thread.Join();
- //SettlListPrint frm = new SettlListPrint();
- //if (frm.ShowDialog() == DialogResult.OK)
- //{
- //}
- //显示打印界面
- //SettlementChecklist frmSettlList;
- //string inparam = joInParam.ToString() ;
- //string sendData = JsonConvert.SerializeObject(inparam);
- //string inpar = sendData;
- //Process p = new Process();
- ////p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //把窗口隐藏,使其在后台运行
- //p.StartInfo.FileName = Global.curEvt.path + "\\SettlList.exe ";
- //p.StartInfo.Arguments = inpar;
- //p.StartInfo.CreateNoWindow = true;
- //p.StartInfo.UseShellExecute = false;
- //p.Start();
- //p.WaitForExit();
- //return JsonHelper.setIrisReturnValue(0, "", null).ToString();
- //调用方式2
- string exeName = "SettlList.exe ";
- string exePath = Global.curEvt.path;
- string inparam = joInParam.ToString();
- string sendData = JsonConvert.SerializeObject(inparam);
- string inpar = sendData;
- Stopwatch oTime = new System.Diagnostics.Stopwatch(); //定义一个计时对象
- oTime.Start();
- ShellExecute(IntPtr.Zero, new StringBuilder("Open"), new StringBuilder(exeName), new StringBuilder(inpar), new StringBuilder(exePath), 1);
- oTime.Stop();
- Global.writeLog("调用:" +oTime.Elapsed.TotalMilliseconds.ToString());
- return JsonHelper.setIrisReturnValue(0, "", null).ToString();
- }
- case "Log"://日志
- {
- MessageBox.Show(businessType);
- break;
- }
- case "RecordUpload"://上传记录
- {
- MessageBox.Show(businessType);
- break;
- }
- case "HospitalRegister"://备案
- {
- MessageBox.Show(businessType);
- break;
- }
- case "CenterQuery1":// 中心提供的查询服务1
- {
- break;
- }
- case "MutualAid"://共济结算
- {
- STA sta = new STA();
- Thread thread = new Thread(new ParameterizedThreadStart(sta.MutualAid));
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- object[] o = new object[2];
- o[0] = "123456";
- thread.Start(o);
- thread.Join();
- rtnResult = (string)o[1];
- //MutualAid frmMA = new MutualAid();
- //frmMA.WindowState = FormWindowState.Maximized;
- //frmMA.ShowDialog();
- 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 "MaternityInsuranceRegist"://生育门诊登记
- {
- STA sta = new STA();
- Thread thread = new Thread(sta.MaternityInsuranceRegist);
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- thread.Start();
- thread.Join();
- break;
- }
- case "SettlementWithNopwdApply"://对账清算
- {
- STA sta = new STA();
- Thread thread = new Thread(sta.SettlementWithNopwdApply);
- thread.SetApartmentState(ApartmentState.STA); //重点
- thread.IsBackground = true;
- thread.Start();
- thread.Join();
- 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)
- {
-
- return "";
- }
- 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;
- }
- Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "insuplc_admdvs");
- if (invoker.invokeYHCom(funNO, joParam ,out errMsg) != 0)
- {
- rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
- return rtnResult;
- }
- else
- {
- JObject joRtn = new JObject();
- joRtn.Add("result",errMsg);
- 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));
- }
- }
- #endregion
- }
- }
|