InsuBusiness.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  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. //string patInfo = "";
  235. //errMsg = showPatientInfo(out patInfo, out outParam);
  236. //if (!errMsg.Equals("0"))
  237. //{
  238. // return errMsg;
  239. //}
  240. //Global.writeLog("获取到病人信息:" + patInfo);
  241. //JObject reg = JObject.Parse(patInfo);
  242. //this.OutpatientReg(reg,patInfo);
  243. break;
  244. }
  245. case "M2C"://门诊登记撤销
  246. {
  247. break;
  248. }
  249. case "Z0"://住院修改
  250. {
  251. break;
  252. }
  253. case "Z2"://入院登记
  254. {
  255. Global.Set.clearingWay = "1"; //住院
  256. rtnResult = new InpatientRegistionProcess().Process(joParam).Data;
  257. break;
  258. }
  259. case "Z2C"://入院登记取消
  260. {
  261. rtnResult = new InpatientRegCancelProcess().Process(joParam).Data;
  262. break;
  263. }
  264. case "Z6"://出院登记
  265. {
  266. break;
  267. }
  268. case "Z6C"://出院登记取消
  269. {
  270. rtnResult = new InpatientExitCancelProcess().Process(joParam).Data;
  271. break;
  272. }
  273. default:
  274. {
  275. rtnResult = JsonHelper.setExceptionJson(-1, "Register 交易", "传入的业务编码不对!").ToString();
  276. return rtnResult;
  277. }
  278. }
  279. }
  280. catch (Exception ex)
  281. {
  282. rtnResult = JsonHelper.setIrisReturnValue(-1, "Register 发生异常;" + ex.Message, null).ToString();
  283. return rtnResult;
  284. }
  285. finally
  286. {
  287. Global.writeLog("Register 出参:" + JsonHelper.Compress(rtnResult));
  288. }
  289. return rtnResult;
  290. }
  291. /// <summary>
  292. /// 费用上传
  293. /// </summary>
  294. /// <param name="InParam"></param>
  295. /// <returns></returns>
  296. public string FeeUpload(string InParam)
  297. {
  298. Global.writeLog("FeeUpload 入参:" + JsonHelper.Compress(InParam));
  299. //设置返回值,错误信息
  300. string errMsg, rtnResult = "", outParam;
  301. try
  302. {
  303. //解析入参
  304. if (parseInparam(InParam, out errMsg) != 0)
  305. {
  306. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  307. return rtnResult;
  308. }
  309. //BS架构调用方式问题,每次调用都需要重新初始化
  310. if (init(InParam, out outParam) != 0)
  311. {
  312. rtnResult = outParam;
  313. return rtnResult;
  314. }
  315. //获取pat
  316. hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  317. switch (businessType)
  318. {
  319. case "M3"://门诊费用上传
  320. {
  321. break;
  322. }
  323. case "M3C"://门诊费用撤销
  324. {
  325. break;
  326. }
  327. case "Z3"://入院费用上传
  328. {
  329. rtnResult = new InpatientFeeUploadProcess().Process(joParam).Data;
  330. break;
  331. }
  332. case "Z3C"://住院费用上传取消
  333. {
  334. rtnResult = new InpatientFeeUploadCancelProcess().Process(joParam).Data;
  335. break;
  336. }
  337. default:
  338. {
  339. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", "传入的业务编码不对!").ToString();
  340. return rtnResult;
  341. }
  342. }
  343. return rtnResult;
  344. }
  345. catch (Exception ex)
  346. {
  347. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", ex.Message).ToString();
  348. return rtnResult;
  349. }
  350. finally
  351. {
  352. Global.writeLog("FeeUpload 出参:" + JsonHelper.Compress(rtnResult));
  353. }
  354. }
  355. /// <summary>
  356. /// 结算
  357. /// </summary>
  358. /// <param name="InParam"></param>
  359. /// <returns></returns>
  360. public string Settlement(string InParam)
  361. {
  362. Global.writeLog("Settlement 入参:" + JsonHelper.Compress(InParam));
  363. //设置返回值,错误信息
  364. string errMsg, rtnResult = "", outParam;
  365. try
  366. {
  367. //解析入参
  368. if (parseInparam(InParam, out errMsg) != 0)
  369. {
  370. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  371. return rtnResult;
  372. }
  373. //BS架构调用方式问题,每次调用都需要重新初始化
  374. if (init(InParam, out outParam) != 0)
  375. {
  376. rtnResult = outParam;
  377. return rtnResult;
  378. }
  379. //获取pat
  380. hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
  381. switch (businessType)
  382. {
  383. case "M4"://门诊预结算
  384. {
  385. // 没有做任何处理?是否必须???
  386. //OutpatientRegistration frmReg = new OutpatientRegistration();
  387. //if (frmReg.ShowDialog() == DialogResult.OK)
  388. //{
  389. // rtnResult = "调用结束";
  390. //}
  391. break;
  392. }
  393. case "M4C"://门诊预结算撤销
  394. {
  395. break;
  396. }
  397. case "M5"://门诊结算
  398. {
  399. Global.Set.clearingWay = "6"; //门诊
  400. Business.OPSettlementService opService = new Business.OPSettlementService();
  401. rtnResult = opService.Charge(operationType, joInParam);
  402. break;
  403. }
  404. case "M5C"://门诊结算撤销
  405. {
  406. Business.OPSettlementService opService = new Business.OPSettlementService();
  407. rtnResult = opService.DisCharge(joParam);
  408. break;
  409. }
  410. case "M6"://门诊移动支付结算
  411. {
  412. #region 移动支付
  413. MobilePay mp = new MobilePay(InParam, out errMsg);
  414. if (errMsg != "")
  415. {
  416. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  417. return rtnResult;
  418. }
  419. if (mp.MobilePaySettlement(out outParam) != 0)
  420. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  421. else
  422. rtnResult = outParam;
  423. return rtnResult;
  424. #endregion
  425. }
  426. case "M6C"://门诊移动支付结算撤销
  427. {
  428. #region 移动支付取消
  429. string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
  430. MobilePay mp = new MobilePay(InParam, out errMsg);
  431. if (errMsg != "")
  432. {
  433. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  434. return rtnResult;
  435. }
  436. if (String.IsNullOrEmpty(onlineYBFalg))
  437. {
  438. mp.MSettl.onlineYBFalg = "N";
  439. }
  440. else
  441. {
  442. mp.MSettl.onlineYBFalg = onlineYBFalg;
  443. }
  444. if (mp.MobilePayCancelSettlement(out outParam) != 0)
  445. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  446. else
  447. rtnResult = outParam;
  448. return rtnResult;
  449. #endregion
  450. }
  451. case "M6Confirm"://门诊移动支付确认
  452. {
  453. #region 移动支付确认
  454. MobilePay mp = new MobilePay(InParam, out errMsg);
  455. if (errMsg != "")
  456. {
  457. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  458. return rtnResult;
  459. }
  460. if (mp.MobilePayConfirmSettlement(out outParam) != 0)
  461. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  462. else
  463. rtnResult = outParam;
  464. return rtnResult;
  465. #endregion
  466. }
  467. case "M6Q":
  468. {
  469. MobilePay mp = new MobilePay(InParam, out errMsg);
  470. if (errMsg != "")
  471. {
  472. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  473. return rtnResult;
  474. }
  475. mp.MobilePayQuery(out outParam);
  476. return outParam;
  477. }
  478. case "Z4"://住院预结算
  479. {
  480. #region 预结算
  481. Global.pat.RYorCY = "2";
  482. JObject joSettle = new JObject();
  483. CallResult result = new IPPreSettlementProcess().Process(joParam);
  484. if (result.Success)
  485. {
  486. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", result.Data).ToString();
  487. }
  488. else
  489. {
  490. rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
  491. }
  492. break;
  493. #endregion
  494. }
  495. case "Z4C"://住院预结算撤销
  496. {
  497. rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
  498. return rtnResult;
  499. }
  500. case "Z5"://住院结算
  501. {
  502. Global.Set.clearingWay = "1"; //住院
  503. Business.IPSettlementService ipService = new Business.IPSettlementService();
  504. rtnResult = ipService.Charge(operationType,joParam);
  505. break;
  506. }
  507. case "Z5C"://住院结算撤销
  508. {
  509. Business.IPSettlementService ipService = new Business.IPSettlementService();
  510. rtnResult = ipService.DisCharge(joParam);
  511. break;
  512. }
  513. default:
  514. {
  515. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
  516. return rtnResult;
  517. }
  518. }
  519. return rtnResult;
  520. }
  521. catch (Exception ex)
  522. {
  523. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
  524. return rtnResult;
  525. }
  526. finally
  527. {
  528. Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
  529. }
  530. }
  531. /// <summary>
  532. /// 辅助交易
  533. /// </summary>
  534. /// <param name="InParam"></param>
  535. /// <returns></returns>
  536. public string AgentFun(string InParam)
  537. {
  538. Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
  539. //设置返回值,错误信息
  540. string errMsg, rtnResult = "", outParam;
  541. try
  542. {
  543. //解析入参
  544. if (parseInparam(InParam, out errMsg) != 0)
  545. {
  546. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  547. return rtnResult;
  548. }
  549. //BS架构调用方式问题,每次调用都需要重新初始化
  550. if (init(InParam, out outParam) != 0)
  551. {
  552. Global.writeLog("初始化异常:"+outParam);
  553. rtnResult = outParam;
  554. // 基础数据没有初始化成功,也可以运行
  555. //if ((!businessType.Equals("BasicData")) && (!businessType.Equals("Print")))
  556. //{
  557. // return rtnResult;
  558. //}
  559. }
  560. //获取pat
  561. hBus.GetAgentFunHisInfo(businessType, joInParam, out Global.pat);
  562. switch (businessType)
  563. {
  564. case "BasicData"://基础数据维护
  565. {
  566. BasicData bd = new BasicData();
  567. if (bd.ShowDialog() != DialogResult.OK)
  568. {
  569. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出基础数据维护界面").ToString();
  570. return rtnResult;
  571. }
  572. break;
  573. }
  574. case "Exception"://异常处理
  575. {
  576. //显示异常处理界面
  577. HandleException frmEX = new HandleException();
  578. if (frmEX.ShowDialog() == DialogResult.OK)
  579. {
  580. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出异常处理界面").ToString();
  581. return rtnResult;
  582. }
  583. break;
  584. }
  585. case "CheckAndClearing"://对账清算
  586. {
  587. Clearing frmEX = new Clearing();
  588. if (frmEX.ShowDialog() != DialogResult.OK)
  589. {
  590. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出对账清算界面").ToString();
  591. return rtnResult;
  592. }
  593. break;
  594. }
  595. case "Print"://打印
  596. {
  597. printFastReport();
  598. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  599. }
  600. case "PrescribeCirculation"://处方流转
  601. {
  602. STA sta = new STA();
  603. Thread thread = new Thread(sta.PrescribeCirculation);
  604. thread.SetApartmentState(ApartmentState.STA); //重点
  605. thread.IsBackground = true;
  606. thread.Start();
  607. thread.Join();
  608. break;
  609. }
  610. case "Log"://日志
  611. {
  612. MessageBox.Show(businessType);
  613. break;
  614. }
  615. case "RecordUpload"://上传记录
  616. {
  617. MessageBox.Show(businessType);
  618. break;
  619. }
  620. case "HospitalRegister"://备案
  621. {
  622. ToRecordChoose Referral = new ToRecordChoose();
  623. Referral.ShowDialog();
  624. break;
  625. }
  626. case "ToPutOnRecord"://医保备案相关
  627. {
  628. STA sta = new STA();
  629. Thread thread = new Thread(sta.ToPutOnRecord);
  630. thread.SetApartmentState(ApartmentState.STA); //重点
  631. thread.IsBackground = true;
  632. thread.Start();
  633. thread.Join();
  634. break;
  635. }
  636. case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
  637. {
  638. if (string.IsNullOrEmpty(Global.pat.insuplc_admdvs))
  639. {
  640. //通过查询医保平台登记信息表获取参保地
  641. if (mIS.queryRegisterInfo(3, out outParam) == 0)
  642. {
  643. JObject joReg = JObject.Parse(outParam);
  644. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode");
  645. }
  646. }
  647. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  648. JObject joResult = new JObject();
  649. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  650. //事前分析
  651. if (Global.curEvt.ext.isOpenAnalysis)
  652. {
  653. if (hBus.PreAnalysis("5", joResult.ToString(), out errMsg) != 0)
  654. {
  655. MessageBox.Show(errMsg);
  656. break;
  657. }
  658. }
  659. break;
  660. }
  661. case "HistoryPrescriptionQuery":
  662. // 历史处方查询
  663. string funNo = JsonHelper.getDestValue(joInParam, "funNO");
  664. TradeEnum trade = TradeEnum.DEFAULT.GetByCode(funNo);
  665. new OtherQueryProcess(trade).Process(JObject.Parse(InParam));
  666. break;
  667. case "DualChannelRecord":
  668. // 双通道备案
  669. DualChannelRecordForm recordForm = new DualChannelRecordForm();
  670. recordForm.ShowDialog();
  671. break;
  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. }