InsuBusiness.cs 38 KB

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