| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using Newtonsoft.Json;
- using System.Windows.Forms;
- using PTMedInsuInterface.Common;
- using PTMedInsuInterface.Helper;
- using PTMedInsuInterface.Business;
- using PTMedInsuInterface.Variables;
- using System.Net.Http;
- namespace PTMedInsuInterface
- {
-
-
- public class InsuBusiness: IInsuBusiness
- {
- string errorCode = "0", errorMessage = "成功", result = "{}";
- string Test = "000000";
- private InvokeHelper invoker = new InvokeHelper();
- private HisIrisServices hIS = new HisIrisServices();
- private MIIrisServices mIS = new MIIrisServices();
- private ShellBusiness sBus = new ShellBusiness();
- private bool isServiceSeflMachine = false;
- private string isNeedRedirect = "0";
- public InsuBusiness()
- {
- sBus.getCurrentEnvironmentInfo();
- }
- #region 主要交易
- /// <summary>
- /// 初始化,前端传过来接口DR,根据DR获取接口完整信息传给业务DLL
- /// </summary>
- /// <param name="InParam"></param>
- /// <returns></returns>
- //public string Init(string InParam)
- //{
- // JObject joRtn = new JObject();
- // try
- // {
- // if (!sBus.isExistConfig())
- // {
- // return JsonHelper.setExceptionJson(-1, "Init(getPlatformHospitalDr)异常", "未找到配置文件INSUConfigure.ini").ToString();
- // }
- // //获取Iris配置
- // sBus.getHisConfingue(out Global.hisConfig);
- // //获取云医保配置
- // sBus.getInsuConfingue(out Global.insuConfig);
- // //设置DLL 命名空间,
- // sBus.getDLLInfo(out Global.dll);
- // JObject joInparam = JObject.Parse(InParam);
- // string hospID = JsonHelper.getDestValue(joInparam, "hospID");
- // Global.inf.hisHospitalDr=Global.inf.hospitalDr = Convert.ToInt32(hospID);
- // string hospDr = "";
- // if (Global.curEvt.MIVer == "2")
- // {
- // if (mIS.getPlatformHospitalDr(hospID, out hospDr) != 0)
- // {
- // return JsonHelper.setExceptionJson(-1, "Init(getPlatformHospitalDr)异常", hospDr).ToString();
- // }
- // if (hospDr == "")
- // {
- // return JsonHelper.setExceptionJson(-1, "Init", "医院ID不能为空!").ToString();
- // }
- // Global.inf.hospitalDr = Convert.ToInt32(hospDr);
- // }
- // else
- // hospDr = hospID;
- // string interfaceDr = JsonHelper.getDestValue(joInparam, "interfaceDr");
- // //如果为空则取insuAdmObj里的interfaceDr
- // if (interfaceDr == "")
- // {
- // interfaceDr = JsonHelper.getDestValue(joInparam, "insuAdmObj.interfaceDr");
- // }
- // //获取接口信息
- // if (interfaceDr == "")
- // {
- // ShellBusiness shell = new ShellBusiness();
- // JObject joInterfaceResult = shell.showInterfaceChooseForm();
- // if (joInterfaceResult["errorCode"].ToString() != "0")
- // {
- // joRtn = JsonHelper.setExceptionJson(-100, "showInterfaceChooseForm", joInterfaceResult["errorMessage"].ToString());
- // return joRtn.ToString();
- // }
- // else
- // {
- // JObject joInterface = JObject.FromObject(joInterfaceResult["result"]);
- // sBus.getDLLInfo(joInterface);
- // joRtn = (JObject)joInterfaceResult.DeepClone();
- // }
- // }
- // else
- // {
- // joRtn = mIS.getspecifiedInterface(int.Parse(hospDr), int.Parse(interfaceDr));
- // if (JsonHelper.parseIrisRtnValue(joRtn,out errorMessage) != 0)
- // {
- // return joRtn.ToString();
- // }
- // else
- // {
- // JObject joInterface = JObject.FromObject(joRtn["result"]);
- // sBus.getDLLInfo(joInterface);
- // }
- // }
- // joRtn.Add("hisIrisUrl", Global.hisConfig.ip + "//" + Global.hisConfig.url);
- // joRtn.Add("insuIrisUrl", Global.insuConfig.ip + "//" + Global.insuConfig.url);
- // return joRtn.ToString();
- // }
- // catch (Exception e)
- // {
- // joRtn = JsonHelper.setExceptionJson(-1, "Init", e.Message );
- // return joRtn.ToString();
- // }
- // finally
- // {
- // Global.writeLog("Init", InParam, joRtn.ToString());
- // }
- //}
- public string Init(string InParam)
- {
- Global.writeLog($"入参:{InParam}");
- JObject joRtn = new JObject();
- try
- {
- if (!sBus.isExistConfig())
- {
- return JsonHelper.setExceptionJson(-1, "Init(getPlatformHospitalDr)异常", "未找到配置文件INSUConfigure.ini").ToString();
- }
- //获取Iris配置
- sBus.getHisConfingue(out Global.hisConfig);
- //获取云医保配置
- sBus.getInsuConfingue(out Global.insuConfig);
- //设置DLL 命名空间,
- sBus.getDLLInfo(out Global.dll);
- JObject joInparam = JObject.Parse(InParam);
- string hospID = JsonHelper.getDestValue(joInparam, "hospID");
- Global.inf.hisHospitalDr = Global.inf.hospitalDr = Convert.ToInt32(hospID);
- string hospDr = "";
- if (Global.curEvt.MIVer.Trim() == "2")
- {
- if (mIS.getPlatformHospitalDr(hospID, out hospDr) != 0)
- {
- return JsonHelper.setExceptionJson(-1, "Init(getPlatformHospitalDr)异常", hospDr).ToString();
- }
- if (hospDr == "")
- {
- return JsonHelper.setExceptionJson(-1, "Init", "医院ID不能为空!").ToString();
- }
- Global.inf.hospitalDr = Convert.ToInt32(hospDr);
- }
- else
- hospDr = hospID;
- string interfaceDr = JsonHelper.getDestValue(joInparam, "interfaceDr");
- //如果为空则取insuAdmObj里的interfaceDr
- if (interfaceDr == "")
- {
- interfaceDr = JsonHelper.getDestValue(joInparam, "insuAdmObj.interfaceDr");
- }
- //获取接口信息
- if (interfaceDr == "")
- {
- //如果是自助机,则选择自助机的接口
- if (isServiceSeflMachine)
- {
- joRtn = mIS.getSelfServiceInterface();
- isNeedRedirect = "1";
- }
- else
- {
- ShellBusiness shell = new ShellBusiness();
- joRtn = shell.showInterfaceChooseForm();
- }
-
- }
- else
- {
- joRtn = mIS.getspecifiedInterface(int.Parse(hospDr), int.Parse(interfaceDr));
- }
- if (JsonHelper.parseIrisRtnValue(joRtn, out errorMessage) != 0)
- {
- return joRtn.ToString();
- }
- else
- {
- JObject joInterface = JObject.FromObject(joRtn["result"]);
- sBus.getDLLInfo(joInterface);
- }
- joRtn.Add("hisIrisUrl", Global.hisConfig.ip + "//" + Global.hisConfig.url);
- joRtn.Add("insuIrisUrl", Global.insuConfig.ip + "//" + Global.insuConfig.url);
- return joRtn.ToString();
- }
- catch (Exception e)
- {
- joRtn = JsonHelper.setExceptionJson(-1, "Init", e.Message);
- return joRtn.ToString();
- }
- finally
- {
- Global.writeLog("Init", InParam, joRtn.ToString());
- }
- }
- public string GetPatientInfo(string InParam)
- {
- Global.writeLog_debug($"调用单例模式类,程序应用域(shell):{AppDomain.CurrentDomain.FriendlyName}--{AppDomain.CurrentDomain.Id}");
- //return JsonHelper.setIrisReturnValue(-1,"测试",null).ToString();
- return Transact("GetPatientInfo", InParam);
- }
- public string Register(string InParam)
- {
- return Transact("Register", InParam);
- }
- public string FeeUpload(string InParam)
- {
- return Transact("FeeUpload", InParam);
- }
- public string Settlement(string InParam)
- {
- return Transact("Settlement", InParam);
- }
- public string AgentFun(string InParam)
- {
- return Transact("AgentFun", InParam);
- }
- public string PlatformDirectConnect(string InParam)
- {
- string outParam = string.Empty;
- JObject joRtn = new JObject();
- JObject joInparam = new JObject();
- try
- {
- //获取Iris配置
- sBus.getHisConfingue(out Global.hisConfig);
- //获取云医保配置
- sBus.getInsuConfingue(out Global.insuConfig);
- joInparam = JObject.Parse(InParam);
- string interfaceInfo = JsonHelper.getDestValue(joInparam, "interfaceinfo");
- JObject joInterfaceInfo;
- if (interfaceInfo == "")
- { joInterfaceInfo = null; }
- else
- { joInterfaceInfo = JObject.Parse(interfaceInfo); }
- if (joInterfaceInfo != null)
- {
- Global.dll.name = JsonHelper.getDestValue(joInterfaceInfo, "dLLName");
- Global.dll.nameSpace = "PTMedicalInsurance";
- }
- else
- {
- string hospID = JsonHelper.getDestValue(joInparam, "hospID");
- string interfaceDr = JsonHelper.getDestValue(joInparam, "interfaceDr");
- joInterfaceInfo = mIS.getspecifiedInterface(int.Parse(hospID), int.Parse(interfaceDr));
- if (JsonHelper.parseIrisRtnValue(joInterfaceInfo, out errorMessage) != 0)
- {
- joRtn = JsonHelper.setExceptionJson(-100, "PlatformDirectConnect", errorMessage);
- outParam = joRtn.ToString();
- return outParam;
- }
- else
- {
- Global.dll.name = JsonHelper.getDestValue(joInterfaceInfo, "result.DLLName");
- Global.dll.nameSpace = "PTMedicalInsurance";
- joInparam.Add("interfaceinfo", JObject.Parse(JsonHelper.getDestValue(joInterfaceInfo, "result")));
- }
- }
-
- InvokeHelper bus = new InvokeHelper();
- joRtn = bus.InvokeBusinessDLL("PlatformDirectConnect", joInparam.ToString());
- outParam = joRtn.ToString();
- return outParam;
- }
- catch (Exception ex)
- {
- joRtn = JsonHelper.setExceptionJson(-100, "PlatformDirectConnect", ex.Message);
- outParam = joRtn.ToString();
- return outParam;
- }
- finally
- {
- Global.writeLog("PlatformDirectConnect", InParam, outParam);
- }
- }
- public string SelfServiceMachine(string InParam)
- {
- isServiceSeflMachine = true;
- return Transact("SelfServiceMachine", InParam);
- }
- #endregion
- #region 私有交易
- /// <summary>
- /// 交易封装
- /// </summary>
- private string Transact(string transName,string inParam)
- {
- string outParam = string.Empty, errorMsg = "", businessType = "";
- JObject joRtn ;
- JObject joInparam;
- try
- {
- joInparam = JObject.Parse(inParam);
-
- businessType = JsonHelper.getDestValue(joInparam, "businessType");
- string initRtn = Init(inParam);
- JObject joInit = JObject.Parse(initRtn);
- if (JsonHelper.parseIrisRtnValue(joInit, out errorMsg) != 0)
- {
- outParam = JsonHelper.setExceptionJson(-100, "初始化失败", errorMsg).ToString();
- return outParam;
- }
- JObject joInterface = JObject.FromObject(joInit["result"]);
- //组织业务DLL入参
- JObject joBusInparam= JObject.FromObject(joInparam.DeepClone());
- joBusInparam.Add("interfaceinfo", joInterface);
- if (isServiceSeflMachine)
- {
- joBusInparam.Add("isNeedRedirect", isNeedRedirect);
- }
- InvokeHelper bus = new InvokeHelper();
- JObject joPaitientInfo = bus.InvokeBusinessDLL(transName, joBusInparam.ToString());
- if (joPaitientInfo["errorCode"].ToString() != "0")
- {
- outParam = joPaitientInfo.ToString();
- return outParam;
- }
- else
- {
- joRtn = new JObject();
- dynamic joResult = new JObject();
- //List<string> lst = new List<string> { "Settlement", "SelfServiceMachine" };
- //if (lst.Contains(transName)) //不这样写的话,住院结算后HIS前端一直转圈
- //{
- // joRtn = joPaitientInfo;
- //}
- //else
- //{
- // joResult.patientInfo = joPaitientInfo["result"];
- // joResult.interfaceInfo = joInit;
- // joRtn.Add("result", JObject.FromObject(joResult));
- // joRtn.Add("errorCode", 0);
- // joRtn.Add("errorMessage", "");
- //}
- List<string> lst = new List<string> { "GetPatientInfo" };
- if (lst.Contains(transName) || lst.Contains(businessType)) //不这样写的话,住院结算后HIS前端一直转圈
- {
- joResult.patientInfo = joPaitientInfo["result"];
- joResult.interfaceInfo = joInit;
- joRtn.Add("result", JObject.FromObject(joResult));
- joRtn.Add("errorCode", 0);
- joRtn.Add("errorMessage", "");
- }
- else
- {
- joRtn = joPaitientInfo;
- }
- outParam = joRtn.ToString();
- return outParam;
- }
- }
- catch (Exception ex)
- {
- String innerMessage = (ex.InnerException != null)
- ? ex.InnerException.Message
- : "";
- joRtn = JsonHelper.setExceptionJson(-100, transName, "aa"+ex.Message + innerMessage);
- outParam = joRtn.ToString();
- return outParam;
- }
- finally
- {
- Global.writeLog(transName, inParam, outParam);
- }
- }
- #endregion
- }
- }
|