InsuBusiness.cs 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  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. break;
  377. }
  378. case "M4C"://门诊预结算撤销
  379. {
  380. break;
  381. }
  382. case "M5"://门诊结算
  383. {
  384. Global.Set.clearingWay = "6"; //门诊
  385. Business.OPSettlementService opService = new Business.OPSettlementService();
  386. rtnResult = opService.Charge(operationType, joInParam);
  387. break;
  388. }
  389. case "M5C"://门诊结算撤销
  390. {
  391. Business.OPSettlementService opService = new Business.OPSettlementService();
  392. rtnResult = opService.DisCharge(joParam);
  393. break;
  394. }
  395. case "M6"://门诊移动支付结算
  396. {
  397. #region 移动支付
  398. MobilePay mp = new MobilePay(InParam, out errMsg);
  399. if (errMsg != "")
  400. {
  401. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  402. return rtnResult;
  403. }
  404. if (mp.MobilePaySettlement(out outParam) != 0)
  405. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  406. else
  407. rtnResult = outParam;
  408. return rtnResult;
  409. #endregion
  410. }
  411. case "M6C"://门诊移动支付结算撤销
  412. {
  413. #region 移动支付取消
  414. string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
  415. MobilePay mp = new MobilePay(InParam, out errMsg);
  416. if (errMsg != "")
  417. {
  418. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  419. return rtnResult;
  420. }
  421. if (String.IsNullOrEmpty(onlineYBFalg))
  422. {
  423. mp.MSettl.onlineYBFalg = "N";
  424. }
  425. else
  426. {
  427. mp.MSettl.onlineYBFalg = onlineYBFalg;
  428. }
  429. if (mp.MobilePayCancelSettlement(out outParam) != 0)
  430. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  431. else
  432. rtnResult = outParam;
  433. return rtnResult;
  434. #endregion
  435. }
  436. case "M6Confirm"://门诊移动支付确认
  437. {
  438. #region 移动支付确认
  439. MobilePay mp = new MobilePay(InParam, out errMsg);
  440. if (errMsg != "")
  441. {
  442. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  443. return rtnResult;
  444. }
  445. if (mp.MobilePayConfirmSettlement(out outParam) != 0)
  446. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  447. else
  448. rtnResult = outParam;
  449. return rtnResult;
  450. #endregion
  451. }
  452. case "M6Q":
  453. {
  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. mp.MobilePayQuery(out outParam);
  461. return outParam;
  462. }
  463. case "Z4"://住院预结算
  464. {
  465. #region 预结算
  466. Global.pat.RYorCY = "2";
  467. JObject joSettle = new JObject();
  468. CallResult result = new IPPreSettlementProcess().Process(joParam);
  469. if (result.Success)
  470. {
  471. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", result.Data).ToString();
  472. }
  473. else
  474. {
  475. rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
  476. }
  477. break;
  478. #endregion
  479. }
  480. case "Z4C"://住院预结算撤销
  481. {
  482. rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
  483. return rtnResult;
  484. }
  485. case "Z5"://住院结算
  486. {
  487. Global.Set.clearingWay = "1"; //住院
  488. Business.IPSettlementService ipService = new Business.IPSettlementService();
  489. rtnResult = ipService.Charge(operationType,joParam);
  490. break;
  491. }
  492. case "Z5C"://住院结算撤销
  493. {
  494. Business.IPSettlementService ipService = new Business.IPSettlementService();
  495. rtnResult = ipService.DisCharge(joParam);
  496. break;
  497. }
  498. default:
  499. {
  500. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
  501. return rtnResult;
  502. }
  503. }
  504. return rtnResult;
  505. }
  506. catch (Exception ex)
  507. {
  508. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
  509. return rtnResult;
  510. }
  511. finally
  512. {
  513. Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
  514. }
  515. }
  516. /// <summary>
  517. /// 辅助交易
  518. /// </summary>
  519. /// <param name="InParam"></param>
  520. /// <returns></returns>
  521. public string AgentFun(string InParam)
  522. {
  523. Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
  524. //设置返回值,错误信息
  525. string errMsg, rtnResult = "", outParam;
  526. try
  527. {
  528. //解析入参
  529. if (parseInparam(InParam, out errMsg) != 0)
  530. {
  531. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  532. return rtnResult;
  533. }
  534. //BS架构调用方式问题,每次调用都需要重新初始化
  535. if (init(InParam, out outParam) != 0)
  536. {
  537. Global.writeLog("初始化异常:"+outParam);
  538. rtnResult = outParam;
  539. // 基础数据没有初始化成功,也可以运行
  540. //if ((!businessType.Equals("BasicData")) && (!businessType.Equals("Print")))
  541. //{
  542. // return rtnResult;
  543. //}
  544. }
  545. //获取pat
  546. hBus.GetAgentFunHisInfo(businessType, joInParam, out Global.pat);
  547. switch (businessType)
  548. {
  549. case "BasicData"://基础数据维护
  550. {
  551. BasicData bd = new BasicData();
  552. if (bd.ShowDialog() != DialogResult.OK)
  553. {
  554. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出基础数据维护界面").ToString();
  555. return rtnResult;
  556. }
  557. break;
  558. }
  559. case "Exception"://异常处理
  560. {
  561. //显示异常处理界面
  562. HandleException frmEX = new HandleException();
  563. if (frmEX.ShowDialog() == DialogResult.OK)
  564. {
  565. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出异常处理界面").ToString();
  566. return rtnResult;
  567. }
  568. break;
  569. }
  570. case "CheckAndClearing"://对账清算
  571. {
  572. Clearing frmEX = new Clearing();
  573. if (frmEX.ShowDialog() != DialogResult.OK)
  574. {
  575. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出对账清算界面").ToString();
  576. return rtnResult;
  577. }
  578. break;
  579. }
  580. case "Print"://打印
  581. {
  582. printFastReport();
  583. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  584. }
  585. case "PrescribeCirculation"://处方流转
  586. {
  587. STA sta = new STA();
  588. Thread thread = new Thread(sta.PrescribeCirculation);
  589. thread.SetApartmentState(ApartmentState.STA); //重点
  590. thread.IsBackground = true;
  591. thread.Start();
  592. thread.Join();
  593. break;
  594. }
  595. case "Log"://日志
  596. {
  597. MessageBox.Show(businessType);
  598. break;
  599. }
  600. case "RecordUpload"://上传记录
  601. {
  602. MessageBox.Show(businessType);
  603. break;
  604. }
  605. case "HospitalRegister"://备案
  606. {
  607. ToRecordChoose Referral = new ToRecordChoose();
  608. Referral.ShowDialog();
  609. break;
  610. }
  611. case "ToPutOnRecord"://医保备案相关
  612. {
  613. STA sta = new STA();
  614. Thread thread = new Thread(sta.ToPutOnRecord);
  615. thread.SetApartmentState(ApartmentState.STA); //重点
  616. thread.IsBackground = true;
  617. thread.Start();
  618. thread.Join();
  619. break;
  620. }
  621. case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
  622. {
  623. if (string.IsNullOrEmpty(Global.pat.insuplc_admdvs))
  624. {
  625. //通过查询医保平台登记信息表获取参保地
  626. if (mIS.queryRegisterInfo(3, out outParam) == 0)
  627. {
  628. JObject joReg = JObject.Parse(outParam);
  629. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode");
  630. }
  631. }
  632. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  633. JObject joResult = new JObject();
  634. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  635. //事前分析
  636. if (Global.curEvt.ext.isOpenAnalysis)
  637. {
  638. if (hBus.PreAnalysis("5", joResult.ToString(), out errMsg) != 0)
  639. {
  640. MessageBox.Show(errMsg);
  641. break;
  642. }
  643. }
  644. break;
  645. }
  646. case "HistoryPrescriptionQuery":
  647. {
  648. // 历史处方查询
  649. string funNo = JsonHelper.getDestValue(joInParam, "funNO");
  650. TradeEnum trade = TradeEnum.DEFAULT.GetByCode(funNo);
  651. new OtherQueryProcess(trade).Process(JObject.Parse(InParam));
  652. break;
  653. }
  654. case "DualChannelRecord":
  655. {
  656. // 双通道备案
  657. DualChannelRecordForm recordForm = new DualChannelRecordForm();
  658. recordForm.ShowDialog();
  659. break;
  660. }
  661. case "CenterQuery"://中心查询
  662. {
  663. STA sta = new STA();
  664. Thread thread = new Thread(sta.CenterQuery);
  665. thread.SetApartmentState(ApartmentState.STA); //重点
  666. thread.IsBackground = true;
  667. thread.Start();
  668. thread.Join();
  669. break;
  670. }
  671. case "MedInsuQuery"://医保查询
  672. {
  673. MedInsuQuery MedQuery = new MedInsuQuery();
  674. if (MedQuery.ShowDialog() != DialogResult.OK)
  675. {
  676. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保查询界面").ToString();
  677. return rtnResult;
  678. }
  679. break;
  680. }
  681. default:
  682. {
  683. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对!").ToString();
  684. break;
  685. }
  686. }
  687. return rtnResult;
  688. }
  689. catch (Exception ex)
  690. {
  691. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
  692. return rtnResult;
  693. }
  694. finally
  695. {
  696. Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
  697. }
  698. }
  699. private void printFastReport()
  700. {
  701. SettlementBillPrint frmSettlList;
  702. string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  703. if (insuAdmObj == "")
  704. {
  705. frmSettlList = new SettlementBillPrint();
  706. frmSettlList.ShowDialog();
  707. }
  708. else
  709. {
  710. JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  711. frmSettlList = new SettlementBillPrint(joInsuAdmObj);
  712. string groupID = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "groupID");
  713. DataTable dt = (DataTable)frmSettlList.dgvSettlRecord.DataSource;
  714. frmSettlList.btnPrint_Click(null, null);
  715. }
  716. }
  717. public string PlatformDirectConnect(string InParam)
  718. {
  719. //设置返回值,错误信息
  720. string errMsg, rtnResult = "", outParam;
  721. try
  722. {
  723. Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
  724. //解析入参
  725. if (parseInparam(InParam, out errMsg) != 0)
  726. {
  727. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  728. return rtnResult;
  729. }
  730. Global.businessType = businessType;
  731. string funNO = JsonHelper.getDestValue(joInParam, "funNO");
  732. //BS架构调用方式问题,每次调用都需要重新初始化
  733. if (init(InParam, out outParam) != 0)
  734. {
  735. rtnResult = outParam;
  736. return rtnResult;
  737. }
  738. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "insuplc_admdvs");
  739. //if ((funNO == "3505")|| (funNO == "3506"))
  740. //{
  741. // joParam = JObject.Parse(joParam.ToString().Replace("drug_trac_info", "drugtracinfo"));
  742. //}
  743. JObject joRtn = invoker.invokeCenterAgentService(funNO, joParam);
  744. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  745. {
  746. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
  747. return rtnResult;
  748. }
  749. else
  750. {
  751. rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
  752. return rtnResult;
  753. }
  754. }
  755. catch (Exception ex)
  756. {
  757. rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
  758. return rtnResult;
  759. }
  760. finally
  761. {
  762. Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
  763. }
  764. }
  765. /// <summary>
  766. /// 自助机
  767. /// </summary>
  768. /// <param name="InParam"></param>
  769. /// <returns></returns>
  770. public string SelfServiceMachine(string InParam)
  771. {
  772. Global.writeLog("SelfServiceMachine 入参:" + JsonHelper.Compress(InParam));
  773. //设置返回值,错误信息
  774. string errMsg, rtnResult = "", outParam;
  775. try
  776. {
  777. //解析入参
  778. if (parseInparam(InParam, out errMsg) != 0)
  779. {
  780. rtnResult = JsonHelper.setExceptionJson(-1, "parseInparam", errMsg).ToString();
  781. return rtnResult;
  782. }
  783. //获取pat
  784. hBus.GetSelfServiceMachineInfo(businessType, joInParam, out Global.pat);
  785. //BS架构调用方式问题,每次调用都需要重新初始化
  786. if (init(InParam, out errMsg) != 0)
  787. //if (hBus.InitA(InParam, out errMsg) != 0)
  788. {
  789. rtnResult = JsonHelper.setExceptionJson(-1, "InitA", errMsg).ToString(); ;
  790. return rtnResult;
  791. }
  792. else
  793. {
  794. //joInParam.Add("patInfo", errMsg);
  795. Global.writeLog($"InitA初始化成功!");
  796. }
  797. switch (businessType)
  798. {
  799. case "GetPatientInfo"://读取患者信息,该节点无需重定向
  800. {
  801. Business.Core.SelfServiceMachine.PatientService patientService = new Business.Core.SelfServiceMachine.PatientService();
  802. rtnResult = patientService.GetPatientInfo();
  803. break;
  804. }
  805. case "OPReg"://门诊挂号
  806. {
  807. #region 链条式任务调度者
  808. OPRegService service = new OPRegService();
  809. rtnResult = service.Charge(operationType, joInParam);
  810. break;
  811. #endregion
  812. }
  813. case "OPSettl"://门诊结算
  814. {
  815. Business.Core.SelfServiceMachine.ProcessScheduler.OPSettlementService service = new Business.Core.SelfServiceMachine.ProcessScheduler.OPSettlementService();
  816. rtnResult = service.Charge(operationType, joInParam);
  817. break;
  818. }
  819. case "IPInReg"://入院登记
  820. {
  821. IPAdmRegService service = new IPAdmRegService();
  822. rtnResult = service.Register(operationType, joInParam);
  823. break;
  824. }
  825. case "IPInRegCancel"://入院登记
  826. {
  827. IPAdmRegService service = new IPAdmRegService();
  828. rtnResult = service.CancelRegister(operationType, joInParam);
  829. break;
  830. }
  831. case "IPOutReg"://出院登记
  832. {
  833. break;
  834. }
  835. case "IPUpoload"://住院费用上传
  836. {
  837. break;
  838. }
  839. case "IPPreSettl"://住院结算
  840. {
  841. break;
  842. }
  843. case "IPSettl"://住院结算
  844. {
  845. PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler.IPSettlementService service = new PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler.IPSettlementService();
  846. rtnResult = service.Charge(joInParam);
  847. return rtnResult;
  848. }
  849. case "DischargeAudit"://费用核查
  850. {
  851. DischargeAuditService service = new DischargeAuditService();
  852. rtnResult = service.Audit(joInParam);
  853. return rtnResult;
  854. }
  855. default:
  856. {
  857. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", "传入的业务编码不对!").ToString();
  858. return rtnResult;
  859. }
  860. }
  861. return rtnResult;
  862. }
  863. catch (Exception ex)
  864. {
  865. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", ex.Message).ToString();
  866. return rtnResult;
  867. }
  868. finally
  869. {
  870. Global.writeLog("SelfServiceMachine 出参:" + JsonHelper.Compress(rtnResult));
  871. }
  872. }
  873. }
  874. }