InsuBusiness.cs 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using PTMedicalInsurance.Business;
  4. using PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler;
  5. using PTMedicalInsurance.Common;
  6. using PTMedicalInsurance.Forms;
  7. using PTMedicalInsurance.Forms.ElectronicSettlementCertificates;
  8. using PTMedicalInsurance.Helper;
  9. using PTMedicalInsurance.Variables;
  10. using System;
  11. using System.Data;
  12. using System.IO;
  13. using System.Reflection;
  14. using System.Text;
  15. using System.Threading;
  16. using System.Windows.Forms;
  17. using System.Xml.Linq;
  18. namespace PTMedicalInsurance
  19. {
  20. public class InsuBusiness : IInsuBusiness
  21. {
  22. //定义相关的变量
  23. //private Patients patient;
  24. //private Fees fee;
  25. //private Settlements settlement;
  26. //json对象属性
  27. private JObject joInParam;
  28. private JArray jaSession ;
  29. private JArray jaParams;
  30. private JObject joParam;
  31. private JObject joInterface;
  32. private JObject joInsuAdmObj;
  33. //设置业务实例
  34. CenterBusiness cBus = new CenterBusiness();
  35. HisMainBusiness hBus = new HisMainBusiness();
  36. HisIrisServices hIS = new HisIrisServices();
  37. MIIrisServices mIS= new MIIrisServices();
  38. InvokeHelper invoker = new InvokeHelper();
  39. //
  40. private string businessType;
  41. private string operationType;
  42. public InsuBusiness()
  43. {
  44. Global.curEvt.path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
  45. ComputerInfo comp = new ComputerInfo();
  46. Global.curEvt.mac = comp.GetMAC();
  47. Global.curEvt.ip = comp.GetIP();
  48. Global.pat.insuplc_admdvs = ""; //如果是NULL中心会报错
  49. }
  50. private int parseInparam(string inParam,out string errMsg)
  51. {
  52. errMsg = "";
  53. try
  54. {
  55. joInParam = JObject.Parse(inParam);
  56. jaSession = JArray.Parse(JsonHelper.getDestValue(joInParam, "session"));
  57. Global.curEvt.jaSession = jaSession;
  58. jaParams = JArray.Parse(JsonHelper.getDestValue(joInParam, "params"));
  59. joParam = JObject.FromObject(jaParams[0]);
  60. if (JsonHelper.getDestValue(joInParam, "insuAdmObj") != "")
  61. joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInParam, "insuAdmObj"));
  62. joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
  63. businessType = JsonHelper.getDestValue(joInParam, "businessType");
  64. operationType = JsonHelper.getDestValue(joInParam, "operationType");
  65. Global.pat.businessType = businessType;
  66. if (businessType.Substring(0, 2) == "M6")
  67. {
  68. string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
  69. if (String.IsNullOrEmpty(onlineYBFalg))
  70. onlineYBFalg = "N";
  71. if (onlineYBFalg == "Y")
  72. Environment.CurrentDirectory = @"D:\HttpServerAPI\bin\libs"; ;
  73. }
  74. return 0;
  75. }
  76. catch (Exception e)
  77. {
  78. errMsg = "parseInparam 解析入参异常:" + e.Message;
  79. return -1;
  80. }
  81. }
  82. /// <summary>
  83. /// 签到
  84. /// </summary>
  85. /// <param name="InParam"></param>
  86. /// <returns></returns>
  87. public string Init(string InParam)
  88. {
  89. string errMsg, rtnResult ="";
  90. JObject joRtn = new JObject();
  91. try
  92. {
  93. if (hBus.initEnvironment(InParam, out errMsg) != 0)
  94. {
  95. return JsonHelper.setExceptionJson(-100, "initEnvironment 失败", errMsg).ToString();
  96. }
  97. else
  98. {
  99. if (mIS.isSigned(ref Global.curEvt.signno) != true)
  100. {
  101. if (businessType != "BasicData")//如果是打开数据对照界面不调用初始化
  102. {
  103. //签到
  104. if (cBus.signIn(out joRtn) != 0)
  105. {
  106. rtnResult = JsonHelper.setExceptionJson(-1, "签到异常", (string)joRtn["err_msg"]).ToString();
  107. return rtnResult;
  108. }
  109. else
  110. {
  111. Global.curEvt.signno = JsonHelper.getDestValue(joRtn, "output.signinoutb.sign_no");
  112. //插入签到表
  113. if (mIS.saveSignRecord(Global.curEvt.signno, out errMsg) != 0)
  114. {
  115. rtnResult = JsonHelper.setIrisReturnValue(0, "中心签到成功但插入签到表失败:" + errMsg, null).ToString();
  116. }
  117. else
  118. {
  119. rtnResult = JsonHelper.setIrisReturnValue(0, "签到成功", joRtn).ToString();
  120. }
  121. }
  122. }
  123. else
  124. {
  125. Global.curEvt.signno = "ABC123";
  126. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功(医保对照不初始化)!", null).ToString();
  127. }
  128. }
  129. else
  130. {
  131. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
  132. }
  133. return rtnResult;
  134. }
  135. }
  136. catch (Exception ex)
  137. {
  138. rtnResult = JsonHelper.setExceptionJson(-100, "Init 异常", ex.Message).ToString();
  139. return rtnResult;
  140. }
  141. finally
  142. {
  143. Global.writeLog("初始化结果:" + rtnResult);
  144. }
  145. }
  146. /// <summary>
  147. /// 初始化
  148. /// </summary>
  149. /// <param name="inParam"></param>
  150. /// <param name="outParam"></param>
  151. /// <returns></returns>
  152. private int init(string inParam, out string outParam)
  153. {
  154. string errMsg;
  155. outParam = "";
  156. try
  157. {
  158. //BS架构调用方式问题,每次调用都需要重新初始化
  159. JObject joInitRtn = JObject.Parse(Init(inParam));
  160. if (JsonHelper.parseIrisRtnValue(joInitRtn, out errMsg) != 0)
  161. {
  162. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)", errMsg).ToString();
  163. return -1;
  164. }
  165. else
  166. {
  167. return 0;
  168. }
  169. }
  170. catch (Exception ex)
  171. {
  172. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)异常", ex.Message).ToString();
  173. return -1;
  174. }
  175. }
  176. /// <summary>
  177. /// 获取患者信息
  178. /// </summary>
  179. /// <param name="InParam"></param>
  180. /// <returns></returns>
  181. public string GetPatientInfo(string InParam)
  182. {
  183. Global.writeLog("GetPatientInfo入参:" + JsonHelper.Compress(InParam));
  184. //设置返回值,错误信息
  185. string rtnResult = "",outParam;
  186. //BS架构调用方式问题,每次调用都需要重新初始化
  187. if (init(InParam,out outParam)!= 0)
  188. {
  189. rtnResult = outParam;
  190. return rtnResult;
  191. }
  192. JObject joInParam = JObject.Parse(InParam);
  193. string businessType = JsonHelper.getDestValue(joInParam,"businessType");
  194. try
  195. {
  196. switch (businessType)
  197. {
  198. case "M1"://门诊读卡
  199. {
  200. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  201. if (hBus.readCard(out outParam) != 0)
  202. {
  203. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  204. }
  205. else if (string.IsNullOrEmpty(outParam))
  206. {
  207. // 点击取消或关闭
  208. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", "读卡信息为空").ToString();
  209. }
  210. else
  211. {
  212. //展示患者信息界面
  213. if (hBus.showPatInfo(outParam, out outParam) != 0)
  214. {
  215. rtnResult = outParam;
  216. }
  217. else
  218. {
  219. rtnResult = JsonHelper.setIrisReturnValue(0, "", JObject.Parse(outParam)).ToString();
  220. }
  221. }
  222. break;
  223. }
  224. case "Z1"://住院读卡
  225. {
  226. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  227. if (hBus.readCard(out outParam) != 0)
  228. {
  229. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  230. }
  231. else
  232. {
  233. string patInfo = outParam;
  234. //展示患者信息界面
  235. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  236. {
  237. rtnResult = outParam;
  238. }
  239. else
  240. {
  241. rtnResult = JsonHelper.setIrisReturnValue(0,"",JObject.Parse(outParam)).ToString();
  242. }
  243. }
  244. break;
  245. }
  246. }
  247. return rtnResult;
  248. }
  249. catch (Exception ex)
  250. {
  251. rtnResult = JsonHelper.setIrisReturnValue(-1 , "GetPatientInfo发生异常;" + ex.Message,null).ToString();
  252. return rtnResult;
  253. }
  254. finally
  255. {
  256. Global.writeLog("GetPatientInfo出参:" + JsonHelper.Compress(rtnResult));
  257. }
  258. }
  259. /// <summary>
  260. /// 登记
  261. /// </summary>
  262. /// <param name="InParam"></param>
  263. /// <returns></returns>
  264. public string Register(string InParam)
  265. {
  266. Global.writeLog("Register 入参:" + JsonHelper.Compress(InParam));
  267. //设置返回值,错误信息
  268. string errMsg, rtnResult = "", outParam;
  269. try
  270. {
  271. //解析入参
  272. if (parseInparam(InParam, out errMsg) != 0)
  273. {
  274. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  275. return rtnResult;
  276. }
  277. //BS架构调用方式问题,每次调用都需要重新初始化
  278. if (init(InParam, out outParam) != 0)
  279. {
  280. rtnResult = outParam;
  281. return rtnResult;
  282. }
  283. //获取pat
  284. hBus.GetRegPatInfo(businessType, joInParam, out Global.pat);
  285. switch (businessType)
  286. {
  287. case "M2"://门诊登记
  288. {
  289. string patInfo = "";
  290. errMsg = showPatientInfo(out patInfo, out outParam);
  291. if (!errMsg.Equals("0"))
  292. {
  293. return errMsg;
  294. }
  295. Global.writeLog("获取到病人信息:" + patInfo);
  296. JObject reg = JObject.Parse(patInfo);
  297. this.OutpatientReg(reg,patInfo);
  298. break;
  299. }
  300. case "M2C"://门诊登记撤销
  301. {
  302. break;
  303. }
  304. case "Z0"://住院修改
  305. {
  306. break;
  307. }
  308. case "Z2"://入院登记
  309. {
  310. string regInParam = "";
  311. if (Global.pat.insuType == "410")
  312. {
  313. Global.pat.isWorkInjury = true;
  314. }
  315. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  316. {
  317. rtnResult = JsonHelper.setExceptionJson(-1, "姓名校验异常!", errMsg).ToString();
  318. return rtnResult;
  319. }
  320. //显示登记面板
  321. if (hBus.showInPatRegisterForm( out regInParam) == 0)
  322. {
  323. JObject joRegIn_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2401", regInParam));
  324. JObject joRegIn = JObject.Parse(JsonHelper.setCenterInpar("2401", regInParam));
  325. //上传给中心
  326. JObject joRegOut = invoker.invokeCenterService("2401", joRegIn);
  327. //将中心返回的结果返回HIS,调用HIS服务进行保存
  328. if (JsonHelper.parseCenterRtnValue(joRegOut,out errMsg) == 0)
  329. {
  330. joRegOut.Add("validflag",1);
  331. joRegOut.Add("regstate", 1);
  332. joRegOut.Add("type", 1);
  333. Global.pat.mdtrtID = JsonHelper.getDestValue(joRegOut, "output.result.mdtrt_id");
  334. //插入患者本次就诊用的参保信息
  335. if (hBus.insertPatCurInsuInfo(JsonHelper.getDestValue(joParam, "patientInfo"), out outParam) != 0)
  336. {
  337. if (DialogResult.Yes == MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  338. {
  339. }
  340. else
  341. {
  342. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!", outParam).ToString();
  343. return rtnResult;
  344. }
  345. }
  346. //插入医保平台
  347. if (mIS.saveInpatRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  348. {
  349. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存登记信息", outParam).ToString();
  350. return rtnResult;
  351. }
  352. #region【插入全量信息表-自助机业务】
  353. JObject joOutput = new JObject();
  354. joOutput.Add("output", JObject.Parse(JsonHelper.getDestValue(joParam, "patientInfo.output")));
  355. //插入医保平台全量信息表
  356. if (mIS.saveMIPatFullInsuInfo(joOutput, out outParam) != 0)
  357. {
  358. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存登记全量信息失败", outParam).ToString();
  359. return rtnResult;
  360. }
  361. //插入费用核查表 入院登记
  362. if (mIS.saveDischargeAudit(3, 2, 0, joRegIn, out outParam) != 0)
  363. {
  364. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存费用核查入院登记信息", outParam).ToString();
  365. return rtnResult;
  366. }
  367. //插入费用核查表 出院登记 默认,具体需要最终审核
  368. JObject joDisReg = (JObject)joRegIn.DeepClone();
  369. //joDisReg["input"]["mdtrtinfo"]["psn_setlway"] = new JObject();
  370. joDisReg["input"]["mdtrtinfo"]["psn_setlway"] = "01";
  371. //joDisReg["input"]["mdtrtinfo"]["acct_used_flag"] = new JObject();
  372. joDisReg["input"]["mdtrtinfo"]["acct_used_flag"] = "1";
  373. //joDisReg["input"]["mdtrtinfo"]["mid_setl_flag"] = new JObject();
  374. joDisReg["input"]["mdtrtinfo"]["mid_setl_flag"] = "0";
  375. if (mIS.saveDischargeAudit(3, 3, 0, joDisReg, out outParam) != 0)
  376. {
  377. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存费用核查出院登记信息(默认)", outParam).ToString();
  378. return rtnResult;
  379. }
  380. #endregion
  381. //返回登记信息,插入HIS
  382. if (hIS.returnRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  383. {
  384. rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
  385. return rtnResult;
  386. }
  387. else
  388. {
  389. rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
  390. return rtnResult;
  391. }
  392. }
  393. else
  394. {
  395. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", errMsg).ToString();
  396. return rtnResult;
  397. }
  398. }
  399. else
  400. {
  401. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", regInParam).ToString();
  402. return rtnResult;
  403. }
  404. }
  405. case "Z2C"://入院登记取消
  406. {
  407. //从医保平台获取患者详细的医保登记信息
  408. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  409. {
  410. rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  411. return rtnResult;
  412. }
  413. JObject joReg = JObject.Parse(outParam);
  414. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  415. if (Global.pat.insuType == "410")
  416. {
  417. Global.pat.isWorkInjury = true;
  418. }
  419. //取消中心登记
  420. if (cBus.cancleRegister("2404", out outParam) != 0)
  421. {
  422. //如果医保中心没有HIS所传的医保登记信息则默认撤销HIS登记信息
  423. int i = outParam.IndexOf("不存在有效的就诊登记信息");
  424. if (i != 0)
  425. {
  426. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam+ ",是否强制撤销HIS医保登记信息?", "提示", MessageBoxButtons.YesNo))
  427. {
  428. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  429. return rtnResult;
  430. }
  431. }
  432. }
  433. //取消医保平台登记
  434. if (mIS.cancleRegister(1, out outParam) != 0)
  435. {
  436. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  437. return rtnResult;
  438. }
  439. //取消HIS 登记
  440. if (hIS.cancleRegister( out outParam) != 0)
  441. {
  442. rtnResult = JsonHelper.setExceptionJson(-1, "中心和云医保平台取消登记成功,但HIS取消失败,", outParam).ToString();
  443. return rtnResult;
  444. }
  445. else
  446. {
  447. //CM 20230602 删除医保平台医保费用明细上传表数据
  448. mIS.deleteFee(out errMsg);
  449. rtnResult = JsonHelper.setIrisReturnValue(0, "取消医保登记成功", null).ToString();
  450. return rtnResult;
  451. }
  452. }
  453. case "Z6"://出院登记
  454. {
  455. break;
  456. }
  457. case "Z6C"://出院登记取消
  458. {
  459. //从医保平台获取患者详细的医保登记信息
  460. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  461. {
  462. rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  463. return rtnResult;
  464. }
  465. JObject joReg = JObject.Parse(outParam);
  466. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  467. if (Global.pat.insuType == "410")
  468. {
  469. Global.pat.isWorkInjury = true;
  470. }
  471. if (cBus.cancleRegister("2405", out errMsg) != 0)
  472. {
  473. rtnResult = JsonHelper.setExceptionJson(-1, "取消出院登记", errMsg).ToString();
  474. return rtnResult;
  475. }
  476. else
  477. {
  478. rtnResult = JsonHelper.setIrisReturnValue(0, "取消出院登记成功", null).ToString();
  479. return rtnResult;
  480. }
  481. }
  482. default:
  483. {
  484. rtnResult = JsonHelper.setExceptionJson(-1, "Register 交易", "传入的业务编码不对!").ToString();
  485. return rtnResult;
  486. }
  487. }
  488. }
  489. catch (Exception ex)
  490. {
  491. rtnResult = JsonHelper.setIrisReturnValue(-1, "Register 发生异常;" + ex.Message, null).ToString();
  492. return rtnResult;
  493. }
  494. finally
  495. {
  496. Global.writeLog("Register 出参:" + JsonHelper.Compress(rtnResult));
  497. }
  498. return "";
  499. }
  500. /// <summary>
  501. /// 费用上传
  502. /// </summary>
  503. /// <param name="InParam"></param>
  504. /// <returns></returns>
  505. public string FeeUpload(string InParam)
  506. {
  507. Global.writeLog("FeeUpload 入参:" + JsonHelper.Compress(InParam));
  508. //设置返回值,错误信息
  509. string errMsg, rtnResult = "", outParam;
  510. try
  511. {
  512. //解析入参
  513. if (parseInparam(InParam, out errMsg) != 0)
  514. {
  515. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  516. return rtnResult;
  517. }
  518. //BS架构调用方式问题,每次调用都需要重新初始化
  519. if (init(InParam, out outParam) != 0)
  520. {
  521. rtnResult = outParam;
  522. return rtnResult;
  523. }
  524. //获取pat
  525. hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  526. switch (businessType)
  527. {
  528. case "M3"://门诊费用上传
  529. {
  530. break;
  531. }
  532. case "M3C"://门诊费用撤销
  533. {
  534. break;
  535. }
  536. case "Z3"://入院费用上传
  537. {
  538. //从医保平台获取患者详细的医保登记信息
  539. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  540. {
  541. rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  542. return rtnResult;
  543. }
  544. JObject joReg = JObject.Parse(outParam);
  545. Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
  546. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  547. if (Global.pat.insuType == "410")
  548. {
  549. Global.pat.isWorkInjury = true;
  550. }
  551. //先取消中心费用传送
  552. cBus.cancleFeeUpload("2302", out errMsg);
  553. //再删除医保传送表的数据
  554. mIS.deleteFee(out errMsg);
  555. #region【住院费用上传前调用3101事前服务】
  556. //1.获取3101入参报文
  557. //事前分析
  558. if (Global.curEvt.ext.isOpenAnalysis)
  559. {
  560. if (hBus.PreAnalysis("4", "", out errMsg) != 0)
  561. {
  562. rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  563. return rtnResult;
  564. }
  565. }
  566. #endregion
  567. //费用上传
  568. if (hBus.uploadFee("2301", 50, out outParam) != 0)
  569. {
  570. rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
  571. return rtnResult;
  572. }
  573. else
  574. {
  575. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传成功", null).ToString();
  576. return rtnResult;
  577. }
  578. }
  579. case "Z3C"://住院费用上传取消
  580. {
  581. //从医保平台获取患者详细的医保登记信息
  582. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  583. {
  584. rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  585. return rtnResult;
  586. }
  587. JObject joReg = JObject.Parse(outParam);
  588. Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
  589. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  590. if (Global.pat.insuType == "410")
  591. {
  592. Global.pat.isWorkInjury = true;
  593. }
  594. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  595. {
  596. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  597. return rtnResult;
  598. }
  599. if (mIS.deleteFee( out errMsg) != 0)
  600. {
  601. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  602. return rtnResult;
  603. }
  604. else
  605. {
  606. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传取消成功", null).ToString();
  607. return rtnResult;
  608. }
  609. }
  610. default:
  611. {
  612. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", "传入的业务编码不对!").ToString();
  613. return rtnResult;
  614. }
  615. }
  616. return rtnResult;
  617. }
  618. catch (Exception ex)
  619. {
  620. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", ex.Message).ToString();
  621. return rtnResult;
  622. }
  623. finally
  624. {
  625. Global.writeLog("FeeUpload 出参:" + JsonHelper.Compress(rtnResult));
  626. }
  627. }
  628. public JObject OutpatientReg(JObject joReg,string patInfo)
  629. {
  630. //医保挂号
  631. JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  632. jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
  633. JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
  634. string errMsg = "";
  635. if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
  636. {
  637. return JsonHelper.setExceptionJson(-1, "医保挂号", errMsg);
  638. }
  639. else
  640. {
  641. Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
  642. string outParam = "";
  643. //插入患者本次就诊用的参保信息
  644. if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
  645. {
  646. if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  647. {
  648. return JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam);
  649. }
  650. }
  651. }
  652. return jo2201Rtn;
  653. }
  654. private string showPatientInfo(out string patInfo,out string outParam)
  655. {
  656. patInfo = "";
  657. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  658. if (hBus.readCard(out outParam) != 0)
  659. {
  660. return JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  661. }
  662. else
  663. {
  664. patInfo = outParam;
  665. //展示患者信息界面
  666. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  667. {
  668. return JsonHelper.setExceptionJson(-100, "操作员取消!", outParam).ToString();
  669. }
  670. }
  671. //患者信息赋值给全局变量
  672. patInfo = outParam;
  673. string errMsg = "";
  674. if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  675. {
  676. return JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  677. }
  678. //校验HIS姓名与医保姓名是否一致
  679. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  680. {
  681. return JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  682. }
  683. //先登记
  684. if (hBus.showOutPatRegisterForm(out outParam) != 0)
  685. {
  686. return JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString();
  687. }
  688. return "0";
  689. }
  690. /// <summary>
  691. /// 结算
  692. /// </summary>
  693. /// <param name="InParam"></param>
  694. /// <returns></returns>
  695. public string Settlement(string InParam)
  696. {
  697. Global.writeLog("Settlement 入参:" + JsonHelper.Compress(InParam));
  698. //设置返回值,错误信息
  699. string errMsg, rtnResult = "", outParam;
  700. try
  701. {
  702. //解析入参
  703. if (parseInparam(InParam, out errMsg) != 0)
  704. {
  705. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  706. return rtnResult;
  707. }
  708. //BS架构调用方式问题,每次调用都需要重新初始化
  709. if (init(InParam, out outParam) != 0)
  710. {
  711. rtnResult = outParam;
  712. return rtnResult;
  713. }
  714. //获取pat
  715. hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
  716. switch (businessType)
  717. {
  718. case "M4"://门诊预结算
  719. {
  720. // 没有做任何处理?是否必须???
  721. //OutpatientRegistration frmReg = new OutpatientRegistration();
  722. //if (frmReg.ShowDialog() == DialogResult.OK)
  723. //{
  724. // rtnResult = "调用结束";
  725. //}
  726. break;
  727. }
  728. case "M4C"://门诊预结算撤销
  729. {
  730. break;
  731. }
  732. case "M5"://门诊结算
  733. {
  734. #region 读卡
  735. string patInfo = "";
  736. errMsg = showPatientInfo(out patInfo,out outParam);
  737. if (!errMsg.Equals("0"))
  738. {
  739. return errMsg;
  740. }
  741. #endregion
  742. #region 门诊挂号[2201]
  743. JObject joReg = JObject.Parse(outParam);
  744. JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  745. jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar_plain));
  746. JObject jo2201Rtn = OutpatientReg(joReg, patInfo);
  747. //此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
  748. JObject jo2203Inpar = new JObject();
  749. JObject jo2203Inpar_plain = new JObject();
  750. jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
  751. jo2203Inpar.Add("diseinfo", JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
  752. jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
  753. jo2203Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203", jo2203Inpar));
  754. jo2203Inpar = JObject.Parse(JsonHelper.setCenterInpar("2203", jo2203Inpar));
  755. //门诊登记信息,插入云医保平台
  756. jo2201Rtn.Add("validflag", 1);
  757. jo2201Rtn.Add("regstate", 1);
  758. jo2201Rtn.Add("type", 3);
  759. if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203Inpar_plain, out errMsg) != 0)
  760. {
  761. return JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString();
  762. }
  763. #endregion
  764. #region 就诊信息上传[2203]/[2203A]
  765. //门诊就诊信息上传
  766. JObject jo2203Rtn = invoker.invokeCenterService("2203", jo2203Inpar );
  767. if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
  768. {
  769. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
  770. return rtnResult;
  771. }
  772. #endregion
  773. #region【门诊就诊信息上传成功后调用3101事前服务】
  774. //事前分析
  775. if (Global.curEvt.ext.isOpenAnalysis)
  776. {
  777. //1.门诊挂号 2.门诊收费登记 3.住院登记 4.住院收费登记 5.住院执行医嘱 6.门诊结算 7.门诊预结算 8.住院结算 9.住院预结算 10.购药划卡
  778. if (hBus.PreAnalysis("1", "", out errMsg) != 0)
  779. {
  780. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传成功后调用3101事前服务失败:", errMsg).ToString();
  781. //return rtnResult;
  782. }
  783. }
  784. #endregion
  785. #region 费用上传[2204]
  786. if (hBus.uploadFee("2204", 50, out outParam) != 0)
  787. {
  788. rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
  789. return rtnResult;
  790. }
  791. #endregion
  792. #region 门诊预结算[2206]
  793. //调用IRIS获取医保各项金额
  794. if (mIS.getSumFee(out outParam) != 0)
  795. {
  796. rtnResult = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outParam).ToString();
  797. return rtnResult;
  798. }
  799. JObject joSumFee = JObject.Parse(outParam);
  800. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joReg, "settlement"));
  801. //修改joSettlement的就诊ID ,总金额等
  802. joSettlement["mdtrt_id"] = Global.pat.mdtrtID;
  803. joSettlement["medfee_sumamt"] = JsonHelper.getDestValue(joSumFee, "data.Sumamt");
  804. if ("RegisterOP".Equals(operationType))
  805. {
  806. // 门诊挂号(医疗类别)
  807. joSettlement["med_type"] = "12";
  808. }
  809. //预结算2206
  810. if (hBus.preSettlement_OutPat(joSettlement, out outParam) != 0)
  811. {
  812. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  813. return rtnResult;
  814. }
  815. #endregion
  816. #region【门诊正式结算前调用1192身份验证】重庆无?
  817. //if (hBus.IdentityVerify("2207", out errMsg) != 0)
  818. //{
  819. // rtnResult = JsonHelper.setExceptionJson(-1, "调用门诊正式结算2207前,身份核验1192失败", errMsg).ToString();
  820. // return rtnResult;
  821. //}
  822. //else
  823. //{
  824. // JObject joDataExp = new JObject();
  825. // joDataExp.Add("cardtoken", Global.pat.card.Cardtoken);
  826. // joDataExp.Add("acct_payamt", Global.Set.acctPay);
  827. // joDataExp.Add("elec_bill_code", "");
  828. // joDataExp.Add("elec_billno_code", "");
  829. // joDataExp.Add("elec_bill_chkcode", "");
  830. // joSettlement["exp_content"] = joDataExp;
  831. //}
  832. #endregion
  833. # region 正式结算[2207]
  834. JObject joData = new JObject();
  835. joSettlement["mdtrt_cert_no"] = Global.pat.mdtrtcertNO;
  836. joData.Add("data",joSettlement);
  837. JObject joRtn = invoker.invokeCenterService("2207", JsonHelper.setCenterInpar("2207", joData));
  838. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  839. {
  840. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  841. return rtnResult;
  842. }
  843. else
  844. {
  845. Global.pat.admType = 1;
  846. Global.pat.ExpContent = ""; //门诊不需要保存 外伤标志等相关扩展参数
  847. //返回给云医保平台结算信息
  848. if (mIS.saveSettlement(joRtn, out errMsg) != 0)
  849. {
  850. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  851. return rtnResult;
  852. }
  853. //返回给云医保平台结算明细信息
  854. if (mIS.saveSettlementDetail(joRtn, out errMsg) != 0)
  855. {
  856. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  857. return rtnResult;
  858. }
  859. //返回给HIS
  860. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo"));
  861. if (hIS.returnOutpatSettlementInfo(joSettlement, joSetlinfo, out outParam) != 0)
  862. {
  863. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  864. return rtnResult;
  865. }
  866. else
  867. {
  868. JObject joHisServieRtn = JObject.Parse(outParam);
  869. hBus.returnToFrontEndAfterSettlement(joRtn, joHisServieRtn, out outParam);
  870. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  871. return rtnResult;
  872. }
  873. }
  874. #endregion
  875. }
  876. case "M5C"://门诊结算撤销
  877. {
  878. #region 查询结算信息
  879. //查询HIS医保结算记录表获取该病人的参保地
  880. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  881. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  882. sqlStr = sqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  883. JObject joSql = new JObject();
  884. joSql.Add("sqlStr", sqlStr);
  885. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  886. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  887. //{
  888. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  889. // return rtnResult;
  890. //}
  891. //Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].SpecialType");
  892. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  893. if (JsonHelper.getDestValue(joSettlInfo, "result.data[0].SpecialType") == "GGS")
  894. {
  895. Global.pat.isWorkInjury = true;
  896. }
  897. #endregion
  898. #region 门诊结算撤销 [2208]
  899. string newSettleID = "";
  900. if (cBus.cancleSettlement("2208", out outParam) != 0)
  901. {
  902. int i = outParam.IndexOf("获取到的就诊信息为无效状态,不能办理结算撤销业务");
  903. if (i != 0)
  904. {
  905. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam + ",是否强制撤销HIS结算信息?", "提示", MessageBoxButtons.YesNo))
  906. {
  907. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消结算失败,", outParam).ToString();
  908. return rtnResult;
  909. }
  910. newSettleID = "YC";
  911. }
  912. else
  913. {
  914. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算", outParam).ToString();
  915. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  916. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  917. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  918. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  919. JObject joSqlStr = new JObject();
  920. joSqlStr.Add("sqlStr", SqlStr);
  921. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  922. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  923. if (jaCancleSettlInfo.Count == 1)
  924. {
  925. //询问收款员是否继续进行HIS退费
  926. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  927. {
  928. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  929. }
  930. }
  931. else
  932. {
  933. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  934. }
  935. return rtnResult;
  936. }
  937. }
  938. else
  939. {
  940. newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  941. }
  942. //退云医保平台结算
  943. if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
  944. {
  945. rtnResult = JsonHelper.setExceptionJson(-1, "取消平台结算信息", outParam).ToString();
  946. //return rtnResult;
  947. }
  948. #endregion
  949. if (newSettleID != "YC")
  950. {
  951. #region 费用明细取消[2205]
  952. //中心取消传送
  953. if (cBus.cancleFeeUpload("2205", out errMsg) != 0)
  954. {
  955. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  956. return rtnResult;
  957. }
  958. //云平台取消传送
  959. if (mIS.deleteFee(out errMsg) != 0)
  960. {
  961. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  962. return rtnResult;
  963. }
  964. #endregion
  965. #region 取消挂号[2202]
  966. //取消中心登记
  967. if (cBus.cancleRegister("2202", out outParam) != 0)
  968. {
  969. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  970. return rtnResult;
  971. }
  972. //取消医保平台登记
  973. if (mIS.cancleRegister(3, out outParam) != 0)
  974. {
  975. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  976. return rtnResult;
  977. }
  978. #endregion
  979. }
  980. #region 退HIS结算
  981. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  982. {
  983. rtnResult = JsonHelper.setExceptionJson(-1, "取消HIS结算信息", outParam).ToString();
  984. return rtnResult;
  985. }
  986. else
  987. {
  988. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  989. return rtnResult;
  990. }
  991. #endregion
  992. }
  993. case "M6"://门诊移动支付结算
  994. {
  995. MobilePay mp = new MobilePay(InParam, out errMsg);
  996. if (errMsg != "")
  997. {
  998. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  999. return rtnResult;
  1000. }
  1001. if (mp.MobilePaySettlement(out outParam) != 0)
  1002. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  1003. else
  1004. rtnResult = outParam;
  1005. return rtnResult;
  1006. }
  1007. case "M6C"://门诊移动支付结算撤销
  1008. {
  1009. string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
  1010. MobilePay mp = new MobilePay(InParam, out errMsg);
  1011. if (errMsg != "")
  1012. {
  1013. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  1014. return rtnResult;
  1015. }
  1016. if (String.IsNullOrEmpty(onlineYBFalg))
  1017. mp.MSettl.onlineYBFalg = "N";
  1018. else
  1019. mp.MSettl.onlineYBFalg = onlineYBFalg;
  1020. if (mp.MobilePayCancelSettlement(out outParam) != 0)
  1021. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  1022. else
  1023. rtnResult = JsonHelper.setExceptionJson(0, "Settlement 交易", outParam).ToString();
  1024. return rtnResult;
  1025. }
  1026. case "M6Confirm"://门诊移动支付确认
  1027. {
  1028. MobilePay mp = new MobilePay(InParam, out errMsg);
  1029. if (errMsg != "")
  1030. {
  1031. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  1032. return rtnResult;
  1033. }
  1034. if (mp.MobilePayConfirmSettlement(out outParam) != 0)
  1035. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  1036. else
  1037. rtnResult = outParam;
  1038. return rtnResult;
  1039. }
  1040. case "M6CallBack"://门诊移动支付回调
  1041. {
  1042. JObject jo = JObject.Parse(InParam);
  1043. joInsuAdmObj = new JObject();
  1044. joInsuAdmObj.Add("payOrdId", "");
  1045. jo.Add("insuAdmObj",joInsuAdmObj);
  1046. MobilePay mp = new MobilePay(jo.ToString(), out errMsg);
  1047. if (errMsg != "")
  1048. {
  1049. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  1050. return rtnResult;
  1051. }
  1052. if (mp.MobilePayCallbackSettlement(out outParam) != 0)
  1053. rtnResult = outParam;
  1054. else
  1055. rtnResult = outParam;
  1056. return rtnResult;
  1057. }
  1058. case "Z4"://住院预结算
  1059. {
  1060. #region 预结算(需先进行调用费用明细上传)
  1061. Global.pat.RYorCY = "2";
  1062. JObject joSettle = new JObject();
  1063. if (hBus.preSettlement("2303",out joSettle, out outParam) != 0)
  1064. {
  1065. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1066. return rtnResult;
  1067. }
  1068. else
  1069. {
  1070. rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
  1071. return rtnResult;
  1072. }
  1073. #endregion
  1074. }
  1075. case "Z4C"://住院预结算撤销
  1076. {
  1077. rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
  1078. return rtnResult;
  1079. }
  1080. case "Z5"://住院结算
  1081. {
  1082. //从医保平台获取患者详细的医保登记信息
  1083. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  1084. {
  1085. rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  1086. return rtnResult;
  1087. }
  1088. JObject joReg = JObject.Parse(outParam);
  1089. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  1090. if (Global.pat.insuType == "410")
  1091. {
  1092. Global.pat.isWorkInjury = true;
  1093. }
  1094. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1095. //1.获取3102入参报文
  1096. /*
  1097. if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
  1098. {
  1099. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  1100. return rtnResult;
  1101. }
  1102. else
  1103. {
  1104. //2.调用医保3102明细审核事前分析服务
  1105. JObject joInput = new JObject();
  1106. joInput = JObject.Parse(outParam);
  1107. JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1108. if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1109. {
  1110. DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果1:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1111. if (dr != DialogResult.OK)
  1112. {
  1113. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1114. return rtnResult;
  1115. }
  1116. }
  1117. }
  1118. */
  1119. #endregion
  1120. Global.pat.admType = 2;
  1121. Global.pat.RYorCY = "2";
  1122. #region【住院预结算前调用1192身份验证】
  1123. //if (hBus.IdentityVerify("2304", out errMsg) != 0)
  1124. //{
  1125. // rtnResult = JsonHelper.setExceptionJson(-1, "调用住院正式结算2304前,身份核验1192失败", errMsg).ToString();
  1126. // return rtnResult;
  1127. //}
  1128. #endregion
  1129. JObject joPreSetOutpar ;
  1130. // 结算前先调用预结算?
  1131. if (hBus.preSettlement("2303",out joPreSetOutpar, out outParam) != 0)
  1132. {
  1133. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1134. return rtnResult;
  1135. }
  1136. else
  1137. {
  1138. #region 出院登记
  1139. JObject jo2402Inpar = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "DischargeRegister"));
  1140. JObject jo2402Rtn = invoker.invokeCenterService("2402", JsonHelper.setCenterInpar("2402", jo2402Inpar));
  1141. if (JsonHelper.parseCenterRtnValue(jo2402Rtn, out errMsg) != 0)
  1142. {
  1143. rtnResult = JsonHelper.setExceptionJson(-1, "预结算失败:出院登记失败", errMsg).ToString();
  1144. return rtnResult;
  1145. }
  1146. #endregion
  1147. #region【住院正式结算前调用读卡】
  1148. if (hBus.readCard(out errMsg) != 0)
  1149. {
  1150. rtnResult = JsonHelper.setExceptionJson(-1, "结算前读卡失败", errMsg).ToString();
  1151. return rtnResult;
  1152. }
  1153. #endregion
  1154. #region 正式出院结算
  1155. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "Settlement"));
  1156. joSettlement["mdtrt_cert_no"] = Global.pat.mdtrtcertNO;
  1157. JObject joSettl = new JObject();
  1158. joSettl.Add("data", joSettlement);
  1159. JObject jo2304Rtn = invoker.invokeCenterService("2304",JsonHelper.setCenterInpar("2304", joSettl));
  1160. if (JsonHelper.parseCenterRtnValue(jo2304Rtn, out errMsg) != 0)
  1161. {
  1162. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1163. cBus.cancleRegister("2405", out errMsg);
  1164. return rtnResult;
  1165. }
  1166. else
  1167. {
  1168. Global.pat.admType = 2;
  1169. //返回给云医保平台结算信息
  1170. if (mIS.saveSettlement(jo2304Rtn, out errMsg) != 0)
  1171. {
  1172. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  1173. return rtnResult;
  1174. }
  1175. //返回给云医保平台结算明细信息
  1176. if (mIS.saveSettlementDetail(jo2304Rtn, out errMsg) != 0)
  1177. {
  1178. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  1179. Global.writeLog(rtnResult);
  1180. MessageBox.Show(errMsg);
  1181. }
  1182. //返回给HIS
  1183. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo"));
  1184. if (hIS.returnInpatSettlementInfo(joParam, joSetlinfo, out outParam) != 0)
  1185. {
  1186. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  1187. return rtnResult;
  1188. }
  1189. else
  1190. {
  1191. //返回给前端
  1192. JObject joHisServieRtn = JObject.Parse(outParam);
  1193. hBus.returnToFrontEndAfterSettlement(jo2304Rtn, joHisServieRtn, out outParam);
  1194. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  1195. return rtnResult;
  1196. }
  1197. }
  1198. #endregion
  1199. }
  1200. }
  1201. case "Z5C"://住院结算撤销
  1202. {
  1203. //查询结算表
  1204. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and Hospital_Dr=" + Global.inf.hospitalDr
  1205. + " and Adm_Dr='" + Global.pat.adm_Dr + "'"
  1206. + " and MdtrtID='" + Global.pat.mdtrtID + "'"
  1207. + " Order By ID DESC ";
  1208. JObject joSql = new JObject();
  1209. joSql.Add("sqlStr", sqlStr);
  1210. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  1211. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  1212. //{
  1213. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  1214. // return rtnResult;
  1215. //}
  1216. //MessageBox.Show(joSettlInfo.ToString());
  1217. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  1218. Global.pat.insuType = JsonHelper.getDestValue(joSettlInfo, "result.data[0].InsuranceType");
  1219. if (Global.pat.insuType == "410")
  1220. {
  1221. Global.pat.isWorkInjury = true;
  1222. }
  1223. Global.pat.SettID_YBJSB = JsonHelper.getDestValue(joSettlInfo, "result.data[0].SettlementID");
  1224. if (Global.pat.settlID != Global.pat.SettID_YBJSB)
  1225. {
  1226. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "通过09010059服务获取到的SettlementID<" + Global.pat.settlID + ">与DLL通过SQL语句" +
  1227. joSql + ",获取到的SettlementID<" + Global.pat.SettID_YBJSB + ">不同,可能存在HIS单边账,请联系医保开发人员处理该笔结算记录!").ToString();
  1228. //return rtnResult;
  1229. }
  1230. Global.pat.settlID = Global.pat.SettID_YBJSB;
  1231. //取消中心结算信息
  1232. if (cBus.cancleSettlement("2305", out outParam) != 0)
  1233. {
  1234. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算信息失败!", outParam).ToString();
  1235. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  1236. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  1237. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  1238. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  1239. JObject joSqlStr = new JObject();
  1240. joSqlStr.Add("sqlStr", SqlStr);
  1241. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  1242. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  1243. if (jaCancleSettlInfo.Count == 1)
  1244. {
  1245. //询问收款员是否继续进行HIS退费
  1246. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  1247. {
  1248. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  1249. }
  1250. }
  1251. else
  1252. {
  1253. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  1254. }
  1255. return rtnResult;
  1256. }
  1257. else
  1258. {
  1259. //退结算会返一个新的ID
  1260. string newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  1261. //取消平台结算信息
  1262. if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
  1263. {
  1264. rtnResult = JsonHelper.setExceptionJson(-1, "中心结算取消成功,医保平台结算信息取消失败!", outParam).ToString();
  1265. return rtnResult;
  1266. }
  1267. //取消出院登记
  1268. if (cBus.cancleRegister("2405", out outParam) != 0)
  1269. {
  1270. rtnResult = JsonHelper.setExceptionJson(0, "中心,医保平台及HIS结算信息取消成功,取消出院登记失败!请手工取消出院登记!", outParam).ToString();
  1271. return rtnResult;
  1272. }
  1273. //中心取消传送
  1274. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  1275. {
  1276. //rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  1277. //return rtnResult;
  1278. }
  1279. //云平台取消传送
  1280. if (mIS.deleteFee(out errMsg) != 0)
  1281. {
  1282. //rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  1283. //return rtnResult;
  1284. }
  1285. //取消HIS医保结算信息
  1286. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  1287. {
  1288. rtnResult = JsonHelper.setExceptionJson(-1, "中心跟医保平台结算取消成功, 取消HIS结算信息失败!", outParam).ToString();
  1289. return rtnResult;
  1290. }
  1291. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  1292. return rtnResult;
  1293. }
  1294. }
  1295. default:
  1296. {
  1297. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
  1298. return rtnResult;
  1299. }
  1300. }
  1301. return rtnResult;
  1302. }
  1303. catch (Exception ex)
  1304. {
  1305. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
  1306. return rtnResult;
  1307. }
  1308. finally
  1309. {
  1310. Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
  1311. }
  1312. }
  1313. //[STAThread]
  1314. //public void print(JObject joInParam)
  1315. //{
  1316. // //显示打印界面
  1317. // SettlementChecklist frmSettlList;
  1318. // string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1319. // if (insuAdmObj == "")
  1320. // {
  1321. // frmSettlList = new SettlementChecklist();
  1322. // }
  1323. // else
  1324. // {
  1325. // JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1326. // frmSettlList = new SettlementChecklist(joInsuAdmObj);
  1327. // }
  1328. // if (frmSettlList.ShowDialog() == DialogResult.OK)
  1329. // {
  1330. // };
  1331. //}
  1332. //[STAThread]
  1333. /// <summary>
  1334. /// 辅助交易
  1335. /// </summary>
  1336. /// <param name="InParam"></param>
  1337. /// <returns></returns>
  1338. public string AgentFun(string InParam)
  1339. {
  1340. Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
  1341. //设置返回值,错误信息
  1342. string errMsg, rtnResult = "", outParam;
  1343. try
  1344. {
  1345. //解析入参
  1346. if (parseInparam(InParam, out errMsg) != 0)
  1347. {
  1348. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1349. return rtnResult;
  1350. }
  1351. //BS架构调用方式问题,每次调用都需要重新初始化
  1352. if (init(InParam, out outParam) != 0)
  1353. {
  1354. Global.writeLog("初始化异常:"+outParam);
  1355. rtnResult = outParam;
  1356. // 基础数据没有初始化成功,也可以运行
  1357. if (!businessType.Equals("BasicData")) {
  1358. return rtnResult;
  1359. }
  1360. }
  1361. //获取pat
  1362. hBus.GetAgentFunHisInfo(businessType, joInParam, out Global.pat);
  1363. switch (businessType)
  1364. {
  1365. case "BasicData"://基础数据维护
  1366. {
  1367. STA sta = new STA();
  1368. Thread thread = new Thread(sta.BasicData);
  1369. thread.SetApartmentState(ApartmentState.STA); //重点
  1370. thread.IsBackground = true;
  1371. thread.Start();
  1372. thread.Join();
  1373. break;
  1374. }
  1375. case "Exception"://异常处理
  1376. {
  1377. STA sta = new STA();
  1378. Thread thread = new Thread(sta.Exception);
  1379. thread.SetApartmentState(ApartmentState.STA); //重点
  1380. thread.IsBackground = true;
  1381. thread.Start();
  1382. thread.Join();
  1383. break;
  1384. }
  1385. case "CheckAndClearing"://对账清算
  1386. {
  1387. STA sta = new STA();
  1388. Thread thread = new Thread(sta.CheckAndClearing);
  1389. thread.SetApartmentState(ApartmentState.STA); //重点
  1390. thread.IsBackground = true;
  1391. thread.Start();
  1392. thread.Join();
  1393. break;
  1394. }
  1395. case "PrescribeCirculation"://处方流转
  1396. {
  1397. STA sta = new STA();
  1398. Thread thread = new Thread(sta.PrescribeCirculation);
  1399. thread.SetApartmentState(ApartmentState.STA); //重点
  1400. thread.IsBackground = true;
  1401. thread.Start();
  1402. thread.Join();
  1403. break;
  1404. }
  1405. case "Print"://打印
  1406. {
  1407. try
  1408. {
  1409. //显示打印界面
  1410. SettlementChecklist frmSettlList;
  1411. string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1412. if (insuAdmObj == "")
  1413. {
  1414. frmSettlList = new SettlementChecklist();
  1415. frmSettlList.ShowDialog();
  1416. }
  1417. else
  1418. {
  1419. JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1420. frmSettlList = new SettlementChecklist(joInsuAdmObj);
  1421. string groupID = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "groupID");
  1422. DataTable dt = (DataTable)frmSettlList.dgvSettlRecord.DataSource;
  1423. if (dt.Rows.Count != 1)
  1424. {
  1425. frmSettlList.ShowDialog();
  1426. }
  1427. else
  1428. {
  1429. frmSettlList.btnPrint_Click(null, null);
  1430. }
  1431. }
  1432. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  1433. }
  1434. catch (Exception ex)
  1435. {
  1436. MessageBox.Show(ex.Message);
  1437. }
  1438. break;
  1439. }
  1440. case "Log"://日志
  1441. {
  1442. MessageBox.Show(businessType);
  1443. break;
  1444. }
  1445. case "RecordUpload"://上传记录
  1446. {
  1447. MessageBox.Show(businessType);
  1448. break;
  1449. }
  1450. case "HospitalRegister"://备案
  1451. {
  1452. HospitalRegister Referral = new HospitalRegister();
  1453. if (Referral.ShowDialog() != DialogResult.OK)
  1454. {
  1455. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出备案信息界面").ToString();
  1456. return rtnResult;
  1457. }
  1458. break;
  1459. }
  1460. case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
  1461. {
  1462. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1463. JObject joResult = new JObject();
  1464. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  1465. //事前分析
  1466. if (Global.curEvt.ext.isOpenAnalysis)
  1467. {
  1468. if (hBus.PreAnalysis("5", joResult.ToString(), out errMsg) != 0)
  1469. {
  1470. MessageBox.Show(errMsg);
  1471. break;
  1472. }
  1473. }
  1474. break;
  1475. }
  1476. case "CenterQuery"://中心查询
  1477. {
  1478. STA sta = new STA();
  1479. Thread thread = new Thread(sta.CenterQuery);
  1480. thread.SetApartmentState(ApartmentState.STA); //重点
  1481. thread.IsBackground = true;
  1482. thread.Start();
  1483. thread.Join();
  1484. break;
  1485. }
  1486. case "ElectronicSettlementCertificate":// 电子结算凭证上传
  1487. {
  1488. EcSettlCertMainForm ecCert = new EcSettlCertMainForm();
  1489. ecCert.ShowDialog();
  1490. break;
  1491. }
  1492. default:
  1493. {
  1494. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对!").ToString();
  1495. return rtnResult;
  1496. }
  1497. }
  1498. return rtnResult;
  1499. }
  1500. catch (Exception ex)
  1501. {
  1502. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
  1503. return rtnResult;
  1504. }
  1505. finally
  1506. {
  1507. Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
  1508. }
  1509. }
  1510. public string Download(string InParam)
  1511. {
  1512. Global.writeLog("Download 入参:" + JsonHelper.Compress(InParam));
  1513. //设置返回值,错误信息
  1514. string errMsg, rtnResult = "", outParam;
  1515. try
  1516. {
  1517. //解析入参
  1518. if (parseInparam(InParam, out errMsg) != 0)
  1519. {
  1520. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1521. return rtnResult;
  1522. }
  1523. //BS架构调用方式问题,每次调用都需要重新初始化
  1524. if (init(InParam, out outParam) != 0)
  1525. {
  1526. rtnResult = outParam;
  1527. return rtnResult;
  1528. }
  1529. dynamic joData = new JObject();
  1530. joData.data = joParam["data"];
  1531. //string code = (string)joInParam["code"];
  1532. string funNO = (string)joParam["funNO"];
  1533. switch (businessType)
  1534. {
  1535. case "DirectoryDownload":
  1536. {
  1537. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1538. rtnResult = hBus.DownloadDirectory(funNO, downloadParam).ToString();
  1539. break;
  1540. }
  1541. case "DictionayDownload":
  1542. {
  1543. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1544. rtnResult = hBus.downDictionary(downloadParam);
  1545. break;
  1546. }
  1547. }
  1548. return rtnResult;
  1549. }
  1550. catch (Exception ex)
  1551. {
  1552. rtnResult = JsonHelper.setExceptionJson(-100, "Download", ex.Message).ToString();
  1553. return rtnResult;
  1554. }
  1555. finally
  1556. {
  1557. Global.writeLog("Download 出参:" + rtnResult);
  1558. }
  1559. }
  1560. public string PlatformDirectConnect(string InParam)
  1561. {
  1562. //设置返回值,错误信息
  1563. string errMsg, rtnResult = "", outParam;
  1564. try
  1565. {
  1566. Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
  1567. //解析入参
  1568. if (parseInparam(InParam, out errMsg) != 0)
  1569. {
  1570. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1571. return rtnResult;
  1572. }
  1573. Global.businessType = businessType;
  1574. string funNO = JsonHelper.getDestValue(joInParam, "funNO");
  1575. //BS架构调用方式问题,每次调用都需要重新初始化
  1576. if (init(InParam, out outParam) != 0)
  1577. {
  1578. rtnResult = outParam;
  1579. return rtnResult;
  1580. }
  1581. if (funNO=="4101Y")
  1582. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "insuplc_admdvs");
  1583. Global.writeLog("1");
  1584. if (funNO == "3602")
  1585. {
  1586. Clearing frm = new Clearing();
  1587. //先进行9101文件上传
  1588. string finalAchPath = JsonHelper.getDestValue(joParam, "data.filePath");
  1589. Global.writeLog($"finalAchPath:{finalAchPath}");
  1590. //检测文件大小
  1591. // 创建一个 FileInfo 对象
  1592. FileInfo fileInfo = new FileInfo(finalAchPath);
  1593. // 检查文件是否存在
  1594. if (fileInfo.Exists)
  1595. {
  1596. // 获取文件大小(以字节为单位)
  1597. long fileSizeInBytes = fileInfo.Length;
  1598. Global.writeLog("文件大小为: " + fileSizeInBytes + " 字节");
  1599. //long maxUploadSize = 10 * 1024 * 1024;//不能超过30M 否则溢出
  1600. //if (fileSizeInBytes > maxUploadSize)
  1601. //{
  1602. // rtnResult = JsonHelper.setExceptionJson(-1, $"平台直连错误:【9101】文件上传失败!文件过大,请检查!", outParam).ToString();
  1603. // return rtnResult;
  1604. //}
  1605. }
  1606. else
  1607. {
  1608. rtnResult = JsonHelper.setExceptionJson(-1, $"平台直连错误:【9101】文件上传失败!{finalAchPath}文件不存在", outParam).ToString();
  1609. return rtnResult;
  1610. }
  1611. string file_qury_no = "";
  1612. JObject joTmp = new JObject();
  1613. //byte[] zipBytes = File.ReadAllBytes(finalAchPath);
  1614. //string base64String = Convert.ToBase64String(zipBytes);
  1615. //var sb = new StringBuilder();
  1616. //using (var writer = new StringWriter(sb))
  1617. //{
  1618. // Base64StreamingEncoder.ConvertToBase64Stream(finalAchPath, writer);
  1619. //}
  1620. //string base64String = sb.ToString(); // 仍可能 OOM,慎用于大文件!
  1621. //joTmp.Add("in", base64String);
  1622. //joTmp.Add("filename", Path.GetFileName(finalAchPath));
  1623. //joTmp.Add("fixmedins_code", Global.inf.hospitalNO);
  1624. //JObject joFsUploadIn = new JObject();
  1625. //joFsUploadIn.Add("fsUploadIn", joTmp);
  1626. //InvokeHelper invoker = new InvokeHelper();
  1627. //JObject jo9101Rtn = invoker.invokeCenterService("9101", JsonHelper.setCenterInpar("9101", joFsUploadIn.ToString()));
  1628. //if (JsonHelper.parseCenterReturnJson(jo9101Rtn, out outParam) != 0)
  1629. //{
  1630. // rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误:【9101】文件上传失败", outParam).ToString();
  1631. // return rtnResult;
  1632. //}
  1633. //else
  1634. //{
  1635. // file_qury_no = JsonHelper.getDestValue(jo9101Rtn, "output.file_qury_no");
  1636. //}
  1637. string result = "";
  1638. if (invoker.UploadFileAsJsonStream(finalAchPath, Path.GetFileName(finalAchPath), ref result, ref errMsg) != 0)
  1639. {
  1640. rtnResult = JsonHelper.setExceptionJson(-1, "9101上传测试", errMsg).ToString();
  1641. return rtnResult;
  1642. }
  1643. else
  1644. {
  1645. JObject jo9101Rtn = JObject.Parse(result);
  1646. Global.writeLog("9101Rtn:" + jo9101Rtn.ToString());
  1647. if (JsonHelper.parseCenterReturnJson(jo9101Rtn, out outParam) != 0)
  1648. {
  1649. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误:【9101】文件上传失败", outParam).ToString();
  1650. return rtnResult;
  1651. }
  1652. else
  1653. {
  1654. file_qury_no = JsonHelper.getDestValue(jo9101Rtn, "output.file_qury_no");
  1655. }
  1656. }
  1657. if (!((JObject)joParam["data"]).ContainsKey("exp_content"))
  1658. {
  1659. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", "3602交易入参必须包含exp_content节点").ToString();
  1660. return rtnResult;
  1661. }
  1662. JObject joExp = JObject.Parse(JsonHelper.getDestValue(joParam, "data.exp_content"));
  1663. if (joExp.ContainsKey("file_qury_no"))
  1664. {
  1665. joExp["file_qury_no"] = file_qury_no;
  1666. }
  1667. else
  1668. {
  1669. joExp.Add("file_qury_no", file_qury_no);
  1670. }
  1671. joParam["data"]["exp_content"] = JsonConvert.SerializeObject(joExp);
  1672. }
  1673. JObject joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joParam));
  1674. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1675. {
  1676. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
  1677. return rtnResult;
  1678. }
  1679. else
  1680. {
  1681. rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
  1682. return rtnResult;
  1683. }
  1684. }
  1685. catch (Exception ex)
  1686. {
  1687. rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
  1688. return rtnResult;
  1689. }
  1690. finally
  1691. {
  1692. Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
  1693. }
  1694. }
  1695. /// <summary>
  1696. /// 自助机
  1697. /// </summary>
  1698. /// <param name="InParam"></param>
  1699. /// <returns></returns>
  1700. public string SelfServiceMachine(string InParam)
  1701. {
  1702. Global.writeLog("SelfServiceMachine 入参:" + JsonHelper.Compress(InParam));
  1703. //设置返回值,错误信息
  1704. string errMsg, rtnResult = "", outParam;
  1705. try
  1706. {
  1707. //解析入参
  1708. if (parseInparam(InParam, out errMsg) != 0)
  1709. {
  1710. rtnResult = JsonHelper.setExceptionJson(-1, "parseInparam", errMsg).ToString();
  1711. return rtnResult;
  1712. }
  1713. //获取pat
  1714. hBus.GetSelfServiceMachineInfo(businessType, joInParam, out Global.pat);
  1715. //BS架构调用方式问题,每次调用都需要重新初始化
  1716. if (init(InParam, out errMsg) != 0)
  1717. //if (hBus.InitA(InParam, out errMsg) != 0)
  1718. {
  1719. rtnResult = JsonHelper.setExceptionJson(-1, "InitA", errMsg).ToString(); ;
  1720. return rtnResult;
  1721. }
  1722. else
  1723. {
  1724. //joInParam.Add("patInfo", errMsg);
  1725. Global.writeLog($"InitA初始化成功!");
  1726. }
  1727. switch (businessType)
  1728. {
  1729. case "GetPatientInfo"://读取患者信息,该节点无需重定向
  1730. {
  1731. Business.Core.SelfServiceMachine.PatientService patientService = new Business.Core.SelfServiceMachine.PatientService();
  1732. rtnResult = patientService.GetPatientInfo();
  1733. break;
  1734. }
  1735. case "OPReg"://门诊挂号
  1736. {
  1737. #region 【链条式任务调度者】
  1738. OPRegService service = new OPRegService();
  1739. rtnResult = service.Charge(operationType, joInParam);
  1740. break;
  1741. #endregion
  1742. }
  1743. case "OPSettl"://门诊结算
  1744. {
  1745. OPSettlementService service = new OPSettlementService();
  1746. rtnResult = service.Charge(operationType, joInParam);
  1747. break;
  1748. }
  1749. case "IPInReg"://入院登记
  1750. {
  1751. IPAdmRegService service = new IPAdmRegService();
  1752. rtnResult = service.Register(operationType, joInParam);
  1753. break;
  1754. }
  1755. case "IPInRegCancel"://取消入院登记
  1756. {
  1757. IPAdmRegService service = new IPAdmRegService();
  1758. rtnResult = service.CancelRegister(operationType, joInParam);
  1759. break;
  1760. }
  1761. case "IPOutReg"://出院登记
  1762. {
  1763. break;
  1764. }
  1765. case "IPUpoload"://住院费用上传
  1766. {
  1767. break;
  1768. }
  1769. case "IPPreSettl"://住院预计结算
  1770. {
  1771. break;
  1772. }
  1773. case "IPSettl"://住院结算
  1774. {
  1775. IPSettlementService service = new IPSettlementService();
  1776. rtnResult = service.Charge(joInParam);
  1777. return rtnResult;
  1778. }
  1779. case "DischargeAudit"://费用核查
  1780. {
  1781. DischargeAuditService service = new DischargeAuditService();
  1782. rtnResult = service.Audit(joInParam);
  1783. return rtnResult;
  1784. }
  1785. default:
  1786. {
  1787. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", "传入的业务编码不对!").ToString();
  1788. return rtnResult;
  1789. }
  1790. }
  1791. return rtnResult;
  1792. }
  1793. catch (Exception ex)
  1794. {
  1795. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", ex.Message).ToString();
  1796. return rtnResult;
  1797. }
  1798. finally
  1799. {
  1800. Global.writeLog("SelfServiceMachine 出参:" + JsonHelper.Compress(rtnResult));
  1801. }
  1802. }
  1803. }
  1804. }