InsuBusiness.cs 46 KB

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