InsuBusiness.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using PTMedicalInsurance.Common;
  7. using PTMedicalInsurance.Business;
  8. using System.Windows.Forms;
  9. using PTMedicalInsurance.Helper;
  10. using Newtonsoft.Json.Linq;
  11. using PTMedicalInsurance.Variables;
  12. using PTMedicalInsurance.Forms;
  13. using System.IO;
  14. using System.Reflection;
  15. using System.Data;
  16. using System.Threading;
  17. using PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler;
  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. if ((businessType == "M6") || (businessType == "M6C") || (businessType == "M6Confirm"))
  66. {
  67. Environment.CurrentDirectory = @"D:\HttpServerAPI\bin";
  68. }
  69. return 0;
  70. }
  71. catch (Exception ex)
  72. {
  73. errMsg = "parseInparam 解析入参异常:" + errMsg;
  74. return -1;
  75. }
  76. }
  77. /// <summary>
  78. /// 签到
  79. /// </summary>
  80. /// <param name="InParam"></param>
  81. /// <returns></returns>
  82. public string Init(string InParam)
  83. {
  84. string errMsg, rtnResult ="";
  85. JObject joRtn = new JObject();
  86. try
  87. {
  88. if (hBus.initEnvironment(InParam, out errMsg) != 0)
  89. {
  90. return JsonHelper.setExceptionJson(-100, "initEnvironment 失败", errMsg).ToString();
  91. }
  92. else
  93. {
  94. if (mIS.isSigned(ref Global.curEvt.signno) != true)
  95. {
  96. if ((businessType != "BasicData") && (businessType != "Print") && (businessType != "MedInsuQuery"))//如果是打开数据对照界面不调用初始化
  97. {
  98. CallResult callResult = new SignInProcess().Process(joRtn);
  99. rtnResult = callResult.Data;
  100. }
  101. else
  102. {
  103. Global.curEvt.signno = "ABC123";
  104. rtnResult = JsonHelper.setIrisReturnValue(0, "非必要初始化业务!", null).ToString();
  105. }
  106. }
  107. else
  108. {
  109. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
  110. }
  111. return rtnResult;
  112. }
  113. }
  114. catch (Exception ex)
  115. {
  116. rtnResult = JsonHelper.setExceptionJson(-100, "Init 异常", ex.Message).ToString();
  117. return rtnResult;
  118. }
  119. finally
  120. {
  121. Global.writeLog("初始化结果:" + rtnResult);
  122. }
  123. }
  124. /// <summary>
  125. /// 初始化
  126. /// </summary>
  127. /// <param name="inParam"></param>
  128. /// <param name="outParam"></param>
  129. /// <returns></returns>
  130. private int init(string inParam, out string outParam)
  131. {
  132. string errMsg;
  133. outParam = "";
  134. try
  135. {
  136. //BS架构调用方式问题,每次调用都需要重新初始化
  137. JObject joInitRtn = JObject.Parse(Init(inParam));
  138. if (JsonHelper.parseIrisRtnValue(joInitRtn, out errMsg) != 0)
  139. {
  140. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)", errMsg).ToString();
  141. return -1;
  142. }
  143. else
  144. {
  145. return 0;
  146. }
  147. }
  148. catch (Exception ex)
  149. {
  150. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)异常", ex.Message).ToString();
  151. return -1;
  152. }
  153. }
  154. /// <summary>
  155. /// 获取患者信息
  156. /// </summary>
  157. /// <param name="InParam"></param>
  158. /// <returns></returns>
  159. public string GetPatientInfo(string InParam)
  160. {
  161. Global.writeLog("GetPatientInfo入参:" + JsonHelper.Compress(InParam));
  162. //设置返回值,错误信息
  163. string rtnResult = "",outParam;
  164. //BS架构调用方式问题,每次调用都需要重新初始化
  165. if (init(InParam,out outParam)!= 0)
  166. {
  167. rtnResult = outParam;
  168. return rtnResult;
  169. }
  170. JObject joInParam = JObject.Parse(InParam);
  171. string businessType = JsonHelper.getDestValue(joInParam,"businessType");
  172. Global.pat.presetIDNO = JsonHelper.getDestValue(joInParam, "params[0].idNo");
  173. try
  174. {
  175. switch (businessType)
  176. {
  177. case "M1"://门诊读卡
  178. case "Z1"://住院读卡
  179. {
  180. Global.pat.admID = JsonHelper.getDestValue(joInParam, "params[0].admID");
  181. if (!string.IsNullOrEmpty(Global.pat.admID)) {
  182. Global.pat.adm_Dr = int.Parse(Global.pat.admID);
  183. }
  184. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  185. PatientService patientService = new PatientService();
  186. patientService.readPatientInfo(out outParam);
  187. // 同时支持返回错误信息和对象
  188. rtnResult = outParam.ParseReturnObject();
  189. break;
  190. }
  191. }
  192. return rtnResult;
  193. }
  194. catch (Exception ex)
  195. {
  196. rtnResult = JsonHelper.setIrisReturnValue(-1 , "GetPatientInfo发生异常;" + ex.Message,null).ToString();
  197. return rtnResult;
  198. }
  199. finally
  200. {
  201. Global.writeLog("GetPatientInfo出参:" + JsonHelper.Compress(rtnResult));
  202. }
  203. }
  204. /// <summary>
  205. /// 登记
  206. /// </summary>
  207. /// <param name="InParam"></param>
  208. /// <returns></returns>
  209. public string Register(string InParam)
  210. {
  211. Global.writeLog("Register 入参:" + JsonHelper.Compress(InParam));
  212. //设置返回值,错误信息
  213. string errMsg, rtnResult = "", outParam;
  214. try
  215. {
  216. //解析入参
  217. if (parseInparam(InParam, out errMsg) != 0)
  218. {
  219. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  220. return rtnResult;
  221. }
  222. //BS架构调用方式问题,每次调用都需要重新初始化
  223. if (init(InParam, out outParam) != 0)
  224. {
  225. rtnResult = outParam;
  226. return rtnResult;
  227. }
  228. //获取pat
  229. hBus.GetRegPatInfo(businessType, joInParam, out Global.pat);
  230. switch (businessType)
  231. {
  232. case "M2"://门诊登记
  233. {
  234. break;
  235. }
  236. case "M2C"://门诊登记撤销
  237. {
  238. break;
  239. }
  240. case "Z0"://住院修改
  241. {
  242. break;
  243. }
  244. case "Z2"://入院登记
  245. {
  246. Global.Set.clearingWay = "1"; //住院
  247. rtnResult = new InpatientRegistionProcess().Process(joParam).Data;
  248. break;
  249. }
  250. case "Z2C"://入院登记取消
  251. {
  252. rtnResult = new InpatientRegCancelProcess().Process(joParam).Data;
  253. break;
  254. }
  255. case "Z6"://出院登记
  256. {
  257. break;
  258. }
  259. case "Z6C"://出院登记取消
  260. {
  261. rtnResult = new InpatientExitCancelProcess().Process(joParam).Data;
  262. break;
  263. }
  264. default:
  265. {
  266. rtnResult = JsonHelper.setExceptionJson(-1, "Register 交易", "传入的业务编码不对!").ToString();
  267. return rtnResult;
  268. }
  269. }
  270. }
  271. catch (Exception ex)
  272. {
  273. rtnResult = JsonHelper.setIrisReturnValue(-1, "Register 发生异常;" + ex.Message, null).ToString();
  274. return rtnResult;
  275. }
  276. finally
  277. {
  278. Global.writeLog("Register 出参:" + JsonHelper.Compress(rtnResult));
  279. }
  280. return rtnResult;
  281. }
  282. /// <summary>
  283. /// 费用上传
  284. /// </summary>
  285. /// <param name="InParam"></param>
  286. /// <returns></returns>
  287. public string FeeUpload(string InParam)
  288. {
  289. Global.writeLog("FeeUpload 入参:" + JsonHelper.Compress(InParam));
  290. //设置返回值,错误信息
  291. string errMsg, rtnResult = "", outParam;
  292. try
  293. {
  294. //解析入参
  295. if (parseInparam(InParam, out errMsg) != 0)
  296. {
  297. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  298. return rtnResult;
  299. }
  300. //BS架构调用方式问题,每次调用都需要重新初始化
  301. if (init(InParam, out outParam) != 0)
  302. {
  303. rtnResult = outParam;
  304. return rtnResult;
  305. }
  306. //获取pat
  307. hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  308. switch (businessType)
  309. {
  310. case "M3"://门诊费用上传
  311. {
  312. break;
  313. }
  314. case "M3C"://门诊费用撤销
  315. {
  316. break;
  317. }
  318. case "Z3"://入院费用上传
  319. {
  320. rtnResult = new InpatientFeeUploadProcess().Process(joParam).Data;
  321. break;
  322. }
  323. case "Z3C"://住院费用上传取消
  324. {
  325. rtnResult = new InpatientFeeUploadCancelProcess().Process(joParam).Data;
  326. break;
  327. }
  328. default:
  329. {
  330. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", "传入的业务编码不对!").ToString();
  331. return rtnResult;
  332. }
  333. }
  334. return rtnResult;
  335. }
  336. catch (Exception ex)
  337. {
  338. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", ex.Message).ToString();
  339. return rtnResult;
  340. }
  341. finally
  342. {
  343. Global.writeLog("FeeUpload 出参:" + JsonHelper.Compress(rtnResult));
  344. }
  345. }
  346. /// <summary>
  347. /// 结算
  348. /// </summary>
  349. /// <param name="InParam"></param>
  350. /// <returns></returns>
  351. public string Settlement(string InParam)
  352. {
  353. Global.writeLog("Settlement 入参:" + JsonHelper.Compress(InParam));
  354. //设置返回值,错误信息
  355. string errMsg, rtnResult = "", outParam;
  356. try
  357. {
  358. //解析入参
  359. if (parseInparam(InParam, out errMsg) != 0)
  360. {
  361. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  362. return rtnResult;
  363. }
  364. //BS架构调用方式问题,每次调用都需要重新初始化
  365. if (init(InParam, out outParam) != 0)
  366. {
  367. rtnResult = outParam;
  368. return rtnResult;
  369. }
  370. //获取pat
  371. hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
  372. switch (businessType)
  373. {
  374. case "M4"://门诊预结算
  375. {
  376. // 没有做任何处理?是否必须???
  377. //OutpatientRegistration frmReg = new OutpatientRegistration();
  378. //if (frmReg.ShowDialog() == DialogResult.OK)
  379. //{
  380. // rtnResult = "调用结束";
  381. //}
  382. break;
  383. }
  384. case "M4C"://门诊预结算撤销
  385. {
  386. break;
  387. }
  388. case "M5"://门诊结算
  389. {
  390. Global.Set.clearingWay = "6"; //门诊
  391. Business.OPSettlementService opService = new Business.OPSettlementService();
  392. rtnResult = opService.Charge(operationType, joInParam);
  393. break;
  394. }
  395. case "M5C"://门诊结算撤销
  396. {
  397. Business.OPSettlementService opService = new Business.OPSettlementService();
  398. rtnResult = opService.DisCharge(joParam);
  399. break;
  400. }
  401. case "M6"://门诊移动支付结算
  402. {
  403. #region 移动支付
  404. MobilePay mp = new MobilePay(InParam, out errMsg);
  405. if (errMsg != "")
  406. {
  407. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  408. return rtnResult;
  409. }
  410. if (mp.MobilePaySettlement(out outParam) != 0)
  411. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  412. else
  413. rtnResult = outParam;
  414. return rtnResult;
  415. #endregion
  416. }
  417. case "M6C"://门诊移动支付结算撤销
  418. {
  419. #region 移动支付取消
  420. string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
  421. MobilePay mp = new MobilePay(InParam, out errMsg);
  422. if (errMsg != "")
  423. {
  424. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  425. return rtnResult;
  426. }
  427. if (String.IsNullOrEmpty(onlineYBFalg))
  428. {
  429. mp.MSettl.onlineYBFalg = "N";
  430. }
  431. else
  432. {
  433. mp.MSettl.onlineYBFalg = onlineYBFalg;
  434. }
  435. if (mp.MobilePayCancelSettlement(out outParam) != 0)
  436. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  437. else
  438. rtnResult = outParam;
  439. return rtnResult;
  440. #endregion
  441. }
  442. case "M6Confirm"://门诊移动支付确认
  443. {
  444. #region 移动支付确认
  445. MobilePay mp = new MobilePay(InParam, out errMsg);
  446. if (errMsg != "")
  447. {
  448. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  449. return rtnResult;
  450. }
  451. if (mp.MobilePayConfirmSettlement(out outParam) != 0)
  452. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  453. else
  454. rtnResult = outParam;
  455. return rtnResult;
  456. #endregion
  457. }
  458. case "M6Q":
  459. {
  460. MobilePay mp = new MobilePay(InParam, out errMsg);
  461. if (errMsg != "")
  462. {
  463. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  464. return rtnResult;
  465. }
  466. mp.MobilePayQuery(out outParam);
  467. return outParam;
  468. }
  469. case "Z4"://住院预结算
  470. {
  471. #region 预结算
  472. Global.pat.RYorCY = "2";
  473. JObject joSettle = new JObject();
  474. CallResult result = new IPPreSettlementProcess().Process(joParam);
  475. if (result.Success)
  476. {
  477. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", result.Data).ToString();
  478. }
  479. else
  480. {
  481. rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
  482. }
  483. break;
  484. #endregion
  485. }
  486. case "Z4C"://住院预结算撤销
  487. {
  488. rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
  489. return rtnResult;
  490. }
  491. case "Z5"://住院结算
  492. {
  493. Global.Set.clearingWay = "1"; //住院
  494. Business.IPSettlementService ipService = new Business.IPSettlementService();
  495. rtnResult = ipService.Charge(operationType,joParam);
  496. break;
  497. }
  498. case "Z5C"://住院结算撤销
  499. {
  500. Business.IPSettlementService ipService = new Business.IPSettlementService();
  501. rtnResult = ipService.DisCharge(joParam);
  502. break;
  503. }
  504. default:
  505. {
  506. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
  507. return rtnResult;
  508. }
  509. }
  510. return rtnResult;
  511. }
  512. catch (Exception ex)
  513. {
  514. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
  515. return rtnResult;
  516. }
  517. finally
  518. {
  519. Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
  520. }
  521. }
  522. /// <summary>
  523. /// 辅助交易
  524. /// </summary>
  525. /// <param name="InParam"></param>
  526. /// <returns></returns>
  527. public string AgentFun(string InParam)
  528. {
  529. Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
  530. //设置返回值,错误信息
  531. string errMsg, rtnResult = "", outParam;
  532. try
  533. {
  534. //解析入参
  535. if (parseInparam(InParam, out errMsg) != 0)
  536. {
  537. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  538. return rtnResult;
  539. }
  540. //BS架构调用方式问题,每次调用都需要重新初始化
  541. if (init(InParam, out outParam) != 0)
  542. {
  543. Global.writeLog("初始化异常:"+outParam);
  544. rtnResult = outParam;
  545. // 基础数据没有初始化成功,也可以运行
  546. //if ((!businessType.Equals("BasicData")) && (!businessType.Equals("Print")))
  547. //{
  548. // return rtnResult;
  549. //}
  550. }
  551. //获取pat
  552. hBus.GetAgentFunHisInfo(businessType, joInParam, out Global.pat);
  553. switch (businessType)
  554. {
  555. case "BasicData"://基础数据维护
  556. {
  557. BasicData bd = new BasicData();
  558. if (bd.ShowDialog() != DialogResult.OK)
  559. {
  560. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出基础数据维护界面").ToString();
  561. return rtnResult;
  562. }
  563. break;
  564. }
  565. case "Exception"://异常处理
  566. {
  567. //显示异常处理界面
  568. HandleException frmEX = new HandleException();
  569. if (frmEX.ShowDialog() == DialogResult.OK)
  570. {
  571. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出异常处理界面").ToString();
  572. return rtnResult;
  573. }
  574. break;
  575. }
  576. case "CheckAndClearing"://对账清算
  577. {
  578. Clearing frmEX = new Clearing();
  579. if (frmEX.ShowDialog() != DialogResult.OK)
  580. {
  581. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出对账清算界面").ToString();
  582. return rtnResult;
  583. }
  584. break;
  585. }
  586. case "Print"://打印
  587. {
  588. printFastReport();
  589. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  590. }
  591. case "PrescribeCirculation"://处方流转
  592. {
  593. STA sta = new STA();
  594. Thread thread = new Thread(sta.PrescribeCirculation);
  595. thread.SetApartmentState(ApartmentState.STA); //重点
  596. thread.IsBackground = true;
  597. thread.Start();
  598. thread.Join();
  599. break;
  600. }
  601. case "Log"://日志
  602. {
  603. MessageBox.Show(businessType);
  604. break;
  605. }
  606. case "RecordUpload"://上传记录
  607. {
  608. MessageBox.Show(businessType);
  609. break;
  610. }
  611. case "HospitalRegister"://备案
  612. {
  613. ToRecordChoose Referral = new ToRecordChoose();
  614. Referral.ShowDialog();
  615. break;
  616. }
  617. case "ToPutOnRecord"://医保备案相关
  618. {
  619. STA sta = new STA();
  620. Thread thread = new Thread(sta.ToPutOnRecord);
  621. thread.SetApartmentState(ApartmentState.STA); //重点
  622. thread.IsBackground = true;
  623. thread.Start();
  624. thread.Join();
  625. break;
  626. }
  627. case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
  628. {
  629. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  630. Global.pat.psn_no = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].patn_id");
  631. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].poolarea");
  632. Global.pat.insuType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].insutype");
  633. Global.pat.medType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].med_type");
  634. if (string.IsNullOrEmpty(Global.pat.insuplc_admdvs))
  635. {
  636. //通过查询医保平台登记信息表获取参保地
  637. if (mIS.queryRegisterInfo(3, out outParam) == 0)
  638. {
  639. JObject joReg = JObject.Parse(outParam);
  640. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode");
  641. }
  642. }
  643. JObject joResult = new JObject();
  644. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  645. //事前分析
  646. if (Global.curEvt.ext.isOpenAnalysis)
  647. {
  648. if (hBus.PreAnalysis("5", joResult.ToString(), out errMsg) != 0)
  649. {
  650. MessageBox.Show(errMsg);
  651. break;
  652. }
  653. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  654. }
  655. break;
  656. }
  657. case "HistoryPrescriptionQuery":
  658. {
  659. // 历史处方查询
  660. string funNo = JsonHelper.getDestValue(joInParam, "funNO");
  661. TradeEnum trade = TradeEnum.DEFAULT.GetByCode(funNo);
  662. new OtherQueryProcess(trade).Process(JObject.Parse(InParam));
  663. break;
  664. }
  665. case "DualChannelRecord":
  666. {
  667. // 双通道备案
  668. DualChannelRecordForm recordForm = new DualChannelRecordForm();
  669. recordForm.ShowDialog();
  670. break;
  671. }
  672. case "CenterQuery"://中心查询
  673. {
  674. STA sta = new STA();
  675. Thread thread = new Thread(sta.CenterQuery);
  676. thread.SetApartmentState(ApartmentState.STA); //重点
  677. thread.IsBackground = true;
  678. thread.Start();
  679. thread.Join();
  680. break;
  681. }
  682. case "MedInsuQuery"://医保查询
  683. {
  684. MedInsuQuery MedQuery = new MedInsuQuery();
  685. if (MedQuery.ShowDialog() != DialogResult.OK)
  686. {
  687. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保查询界面").ToString();
  688. return rtnResult;
  689. }
  690. break;
  691. }
  692. default:
  693. {
  694. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对!").ToString();
  695. break;
  696. }
  697. }
  698. return rtnResult;
  699. }
  700. catch (Exception ex)
  701. {
  702. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
  703. return rtnResult;
  704. }
  705. finally
  706. {
  707. Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
  708. }
  709. }
  710. private void printFastReport()
  711. {
  712. SettlementBillPrint frmSettlList;
  713. string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  714. if (insuAdmObj == "")
  715. {
  716. frmSettlList = new SettlementBillPrint();
  717. frmSettlList.ShowDialog();
  718. }
  719. else
  720. {
  721. JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  722. frmSettlList = new SettlementBillPrint(joInsuAdmObj);
  723. string groupID = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "groupID");
  724. DataTable dt = (DataTable)frmSettlList.dgvSettlRecord.DataSource;
  725. frmSettlList.btnPrint_Click(null, null);
  726. }
  727. }
  728. public string PlatformDirectConnect(string InParam)
  729. {
  730. //设置返回值,错误信息
  731. string errMsg, rtnResult = "", outParam;
  732. try
  733. {
  734. Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
  735. //解析入参
  736. if (parseInparam(InParam, out errMsg) != 0)
  737. {
  738. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  739. return rtnResult;
  740. }
  741. Global.businessType = businessType;
  742. string funNO = JsonHelper.getDestValue(joInParam, "funNO");
  743. //BS架构调用方式问题,每次调用都需要重新初始化
  744. if (init(InParam, out outParam) != 0)
  745. {
  746. rtnResult = outParam;
  747. return rtnResult;
  748. }
  749. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "insuplc_admdvs");
  750. JObject joRtn = invoker.invokeCenterAgentService(funNO, joParam);
  751. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  752. {
  753. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
  754. return rtnResult;
  755. }
  756. else
  757. {
  758. rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
  759. return rtnResult;
  760. }
  761. }
  762. catch (Exception ex)
  763. {
  764. rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
  765. return rtnResult;
  766. }
  767. finally
  768. {
  769. Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
  770. }
  771. }
  772. /// <summary>
  773. /// 自助机
  774. /// </summary>
  775. /// <param name="InParam"></param>
  776. /// <returns></returns>
  777. public string SelfServiceMachine(string InParam)
  778. {
  779. Global.writeLog("SelfServiceMachine 入参:" + JsonHelper.Compress(InParam));
  780. //设置返回值,错误信息
  781. string errMsg, rtnResult = "", outParam;
  782. try
  783. {
  784. //解析入参
  785. if (parseInparam(InParam, out errMsg) != 0)
  786. {
  787. rtnResult = JsonHelper.setExceptionJson(-1, "parseInparam", errMsg).ToString();
  788. return rtnResult;
  789. }
  790. //获取pat
  791. hBus.GetSelfServiceMachineInfo(businessType, joInParam, out Global.pat);
  792. //BS架构调用方式问题,每次调用都需要重新初始化
  793. if (init(InParam, out errMsg) != 0)
  794. //if (hBus.InitA(InParam, out errMsg) != 0)
  795. {
  796. rtnResult = JsonHelper.setExceptionJson(-1, "InitA", errMsg).ToString(); ;
  797. return rtnResult;
  798. }
  799. else
  800. {
  801. //joInParam.Add("patInfo", errMsg);
  802. Global.writeLog($"InitA初始化成功!");
  803. }
  804. switch (businessType)
  805. {
  806. case "GetPatientInfo"://读取患者信息,该节点无需重定向
  807. {
  808. Business.Core.SelfServiceMachine.PatientService patientService = new Business.Core.SelfServiceMachine.PatientService();
  809. rtnResult = patientService.GetPatientInfo();
  810. break;
  811. }
  812. case "OPReg"://门诊挂号
  813. {
  814. #region 链条式任务调度者
  815. OPRegService service = new OPRegService();
  816. rtnResult = service.Charge(operationType, joInParam);
  817. break;
  818. #endregion
  819. }
  820. case "OPSettl"://门诊结算
  821. {
  822. Business.Core.SelfServiceMachine.ProcessScheduler.OPSettlementService service = new Business.Core.SelfServiceMachine.ProcessScheduler.OPSettlementService();
  823. rtnResult = service.Charge(operationType, joInParam);
  824. break;
  825. }
  826. case "IPInReg"://入院登记
  827. {
  828. IPAdmRegService service = new IPAdmRegService();
  829. rtnResult = service.Register(operationType, joInParam);
  830. break;
  831. }
  832. case "IPInRegCancel"://入院登记
  833. {
  834. IPAdmRegService service = new IPAdmRegService();
  835. rtnResult = service.CancelRegister(operationType, joInParam);
  836. break;
  837. }
  838. case "IPOutReg"://出院登记
  839. {
  840. break;
  841. }
  842. case "IPUpoload"://住院费用上传
  843. {
  844. break;
  845. }
  846. case "IPPreSettl"://住院结算
  847. {
  848. break;
  849. }
  850. case "IPSettl"://住院结算
  851. {
  852. PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler.IPSettlementService service = new PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler.IPSettlementService();
  853. rtnResult = service.Charge(joInParam);
  854. return rtnResult;
  855. }
  856. case "DischargeAudit"://费用核查
  857. {
  858. DischargeAuditService service = new DischargeAuditService();
  859. rtnResult = service.Audit(joInParam);
  860. return rtnResult;
  861. }
  862. default:
  863. {
  864. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", "传入的业务编码不对!").ToString();
  865. return rtnResult;
  866. }
  867. }
  868. return rtnResult;
  869. }
  870. catch (Exception ex)
  871. {
  872. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", ex.Message).ToString();
  873. return rtnResult;
  874. }
  875. finally
  876. {
  877. Global.writeLog("SelfServiceMachine 出参:" + JsonHelper.Compress(rtnResult));
  878. }
  879. }
  880. }
  881. }