InsuBusiness.cs 90 KB

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