InsuBusiness.cs 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849
  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. namespace PTMedicalInsurance
  17. {
  18. public class InsuBusiness : IInsuBusiness
  19. {
  20. //定义相关的变量 20240720 GX hh
  21. private Patients patient;
  22. private Fees fee;
  23. private Settlements settlement;
  24. //json对象属性
  25. private JObject joInParam;
  26. private JArray jaSession ;
  27. private JArray jaParams;
  28. private JObject joParam;
  29. private JObject joInterface;
  30. //设置业务实例
  31. CenterBusiness cBus = new CenterBusiness();
  32. HisMainBusiness hBus = new HisMainBusiness();
  33. HisIrisServices hIS = new HisIrisServices();
  34. MIIrisServices mIS= new MIIrisServices();
  35. InvokeHelper invoker = new InvokeHelper();
  36. InsuServices iris = new InsuServices();
  37. private string businessType;
  38. public InsuBusiness()
  39. {
  40. Global.curEvt.path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
  41. ComputerInfo comp = new ComputerInfo();
  42. Global.curEvt.mac = comp.GetMAC();
  43. Global.curEvt.ip = comp.GetIP();
  44. Global.pat.insuplc_admdvs = ""; //如果是NULL中心会报错
  45. }
  46. private int parseInparam(string inParam,out string errMsg)
  47. {
  48. errMsg = "";
  49. try
  50. {
  51. joInParam = JObject.Parse(inParam);
  52. jaSession = JArray.Parse(JsonHelper.getDestValue(joInParam, "session"));
  53. Global.curEvt.jaSession = jaSession;
  54. jaParams = JArray.Parse(JsonHelper.getDestValue(joInParam, "params"));
  55. joParam = JObject.FromObject(jaParams[0]);
  56. joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
  57. businessType = JsonHelper.getDestValue(joInParam, "businessType");
  58. Global.inf.businessType = businessType;
  59. return 0;
  60. }
  61. catch (Exception ex)
  62. {
  63. errMsg = "parseInparam 解析入参异常:" + errMsg;
  64. return -1;
  65. }
  66. }
  67. /// <summary>
  68. /// 签到
  69. /// </summary>
  70. /// <param name="InParam"></param>
  71. /// <returns></returns>
  72. public string Init(string InParam)
  73. {
  74. string errMsg, rtnResult ="";
  75. JObject joRtn = new JObject();
  76. try
  77. {
  78. if (hBus.initEnvironment(InParam, out errMsg) != 0)
  79. {
  80. return JsonHelper.setExceptionJson(-100, "initEnvironment 失败", errMsg).ToString();
  81. }
  82. else
  83. {
  84. if (mIS.isSigned(ref Global.curEvt.signno) != true)
  85. {
  86. if ((businessType != "BasicData") || (businessType != "MedInsuQuery"))//如果是打开数据对照界面不调用初始化
  87. {
  88. //签到
  89. if (cBus.signIn(out joRtn) != 0)
  90. {
  91. rtnResult = JsonHelper.setExceptionJson(-1, "签到异常", (string)joRtn["err_msg"]).ToString();
  92. return rtnResult;
  93. }
  94. else
  95. {
  96. Global.curEvt.signno = JsonHelper.getDestValue(joRtn, "output.signinoutb.sign_no");
  97. //插入签到表
  98. if (mIS.saveSignRecord(Global.curEvt.signno, out errMsg) != 0)
  99. {
  100. rtnResult = JsonHelper.setIrisReturnValue(0, "中心签到成功但插入签到表失败:" + errMsg, null).ToString();
  101. }
  102. else
  103. {
  104. rtnResult = JsonHelper.setIrisReturnValue(0, "签到成功", joRtn).ToString();
  105. }
  106. }
  107. }
  108. else
  109. {
  110. Global.curEvt.signno = "ABC123";
  111. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功(医保对照不初始化)!", null).ToString();
  112. }
  113. }
  114. else
  115. {
  116. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
  117. }
  118. return rtnResult;
  119. }
  120. }
  121. catch (Exception ex)
  122. {
  123. rtnResult = JsonHelper.setExceptionJson(-100, "Init 异常", ex.Message).ToString();
  124. return rtnResult;
  125. }
  126. finally
  127. {
  128. Global.writeLog("初始化结果:" + rtnResult);
  129. }
  130. }
  131. /// <summary>
  132. /// 初始化
  133. /// </summary>
  134. /// <param name="inParam"></param>
  135. /// <param name="outParam"></param>
  136. /// <returns></returns>
  137. private int init(string inParam, out string outParam)
  138. {
  139. string errMsg;
  140. outParam = "";
  141. try
  142. {
  143. //BS架构调用方式问题,每次调用都需要重新初始化
  144. JObject joInitRtn = JObject.Parse(Init(inParam));
  145. if (JsonHelper.parseIrisRtnValue(joInitRtn, out errMsg) != 0)
  146. {
  147. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)", errMsg).ToString();
  148. return -1;
  149. }
  150. else
  151. {
  152. return 0;
  153. }
  154. }
  155. catch (Exception ex)
  156. {
  157. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)异常", ex.Message).ToString();
  158. return -1;
  159. }
  160. }
  161. /// <summary>
  162. /// 获取患者信息
  163. /// </summary>
  164. /// <param name="InParam"></param>
  165. /// <returns></returns>
  166. public string GetPatientInfo(string InParam)
  167. {
  168. Global.writeLog("GetPatientInfo入参:" + JsonHelper.Compress(InParam));
  169. //设置返回值,错误信息
  170. int errCode;
  171. string errMsg, 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.admID = JsonHelper.getDestValue(joInParam, "params[0].admID");
  181. if (!string.IsNullOrEmpty(Global.pat.admID))
  182. {
  183. Global.pat.adm_Dr = int.Parse(Global.pat.admID);
  184. }
  185. try
  186. {
  187. switch (businessType)
  188. {
  189. case "M1"://门诊读卡
  190. {
  191. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  192. if (hBus.readCard(out outParam) != 0)
  193. {
  194. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  195. }
  196. else
  197. {
  198. string patInfo = outParam;
  199. if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  200. {
  201. rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  202. return rtnResult;
  203. }
  204. //展示患者信息界面
  205. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  206. {
  207. rtnResult = outParam;
  208. }
  209. else
  210. {
  211. rtnResult = JsonHelper.setIrisReturnValue(0, "", JObject.Parse(outParam)).ToString();
  212. }
  213. }
  214. break;
  215. }
  216. case "Z1"://住院读卡
  217. {
  218. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  219. if (hBus.readCard(out outParam) != 0)
  220. {
  221. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  222. }
  223. else
  224. {
  225. string patInfo = outParam;
  226. if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  227. {
  228. rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  229. return rtnResult;
  230. }
  231. //展示患者信息界面
  232. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  233. {
  234. rtnResult = outParam;
  235. }
  236. else
  237. {
  238. rtnResult = JsonHelper.setIrisReturnValue(0,"",JObject.Parse(outParam)).ToString();
  239. }
  240. }
  241. break;
  242. }
  243. }
  244. //在这里判断,建档的时候会直接拦截,因此加上判断条件
  245. //校验HIS姓名与医保姓名是否一致
  246. if (!string.IsNullOrEmpty(Global.pat.admID))
  247. {
  248. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  249. {
  250. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  251. return rtnResult;
  252. }
  253. }
  254. return rtnResult;
  255. }
  256. catch (Exception ex)
  257. {
  258. rtnResult = JsonHelper.setIrisReturnValue(-1 , "GetPatientInfo发生异常;" + ex.Message,null).ToString();
  259. return rtnResult;
  260. }
  261. finally
  262. {
  263. Global.writeLog("GetPatientInfo出参:" + JsonHelper.Compress(rtnResult));
  264. }
  265. }
  266. /// <summary>
  267. /// 登记
  268. /// </summary>
  269. /// <param name="InParam"></param>
  270. /// <returns></returns>
  271. public string Register(string InParam)
  272. {
  273. Global.writeLog("Register 入参:" + JsonHelper.Compress(InParam));
  274. //设置返回值,错误信息
  275. string errMsg, rtnResult = "", outParam;
  276. try
  277. {
  278. //解析入参
  279. if (parseInparam(InParam, out errMsg) != 0)
  280. {
  281. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  282. return rtnResult;
  283. }
  284. //BS架构调用方式问题,每次调用都需要重新初始化
  285. if (init(InParam, out outParam) != 0)
  286. {
  287. rtnResult = outParam;
  288. return rtnResult;
  289. }
  290. //获取pat
  291. hBus.GetRegPatInfo(businessType, joInParam, out Global.pat);
  292. switch (businessType)
  293. {
  294. case "M2"://门诊登记
  295. {
  296. break;
  297. }
  298. case "M2C"://门诊登记撤销
  299. {
  300. break;
  301. }
  302. case "Z0"://住院修改
  303. {
  304. break;
  305. }
  306. case "Z2"://入院登记
  307. {
  308. Global.writeLog(Global.pat.insuType);
  309. string regInParam = "";
  310. //显示登记面板
  311. if (hBus.showInPatRegisterForm( out regInParam) == 0)
  312. {
  313. Global.writeLog(regInParam);
  314. JObject joRegIn_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2401", regInParam));
  315. JObject joRegIn = JObject.Parse(JsonHelper.setCenterInpar("2401", regInParam));
  316. //上传给中心
  317. JObject joRegOut = invoker.invokeCenterService("2401", joRegIn);
  318. //将中心返回的结果返回HIS,调用HIS服务进行保存
  319. if (JsonHelper.parseCenterRtnValue(joRegOut,out errMsg) == 0)
  320. {
  321. joRegOut.Add("validflag",1);
  322. joRegOut.Add("regstate", 1);
  323. joRegOut.Add("type", 1);
  324. Global.pat.mdtrtID = JsonHelper.getDestValue(joRegOut, "output.result.mdtrt_id");
  325. //插入患者本次就诊用的参保信息
  326. if (hBus.insertPatCurInsuInfo(JsonHelper.getDestValue(joParam, "patientInfo"), out outParam) != 0)
  327. {
  328. if (DialogResult.Yes == MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  329. {
  330. }
  331. else
  332. {
  333. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!", outParam).ToString();
  334. return rtnResult;
  335. }
  336. }
  337. //插入医保平台
  338. if (mIS.saveInpatRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  339. {
  340. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存登记信息", outParam).ToString();
  341. return rtnResult;
  342. }
  343. //返回登记信息,插入HIS
  344. if (hIS.returnRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  345. {
  346. rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
  347. return rtnResult;
  348. }
  349. else
  350. {
  351. rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
  352. return rtnResult;
  353. }
  354. }
  355. else
  356. {
  357. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", errMsg).ToString();
  358. return rtnResult;
  359. }
  360. }
  361. else
  362. {
  363. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", regInParam).ToString();
  364. return rtnResult;
  365. }
  366. }
  367. case "Z2C"://入院登记取消
  368. {
  369. //中心取消传送
  370. cBus.cancleFeeUpload("2302", out errMsg);
  371. //取消中心登记
  372. if (cBus.cancleRegister("2404", out outParam) != 0)
  373. {
  374. //如果医保中心没有HIS所传的医保登记信息则默认撤销HIS登记信息
  375. int i = outParam.IndexOf("不存在有效的就诊登记信息");
  376. if (i != 0)
  377. {
  378. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam+ ",是否强制撤销HIS医保登记信息?", "提示", MessageBoxButtons.YesNo))
  379. {
  380. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  381. return rtnResult;
  382. }
  383. }
  384. else
  385. {
  386. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  387. return rtnResult;
  388. }
  389. }
  390. //取消医保平台登记
  391. if (mIS.cancleRegister(1, out outParam) != 0)
  392. {
  393. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  394. return rtnResult;
  395. }
  396. //取消HIS 登记
  397. if (hIS.cancleRegister( out outParam) != 0)
  398. {
  399. rtnResult = JsonHelper.setExceptionJson(-1, "中心和云医保平台取消登记成功,但HIS取消失败,", outParam).ToString();
  400. return rtnResult;
  401. }
  402. else
  403. {
  404. //CM 20230602 删除医保平台医保费用明细上传表数据
  405. mIS.deleteFee(out errMsg);
  406. rtnResult = JsonHelper.setIrisReturnValue(0, "取消医保登记成功", null).ToString();
  407. return rtnResult;
  408. }
  409. }
  410. case "Z6"://出院登记
  411. {
  412. break;
  413. }
  414. case "Z6C"://出院登记取消
  415. {
  416. if (cBus.cancleRegister("2405", out errMsg) != 0)
  417. {
  418. rtnResult = JsonHelper.setExceptionJson(-1, "取消出院登记", errMsg).ToString();
  419. return rtnResult;
  420. }
  421. else
  422. {
  423. rtnResult = JsonHelper.setIrisReturnValue(0, "取消出院登记成功", null).ToString();
  424. return rtnResult;
  425. }
  426. break;
  427. }
  428. default:
  429. {
  430. rtnResult = JsonHelper.setExceptionJson(-1, "Register 交易", "传入的业务编码不对!").ToString();
  431. return rtnResult;
  432. }
  433. }
  434. }
  435. catch (Exception ex)
  436. {
  437. rtnResult = JsonHelper.setIrisReturnValue(-1, "Register 发生异常;" + ex.Message, null).ToString();
  438. return rtnResult;
  439. }
  440. finally
  441. {
  442. Global.writeLog("Register 出参:" + JsonHelper.Compress(rtnResult));
  443. }
  444. return "";
  445. }
  446. /// <summary>
  447. /// 费用上传
  448. /// </summary>
  449. /// <param name="InParam"></param>
  450. /// <returns></returns>
  451. public string FeeUpload(string InParam)
  452. {
  453. Global.writeLog("FeeUpload 入参:" + JsonHelper.Compress(InParam));
  454. //设置返回值,错误信息
  455. int errCode;
  456. string errMsg, rtnResult = "", outParam;
  457. try
  458. {
  459. //解析入参
  460. if (parseInparam(InParam, out errMsg) != 0)
  461. {
  462. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  463. return rtnResult;
  464. }
  465. //BS架构调用方式问题,每次调用都需要重新初始化
  466. if (init(InParam, out outParam) != 0)
  467. {
  468. rtnResult = outParam;
  469. return rtnResult;
  470. }
  471. //获取pat
  472. hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  473. switch (businessType)
  474. {
  475. case "M3"://门诊费用上传
  476. {
  477. break;
  478. }
  479. case "M3C"://门诊费用撤销
  480. {
  481. break;
  482. }
  483. case "Z3"://入院费用上传
  484. {
  485. //从医保平台获取患者详细的医保登记信息
  486. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  487. {
  488. rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  489. return rtnResult;
  490. }
  491. JObject joReg = JObject.Parse(outParam);
  492. Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
  493. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  494. //先取消中心费用传送
  495. cBus.cancleFeeUpload("2302", out errMsg);
  496. //再删除医保传送表的数据
  497. mIS.deleteFee( out errMsg);
  498. #region【住院费用上传前调用3101事前服务】
  499. //1.获取3101入参报文
  500. //事前分析
  501. if (Global.curEvt.ext.isOpenAnalysis)
  502. {
  503. if (hBus.PreAnalysis("4", "", out errMsg) != 0)
  504. {
  505. rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  506. return rtnResult;
  507. }
  508. }
  509. #endregion
  510. //开始进行费用传送、调用HIS费用查询信息
  511. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  512. {
  513. rtnResult = JsonHelper.setExceptionJson(-1, "获取HIS费用", outParam).ToString();
  514. return rtnResult;
  515. }
  516. //调用医保平台转换
  517. JObject joHisFee = JObject.Parse(outParam);
  518. if (mIS.convertHisFeeWithInsuCode(joHisFee,out outParam) != 0)
  519. {
  520. rtnResult = JsonHelper.setExceptionJson(-1, "转换HIS费用", outParam).ToString();
  521. return rtnResult;
  522. }
  523. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  524. //按指定条数分割后上传,保存,更新
  525. if (hBus.uploadFeeToCenter("2301",100, jaFeeDetail, out outParam) != 0)
  526. {
  527. rtnResult = JsonHelper.setExceptionJson(-1, "上传费用", outParam).ToString();
  528. return rtnResult;
  529. }
  530. else
  531. {
  532. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传成功", null).ToString();
  533. return rtnResult;
  534. }
  535. }
  536. case "Z3C"://住院费用上传取消
  537. {
  538. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  539. {
  540. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  541. return rtnResult;
  542. }
  543. if (mIS.deleteFee( out errMsg) != 0)
  544. {
  545. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  546. return rtnResult;
  547. }
  548. else
  549. {
  550. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传取消成功", null).ToString();
  551. return rtnResult;
  552. }
  553. }
  554. default:
  555. {
  556. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", "传入的业务编码不对!").ToString();
  557. return rtnResult;
  558. }
  559. }
  560. return rtnResult;
  561. }
  562. catch (Exception ex)
  563. {
  564. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", ex.Message).ToString();
  565. return rtnResult;
  566. }
  567. finally
  568. {
  569. Global.writeLog("FeeUpload 出参:" + JsonHelper.Compress(rtnResult));
  570. }
  571. }
  572. /// <summary>
  573. /// 结算
  574. /// </summary>
  575. /// <param name="InParam"></param>
  576. /// <returns></returns>
  577. public string Settlement(string InParam)
  578. {
  579. Global.writeLog("Settlement 入参:" + JsonHelper.Compress(InParam));
  580. //设置返回值,错误信息
  581. string errMsg, rtnResult = "", outParam;
  582. try
  583. {
  584. //解析入参
  585. if (parseInparam(InParam, out errMsg) != 0)
  586. {
  587. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  588. return rtnResult;
  589. }
  590. //BS架构调用方式问题,每次调用都需要重新初始化
  591. if (init(InParam, out outParam) != 0)
  592. {
  593. rtnResult = outParam;
  594. return rtnResult;
  595. }
  596. //获取pat
  597. hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
  598. switch (businessType)
  599. {
  600. case "M4"://门诊预结算
  601. {
  602. OutpatientRegistration frmReg = new OutpatientRegistration();
  603. if (frmReg.ShowDialog() == DialogResult.OK)
  604. {
  605. rtnResult = "调用结束";
  606. }
  607. break;
  608. }
  609. case "M4C"://门诊预结算撤销
  610. {
  611. break;
  612. }
  613. case "M5"://门诊结算
  614. {
  615. string patInfo ="";
  616. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  617. if (hBus.readCard(out outParam) != 0)
  618. {
  619. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  620. return rtnResult;
  621. }
  622. else
  623. {
  624. patInfo = outParam;
  625. //展示患者信息界面
  626. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  627. {
  628. rtnResult = outParam;
  629. return rtnResult;
  630. }
  631. }
  632. //患者信息赋值给全局变量
  633. patInfo = outParam;
  634. if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  635. {
  636. rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  637. return rtnResult;
  638. }
  639. //校验HIS姓名与医保姓名是否一致
  640. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  641. {
  642. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  643. return rtnResult;
  644. }
  645. //显示登记面板
  646. if (hBus.showOutPatRegisterForm(out outParam) != 0)
  647. {
  648. rtnResult = JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString();
  649. return rtnResult;
  650. }
  651. JObject joReg = JObject.Parse(outParam);
  652. //医保挂号
  653. JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  654. JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  655. jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
  656. jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2201", jo2201Inpar_plain));
  657. //此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
  658. JObject jo2203Inpar = new JObject();
  659. JObject jo2203Inpar_plain = new JObject();
  660. jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
  661. jo2203Inpar.Add("diseinfo", JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
  662. JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
  663. if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
  664. {
  665. rtnResult = JsonHelper.setExceptionJson(-1, "医保挂号", errMsg).ToString();
  666. return rtnResult;
  667. }
  668. else
  669. {
  670. Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
  671. //插入患者本次就诊用的参保信息
  672. if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
  673. {
  674. if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  675. {
  676. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam).ToString();
  677. return rtnResult;
  678. }
  679. }
  680. jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
  681. jo2203Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203", jo2203Inpar));
  682. jo2203Inpar = JObject.Parse(JsonHelper.setCenterInpar("2203", jo2203Inpar));
  683. //门诊登记信息,插入云医保平台
  684. jo2201Rtn.Add("validflag", 1);
  685. jo2201Rtn.Add("regstate", 1);
  686. jo2201Rtn.Add("type", 3);
  687. Global.writeLog(jo2201Inpar_plain.ToString());
  688. if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203Inpar_plain, out errMsg) != 0)
  689. {
  690. rtnResult = JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString();
  691. return rtnResult;
  692. }
  693. }
  694. //门诊就诊信息上传
  695. JObject jo2203Rtn = invoker.invokeCenterService("2203",jo2203Inpar );
  696. if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
  697. {
  698. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
  699. return rtnResult;
  700. }
  701. #region【门诊就诊信息上传成功后调用3101事前服务】
  702. ////事前分析
  703. if (Global.curEvt.ext.isOpenAnalysis)
  704. {
  705. if (hBus.PreAnalysis("1", "", out errMsg) != 0)
  706. {
  707. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传成功后调用3101事前服务失败:", errMsg).ToString();
  708. return rtnResult;
  709. }
  710. }
  711. #endregion
  712. //费用上传
  713. if (hBus.uploadFee("2204", 50, out outParam) != 0)
  714. {
  715. rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
  716. return rtnResult;
  717. }
  718. //调用IRIS获取医保各项金额
  719. if (mIS.getSumFee(out outParam) != 0)
  720. {
  721. rtnResult = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outParam).ToString();
  722. return rtnResult;
  723. }
  724. JObject joSumFee = JObject.Parse(outParam);
  725. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joReg, "settlement"));
  726. //修改joSettlement的就诊ID ,总金额等
  727. joSettlement["mdtrt_id"] = Global.pat.mdtrtID;
  728. joSettlement["medfee_sumamt"] = JsonHelper.getDestValue(joSumFee, "data.Sumamt");
  729. //预结算2206
  730. if (hBus.preSettlement_OutPat(joSettlement, out outParam) != 0)
  731. {
  732. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  733. return rtnResult;
  734. }
  735. #region【门诊正式结算-2207】
  736. JObject joData = new JObject();
  737. joData.Add("data",joSettlement);
  738. JObject joRtn = invoker.invokeCenterService("2207", JsonHelper.setCenterInpar("2207", joData));
  739. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  740. {
  741. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  742. return rtnResult;
  743. }
  744. else
  745. {
  746. Global.pat.admType = 1;
  747. //返回给云医保平台结算信息-09010051
  748. if (mIS.saveSettlement(joRtn, out errMsg) != 0)
  749. {
  750. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  751. return rtnResult;
  752. }
  753. //返回给云医保平台结算明细信息-09010056
  754. if (mIS.saveSettlementDetail(joRtn, out errMsg) != 0)
  755. {
  756. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  757. return rtnResult;
  758. }
  759. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo"));
  760. Global.Set.settlID = JsonHelper.getDestValue(joRtn, "output.setlinfo.setl_id"); //使用人-结算ID
  761. Global.Set.mdtrtID = JsonHelper.getDestValue(joRtn, "output.setlinfo.mdtrt_id"); //使用人-就诊ID
  762. Global.pat.psn_no = JsonHelper.getDestValue(joRtn, "output.setlinfo.psn_type"); //使用人-人员类别
  763. Global.pat.name_SYR = JsonHelper.getDestValue(joRtn, "output.setlinfo.psn_name"); //使用人姓名
  764. Global.pat.certNO_SYR = JsonHelper.getDestValue(joRtn, "output.setlinfo.certno"); //使用人证件号码
  765. #region【医保账户代支业务】
  766. if (Global.pat.AccountMutualAidPay)
  767. {
  768. decimal psnCashPay = decimal.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo.psn_cash_pay")); //现金支付金额
  769. Global.Set.psnCashPay = psnCashPay.ToString();
  770. if (psnCashPay == 0) { MessageBox.Show("该患者本次结算自付金额为0,不需要进行医保账户代支结算!"); }
  771. else
  772. {
  773. #region【选择接口目录】
  774. MutualAidChooser frm = new MutualAidChooser();
  775. if (frm.ShowDialog() == DialogResult.OK)
  776. {
  777. string mutualAidPay = frm.mutualAidPay;
  778. int i = frm.cbxInterface.SelectedIndex;
  779. DataTable dtInteface = (DataTable)frm.cbxInterface.DataSource;
  780. Global.inf.mutualAidCenterURL = dtInteface.Rows[i]["CenterURL"].ToString();
  781. Global.inf.mutualAidHospitalAreaCode = dtInteface.Rows[i]["AreaCode"].ToString();
  782. Global.inf.mutualAidInterfaceDr = int.Parse(dtInteface.Rows[i]["ID"].ToString());
  783. //选中的账户授权人的接口类型与使用人不一致的情况下,调用签到信息
  784. //if (Global.inf.mutualAidInterfaceDr != Global.inf.interfaceDr)
  785. {
  786. if (mIS.isSigned_MutualAid(ref Global.curEvt.signno) != true)
  787. {
  788. //先签到
  789. CenterBusiness cBus = new CenterBusiness();
  790. JObject jo9001Rtn = new JObject();
  791. cBus.signIn_MutualAid(out jo9001Rtn);
  792. //插入签到表
  793. mIS.saveSignRecord_MutualAid(Global.curEvt.signno, out errMsg);
  794. }
  795. }
  796. #region【读卡-医保账户代支授权人】
  797. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  798. if (hBus.MutualAidReadCard(out outParam) != 0)
  799. {
  800. MessageBox.Show(JsonHelper.setExceptionJson(-100, "医保账户代支读卡失败,原结算仍需使用现金支付!", outParam).ToString());
  801. }
  802. else
  803. {
  804. //展示患者信息界面
  805. Global.pat.patInfo_mutualAidPay = outParam;
  806. if (hBus.MutualAidShowPatInfo(outParam, out patInfo) != 0)
  807. {
  808. MessageBox.Show("医保账户代支读卡成功,展示患者信息界面失败,原结算仍需使用现金支付:" + patInfo);
  809. }
  810. //开启自付界面,因涉及到多次自付
  811. MutualAid frmMA = new MutualAid(Global.Set.settlID, "M5");
  812. if (frmMA.dtSettlInfo.Rows.Count != 0)
  813. {
  814. frmMA.WindowState = FormWindowState.Maximized;
  815. if (frmMA.ShowDialog() == DialogResult.OK)
  816. {
  817. joSetlinfo = JObject.Parse(frmMA.finalSettlementInfo);
  818. }
  819. else
  820. {
  821. MessageBox.Show("注意:收费员取消医保账户代支结算,原结算仍需使用现金支付!");
  822. }
  823. }
  824. else
  825. {
  826. MessageBox.Show("医保账户代支失败,未获取到账户代支使用人的原医保结算记录!");
  827. }
  828. }
  829. #endregion
  830. }
  831. else
  832. {
  833. MessageBox.Show("注意:收费员取消医保账户代支结算,原结算仍需使用现金支付!");
  834. //return;
  835. }
  836. #endregion
  837. }
  838. }
  839. #endregion
  840. //查询医保结算表本次主结算是否存在账户代支结算记录 如果没有 就把共济标志更新为0
  841. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  842. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr;
  843. sqlStr = sqlStr + " AND MainSettlementIDOfMutualAid ='" + Global.Set.settlID + "'";
  844. JObject joRtnSetl = iris.querySettlementInfo(sqlStr);
  845. DataTable dt = (DataTable)joRtnSetl["result"]["data"].ToObject(typeof(DataTable));
  846. if (dt.Rows.Count == 1)
  847. {
  848. //如果未使用医保账户代支结算,这里应该需要把前面保存的医保结算表记录里的 MainSettlementIDOfMutualAid="",MutualAidFlag=0
  849. //更新云医保平台结算信息-09010080
  850. if (mIS.updateSettlement(Global.Set.settlID, 0, out errMsg) != 0)
  851. {
  852. rtnResult = JsonHelper.setExceptionJson(-1, "更新云医保平台账户共济主结算信息失败", errMsg).ToString();
  853. return rtnResult;
  854. }
  855. }
  856. //返回给HIS-【返回2207结算结果给HIS-05110018】
  857. if (hIS.returnOutpatSettlementInfo(joSettlement, joSetlinfo, out outParam) != 0)
  858. {
  859. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  860. return rtnResult;
  861. }
  862. else
  863. {
  864. JObject joHisServieRtn = JObject.Parse(outParam);
  865. hBus.returnToFrontEndAfterSettlement(joRtn, joHisServieRtn, out outParam);
  866. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  867. return rtnResult;
  868. }
  869. }
  870. #endregion
  871. }
  872. case "M5C"://门诊结算撤销
  873. {
  874. //查询HIS医保结算记录表获取该病人的参保地
  875. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  876. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  877. sqlStr = sqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  878. JObject joSql = new JObject();
  879. joSql.Add("sqlStr", sqlStr);
  880. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  881. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  882. //{
  883. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  884. // return rtnResult;
  885. //}
  886. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  887. #region【撤销医保账户代支结算】
  888. int mutualAidFlag = 0;
  889. if (!string.IsNullOrEmpty(JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs")))
  890. {
  891. mutualAidFlag = Convert.ToInt32(JsonHelper.getDestValue(joSettlInfo, "result.data[0].MutualAidFlag"));
  892. }
  893. if (mutualAidFlag > 0)
  894. {
  895. //开启自付界面,因涉及到多次自付
  896. MutualAid frmMA = new MutualAid(Global.pat.settlID, "M5C");
  897. if (frmMA.dtSettlInfo.Rows.Count != 0)
  898. {
  899. frmMA.WindowState = FormWindowState.Maximized;
  900. if (frmMA.ShowDialog() != DialogResult.OK)
  901. {
  902. rtnResult = JsonHelper.setExceptionJson(-1, "收款员取消账户代支撤销!", null).ToString();
  903. return rtnResult;
  904. }
  905. }
  906. else
  907. {
  908. rtnResult = JsonHelper.setExceptionJson(-1, "医保账户代支失败,未获取到账户代支使用人的原医保结算记录!", null).ToString();
  909. return rtnResult;
  910. }
  911. }
  912. #endregion
  913. //退中心结算
  914. string newSettleID = "";
  915. if (cBus.cancleSettlement("2208", out outParam) != 0)
  916. {
  917. int i = outParam.IndexOf("获取到的就诊信息为无效状态,不能办理结算撤销业务");
  918. if (i != 0)
  919. {
  920. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam + ",是否强制撤销HIS结算信息?", "提示", MessageBoxButtons.YesNo))
  921. {
  922. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消结算失败,", outParam).ToString();
  923. return rtnResult;
  924. }
  925. newSettleID = "YC";
  926. }
  927. else
  928. {
  929. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算", outParam).ToString();
  930. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  931. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  932. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  933. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  934. JObject joSqlStr = new JObject();
  935. joSqlStr.Add("sqlStr", SqlStr);
  936. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  937. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  938. if (jaCancleSettlInfo.Count == 1)
  939. {
  940. //询问收款员是否继续进行HIS退费
  941. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  942. {
  943. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  944. }
  945. }
  946. else
  947. {
  948. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  949. }
  950. return rtnResult;
  951. }
  952. }
  953. else
  954. {
  955. newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  956. }
  957. //退云医保平台结算
  958. if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
  959. {
  960. rtnResult = JsonHelper.setExceptionJson(-1, "取消平台结算信息", outParam).ToString();
  961. //return rtnResult;
  962. }
  963. if (newSettleID != "YC")
  964. {
  965. //中心取消传送
  966. if (cBus.cancleFeeUpload("2205", out errMsg) != 0)
  967. {
  968. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  969. //return rtnResult;
  970. }
  971. //云平台取消传送
  972. if (mIS.deleteFee(out errMsg) != 0)
  973. {
  974. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  975. return rtnResult;
  976. }
  977. //取消中心登记
  978. if (cBus.cancleRegister("2202", out outParam) != 0)
  979. {
  980. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  981. //return rtnResult;
  982. }
  983. //取消医保平台登记
  984. if (mIS.cancleRegister(3, out outParam) != 0)
  985. {
  986. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  987. return rtnResult;
  988. }
  989. }
  990. //退HIS结算
  991. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  992. {
  993. rtnResult = JsonHelper.setExceptionJson(-1, "取消HIS结算信息", outParam).ToString();
  994. return rtnResult;
  995. }
  996. else
  997. {
  998. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  999. return rtnResult;
  1000. }
  1001. }
  1002. case "Z4"://住院预结算
  1003. {
  1004. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1005. /*
  1006. //1.获取3102入参报文
  1007. if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
  1008. {
  1009. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  1010. return rtnResult;
  1011. }
  1012. else
  1013. {
  1014. //2.调用医保3102明细审核事前分析服务
  1015. JObject joInput = new JObject();
  1016. joInput = JObject.Parse(outParam);
  1017. JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1018. if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1019. {
  1020. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1021. return rtnResult;
  1022. //DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1023. //if (dr != DialogResult.OK)
  1024. //{
  1025. // rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  1026. // return rtnResult;
  1027. //}
  1028. }
  1029. else
  1030. {
  1031. JArray jaResult = JArray.Parse(JsonHelper.getDestValue(jo3102Rtn, "output.result"));
  1032. if (jaResult.HasValues)
  1033. {
  1034. PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(jo3102Rtn);
  1035. paipaForm.Text = "事前事中智能审核-3102医保明细审核事中分析服务调用返回";
  1036. if (paipaForm.ShowDialog() != DialogResult.OK)
  1037. {
  1038. errMsg = "事前事中审核不通过,操作员取消!";
  1039. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1040. return rtnResult;
  1041. }
  1042. else
  1043. {
  1044. //【3103】事前事中服务反馈服务
  1045. if (hBus.PreAnalysisFeedBack("3102", paipaForm.JrID, out errMsg) != 0)
  1046. {
  1047. rtnResult = JsonHelper.setExceptionJson(-1, "【3103】事前事中服务反馈服务", errMsg).ToString();
  1048. return rtnResult;
  1049. }
  1050. }
  1051. }
  1052. }
  1053. }
  1054. */
  1055. #endregion
  1056. Global.pat.RYorCY = "2";
  1057. JObject joSettle = new JObject();
  1058. if (hBus.preSettlement("2303",out joSettle, out outParam) != 0)
  1059. {
  1060. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1061. return rtnResult;
  1062. }
  1063. else
  1064. {
  1065. rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
  1066. return rtnResult;
  1067. }
  1068. }
  1069. case "Z4C"://住院预结算撤销
  1070. {
  1071. rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
  1072. return rtnResult;
  1073. }
  1074. case "Z5"://住院结算
  1075. {
  1076. string patInfo = "";
  1077. #region【调用银海COM组件读卡弹框-1401交易:出院结算前校验身份信息】
  1078. //调用银海com组件读卡弹框 1401交易
  1079. InvokeHelper yinhaiCom = new InvokeHelper();
  1080. JObject joInput1401 = new JObject();
  1081. dynamic joData1401 = new JObject();
  1082. joData1401.fixmedinsCode = Global.inf.hospitalNO;
  1083. joData1401.psnNo = "";
  1084. //交易输入报文格式
  1085. joInput1401["transNo"] = "1401";
  1086. joInput1401["transType"] = "passwordCheck";
  1087. joInput1401["timestamp"] = DateTime.Now.ToString("YYYYMMDDHH24MISS");
  1088. joInput1401.Add("data", JObject.FromObject(joData1401));
  1089. string sRtnValue1401 = string.Empty;
  1090. yinhaiCom.Call("1401", joInput1401.ToString(), out sRtnValue1401);
  1091. JObject joRtn1401 = new JObject();
  1092. joRtn1401 = JObject.Parse(sRtnValue1401);
  1093. if (JsonHelper.parseCenterRtnValue(joRtn1401, out errMsg) != 0)
  1094. {
  1095. rtnResult = JsonHelper.setExceptionJson(-1, "结算前验证身份信息调用银海控件失败:", errMsg).ToString();
  1096. return rtnResult;
  1097. }
  1098. else
  1099. {
  1100. outParam = joRtn1401.ToString();
  1101. Global.pat.certNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.certno"); //证件号码
  1102. Global.pat.name = JsonHelper.getDestValue(JObject.Parse(outParam), "output.psn_name"); //姓名
  1103. Global.pat.card.NO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.card_no"); //社会保障卡号
  1104. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuplc_admdvs"); //参保地
  1105. Global.pat.card.SN = JsonHelper.getDestValue(JObject.Parse(outParam), "output.card_sn"); //卡识别码
  1106. Global.pat.certType = JsonHelper.getDestValue(JObject.Parse(outParam), "output.psn_cert_type"); //证件类别
  1107. Global.pat.mdtrtcertNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.mdtrt_cert_no"); //就诊凭证编号
  1108. Global.pat.mdtrtcertType = JsonHelper.getDestValue(JObject.Parse(outParam), "output.mdtrt_cert_type"); //就诊凭证类型
  1109. Global.pat.IDNO = Global.pat.certNO;
  1110. Global.pat.card.QrCode = JsonHelper.getDestValue(JObject.Parse(outParam), "output.qrcode"); //
  1111. #region【1101获取身份信息】
  1112. JObject joData1101 = new JObject();
  1113. joData1101.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); //就诊凭证类型
  1114. joData1101.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); //就诊凭证编码
  1115. joData1101.Add("card_sn", Global.pat.card.SN); //卡识别码
  1116. joData1101.Add("begntime", "");
  1117. joData1101.Add("psn_cert_type", Global.pat.certType); //证件类别
  1118. joData1101.Add("certno", Global.pat.certNO); //证件号码
  1119. joData1101.Add("psn_name", Global.pat.name); //姓名
  1120. JObject joInput1101 = new JObject();
  1121. joInput1101.Add("data", joData1101);
  1122. InvokeHelper invoker = new InvokeHelper();
  1123. JObject joRtn1101 = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", joInput1101));
  1124. if (JsonHelper.parseCenterRtnValue(joRtn1101, out errMsg) != 0)
  1125. {
  1126. rtnResult = JsonHelper.setExceptionJson(-1, "结算前验证身份信息调用1101交易失败:", errMsg).ToString();
  1127. return rtnResult;
  1128. }
  1129. else
  1130. {
  1131. Global.pat.name = JsonHelper.getDestValue(JObject.Parse(joRtn1101.ToString()), "output.baseinfo.psn_name");
  1132. if (Global.pat.psn_no != JsonHelper.getDestValue(JObject.Parse(joRtn1101.ToString()), "output.baseinfo.psn_no")) //医保编号
  1133. {
  1134. rtnResult = JsonHelper.setExceptionJson(-1, "结算前验证身份信息失败:", "通过就诊凭证获取到的参保人信息与就诊人信息不一致!").ToString();
  1135. return rtnResult;
  1136. }
  1137. }
  1138. #endregion
  1139. }
  1140. #endregion
  1141. //校验HIS姓名与医保姓名是否一致
  1142. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  1143. {
  1144. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  1145. return rtnResult;
  1146. }
  1147. Global.pat.RYorCY = "2";
  1148. JObject joPreSetOutpar ;
  1149. if (hBus.preSettlement("2303",out joPreSetOutpar, out outParam) != 0)
  1150. {
  1151. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1152. return rtnResult;
  1153. }
  1154. else
  1155. {
  1156. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "Settlement"));
  1157. //正式结算
  1158. joSettlement.Add("data", joSettlement);
  1159. JObject jo2304Rtn = invoker.invokeCenterService("2304",JsonHelper.setCenterInpar("2304",joSettlement));
  1160. if (JsonHelper.parseCenterRtnValue(jo2304Rtn, out errMsg) != 0)
  1161. {
  1162. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1163. cBus.cancleRegister("2405", out errMsg);
  1164. return rtnResult;
  1165. }
  1166. else
  1167. {
  1168. Global.pat.admType = 2;
  1169. //返回给云医保平台结算信息
  1170. if (mIS.saveSettlement(jo2304Rtn, out errMsg) != 0)
  1171. {
  1172. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  1173. return rtnResult;
  1174. }
  1175. //返回给云医保平台结算明细信息
  1176. if (mIS.saveSettlementDetail(jo2304Rtn, out errMsg) != 0)
  1177. {
  1178. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  1179. Global.writeLog(rtnResult);
  1180. MessageBox.Show(errMsg);
  1181. }
  1182. //返回给HIS
  1183. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo"));
  1184. Global.Set.settlID = JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.setl_id"); //使用人-结算ID
  1185. Global.Set.mdtrtID = JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.mdtrt_id"); //使用人-就诊ID
  1186. Global.pat.psn_no = JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.psn_type"); //使用人-人员类别
  1187. Global.pat.name_SYR = JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.psn_name"); //使用人姓名
  1188. Global.pat.certNO_SYR = JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.certno"); //使用人证件号码
  1189. #region【医保账户代支业务】
  1190. if (Global.pat.AccountMutualAidPay)
  1191. {
  1192. decimal psnCashPay = decimal.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.psn_cash_pay")); //现金支付金额
  1193. Global.Set.psnCashPay = psnCashPay.ToString();
  1194. if (psnCashPay == 0) { MessageBox.Show("该患者本次结算自付金额为0,不需要进行医保账户代支结算!"); }
  1195. else
  1196. {
  1197. #region【选择接口目录】
  1198. MutualAidChooser frm = new MutualAidChooser();
  1199. if (frm.ShowDialog() == DialogResult.OK)
  1200. {
  1201. string mutualAidPay = frm.mutualAidPay;
  1202. int i = frm.cbxInterface.SelectedIndex;
  1203. DataTable dtInteface = (DataTable)frm.cbxInterface.DataSource;
  1204. Global.inf.mutualAidCenterURL = dtInteface.Rows[i]["CenterURL"].ToString();
  1205. Global.inf.mutualAidHospitalAreaCode = dtInteface.Rows[i]["AreaCode"].ToString();
  1206. Global.inf.mutualAidInterfaceDr = int.Parse(dtInteface.Rows[i]["ID"].ToString());
  1207. //选中的账户授权人的接口类型与使用人不一致的情况下,调用签到信息
  1208. //if (Global.inf.mutualAidInterfaceDr != Global.inf.interfaceDr)
  1209. {
  1210. if (mIS.isSigned_MutualAid(ref Global.curEvt.signno) != true)
  1211. {
  1212. //先签到
  1213. CenterBusiness cBus = new CenterBusiness();
  1214. JObject jo9001Rtn = new JObject();
  1215. cBus.signIn_MutualAid(out jo9001Rtn);
  1216. //插入签到表
  1217. mIS.saveSignRecord_MutualAid(Global.curEvt.signno, out errMsg);
  1218. }
  1219. }
  1220. #region【读卡-医保账户代支授权人】
  1221. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  1222. if (hBus.MutualAidReadCard(out outParam) != 0)
  1223. {
  1224. MessageBox.Show(JsonHelper.setExceptionJson(-100, "医保账户代支读卡失败,原结算仍需使用现金支付!", outParam).ToString());
  1225. }
  1226. else
  1227. {
  1228. //展示患者信息界面
  1229. Global.pat.patInfo_mutualAidPay = outParam;
  1230. if (hBus.MutualAidShowPatInfo(outParam, out patInfo) != 0)
  1231. {
  1232. MessageBox.Show("医保账户代支读卡成功,展示患者信息界面失败,原结算仍需使用现金支付:" + patInfo);
  1233. }
  1234. //开启自付界面,因涉及到多次自付
  1235. MutualAid frmMA = new MutualAid(Global.Set.settlID, "Z5");
  1236. if (frmMA.dtSettlInfo.Rows.Count != 0)
  1237. {
  1238. frmMA.WindowState = FormWindowState.Maximized;
  1239. if (frmMA.ShowDialog() == DialogResult.OK)
  1240. {
  1241. joSetlinfo = JObject.Parse(frmMA.finalSettlementInfo);
  1242. }
  1243. else
  1244. {
  1245. MessageBox.Show("注意:收费员取消医保账户代支结算,原结算仍需使用现金支付!");
  1246. }
  1247. }
  1248. else
  1249. {
  1250. MessageBox.Show("医保账户代支失败,未获取到账户代支使用人的原医保结算记录!");
  1251. }
  1252. }
  1253. #endregion
  1254. }
  1255. else
  1256. {
  1257. MessageBox.Show("注意:收费员取消医保账户代支结算,原结算仍需使用现金支付!");
  1258. //return;
  1259. }
  1260. #endregion
  1261. }
  1262. }
  1263. #endregion
  1264. //查询医保结算表本次主结算是否存在账户代支结算记录 如果没有 就把共济标志更新为0
  1265. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  1266. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr;
  1267. sqlStr = sqlStr + " AND MainSettlementIDOfMutualAid ='" + Global.Set.settlID + "'";
  1268. JObject joRtnSetl = iris.querySettlementInfo(sqlStr);
  1269. DataTable dt = (DataTable)joRtnSetl["result"]["data"].ToObject(typeof(DataTable));
  1270. if (dt.Rows.Count == 1)
  1271. {
  1272. //如果未使用医保账户代支结算,这里应该需要把前面保存的医保结算表记录里的 MainSettlementIDOfMutualAid="",MutualAidFlag=0
  1273. //更新云医保平台结算信息-09010080
  1274. if (mIS.updateSettlement(Global.Set.settlID, 0, out errMsg) != 0)
  1275. {
  1276. rtnResult = JsonHelper.setExceptionJson(-1, "更新云医保平台账户共济主结算信息失败", errMsg).ToString();
  1277. return rtnResult;
  1278. }
  1279. }
  1280. if (hIS.returnInpatSettlementInfo(joParam, joSetlinfo, out outParam) != 0)
  1281. {
  1282. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  1283. return rtnResult;
  1284. }
  1285. else
  1286. {
  1287. //返回给前端
  1288. JObject joHisServieRtn = JObject.Parse(outParam);
  1289. hBus.returnToFrontEndAfterSettlement(jo2304Rtn, joHisServieRtn, out outParam);
  1290. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  1291. return rtnResult;
  1292. }
  1293. }
  1294. }
  1295. }
  1296. case "Z5C"://住院结算撤销
  1297. {
  1298. //查询结算表
  1299. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and Hospital_Dr=" + Global.inf.hospitalDr
  1300. + " and Adm_Dr='" + Global.pat.adm_Dr + "'"
  1301. + " and MdtrtID='" + Global.pat.mdtrtID + "'"
  1302. + " Order By ID DESC ";
  1303. JObject joSql = new JObject();
  1304. joSql.Add("sqlStr", sqlStr);
  1305. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  1306. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  1307. //{
  1308. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  1309. // return rtnResult;
  1310. //}
  1311. //MessageBox.Show(joSettlInfo.ToString());
  1312. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  1313. Global.pat.SettID_YBJSB = JsonHelper.getDestValue(joSettlInfo, "result.data[0].SettlementID");
  1314. if (Global.pat.settlID != Global.pat.SettID_YBJSB)
  1315. {
  1316. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "通过09010059服务获取到的SettlementID<" + Global.pat.settlID + ">与DLL通过SQL语句" +
  1317. joSql + ",获取到的SettlementID<" + Global.pat.SettID_YBJSB + ">不同,可能存在HIS单边账,请联系医保开发人员处理该笔结算记录!").ToString();
  1318. //return rtnResult;
  1319. }
  1320. Global.pat.settlID = Global.pat.SettID_YBJSB;
  1321. //取消中心结算信息
  1322. if (cBus.cancleSettlement("2305", out outParam) != 0)
  1323. {
  1324. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算信息失败!", outParam).ToString();
  1325. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  1326. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  1327. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  1328. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  1329. JObject joSqlStr = new JObject();
  1330. joSqlStr.Add("sqlStr", SqlStr);
  1331. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  1332. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  1333. if (jaCancleSettlInfo.Count == 1)
  1334. {
  1335. //询问收款员是否继续进行HIS退费
  1336. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  1337. {
  1338. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  1339. }
  1340. }
  1341. else
  1342. {
  1343. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  1344. }
  1345. return rtnResult;
  1346. }
  1347. else
  1348. {
  1349. //退结算会返一个新的ID
  1350. string newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  1351. //取消平台结算信息
  1352. if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
  1353. {
  1354. rtnResult = JsonHelper.setExceptionJson(-1, "中心结算取消成功,医保平台结算信息取消失败!", outParam).ToString();
  1355. return rtnResult;
  1356. }
  1357. //中心取消传送
  1358. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  1359. {
  1360. //rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  1361. //return rtnResult;
  1362. }
  1363. //云平台取消传送
  1364. if (mIS.deleteFee(out errMsg) != 0)
  1365. {
  1366. //rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  1367. //return rtnResult;
  1368. }
  1369. //取消HIS医保结算信息
  1370. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  1371. {
  1372. rtnResult = JsonHelper.setExceptionJson(-1, "中心跟医保平台结算取消成功, 取消HIS结算信息失败!", outParam).ToString();
  1373. return rtnResult;
  1374. }
  1375. //取消出院登记
  1376. if (cBus.cancleRegister("2405", out outParam) != 0)
  1377. {
  1378. rtnResult = JsonHelper.setExceptionJson(0, "中心,医保平台及HIS结算信息取消成功,取消出院登记失败!请手工取消出院登记!", outParam).ToString();
  1379. return rtnResult;
  1380. }
  1381. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  1382. return rtnResult;
  1383. }
  1384. }
  1385. default:
  1386. {
  1387. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
  1388. return rtnResult;
  1389. }
  1390. }
  1391. return rtnResult;
  1392. }
  1393. catch (Exception ex)
  1394. {
  1395. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
  1396. return rtnResult;
  1397. }
  1398. finally
  1399. {
  1400. Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
  1401. }
  1402. }
  1403. /// <summary>
  1404. /// 辅助交易
  1405. /// </summary>
  1406. /// <param name="InParam"></param>
  1407. /// <returns></returns>
  1408. public string AgentFun(string InParam)
  1409. {
  1410. Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
  1411. //设置返回值,错误信息
  1412. int errCode;
  1413. string errMsg, rtnResult = "", outParam;
  1414. try
  1415. {
  1416. //解析入参
  1417. if (parseInparam(InParam, out errMsg) != 0)
  1418. {
  1419. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1420. return rtnResult;
  1421. }
  1422. //BS架构调用方式问题,每次调用都需要重新初始化
  1423. if (init(InParam, out outParam) != 0)
  1424. {
  1425. rtnResult = outParam;
  1426. return rtnResult;
  1427. }
  1428. //获取通用目录
  1429. string sTYML = mIS.GetCommonInterface_Dr(Global.inf.interfaceDr.ToString(), "");
  1430. if (sTYML == "")
  1431. Global.inf.interfaceDr_TY = Global.inf.interfaceDr;
  1432. else
  1433. Global.inf.interfaceDr_TY = int.Parse(sTYML);
  1434. //获取pat
  1435. //hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  1436. switch (businessType)
  1437. {
  1438. case "BasicData"://基础数据维护
  1439. {
  1440. BasicData bd = new BasicData();
  1441. if (bd.ShowDialog() != DialogResult.OK)
  1442. {
  1443. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出基础数据维护界面").ToString();
  1444. return rtnResult;
  1445. }
  1446. break;
  1447. }
  1448. case "Exception"://异常处理
  1449. {
  1450. //显示异常处理界面
  1451. HandleException frmEX = new HandleException();
  1452. if (frmEX.ShowDialog() != DialogResult.OK)
  1453. {
  1454. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出异常处理界面").ToString();
  1455. return rtnResult;
  1456. }
  1457. break;
  1458. }
  1459. case "CheckAndClearing"://对账清算
  1460. {
  1461. Clearing frmEX = new Clearing();
  1462. if (frmEX.ShowDialog() != DialogResult.OK)
  1463. {
  1464. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出对账清算界面").ToString();
  1465. return rtnResult;
  1466. }
  1467. break;
  1468. }
  1469. case "Print"://打印
  1470. {
  1471. //显示打印界面
  1472. SettlementBillPrint frmSettlList;
  1473. string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1474. if (insuAdmObj == "")
  1475. {
  1476. frmSettlList = new SettlementBillPrint();
  1477. if (frmSettlList.ShowDialog() != DialogResult.OK)
  1478. {
  1479. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出打印界面").ToString();
  1480. return rtnResult;
  1481. }
  1482. }
  1483. else
  1484. {
  1485. JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1486. frmSettlList = new SettlementBillPrint(joInsuAdmObj);
  1487. string groupID = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "groupID");
  1488. string userName = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "userName");
  1489. DataTable dt = (DataTable)frmSettlList.dgvSettlRecord.DataSource;
  1490. int i = frmSettlList.dgvSettlRecord.CurrentRow.Index;
  1491. string AdmID = dt.Rows[i]["AdmID"].ToString();
  1492. string PsnNo = dt.Rows[i]["PersonnelNO"].ToString();
  1493. string MdtrtID = dt.Rows[i]["MdtrtID"].ToString();
  1494. string SettlementID = dt.Rows[i]["SettlementID"].ToString();
  1495. Global.pat.adm_Dr = int.Parse(AdmID);
  1496. JObject joRtnFee = frmSettlList.UpdateMedInsuUploadData(AdmID, PsnNo, MdtrtID, SettlementID);
  1497. }
  1498. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  1499. break;
  1500. }
  1501. case "Log"://日志
  1502. {
  1503. MessageBox.Show(businessType);
  1504. break;
  1505. }
  1506. case "RecordUpload"://上传记录
  1507. {
  1508. MessageBox.Show(businessType);
  1509. break;
  1510. }
  1511. case "HospitalRegister"://备案
  1512. {
  1513. ToRecordFrom Referral = new ToRecordFrom();
  1514. if (Referral.ShowDialog() != DialogResult.OK)
  1515. {
  1516. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出备案信息界面").ToString();
  1517. return rtnResult;
  1518. }
  1519. break;
  1520. }
  1521. case "MutualAid"://医保账户代支
  1522. {
  1523. MutualAid frmMA = new MutualAid();
  1524. //frmMA.WindowState = FormWindowState.Maximized;
  1525. frmMA.ShowDialog();
  1526. break;
  1527. }
  1528. case "PrescribeCirculation"://医保处方流转
  1529. {
  1530. //PrescriptionCirculation PresCir = new PrescriptionCirculation();
  1531. PrescriptionCirculation PresCir = new PrescriptionCirculation("45050219890708002X");
  1532. if (PresCir.ShowDialog() != DialogResult.OK)
  1533. {
  1534. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保电子处方流转界面").ToString();
  1535. return rtnResult;
  1536. }
  1537. break;
  1538. }
  1539. case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
  1540. {
  1541. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1542. //Global.pat.psn_no = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].patn_id");
  1543. Global.pat.psn_no = JsonHelper.getDestValue(joInParam, "insuAdmObj.psn_no");
  1544. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].poolarea");
  1545. Global.pat.insuType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].insutype");
  1546. Global.pat.medType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].med_type");
  1547. JObject joResult = new JObject();
  1548. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  1549. string trig_scen = "4"; //住院
  1550. if (Global.pat.medType.Substring(0, 1) == "1")
  1551. trig_scen = "2"; //门诊
  1552. //事前分析
  1553. if (Global.curEvt.ext.isOpenAnalysis)
  1554. {
  1555. //if (hBus.PreAnalysis("2", joResult.ToString(), out errMsg) != 0) 20240614 苏国平、朱鹏飞要求更改
  1556. if (hBus.PreAnalysis(trig_scen, joResult.ToString(), out errMsg) != 0)
  1557. {
  1558. //MessageBox.Show(errMsg);
  1559. rtnResult = JsonHelper.setIrisReturnValue(-1, "医保事前事中服务:" + errMsg, null).ToString();
  1560. break;
  1561. }
  1562. else
  1563. {
  1564. rtnResult = JsonHelper.setIrisReturnValue(0, "医保事前事中服务" + errMsg, null).ToString();
  1565. }
  1566. }
  1567. else
  1568. {
  1569. rtnResult = JsonHelper.setIrisReturnValue(0, "事前事中服务接口未开启", null).ToString();
  1570. }
  1571. break;
  1572. }
  1573. case "MedInsuQuery"://医保查询
  1574. {
  1575. MedInsuQuery MedQuery = new MedInsuQuery();
  1576. if (MedQuery.ShowDialog() != DialogResult.OK)
  1577. {
  1578. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保查询界面").ToString();
  1579. return rtnResult;
  1580. }
  1581. break;
  1582. }
  1583. default:
  1584. {
  1585. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对!").ToString();
  1586. return rtnResult;
  1587. }
  1588. }
  1589. return rtnResult;
  1590. }
  1591. catch (Exception ex)
  1592. {
  1593. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
  1594. return rtnResult;
  1595. }
  1596. finally
  1597. {
  1598. Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
  1599. }
  1600. }
  1601. public string Download(string InParam)
  1602. {
  1603. Global.writeLog("Download 入参:" + JsonHelper.Compress(InParam));
  1604. //设置返回值,错误信息
  1605. int errCode;
  1606. string errMsg, rtnResult = "", outParam;
  1607. try
  1608. {
  1609. //解析入参
  1610. if (parseInparam(InParam, out errMsg) != 0)
  1611. {
  1612. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1613. return rtnResult;
  1614. }
  1615. //BS架构调用方式问题,每次调用都需要重新初始化
  1616. if (init(InParam, out outParam) != 0)
  1617. {
  1618. rtnResult = outParam;
  1619. return rtnResult;
  1620. }
  1621. dynamic joData = new JObject();
  1622. joData.data = joParam["data"];
  1623. //string code = (string)joInParam["code"];
  1624. string funNO = (string)joParam["funNO"];
  1625. switch (businessType)
  1626. {
  1627. case "DirectoryDownload":
  1628. {
  1629. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1630. rtnResult = hBus.DownloadDirectory(funNO, downloadParam).ToString();
  1631. break;
  1632. }
  1633. case "DictionayDownload":
  1634. {
  1635. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1636. rtnResult = hBus.downDictionary(downloadParam);
  1637. break;
  1638. }
  1639. }
  1640. return rtnResult;
  1641. }
  1642. catch (Exception ex)
  1643. {
  1644. rtnResult = JsonHelper.setExceptionJson(-100, "Download", ex.Message).ToString();
  1645. return rtnResult;
  1646. }
  1647. finally
  1648. {
  1649. Global.writeLog("Download 出参:" + rtnResult);
  1650. }
  1651. }
  1652. public string PlatformDirectConnect(string InParam)
  1653. {
  1654. //设置返回值,错误信息
  1655. int errCode;
  1656. string errMsg, rtnResult = "", outParam;
  1657. try
  1658. {
  1659. Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
  1660. //解析入参
  1661. if (parseInparam(InParam, out errMsg) != 0)
  1662. {
  1663. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1664. return rtnResult;
  1665. }
  1666. Global.businessType = businessType;
  1667. string funNO = JsonHelper.getDestValue(joInParam, "funNO");
  1668. //BS架构调用方式问题,每次调用都需要重新初始化
  1669. if (init(InParam, out outParam) != 0)
  1670. {
  1671. rtnResult = outParam;
  1672. return rtnResult;
  1673. }
  1674. JObject joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joParam));
  1675. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1676. {
  1677. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
  1678. return rtnResult;
  1679. }
  1680. else
  1681. {
  1682. rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
  1683. return rtnResult;
  1684. }
  1685. }
  1686. catch (Exception ex)
  1687. {
  1688. rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
  1689. return rtnResult;
  1690. }
  1691. finally
  1692. {
  1693. Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
  1694. }
  1695. }
  1696. }
  1697. }