InsuBusiness.cs 109 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948
  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. //20221207 CM 朱鹏飞要求屏蔽调用事前事中服务交易
  501. //事前分析
  502. //if (Global.curEvt.ext.isOpenAnalysis)
  503. //{
  504. // if (hBus.PreAnalysis("4", "", out errMsg) != 0)
  505. // {
  506. // rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  507. // return rtnResult;
  508. // }
  509. //}
  510. //if (hIS.GetInsuPatInfo("5", Global.pat, out outParam) != 0) 20240614 苏国平、朱鹏飞要求改4
  511. if (hIS.GetInsuPatInfo("4", Global.pat, out outParam) != 0)
  512. {
  513. rtnResult = JsonHelper.setExceptionJson(-1, "获取3101医保明细审核事前分析服务入参失败:", outParam).ToString();
  514. return rtnResult;
  515. }
  516. else
  517. {
  518. //2.调用医保3101明细审核事前分析服务
  519. JObject joInput = new JObject();
  520. joInput = JObject.Parse(outParam);
  521. JObject jo3101Rtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", joInput.ToString().Replace("\r\n", "")));
  522. if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
  523. {
  524. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  525. return rtnResult;
  526. }
  527. else
  528. {
  529. JArray jaResult = JArray.Parse(JsonHelper.getDestValue(jo3101Rtn, "output.result"));
  530. if (jaResult.HasValues)
  531. {
  532. PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(jo3101Rtn);
  533. paipaForm.Text = "事前事中智能审核-3101医保明细审核事前分析服务调用失败返回";
  534. if (paipaForm.ShowDialog() != DialogResult.OK)
  535. {
  536. errMsg = "事前事中审核不通过,操作员取消!";
  537. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  538. return rtnResult;
  539. }
  540. else
  541. {
  542. //【3103】事前事中服务反馈服务
  543. if (hBus.PreAnalysisFeedBack("3101", paipaForm.JrID, out errMsg) != 0)
  544. {
  545. rtnResult = JsonHelper.setExceptionJson(-1, "【3103】事前事中服务反馈服务", errMsg).ToString();
  546. return rtnResult;
  547. }
  548. }
  549. }
  550. }
  551. }
  552. #endregion
  553. //开始进行费用传送、调用HIS费用查询信息
  554. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  555. {
  556. rtnResult = JsonHelper.setExceptionJson(-1, "获取HIS费用", outParam).ToString();
  557. return rtnResult;
  558. }
  559. //调用医保平台转换
  560. JObject joHisFee = JObject.Parse(outParam);
  561. if (mIS.convertHisFeeWithInsuCode(joHisFee,out outParam) != 0)
  562. {
  563. rtnResult = JsonHelper.setExceptionJson(-1, "转换HIS费用", outParam).ToString();
  564. return rtnResult;
  565. }
  566. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  567. //按指定条数分割后上传,保存,更新
  568. if (hBus.uploadFeeToCenter("2301",100, jaFeeDetail, out outParam) != 0)
  569. {
  570. rtnResult = JsonHelper.setExceptionJson(-1, "上传费用", outParam).ToString();
  571. return rtnResult;
  572. }
  573. else
  574. {
  575. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传成功", null).ToString();
  576. return rtnResult;
  577. }
  578. }
  579. case "Z3C"://住院费用上传取消
  580. {
  581. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  582. {
  583. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  584. return rtnResult;
  585. }
  586. if (mIS.deleteFee( out errMsg) != 0)
  587. {
  588. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  589. return rtnResult;
  590. }
  591. else
  592. {
  593. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传取消成功", null).ToString();
  594. return rtnResult;
  595. }
  596. }
  597. default:
  598. {
  599. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", "传入的业务编码不对!").ToString();
  600. return rtnResult;
  601. }
  602. }
  603. return rtnResult;
  604. }
  605. catch (Exception ex)
  606. {
  607. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", ex.Message).ToString();
  608. return rtnResult;
  609. }
  610. finally
  611. {
  612. Global.writeLog("FeeUpload 出参:" + JsonHelper.Compress(rtnResult));
  613. }
  614. }
  615. /// <summary>
  616. /// 结算
  617. /// </summary>
  618. /// <param name="InParam"></param>
  619. /// <returns></returns>
  620. public string Settlement(string InParam)
  621. {
  622. Global.writeLog("Settlement 入参:" + JsonHelper.Compress(InParam));
  623. //设置返回值,错误信息
  624. string errMsg, rtnResult = "", outParam;
  625. try
  626. {
  627. //解析入参
  628. if (parseInparam(InParam, out errMsg) != 0)
  629. {
  630. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  631. return rtnResult;
  632. }
  633. //BS架构调用方式问题,每次调用都需要重新初始化
  634. if (init(InParam, out outParam) != 0)
  635. {
  636. rtnResult = outParam;
  637. return rtnResult;
  638. }
  639. //获取pat
  640. hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
  641. switch (businessType)
  642. {
  643. case "M4"://门诊预结算
  644. {
  645. OutpatientRegistration frmReg = new OutpatientRegistration();
  646. if (frmReg.ShowDialog() == DialogResult.OK)
  647. {
  648. rtnResult = "调用结束";
  649. }
  650. break;
  651. }
  652. case "M4C"://门诊预结算撤销
  653. {
  654. break;
  655. }
  656. case "M5"://门诊结算
  657. {
  658. string patInfo ="";
  659. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  660. if (hBus.readCard(out outParam) != 0)
  661. {
  662. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  663. return rtnResult;
  664. }
  665. else
  666. {
  667. patInfo = outParam;
  668. //展示患者信息界面
  669. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  670. {
  671. rtnResult = outParam;
  672. return rtnResult;
  673. }
  674. }
  675. //患者信息赋值给全局变量
  676. patInfo = outParam;
  677. if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  678. {
  679. rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  680. return rtnResult;
  681. }
  682. //校验HIS姓名与医保姓名是否一致
  683. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  684. {
  685. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  686. return rtnResult;
  687. }
  688. //显示登记面板
  689. if (hBus.showOutPatRegisterForm(out outParam) != 0)
  690. {
  691. rtnResult = JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString();
  692. return rtnResult;
  693. }
  694. JObject joReg = JObject.Parse(outParam);
  695. //医保挂号
  696. JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  697. JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  698. jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
  699. jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2201", jo2201Inpar_plain));
  700. //此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
  701. JObject jo2203Inpar = new JObject();
  702. JObject jo2203Inpar_plain = new JObject();
  703. jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
  704. jo2203Inpar.Add("diseinfo", JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
  705. JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
  706. if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
  707. {
  708. rtnResult = JsonHelper.setExceptionJson(-1, "医保挂号", errMsg).ToString();
  709. return rtnResult;
  710. }
  711. else
  712. {
  713. Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
  714. //插入患者本次就诊用的参保信息
  715. if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
  716. {
  717. if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  718. {
  719. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam).ToString();
  720. return rtnResult;
  721. }
  722. }
  723. jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
  724. jo2203Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203", jo2203Inpar));
  725. jo2203Inpar = JObject.Parse(JsonHelper.setCenterInpar("2203", jo2203Inpar));
  726. //门诊登记信息,插入云医保平台
  727. jo2201Rtn.Add("validflag", 1);
  728. jo2201Rtn.Add("regstate", 1);
  729. jo2201Rtn.Add("type", 3);
  730. Global.writeLog(jo2201Inpar_plain.ToString());
  731. if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203Inpar_plain, out errMsg) != 0)
  732. {
  733. rtnResult = JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString();
  734. return rtnResult;
  735. }
  736. }
  737. //门诊就诊信息上传
  738. JObject jo2203Rtn = invoker.invokeCenterService("2203",jo2203Inpar );
  739. if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
  740. {
  741. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
  742. return rtnResult;
  743. }
  744. #region【门诊就诊信息上传成功后调用3101事前服务】
  745. ////事前分析
  746. if (Global.curEvt.ext.isOpenAnalysis)
  747. {
  748. if (hBus.PreAnalysis("1", "", out errMsg) != 0)
  749. {
  750. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传成功后调用3101事前服务失败:", errMsg).ToString();
  751. return rtnResult;
  752. }
  753. }
  754. #endregion
  755. //费用上传
  756. if (hBus.uploadFee("2204", 50, out outParam) != 0)
  757. {
  758. rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
  759. return rtnResult;
  760. }
  761. //调用IRIS获取医保各项金额
  762. if (mIS.getSumFee(out outParam) != 0)
  763. {
  764. rtnResult = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outParam).ToString();
  765. return rtnResult;
  766. }
  767. JObject joSumFee = JObject.Parse(outParam);
  768. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joReg, "settlement"));
  769. //修改joSettlement的就诊ID ,总金额等
  770. joSettlement["mdtrt_id"] = Global.pat.mdtrtID;
  771. joSettlement["medfee_sumamt"] = JsonHelper.getDestValue(joSumFee, "data.Sumamt");
  772. //预结算2206
  773. if (hBus.preSettlement_OutPat(joSettlement, out outParam) != 0)
  774. {
  775. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  776. return rtnResult;
  777. }
  778. #region【门诊正式结算-2207】
  779. JObject joData = new JObject();
  780. joData.Add("data",joSettlement);
  781. JObject joRtn = invoker.invokeCenterService("2207", JsonHelper.setCenterInpar("2207", joData));
  782. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  783. {
  784. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  785. return rtnResult;
  786. }
  787. else
  788. {
  789. Global.pat.admType = 1;
  790. //返回给云医保平台结算信息-09010051
  791. if (mIS.saveSettlement(joRtn, out errMsg) != 0)
  792. {
  793. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  794. return rtnResult;
  795. }
  796. //返回给云医保平台结算明细信息-09010056
  797. if (mIS.saveSettlementDetail(joRtn, out errMsg) != 0)
  798. {
  799. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  800. return rtnResult;
  801. }
  802. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo"));
  803. Global.Set.settlID = JsonHelper.getDestValue(joRtn, "output.setlinfo.setl_id"); //使用人-结算ID
  804. Global.Set.mdtrtID = JsonHelper.getDestValue(joRtn, "output.setlinfo.mdtrt_id"); //使用人-就诊ID
  805. Global.pat.psn_no = JsonHelper.getDestValue(joRtn, "output.setlinfo.psn_type"); //使用人-人员类别
  806. Global.pat.name_SYR = JsonHelper.getDestValue(joRtn, "output.setlinfo.psn_name"); //使用人姓名
  807. Global.pat.certNO_SYR = JsonHelper.getDestValue(joRtn, "output.setlinfo.certno"); //使用人证件号码
  808. #region【医保账户代支业务】
  809. if (Global.pat.AccountMutualAidPay)
  810. {
  811. decimal psnCashPay = decimal.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo.psn_cash_pay")); //现金支付金额
  812. Global.Set.psnCashPay = psnCashPay.ToString();
  813. if (psnCashPay == 0) { MessageBox.Show("该患者本次结算自付金额为0,不需要进行医保账户代支结算!"); }
  814. else
  815. {
  816. #region【选择接口目录】
  817. MutualAidChooser frm = new MutualAidChooser();
  818. if (frm.ShowDialog() == DialogResult.OK)
  819. {
  820. string mutualAidPay = frm.mutualAidPay;
  821. int i = frm.cbxInterface.SelectedIndex;
  822. DataTable dtInteface = (DataTable)frm.cbxInterface.DataSource;
  823. Global.inf.mutualAidCenterURL = dtInteface.Rows[i]["CenterURL"].ToString();
  824. Global.inf.mutualAidHospitalAreaCode = dtInteface.Rows[i]["AreaCode"].ToString();
  825. Global.inf.mutualAidInterfaceDr = int.Parse(dtInteface.Rows[i]["ID"].ToString());
  826. //选中的账户授权人的接口类型与使用人不一致的情况下,调用签到信息
  827. //if (Global.inf.mutualAidInterfaceDr != Global.inf.interfaceDr)
  828. {
  829. if (mIS.isSigned_MutualAid(ref Global.curEvt.signno) != true)
  830. {
  831. //先签到
  832. CenterBusiness cBus = new CenterBusiness();
  833. JObject jo9001Rtn = new JObject();
  834. cBus.signIn_MutualAid(out jo9001Rtn);
  835. //插入签到表
  836. mIS.saveSignRecord_MutualAid(Global.curEvt.signno, out errMsg);
  837. }
  838. }
  839. #region【读卡-医保账户代支授权人】
  840. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  841. if (hBus.MutualAidReadCard(out outParam) != 0)
  842. {
  843. MessageBox.Show(JsonHelper.setExceptionJson(-100, "医保账户代支读卡失败,原结算仍需使用现金支付!", outParam).ToString());
  844. }
  845. else
  846. {
  847. //展示患者信息界面
  848. Global.pat.patInfo_mutualAidPay = outParam;
  849. if (hBus.MutualAidShowPatInfo(outParam, out patInfo) != 0)
  850. {
  851. MessageBox.Show("医保账户代支读卡成功,展示患者信息界面失败,原结算仍需使用现金支付:" + patInfo);
  852. }
  853. //开启自付界面,因涉及到多次自付
  854. MutualAid frmMA = new MutualAid(Global.Set.settlID, "M5");
  855. if (frmMA.dtSettlInfo.Rows.Count != 0)
  856. {
  857. frmMA.WindowState = FormWindowState.Maximized;
  858. if (frmMA.ShowDialog() == DialogResult.OK)
  859. {
  860. joSetlinfo = JObject.Parse(frmMA.finalSettlementInfo);
  861. }
  862. else
  863. {
  864. MessageBox.Show("注意:收费员取消医保账户代支结算,原结算仍需使用现金支付!");
  865. }
  866. }
  867. else
  868. {
  869. MessageBox.Show("医保账户代支失败,未获取到账户代支使用人的原医保结算记录!");
  870. }
  871. }
  872. #endregion
  873. }
  874. else
  875. {
  876. MessageBox.Show("注意:收费员取消医保账户代支结算,原结算仍需使用现金支付!");
  877. //return;
  878. }
  879. #endregion
  880. }
  881. }
  882. #endregion
  883. //查询医保结算表本次主结算是否存在账户代支结算记录 如果没有 就把共济标志更新为0
  884. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  885. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr;
  886. sqlStr = sqlStr + " AND MainSettlementIDOfMutualAid ='" + Global.Set.settlID + "'";
  887. JObject joRtnSetl = iris.querySettlementInfo(sqlStr);
  888. DataTable dt = (DataTable)joRtnSetl["result"]["data"].ToObject(typeof(DataTable));
  889. if (dt.Rows.Count == 1)
  890. {
  891. //如果未使用医保账户代支结算,这里应该需要把前面保存的医保结算表记录里的 MainSettlementIDOfMutualAid="",MutualAidFlag=0
  892. //更新云医保平台结算信息-09010080
  893. if (mIS.updateSettlement(Global.Set.settlID, 0, out errMsg) != 0)
  894. {
  895. rtnResult = JsonHelper.setExceptionJson(-1, "更新云医保平台账户共济主结算信息失败", errMsg).ToString();
  896. return rtnResult;
  897. }
  898. }
  899. //返回给HIS-【返回2207结算结果给HIS-05110018】
  900. if (hIS.returnOutpatSettlementInfo(joSettlement, joSetlinfo, out outParam) != 0)
  901. {
  902. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  903. return rtnResult;
  904. }
  905. else
  906. {
  907. JObject joHisServieRtn = JObject.Parse(outParam);
  908. hBus.returnToFrontEndAfterSettlement(joRtn, joHisServieRtn, out outParam);
  909. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  910. return rtnResult;
  911. }
  912. }
  913. #endregion
  914. }
  915. case "M5C"://门诊结算撤销
  916. {
  917. //查询HIS医保结算记录表获取该病人的参保地
  918. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  919. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  920. sqlStr = sqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  921. JObject joSql = new JObject();
  922. joSql.Add("sqlStr", sqlStr);
  923. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  924. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  925. //{
  926. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  927. // return rtnResult;
  928. //}
  929. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  930. #region【撤销医保账户代支结算】
  931. int mutualAidFlag = 0;
  932. if (!string.IsNullOrEmpty(JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs")))
  933. {
  934. mutualAidFlag = Convert.ToInt32(JsonHelper.getDestValue(joSettlInfo, "result.data[0].MutualAidFlag"));
  935. }
  936. if (mutualAidFlag > 0)
  937. {
  938. //开启自付界面,因涉及到多次自付
  939. MutualAid frmMA = new MutualAid(Global.pat.settlID, "M5C");
  940. if (frmMA.dtSettlInfo.Rows.Count != 0)
  941. {
  942. frmMA.WindowState = FormWindowState.Maximized;
  943. if (frmMA.ShowDialog() != DialogResult.OK)
  944. {
  945. rtnResult = JsonHelper.setExceptionJson(-1, "收款员取消账户代支撤销!", null).ToString();
  946. return rtnResult;
  947. }
  948. }
  949. else
  950. {
  951. rtnResult = JsonHelper.setExceptionJson(-1, "医保账户代支失败,未获取到账户代支使用人的原医保结算记录!", null).ToString();
  952. return rtnResult;
  953. }
  954. }
  955. #endregion
  956. //退中心结算
  957. string newSettleID = "";
  958. if (cBus.cancleSettlement("2208", out outParam) != 0)
  959. {
  960. int i = outParam.IndexOf("获取到的就诊信息为无效状态,不能办理结算撤销业务");
  961. if (i != 0)
  962. {
  963. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam + ",是否强制撤销HIS结算信息?", "提示", MessageBoxButtons.YesNo))
  964. {
  965. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消结算失败,", outParam).ToString();
  966. return rtnResult;
  967. }
  968. newSettleID = "YC";
  969. }
  970. else
  971. {
  972. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算", outParam).ToString();
  973. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  974. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  975. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  976. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  977. JObject joSqlStr = new JObject();
  978. joSqlStr.Add("sqlStr", SqlStr);
  979. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  980. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  981. if (jaCancleSettlInfo.Count == 1)
  982. {
  983. //询问收款员是否继续进行HIS退费
  984. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  985. {
  986. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  987. }
  988. }
  989. else
  990. {
  991. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  992. }
  993. return rtnResult;
  994. }
  995. }
  996. else
  997. {
  998. newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  999. }
  1000. //退云医保平台结算
  1001. if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
  1002. {
  1003. rtnResult = JsonHelper.setExceptionJson(-1, "取消平台结算信息", outParam).ToString();
  1004. //return rtnResult;
  1005. }
  1006. if (newSettleID != "YC")
  1007. {
  1008. //中心取消传送
  1009. if (cBus.cancleFeeUpload("2205", out errMsg) != 0)
  1010. {
  1011. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  1012. //return rtnResult;
  1013. }
  1014. //云平台取消传送
  1015. if (mIS.deleteFee(out errMsg) != 0)
  1016. {
  1017. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  1018. return rtnResult;
  1019. }
  1020. //取消中心登记
  1021. if (cBus.cancleRegister("2202", out outParam) != 0)
  1022. {
  1023. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  1024. //return rtnResult;
  1025. }
  1026. //取消医保平台登记
  1027. if (mIS.cancleRegister(3, out outParam) != 0)
  1028. {
  1029. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  1030. return rtnResult;
  1031. }
  1032. }
  1033. //退HIS结算
  1034. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  1035. {
  1036. rtnResult = JsonHelper.setExceptionJson(-1, "取消HIS结算信息", outParam).ToString();
  1037. return rtnResult;
  1038. }
  1039. else
  1040. {
  1041. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  1042. return rtnResult;
  1043. }
  1044. }
  1045. case "Z4"://住院预结算
  1046. {
  1047. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1048. /*
  1049. //1.获取3102入参报文
  1050. if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
  1051. {
  1052. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  1053. return rtnResult;
  1054. }
  1055. else
  1056. {
  1057. //2.调用医保3102明细审核事前分析服务
  1058. JObject joInput = new JObject();
  1059. joInput = JObject.Parse(outParam);
  1060. JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1061. if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1062. {
  1063. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1064. return rtnResult;
  1065. //DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1066. //if (dr != DialogResult.OK)
  1067. //{
  1068. // rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  1069. // return rtnResult;
  1070. //}
  1071. }
  1072. else
  1073. {
  1074. JArray jaResult = JArray.Parse(JsonHelper.getDestValue(jo3102Rtn, "output.result"));
  1075. if (jaResult.HasValues)
  1076. {
  1077. PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(jo3102Rtn);
  1078. paipaForm.Text = "事前事中智能审核-3102医保明细审核事中分析服务调用返回";
  1079. if (paipaForm.ShowDialog() != DialogResult.OK)
  1080. {
  1081. errMsg = "事前事中审核不通过,操作员取消!";
  1082. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1083. return rtnResult;
  1084. }
  1085. else
  1086. {
  1087. //【3103】事前事中服务反馈服务
  1088. if (hBus.PreAnalysisFeedBack("3102", paipaForm.JrID, out errMsg) != 0)
  1089. {
  1090. rtnResult = JsonHelper.setExceptionJson(-1, "【3103】事前事中服务反馈服务", errMsg).ToString();
  1091. return rtnResult;
  1092. }
  1093. }
  1094. }
  1095. }
  1096. }
  1097. */
  1098. #endregion
  1099. Global.pat.RYorCY = "2";
  1100. JObject joSettle = new JObject();
  1101. if (hBus.preSettlement("2303",out joSettle, out outParam) != 0)
  1102. {
  1103. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1104. return rtnResult;
  1105. }
  1106. else
  1107. {
  1108. rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
  1109. return rtnResult;
  1110. }
  1111. }
  1112. case "Z4C"://住院预结算撤销
  1113. {
  1114. rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
  1115. return rtnResult;
  1116. }
  1117. case "Z5"://住院结算
  1118. {
  1119. string patInfo = "";
  1120. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1121. //1.获取3102入参报文
  1122. if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
  1123. {
  1124. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  1125. return rtnResult;
  1126. }
  1127. else
  1128. {
  1129. //2.调用医保3102明细审核事前分析服务
  1130. JObject joInput = new JObject();
  1131. joInput = JObject.Parse(outParam);
  1132. JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1133. if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1134. {
  1135. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1136. return rtnResult;
  1137. }
  1138. else
  1139. {
  1140. JArray jaResult = JArray.Parse(JsonHelper.getDestValue(jo3102Rtn, "output.result"));
  1141. if (jaResult.HasValues)
  1142. {
  1143. PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(jo3102Rtn);
  1144. paipaForm.Text = "事前事中智能审核-3102医保明细审核事中分析服务调用返回";
  1145. if (paipaForm.ShowDialog() != DialogResult.OK)
  1146. {
  1147. errMsg = "事前事中审核不通过,操作员取消!";
  1148. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1149. return rtnResult;
  1150. }
  1151. else
  1152. {
  1153. //【3103】事前事中服务反馈服务
  1154. if (hBus.PreAnalysisFeedBack("3102", paipaForm.JrID, out errMsg) != 0)
  1155. {
  1156. rtnResult = JsonHelper.setExceptionJson(-1, "【3103】事前事中服务反馈服务", errMsg).ToString();
  1157. return rtnResult;
  1158. }
  1159. }
  1160. }
  1161. }
  1162. }
  1163. #endregion
  1164. #region【调用银海COM组件读卡弹框-1401交易:出院结算前校验身份信息】
  1165. //调用银海com组件读卡弹框 1401交易
  1166. InvokeHelper yinhaiCom = new InvokeHelper();
  1167. JObject joInput1401 = new JObject();
  1168. dynamic joData1401 = new JObject();
  1169. joData1401.fixmedinsCode = Global.inf.hospitalNO;
  1170. joData1401.psnNo = "";
  1171. //交易输入报文格式
  1172. joInput1401["transNo"] = "1401";
  1173. joInput1401["transType"] = "passwordCheck";
  1174. joInput1401["timestamp"] = DateTime.Now.ToString("YYYYMMDDHH24MISS");
  1175. joInput1401.Add("data", JObject.FromObject(joData1401));
  1176. string sRtnValue1401 = string.Empty;
  1177. yinhaiCom.Call("1401", joInput1401.ToString(), out sRtnValue1401);
  1178. JObject joRtn1401 = new JObject();
  1179. joRtn1401 = JObject.Parse(sRtnValue1401);
  1180. if (JsonHelper.parseCenterRtnValue(joRtn1401, out errMsg) != 0)
  1181. {
  1182. rtnResult = JsonHelper.setExceptionJson(-1, "结算前验证身份信息调用银海控件失败:", errMsg).ToString();
  1183. return rtnResult;
  1184. }
  1185. else
  1186. {
  1187. outParam = joRtn1401.ToString();
  1188. Global.pat.certNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.certno"); //证件号码
  1189. Global.pat.name = JsonHelper.getDestValue(JObject.Parse(outParam), "output.psn_name"); //姓名
  1190. Global.pat.card.NO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.card_no"); //社会保障卡号
  1191. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuplc_admdvs"); //参保地
  1192. Global.pat.card.SN = JsonHelper.getDestValue(JObject.Parse(outParam), "output.card_sn"); //卡识别码
  1193. Global.pat.certType = JsonHelper.getDestValue(JObject.Parse(outParam), "output.psn_cert_type"); //证件类别
  1194. Global.pat.mdtrtcertNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.mdtrt_cert_no"); //就诊凭证编号
  1195. Global.pat.mdtrtcertType = JsonHelper.getDestValue(JObject.Parse(outParam), "output.mdtrt_cert_type"); //就诊凭证类型
  1196. Global.pat.IDNO = Global.pat.certNO;
  1197. Global.pat.card.QrCode = JsonHelper.getDestValue(JObject.Parse(outParam), "output.qrcode"); //
  1198. #region【1101获取身份信息】
  1199. JObject joData1101 = new JObject();
  1200. joData1101.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); //就诊凭证类型
  1201. joData1101.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); //就诊凭证编码
  1202. joData1101.Add("card_sn", Global.pat.card.SN); //卡识别码
  1203. joData1101.Add("begntime", "");
  1204. joData1101.Add("psn_cert_type", Global.pat.certType); //证件类别
  1205. joData1101.Add("certno", Global.pat.certNO); //证件号码
  1206. joData1101.Add("psn_name", Global.pat.name); //姓名
  1207. JObject joInput1101 = new JObject();
  1208. joInput1101.Add("data", joData1101);
  1209. InvokeHelper invoker = new InvokeHelper();
  1210. JObject joRtn1101 = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", joInput1101));
  1211. if (JsonHelper.parseCenterRtnValue(joRtn1101, out errMsg) != 0)
  1212. {
  1213. rtnResult = JsonHelper.setExceptionJson(-1, "结算前验证身份信息调用1101交易失败:", errMsg).ToString();
  1214. return rtnResult;
  1215. }
  1216. else
  1217. {
  1218. Global.pat.name = JsonHelper.getDestValue(JObject.Parse(joRtn1101.ToString()), "output.baseinfo.psn_name");
  1219. if (Global.pat.psn_no != JsonHelper.getDestValue(JObject.Parse(joRtn1101.ToString()), "output.baseinfo.psn_no")) //医保编号
  1220. {
  1221. rtnResult = JsonHelper.setExceptionJson(-1, "结算前验证身份信息失败:", "通过就诊凭证获取到的参保人信息与就诊人信息不一致!").ToString();
  1222. return rtnResult;
  1223. }
  1224. }
  1225. #endregion
  1226. }
  1227. #endregion
  1228. //校验HIS姓名与医保姓名是否一致
  1229. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  1230. {
  1231. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  1232. return rtnResult;
  1233. }
  1234. Global.pat.RYorCY = "2";
  1235. JObject joPreSetOutpar ;
  1236. if (hBus.preSettlement("2303",out joPreSetOutpar, out outParam) != 0)
  1237. {
  1238. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1239. return rtnResult;
  1240. }
  1241. else
  1242. {
  1243. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "Settlement"));
  1244. //正式结算
  1245. joSettlement.Add("data", joSettlement);
  1246. JObject jo2304Rtn = invoker.invokeCenterService("2304",JsonHelper.setCenterInpar("2304",joSettlement));
  1247. if (JsonHelper.parseCenterRtnValue(jo2304Rtn, out errMsg) != 0)
  1248. {
  1249. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1250. cBus.cancleRegister("2405", out errMsg);
  1251. return rtnResult;
  1252. }
  1253. else
  1254. {
  1255. Global.pat.admType = 2;
  1256. //返回给云医保平台结算信息
  1257. if (mIS.saveSettlement(jo2304Rtn, out errMsg) != 0)
  1258. {
  1259. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  1260. return rtnResult;
  1261. }
  1262. //返回给云医保平台结算明细信息
  1263. if (mIS.saveSettlementDetail(jo2304Rtn, out errMsg) != 0)
  1264. {
  1265. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  1266. Global.writeLog(rtnResult);
  1267. MessageBox.Show(errMsg);
  1268. }
  1269. //返回给HIS
  1270. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo"));
  1271. Global.Set.settlID = JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.setl_id"); //使用人-结算ID
  1272. Global.Set.mdtrtID = JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.mdtrt_id"); //使用人-就诊ID
  1273. Global.pat.psn_no = JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.psn_type"); //使用人-人员类别
  1274. Global.pat.name_SYR = JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.psn_name"); //使用人姓名
  1275. Global.pat.certNO_SYR = JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.certno"); //使用人证件号码
  1276. #region【医保账户代支业务】
  1277. if (Global.pat.AccountMutualAidPay)
  1278. {
  1279. decimal psnCashPay = decimal.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo.psn_cash_pay")); //现金支付金额
  1280. Global.Set.psnCashPay = psnCashPay.ToString();
  1281. if (psnCashPay == 0) { MessageBox.Show("该患者本次结算自付金额为0,不需要进行医保账户代支结算!"); }
  1282. else
  1283. {
  1284. #region【选择接口目录】
  1285. MutualAidChooser frm = new MutualAidChooser();
  1286. if (frm.ShowDialog() == DialogResult.OK)
  1287. {
  1288. string mutualAidPay = frm.mutualAidPay;
  1289. int i = frm.cbxInterface.SelectedIndex;
  1290. DataTable dtInteface = (DataTable)frm.cbxInterface.DataSource;
  1291. Global.inf.mutualAidCenterURL = dtInteface.Rows[i]["CenterURL"].ToString();
  1292. Global.inf.mutualAidHospitalAreaCode = dtInteface.Rows[i]["AreaCode"].ToString();
  1293. Global.inf.mutualAidInterfaceDr = int.Parse(dtInteface.Rows[i]["ID"].ToString());
  1294. //选中的账户授权人的接口类型与使用人不一致的情况下,调用签到信息
  1295. //if (Global.inf.mutualAidInterfaceDr != Global.inf.interfaceDr)
  1296. {
  1297. if (mIS.isSigned_MutualAid(ref Global.curEvt.signno) != true)
  1298. {
  1299. //先签到
  1300. CenterBusiness cBus = new CenterBusiness();
  1301. JObject jo9001Rtn = new JObject();
  1302. cBus.signIn_MutualAid(out jo9001Rtn);
  1303. //插入签到表
  1304. mIS.saveSignRecord_MutualAid(Global.curEvt.signno, out errMsg);
  1305. }
  1306. }
  1307. #region【读卡-医保账户代支授权人】
  1308. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  1309. if (hBus.MutualAidReadCard(out outParam) != 0)
  1310. {
  1311. MessageBox.Show(JsonHelper.setExceptionJson(-100, "医保账户代支读卡失败,原结算仍需使用现金支付!", outParam).ToString());
  1312. }
  1313. else
  1314. {
  1315. //展示患者信息界面
  1316. Global.pat.patInfo_mutualAidPay = outParam;
  1317. if (hBus.MutualAidShowPatInfo(outParam, out patInfo) != 0)
  1318. {
  1319. MessageBox.Show("医保账户代支读卡成功,展示患者信息界面失败,原结算仍需使用现金支付:" + patInfo);
  1320. }
  1321. //开启自付界面,因涉及到多次自付
  1322. MutualAid frmMA = new MutualAid(Global.Set.settlID, "Z5");
  1323. if (frmMA.dtSettlInfo.Rows.Count != 0)
  1324. {
  1325. frmMA.WindowState = FormWindowState.Maximized;
  1326. if (frmMA.ShowDialog() == DialogResult.OK)
  1327. {
  1328. joSetlinfo = JObject.Parse(frmMA.finalSettlementInfo);
  1329. }
  1330. else
  1331. {
  1332. MessageBox.Show("注意:收费员取消医保账户代支结算,原结算仍需使用现金支付!");
  1333. }
  1334. }
  1335. else
  1336. {
  1337. MessageBox.Show("医保账户代支失败,未获取到账户代支使用人的原医保结算记录!");
  1338. }
  1339. }
  1340. #endregion
  1341. }
  1342. else
  1343. {
  1344. MessageBox.Show("注意:收费员取消医保账户代支结算,原结算仍需使用现金支付!");
  1345. //return;
  1346. }
  1347. #endregion
  1348. }
  1349. }
  1350. #endregion
  1351. //查询医保结算表本次主结算是否存在账户代支结算记录 如果没有 就把共济标志更新为0
  1352. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  1353. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr;
  1354. sqlStr = sqlStr + " AND MainSettlementIDOfMutualAid ='" + Global.Set.settlID + "'";
  1355. JObject joRtnSetl = iris.querySettlementInfo(sqlStr);
  1356. DataTable dt = (DataTable)joRtnSetl["result"]["data"].ToObject(typeof(DataTable));
  1357. if (dt.Rows.Count == 1)
  1358. {
  1359. //如果未使用医保账户代支结算,这里应该需要把前面保存的医保结算表记录里的 MainSettlementIDOfMutualAid="",MutualAidFlag=0
  1360. //更新云医保平台结算信息-09010080
  1361. if (mIS.updateSettlement(Global.Set.settlID, 0, out errMsg) != 0)
  1362. {
  1363. rtnResult = JsonHelper.setExceptionJson(-1, "更新云医保平台账户共济主结算信息失败", errMsg).ToString();
  1364. return rtnResult;
  1365. }
  1366. }
  1367. if (hIS.returnInpatSettlementInfo(joParam, joSetlinfo, out outParam) != 0)
  1368. {
  1369. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  1370. return rtnResult;
  1371. }
  1372. else
  1373. {
  1374. //返回给前端
  1375. JObject joHisServieRtn = JObject.Parse(outParam);
  1376. hBus.returnToFrontEndAfterSettlement(jo2304Rtn, joHisServieRtn, out outParam);
  1377. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  1378. return rtnResult;
  1379. }
  1380. }
  1381. }
  1382. }
  1383. case "Z5C"://住院结算撤销
  1384. {
  1385. //查询结算表
  1386. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and Hospital_Dr=" + Global.inf.hospitalDr
  1387. + " and Adm_Dr='" + Global.pat.adm_Dr + "'"
  1388. + " and MdtrtID='" + Global.pat.mdtrtID + "'"
  1389. + " Order By ID DESC ";
  1390. JObject joSql = new JObject();
  1391. joSql.Add("sqlStr", sqlStr);
  1392. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  1393. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  1394. //{
  1395. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  1396. // return rtnResult;
  1397. //}
  1398. //MessageBox.Show(joSettlInfo.ToString());
  1399. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  1400. Global.pat.SettID_YBJSB = JsonHelper.getDestValue(joSettlInfo, "result.data[0].SettlementID");
  1401. if (Global.pat.settlID != Global.pat.SettID_YBJSB)
  1402. {
  1403. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "通过09010059服务获取到的SettlementID<" + Global.pat.settlID + ">与DLL通过SQL语句" +
  1404. joSql + ",获取到的SettlementID<" + Global.pat.SettID_YBJSB + ">不同,可能存在HIS单边账,请联系医保开发人员处理该笔结算记录!").ToString();
  1405. //return rtnResult;
  1406. }
  1407. Global.pat.settlID = Global.pat.SettID_YBJSB;
  1408. //取消中心结算信息
  1409. if (cBus.cancleSettlement("2305", out outParam) != 0)
  1410. {
  1411. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算信息失败!", outParam).ToString();
  1412. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  1413. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  1414. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  1415. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  1416. JObject joSqlStr = new JObject();
  1417. joSqlStr.Add("sqlStr", SqlStr);
  1418. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  1419. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  1420. if (jaCancleSettlInfo.Count == 1)
  1421. {
  1422. //询问收款员是否继续进行HIS退费
  1423. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  1424. {
  1425. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  1426. }
  1427. }
  1428. else
  1429. {
  1430. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  1431. }
  1432. return rtnResult;
  1433. }
  1434. else
  1435. {
  1436. //退结算会返一个新的ID
  1437. string newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  1438. //取消平台结算信息
  1439. if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
  1440. {
  1441. rtnResult = JsonHelper.setExceptionJson(-1, "中心结算取消成功,医保平台结算信息取消失败!", outParam).ToString();
  1442. return rtnResult;
  1443. }
  1444. //中心取消传送
  1445. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  1446. {
  1447. //rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  1448. //return rtnResult;
  1449. }
  1450. //云平台取消传送
  1451. if (mIS.deleteFee(out errMsg) != 0)
  1452. {
  1453. //rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  1454. //return rtnResult;
  1455. }
  1456. //取消HIS医保结算信息
  1457. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  1458. {
  1459. rtnResult = JsonHelper.setExceptionJson(-1, "中心跟医保平台结算取消成功, 取消HIS结算信息失败!", outParam).ToString();
  1460. return rtnResult;
  1461. }
  1462. //取消出院登记
  1463. if (cBus.cancleRegister("2405", out outParam) != 0)
  1464. {
  1465. rtnResult = JsonHelper.setExceptionJson(0, "中心,医保平台及HIS结算信息取消成功,取消出院登记失败!请手工取消出院登记!", outParam).ToString();
  1466. return rtnResult;
  1467. }
  1468. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  1469. return rtnResult;
  1470. }
  1471. }
  1472. default:
  1473. {
  1474. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
  1475. return rtnResult;
  1476. }
  1477. }
  1478. return rtnResult;
  1479. }
  1480. catch (Exception ex)
  1481. {
  1482. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
  1483. return rtnResult;
  1484. }
  1485. finally
  1486. {
  1487. Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
  1488. }
  1489. }
  1490. /// <summary>
  1491. /// 辅助交易
  1492. /// </summary>
  1493. /// <param name="InParam"></param>
  1494. /// <returns></returns>
  1495. public string AgentFun(string InParam)
  1496. {
  1497. Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
  1498. //设置返回值,错误信息
  1499. int errCode;
  1500. string errMsg, rtnResult = "", outParam;
  1501. try
  1502. {
  1503. //解析入参
  1504. if (parseInparam(InParam, out errMsg) != 0)
  1505. {
  1506. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1507. return rtnResult;
  1508. }
  1509. //BS架构调用方式问题,每次调用都需要重新初始化
  1510. if (init(InParam, out outParam) != 0)
  1511. {
  1512. rtnResult = outParam;
  1513. return rtnResult;
  1514. }
  1515. //获取通用目录
  1516. string sTYML = mIS.GetCommonInterface_Dr(Global.inf.interfaceDr.ToString(), "");
  1517. if (sTYML == "")
  1518. Global.inf.interfaceDr_TY = Global.inf.interfaceDr;
  1519. else
  1520. Global.inf.interfaceDr_TY = int.Parse(sTYML);
  1521. //获取pat
  1522. //hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  1523. switch (businessType)
  1524. {
  1525. case "BasicData"://基础数据维护
  1526. {
  1527. BasicData bd = new BasicData();
  1528. if (bd.ShowDialog() != DialogResult.OK)
  1529. {
  1530. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出基础数据维护界面").ToString();
  1531. return rtnResult;
  1532. }
  1533. break;
  1534. }
  1535. case "Exception"://异常处理
  1536. {
  1537. //显示异常处理界面
  1538. HandleException frmEX = new HandleException();
  1539. if (frmEX.ShowDialog() != DialogResult.OK)
  1540. {
  1541. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出异常处理界面").ToString();
  1542. return rtnResult;
  1543. }
  1544. break;
  1545. }
  1546. case "CheckAndClearing"://对账清算
  1547. {
  1548. Clearing frmEX = new Clearing();
  1549. if (frmEX.ShowDialog() != DialogResult.OK)
  1550. {
  1551. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出对账清算界面").ToString();
  1552. return rtnResult;
  1553. }
  1554. break;
  1555. }
  1556. case "Print"://打印
  1557. {
  1558. //显示打印界面
  1559. SettlementBillPrint frmSettlList;
  1560. string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1561. if (insuAdmObj == "")
  1562. {
  1563. frmSettlList = new SettlementBillPrint();
  1564. if (frmSettlList.ShowDialog() != DialogResult.OK)
  1565. {
  1566. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出打印界面").ToString();
  1567. return rtnResult;
  1568. }
  1569. }
  1570. else
  1571. {
  1572. JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1573. frmSettlList = new SettlementBillPrint(joInsuAdmObj);
  1574. string groupID = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "groupID");
  1575. string userName = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "userName");
  1576. DataTable dt = (DataTable)frmSettlList.dgvSettlRecord.DataSource;
  1577. int i = frmSettlList.dgvSettlRecord.CurrentRow.Index;
  1578. string AdmID = dt.Rows[i]["AdmID"].ToString();
  1579. string PsnNo = dt.Rows[i]["PersonnelNO"].ToString();
  1580. string MdtrtID = dt.Rows[i]["MdtrtID"].ToString();
  1581. string SettlementID = dt.Rows[i]["SettlementID"].ToString();
  1582. Global.pat.adm_Dr = int.Parse(AdmID);
  1583. JObject joRtnFee = frmSettlList.UpdateMedInsuUploadData(AdmID, PsnNo, MdtrtID, SettlementID);
  1584. }
  1585. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  1586. break;
  1587. }
  1588. case "Log"://日志
  1589. {
  1590. MessageBox.Show(businessType);
  1591. break;
  1592. }
  1593. case "RecordUpload"://上传记录
  1594. {
  1595. MessageBox.Show(businessType);
  1596. break;
  1597. }
  1598. case "HospitalRegister"://备案
  1599. {
  1600. ToRecordFrom Referral = new ToRecordFrom();
  1601. if (Referral.ShowDialog() != DialogResult.OK)
  1602. {
  1603. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出备案信息界面").ToString();
  1604. return rtnResult;
  1605. }
  1606. break;
  1607. }
  1608. case "MutualAid"://医保账户代支
  1609. {
  1610. MutualAid frmMA = new MutualAid();
  1611. //frmMA.WindowState = FormWindowState.Maximized;
  1612. frmMA.ShowDialog();
  1613. break;
  1614. }
  1615. case "PrescribeCirculation"://医保处方流转
  1616. {
  1617. //PrescriptionCirculation PresCir = new PrescriptionCirculation();
  1618. PrescriptionCirculation PresCir = new PrescriptionCirculation("45050219890708002X");
  1619. if (PresCir.ShowDialog() != DialogResult.OK)
  1620. {
  1621. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保电子处方流转界面").ToString();
  1622. return rtnResult;
  1623. }
  1624. break;
  1625. }
  1626. case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
  1627. {
  1628. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1629. //Global.pat.psn_no = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].patn_id");
  1630. Global.pat.psn_no = JsonHelper.getDestValue(joInParam, "insuAdmObj.psn_no");
  1631. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].poolarea");
  1632. Global.pat.insuType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].insutype");
  1633. Global.pat.medType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].med_type");
  1634. JObject joResult = new JObject();
  1635. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  1636. string trig_scen = "4"; //住院
  1637. if (Global.pat.medType.Substring(0, 1) == "1")
  1638. trig_scen = "2"; //门诊
  1639. //事前分析
  1640. if (Global.curEvt.ext.isOpenAnalysis)
  1641. {
  1642. //if (hBus.PreAnalysis("2", joResult.ToString(), out errMsg) != 0) 20240614 苏国平、朱鹏飞要求更改
  1643. if (hBus.PreAnalysis(trig_scen, joResult.ToString(), out errMsg) != 0)
  1644. {
  1645. //MessageBox.Show(errMsg);
  1646. rtnResult = JsonHelper.setIrisReturnValue(-1, "医保事前事中服务:" + errMsg, null).ToString();
  1647. break;
  1648. }
  1649. else
  1650. {
  1651. rtnResult = JsonHelper.setIrisReturnValue(0, "医保事前事中服务" + errMsg, null).ToString();
  1652. }
  1653. }
  1654. else
  1655. {
  1656. rtnResult = JsonHelper.setIrisReturnValue(0, "事前事中服务接口未开启", null).ToString();
  1657. }
  1658. break;
  1659. }
  1660. case "MedInsuQuery"://医保查询
  1661. {
  1662. MedInsuQuery MedQuery = new MedInsuQuery();
  1663. if (MedQuery.ShowDialog() != DialogResult.OK)
  1664. {
  1665. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保查询界面").ToString();
  1666. return rtnResult;
  1667. }
  1668. break;
  1669. }
  1670. default:
  1671. {
  1672. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对!").ToString();
  1673. return rtnResult;
  1674. }
  1675. }
  1676. return rtnResult;
  1677. }
  1678. catch (Exception ex)
  1679. {
  1680. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
  1681. return rtnResult;
  1682. }
  1683. finally
  1684. {
  1685. Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
  1686. }
  1687. }
  1688. public string Download(string InParam)
  1689. {
  1690. Global.writeLog("Download 入参:" + JsonHelper.Compress(InParam));
  1691. //设置返回值,错误信息
  1692. int errCode;
  1693. string errMsg, rtnResult = "", outParam;
  1694. try
  1695. {
  1696. //解析入参
  1697. if (parseInparam(InParam, out errMsg) != 0)
  1698. {
  1699. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1700. return rtnResult;
  1701. }
  1702. //BS架构调用方式问题,每次调用都需要重新初始化
  1703. if (init(InParam, out outParam) != 0)
  1704. {
  1705. rtnResult = outParam;
  1706. return rtnResult;
  1707. }
  1708. dynamic joData = new JObject();
  1709. joData.data = joParam["data"];
  1710. //string code = (string)joInParam["code"];
  1711. string funNO = (string)joParam["funNO"];
  1712. switch (businessType)
  1713. {
  1714. case "DirectoryDownload":
  1715. {
  1716. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1717. rtnResult = hBus.DownloadDirectory(funNO, downloadParam).ToString();
  1718. break;
  1719. }
  1720. case "DictionayDownload":
  1721. {
  1722. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1723. rtnResult = hBus.downDictionary(downloadParam);
  1724. break;
  1725. }
  1726. }
  1727. return rtnResult;
  1728. }
  1729. catch (Exception ex)
  1730. {
  1731. rtnResult = JsonHelper.setExceptionJson(-100, "Download", ex.Message).ToString();
  1732. return rtnResult;
  1733. }
  1734. finally
  1735. {
  1736. Global.writeLog("Download 出参:" + rtnResult);
  1737. }
  1738. }
  1739. public string PlatformDirectConnect(string InParam)
  1740. {
  1741. //设置返回值,错误信息
  1742. int errCode;
  1743. string errMsg, rtnResult = "", outParam;
  1744. try
  1745. {
  1746. Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
  1747. //解析入参
  1748. if (parseInparam(InParam, out errMsg) != 0)
  1749. {
  1750. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1751. return rtnResult;
  1752. }
  1753. Global.businessType = businessType;
  1754. string funNO = JsonHelper.getDestValue(joInParam, "funNO");
  1755. //BS架构调用方式问题,每次调用都需要重新初始化
  1756. if (init(InParam, out outParam) != 0)
  1757. {
  1758. rtnResult = outParam;
  1759. return rtnResult;
  1760. }
  1761. JObject joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joParam));
  1762. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1763. {
  1764. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
  1765. return rtnResult;
  1766. }
  1767. else
  1768. {
  1769. rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
  1770. return rtnResult;
  1771. }
  1772. }
  1773. catch (Exception ex)
  1774. {
  1775. rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
  1776. return rtnResult;
  1777. }
  1778. finally
  1779. {
  1780. Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
  1781. }
  1782. }
  1783. }
  1784. }