InsuBusiness.cs 92 KB

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