InsuBusiness.cs 93 KB

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