MobilePay.cs 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.Common;
  3. using PTMedicalInsurance.Helper;
  4. using PTMedicalInsurance.Variables;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace PTMedicalInsurance.Business
  13. {
  14. class MobilePay
  15. {
  16. private HisIrisServices hIS = new HisIrisServices();
  17. private MIIrisServices mIS = new MIIrisServices();
  18. private CenterBusiness cBus = new CenterBusiness();
  19. private InvokeHelper invoker = new InvokeHelper();
  20. private Patients MPat;
  21. public Settlements MSettl;
  22. private JArray jaFee;
  23. //
  24. private string fixmedins_code;//定点医疗服务机构编码
  25. private string yhappid;//渠道ID
  26. private string orgId;//电子凭证机构号
  27. //前端传过来的入参,从这里面取值
  28. private JObject joParam;
  29. private JObject joInsuAdmObj;
  30. public MobilePay(string inpar,out string errMsg)
  31. {
  32. errMsg = "";
  33. try
  34. {
  35. //兰州普瑞眼视光医院
  36. if (Global.inf.interfaceDr == 21)
  37. {
  38. //正式环境
  39. Global.inf.AK = "1HORGG3BI05S75430B0A000062B6208A";
  40. Global.inf.SK = "XxTei2H2xUo/F4v/QbkdcQBxe/2gjyZjTnepVkbdcJ8=";
  41. Global.inf.appId = "1HORGG3BA05R75430B0A00004664FD75";
  42. Global.inf.publicKey = "BJlWERvnklYQa3/yXK5AcBtDzssnY1uubA5acDkIhDd828nJakZa40MQ6vHtAVgsflSE02GhVCWrEhYLzBtLuiY=";
  43. }
  44. //兰州普瑞眼科医院
  45. else if (Global.inf.interfaceDr == 25)
  46. {
  47. //测试环境
  48. //Global.inf.AK = "1H1INA1L90OH3F60C80A00008119D616";
  49. //Global.inf.SK = "APCIAgJqh3+AcK/IXL1WJD130i2q+6UblRxQzus3+sVw";
  50. //Global.inf.appId = "1H1INA1L30OG3F60C80A0000DEE43558";
  51. //Global.inf.publicKey = "BDMsMM2HPRkaKSl2ynBbCRtJodP8Nh4G5IkEnV+7YHaCplkAZbPMsUlvJpWqQ+Q4sT7611xGSZ1/mPsqgqJ49zs=";
  52. //正式环境
  53. Global.inf.AK = "1HV48IJ7I0091C450B0A000075EA02F9";
  54. Global.inf.SK = "PC9p8a2ktTPU7iwbjdGtkBoiHeHOOjB502Zlx3CNl60=";
  55. Global.inf.appId = "1HV48IJ7H0081C450B0A00002AAA2EDF";
  56. Global.inf.publicKey = "BFJpf2wHr0eDGPfcijLVDjkATjRb1M42F+RyKB0KPLQcXyOcMeQ2W4uv14w11XTMr7PGKit4wCXRf2z8aoFRSXo=";
  57. }
  58. JObject joInpar = JObject.Parse(inpar);
  59. joParam = JObject.Parse(JsonHelper.getDestValue(joInpar,"params[0]"));
  60. joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInpar, "insuAdmObj"));
  61. setPatientByInPar();
  62. setSettlementsByInPar();
  63. }
  64. catch (Exception ex)
  65. {
  66. errMsg = "MobilePay异常:" + ex.Message;
  67. }
  68. }
  69. public int MobilePaySettlement(out string outPar)
  70. {
  71. string errMsg,patInfo,YH6201Inpar,YH6201Rtn, YH6202Inpar, YH6202Rtn,YH6301Inpar,YH6301Rtn;
  72. outPar = "";
  73. try
  74. {
  75. EncryptHelper eh = new EncryptHelper();
  76. if (GetPatientInfo(out errMsg) != 0)
  77. {
  78. outPar = errMsg;
  79. return -1;
  80. }
  81. patInfo = errMsg;
  82. if (string.IsNullOrEmpty(Global.pat.insuplc_admdvs)) { Global.pat.insuplc_admdvs = "620100"; }
  83. JObject jo1101Rtn = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", patInfo));
  84. if (JsonHelper.parseCenterRtnValue(jo1101Rtn, out errMsg) != 0)
  85. {
  86. outPar = errMsg;
  87. return -1;
  88. }
  89. setPatientInsuInfo(jo1101Rtn);
  90. if (GetYH6201Inpar(out errMsg) != 0)
  91. {
  92. outPar = errMsg;
  93. return -1;
  94. }
  95. Global.writeLog(errMsg);
  96. YH6201Inpar = errMsg;
  97. //JObject joYH6201Rtn = invoker.invokeMPService("6201", eh.encrypt(errMsg));
  98. JObject joYH6201Rtn = invoker.invokeMPService("6201", errMsg);
  99. if (JsonHelper.parseMPRtnValue(joYH6201Rtn, out errMsg) != 0)
  100. {
  101. outPar = errMsg;
  102. return -1;
  103. }
  104. //JObject joEncData = JObject.Parse(eh.decrypt(errMsg));
  105. JObject joEncData = JObject.Parse(errMsg);
  106. Global.writeLog(JsonHelper.Compress(joEncData));
  107. //设置
  108. setPatientBy6201Rtn(joEncData);
  109. //存入MI 患者表,登记表,费用表
  110. if (saveToMi(out errMsg) != 0)
  111. {
  112. outPar = errMsg;
  113. return -1;
  114. }
  115. //YH6202
  116. if (GetYH6202Inpar(JObject.Parse(YH6201Inpar), out errMsg) != 0)
  117. {
  118. outPar = errMsg;
  119. return -1;
  120. }
  121. YH6202Inpar = errMsg;
  122. JObject joYH6202Rtn = invoker.invokeMPService("6202", YH6202Inpar);
  123. //JObject joYH6202Rtn = invoker.invokeMPService("6202", eh.encrypt(YH6202Inpar));
  124. if (JsonHelper.parseMPRtnValue(joYH6202Rtn, out errMsg) != 0)
  125. {
  126. outPar = errMsg;
  127. return -1;
  128. }
  129. //joEncData = JObject.Parse(eh.decrypt(errMsg));
  130. joEncData = JObject.Parse(errMsg);
  131. Global.writeLog(JsonHelper.Compress(joEncData));
  132. //设置
  133. setSettlementsBy6202Rtn(joEncData);
  134. MSettl.confirmFlag = 0;
  135. //存入MI 结算表
  136. if (saveSettlement (out errMsg) != 0)
  137. {
  138. outPar = errMsg;
  139. return -1;
  140. }
  141. //6301查询具体明细信息
  142. //if (GetYH6301Inpar(out errMsg) != 0)
  143. //{
  144. // outPar = errMsg;
  145. // return -1;
  146. //}
  147. //YH6301Inpar = errMsg;
  148. //JObject joYH6301Rtn = invoker.invokeMPService("6301", eh.encrypt(YH6301Inpar));
  149. //if (JsonHelper.parseMPRtnValue(joYH6301Rtn, out errMsg) != 0)
  150. //{
  151. // outPar = errMsg;
  152. // return -1;
  153. //}
  154. //joEncData = JObject.Parse(eh.decrypt(errMsg));
  155. //JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
  156. //Global.writeLog(JsonHelper.Compress(joEncData));
  157. ////设置
  158. //setSettlementsBy6301Rtn(joSettlInfo);
  159. ////存入MI 结算表
  160. //if (saveSettlement(out errMsg) != 0)
  161. //{
  162. // outPar = errMsg;
  163. //}
  164. //返回给HIS后端
  165. JObject joPreSettl = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.preSetl"));
  166. //JObject joTmp = JObject.Parse(JsonHelper.getDestValue(joYH6201Rtn, "encData"));
  167. JObject joTmp = new JObject();
  168. joTmp.Add("insutype", MPat.insuType);
  169. joTmp.Add("psn_no", MPat.psn_no);
  170. joTmp.Add("insuplc_admdvs", MPat.insuplc_admdvs);
  171. joTmp.Add("mdtrtId", MPat.mdtrtID);
  172. joTmp.Add("mdtrt_id", MPat.mdtrtID);
  173. joPreSettl.Add("setl_id", MPat.payOrdId);
  174. joTmp.Add("mdtrt_cert_type", JsonHelper.getDestValue(joPreSettl, "mdtrt_cert_type"));
  175. joTmp.Add("mdtrt_cert_no", JsonHelper.getDestValue(joPreSettl, "certno"));
  176. joTmp.Add("med_type", JsonHelper.getDestValue(joPreSettl, "med_type"));
  177. if (returnMPSettlementInfo(joTmp, joPreSettl, out errMsg) != 0)
  178. {
  179. outPar = errMsg;
  180. return -1;
  181. }
  182. //返回给HIS前端
  183. outPar = errMsg;
  184. return 0;
  185. }
  186. catch (Exception ex)
  187. {
  188. outPar = ex.Message;
  189. return -1;
  190. }
  191. }
  192. public int MobilePayConfirmSettlement(out string outPar)
  193. {
  194. string errMsg, M6301Inpar;
  195. outPar = "";
  196. try
  197. {
  198. //EncryptHelper eh = new EncryptHelper();
  199. //6301查询具体明细信息
  200. if (Get6301Inpar(out errMsg) != 0)
  201. {
  202. outPar = errMsg;
  203. return -1;
  204. }
  205. M6301Inpar = errMsg;
  206. JObject joM6301Rtn = invoker.invokeMPService("6301", M6301Inpar);
  207. if (JsonHelper.parseMPRtnValue(joM6301Rtn, out errMsg) != 0)
  208. {
  209. outPar = errMsg;
  210. return -1;
  211. }
  212. JObject joEncData = JObject.Parse(errMsg);
  213. JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
  214. //设置
  215. setSettlementsBy6301Rtn(joSettlInfo);
  216. MSettl.confirmFlag = 1;
  217. //存入MI 结算表
  218. if (updateSettlement(out errMsg) != 0)
  219. {
  220. outPar = errMsg;
  221. return -1;
  222. }
  223. else
  224. {
  225. //返回给HIS前端
  226. outPar = JsonHelper.setExceptionJson(0, "云医保平台", "确认成功!").ToString();
  227. return 0;
  228. }
  229. }
  230. catch (Exception ex)
  231. {
  232. outPar = ex.Message;
  233. return -1;
  234. }
  235. }
  236. public int MobilePayCancelSettlement(out string outPar)
  237. {
  238. string errMsg, YH6203Inpar, YH6203Rtn;
  239. outPar = "";
  240. try
  241. {
  242. EncryptHelper eh = new EncryptHelper();
  243. if (MSettl.onlineYBFalg != "Y")
  244. {
  245. //读电子凭证
  246. //if (ReadEc(out errMsg) != 0)
  247. //{
  248. // outPar = errMsg;
  249. // return -1;
  250. //}
  251. //测试环境地址
  252. //Global.inf.ecURL = "http://10.126.40.13:8080/localcfc/api/hsecfc/localQrCodeQuery";
  253. HisMainBusiness hBus = new HisMainBusiness();
  254. if (hBus.readCard(out errMsg) != 0)
  255. {
  256. outPar = JsonHelper.setExceptionJson(-100, "读卡失败!", errMsg).ToString();
  257. return -1;
  258. }
  259. MPat.token = Global.pat.mdtrtcertNO;
  260. }
  261. //获取6203入参
  262. if (Get6203Inpar(out errMsg) != 0)
  263. {
  264. outPar = errMsg;
  265. return -1;
  266. }
  267. YH6203Inpar = errMsg;
  268. JObject jo6203Rtn = invoker.invokeMPService("6203", YH6203Inpar);
  269. //YH6202
  270. if (JsonHelper.parseMPRtnValue(jo6203Rtn, out errMsg) != 0)
  271. {
  272. outPar = errMsg;
  273. return -1;
  274. }
  275. else
  276. {
  277. JObject joEncData = JObject.Parse(errMsg);
  278. string newSettlID = JsonHelper.getDestValue(joEncData, "extData.setlInfo.setl_id");
  279. //处理撤销数据
  280. if (cancleSettlement(MPat.settlID, out errMsg) != 0)
  281. {
  282. outPar = errMsg;
  283. return -1;
  284. }
  285. //joParam.Add("mdtrt_id", MPat.mdtrtID);
  286. //joParam.Add("insuplc_admdvs", MPat.insuplc_admdvs);
  287. //joParam.Add("setl_id", MPat.settlID);
  288. joParam.Add("middleSettleFlag", "");
  289. //退HIS结算
  290. if (hIS.cancleSettlementInfo(joParam, out errMsg) != 0)
  291. {
  292. outPar = errMsg;
  293. return -1;
  294. }
  295. else
  296. {
  297. outPar = errMsg;
  298. return 0;
  299. }
  300. }
  301. }
  302. catch (Exception ex)
  303. {
  304. Global.writeLog("MobilePayCancelSettlement:" + ex.Message);
  305. outPar = ex.Message;
  306. return -1;
  307. }
  308. }
  309. public int MobilePayCallbackSettlement(out string outPar)
  310. {
  311. string errMsg;
  312. outPar = "";
  313. try
  314. {
  315. if (Get6302Result(out errMsg) != 0)
  316. {
  317. JObject joResult = new JObject();
  318. JObject joData = new JObject();
  319. joData.Add("success", "false");
  320. joData.Add("message", errMsg);
  321. joResult.Add("data", joData);
  322. joResult.Add("errorCode", -1);
  323. joResult.Add("result", joData);
  324. outPar = joResult.ToString();
  325. return -1;
  326. }
  327. else
  328. {
  329. JObject joResult = new JObject();
  330. JObject joData = new JObject();
  331. joData.Add("success", "true");
  332. joData.Add("message", errMsg);
  333. joResult.Add("data", joData);
  334. joResult.Add("errorCode", 0);
  335. joResult.Add("result", joData);
  336. outPar = joResult.ToString();
  337. return 0;
  338. }
  339. }
  340. catch (Exception ex)
  341. {
  342. outPar = "MobilePayCallbackSettlement:" + ex.Message;
  343. return -1;
  344. }
  345. finally
  346. {
  347. Global.writeLog("MobilePayCallbackSettlement", "", outPar);
  348. }
  349. }
  350. //组织M6203入参
  351. public int Get6203Inpar(out string outparam)
  352. {
  353. string errMsg = "";
  354. outparam = "";
  355. try
  356. {
  357. JObject joInpar = new JObject();
  358. //获取医保平台结算信息
  359. if (QuerySettleInfo(out errMsg) != 0)
  360. {
  361. outparam = errMsg;
  362. return -1;
  363. }
  364. JObject joRtn = JObject.Parse(errMsg);
  365. JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "result.data[0]"));
  366. MPat.settlID = JsonHelper.getDestValue(joSettl, "SettlementID");
  367. //MPat.mdtrtID = JsonHelper.getDestValue(joSettl, "MdtrtID");
  368. //入参
  369. joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "PayOrdID"));//支付订单号
  370. joInpar.Add("appRefdSn", MPat.recordID);//应用退款流水号
  371. joInpar.Add("appRefdTime", DateTime.Now.ToString("yyyyMMddHHmmss"));//应用退费时间
  372. joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
  373. joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
  374. joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
  375. joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joSettl, "PersonCashPay"));//现金退费金额
  376. joInpar.Add("ecToken", MPat.token);//电子凭证授权Token 前端传入
  377. joInpar.Add("refdType", "HI");//退费类型 前端传入
  378. joInpar.Add("expContent", "");//扩展数据 前端传入
  379. joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
  380. //JObject joData = new JObject();
  381. //joData.Add("data", joInpar);
  382. outparam = joInpar.ToString();
  383. return 0;
  384. }
  385. catch (Exception ex)
  386. {
  387. outparam = "GetYH6203Inpar:" + ex.Message;
  388. return -1;
  389. }
  390. finally
  391. {
  392. Global.writeLog("GetYH6203Inpar", "", outparam);
  393. }
  394. }
  395. public int Get6302Result(out string outparam)
  396. {
  397. string errMsg = "";
  398. outparam = "";
  399. try
  400. {
  401. JObject joInpar = new JObject();
  402. //获取医保平台结算信息
  403. if (QuerySettleInfoBy6302(out errMsg) != 0)
  404. {
  405. outparam = errMsg;
  406. return -1;
  407. }
  408. JObject joRtn = JObject.Parse(errMsg);
  409. JArray jaSettl = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.data"));
  410. if (jaSettl.Count != 1)
  411. {
  412. outparam = "该订单数据不唯一!";
  413. return -1;
  414. }
  415. else
  416. {
  417. //if (jaSettl[0]["ConfirmFlag"].ToString() != "1")
  418. //{
  419. // outparam = "确认标志不为1!";
  420. // return -1;
  421. //}
  422. //else
  423. {
  424. outparam = "回调成功!查询正确!";
  425. return 0;
  426. }
  427. }
  428. }
  429. catch (Exception ex)
  430. {
  431. outparam = "Get6302Result:" + ex.Message;
  432. return -1;
  433. }
  434. finally
  435. {
  436. Global.writeLog("Get6302Result", "", outparam);
  437. }
  438. }
  439. public int QuerySettleInfoBy6302(out string errMsg)
  440. {
  441. errMsg = "";
  442. try
  443. {
  444. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr= " + Global.inf.hospitalDr;
  445. sqlStr = sqlStr + " and AdmType = 3 and PayOrdID= '" + MPat.payOrdId + "'";
  446. JObject joSqlstr = new JObject();
  447. joSqlstr.Add("sqlStr", sqlStr);
  448. JObject joRtn = mIS.DynamicQuerySettlInfo(joSqlstr);
  449. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  450. {
  451. return -1;
  452. }
  453. else
  454. {
  455. errMsg = joRtn.ToString();
  456. return 0;
  457. }
  458. }
  459. catch (Exception ex)
  460. {
  461. errMsg = ex.Message;
  462. return -1;
  463. }
  464. }
  465. #region 读卡
  466. public int ReadEc(out string outParam)
  467. {
  468. outParam = "";
  469. JObject joInput = new JObject();
  470. try
  471. {
  472. STA sta = new STA();
  473. object[] o = new object[2];
  474. sta.ReadCard(o);
  475. if (int.Parse(o[0].ToString()) != 0)
  476. {
  477. outParam = o[1].ToString();
  478. return -1;
  479. }
  480. else
  481. {
  482. outParam = o[1].ToString();
  483. return 0;
  484. }
  485. }
  486. catch (Exception ex)
  487. {
  488. outParam = "异常:" + ex.Message;
  489. return -1;
  490. }
  491. }
  492. #endregion
  493. #region 赋值MPat,Msettle结构体
  494. public void setPatientByInPar()
  495. {
  496. MPat.adm_Dr = int.Parse(JsonHelper.getDestValue(joParam, "admID"));
  497. Global.pat.adm_Dr = MPat.adm_Dr;
  498. MPat.recordID = JsonHelper.getDestValue(joParam, "recordID");
  499. MPat.billID = JsonHelper.getDestValue(joParam, "billID");
  500. MPat.medType = JsonHelper.getDestValue(joInsuAdmObj, "medType");
  501. MPat.certType = JsonHelper.getDestValue(joInsuAdmObj, "mdtrtCertType");
  502. MPat.token = JsonHelper.getDestValue(joInsuAdmObj, "ecToken");
  503. MPat.payAuthNo = JsonHelper.getDestValue(joInsuAdmObj, "payAuthNo");
  504. MPat.uldLatlnt = JsonHelper.getDestValue(joInsuAdmObj, "uldLatlnt");
  505. MPat.payOrdId = JsonHelper.getDestValue(joInsuAdmObj, "payOrdId");
  506. MPat.mdtrtID = JsonHelper.getDestValue(joInsuAdmObj, "mdtrt_id");
  507. Global.pat.mdtrtID = MPat.mdtrtID;
  508. }
  509. public void setPatientByEc(JObject jo)
  510. {
  511. MPat.name = JsonHelper.getDestValue(jo, "userName");
  512. MPat.IDNO = JsonHelper.getDestValue(jo, "idNo");
  513. MPat.certType = JsonHelper.getDestValue(jo, "idType");
  514. MPat.token = JsonHelper.getDestValue(jo, "ecToken");
  515. MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuOrg");
  516. MPat.payAuthNo = JsonHelper.getDestValue(jo, "authNo");
  517. MPat.gend = JsonHelper.getDestValue(jo, "gender");
  518. MPat.brdy = JsonHelper.getDestValue(jo, "birthday");
  519. MPat.naty = JsonHelper.getDestValue(jo, "nationality");
  520. MPat.payOrdId = "";
  521. }
  522. public void setPatientBy6201Rtn(JObject jo)
  523. {
  524. MPat.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
  525. MPat.payToken = JsonHelper.getDestValue(jo, "payToken");
  526. //MPat.psn_no = JsonHelper.getDestValue(jo, "psn_no");
  527. //MPat.insuType = JsonHelper.getDestValue(jo, "insutype");
  528. //MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuplc_admdvs");
  529. MPat.mdtrtID = JsonHelper.getDestValue(jo, "extData.mdtrtId");
  530. }
  531. //{"errorCode":0,"errorMessage":"","result":{"patName":"张振","patBirthdate":"1993-02-07","patSex":"男","credCode":"01","credNo":"522226199302073619"}}
  532. public void setPatientByHisBaseInfo(JObject jo)
  533. {
  534. MPat.name = JsonHelper.getDestValue(jo, "result.patName");
  535. MPat.brdy = JsonHelper.getDestValue(jo, "result.patBirthdate");
  536. MPat.gend = JsonHelper.getDestValue(jo, "result.patSex");
  537. MPat.age = JsonHelper.getDestValue(jo, "result.Age");
  538. MPat.naty = JsonHelper.getDestValue(jo, "result.naty");
  539. MPat.certNO = JsonHelper.getDestValue(jo, "result.credNo");
  540. MPat.IDNO = MPat.certNO;
  541. MPat.certType = JsonHelper.getDestValue(jo, "result.credCode");
  542. }
  543. public void setPatientByMiRegInfo(JObject jo)
  544. {
  545. MPat.name = JsonHelper.getDestValue(jo, "data.PatientName");
  546. MPat.psn_no = JsonHelper.getDestValue(jo, "data.PersonalNO");
  547. MPat.certNO = JsonHelper.getDestValue(jo, "data.CertificateNO");
  548. MPat.IDNO = MPat.certNO;
  549. MPat.certType = JsonHelper.getDestValue(jo, "data.CertificateType");
  550. MPat.payToken = JsonHelper.getDestValue(jo, "data.payToken");
  551. MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "data.InsuranceAreaCode");
  552. }
  553. public void setPatientInsuInfo(JObject jo)
  554. {
  555. MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "output.insuinfo[0].insuplc_admdvs");
  556. MPat.psn_no = JsonHelper.getDestValue(jo, "output.baseinfo.psn_no");
  557. MPat.insuType = JsonHelper.getDestValue(jo, "output.insuinfo[0].insutype");
  558. Global.pat.insuplc_admdvs = MPat.insuplc_admdvs;
  559. Global.pat.psn_no = MPat.psn_no;
  560. Global.pat.insuType = MPat.insuType;
  561. }
  562. public void setPatientByDiagnoseInfo(JObject jo)
  563. {
  564. MPat.admAttendDoctorNO = JsonHelper.getDestValue(jo, "atddr_no");
  565. MPat.admDiagCode = JsonHelper.getDestValue(jo, "dscg_maindiag_code");
  566. MPat.admDiagName = JsonHelper.getDestValue(jo, "dscg_maindiag_name");
  567. MPat.AdmInDepCode = JsonHelper.getDestValue(jo, "adm_dept_codg");
  568. }
  569. public void setSettlementsBy6202Rtn(JObject jo)
  570. {
  571. MSettl.settlID = JsonHelper.getDestValue(jo, "payOrdId");
  572. MPat.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
  573. MSettl.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
  574. MSettl.ordStas = JsonHelper.getDestValue(jo, "ordStas");
  575. MSettl.sumamt = getDecimalFee(jo, "feeSumamt");
  576. MSettl.personCashPay = getDecimalFee(jo, "ownPayAmt");
  577. MSettl.accountPaySumamt = getDecimalFee(jo, "psnAcctPay");
  578. MSettl.fundPaySumamt = getDecimalFee(jo, "fundPay");
  579. MSettl.deposit = getDecimalFee(jo, "deposit");
  580. MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "extData.preSetl.clr_optins");
  581. MSettl.clearingType = JsonHelper.getDestValue(jo, "extData.preSetl.clr_type");
  582. MSettl.clearingWay = JsonHelper.getDestValue(jo, "extData.preSetl.clr_way");
  583. MSettl.civilserviceAllowancePay = getDecimalFee(jo, "extData.preSetl.cvlserv_pay");
  584. MSettl.ownPayAmount = getDecimalFee(jo, "extData.preSetl.fulamt_ownpay_amt");
  585. MSettl.overLimitAmountmt = getDecimalFee(jo, "extData.preSetl.overlmt_selfpay");
  586. MSettl.preSelfPayAmount = getDecimalFee(jo, "extData.preSetl.preselfpay_amt");
  587. MSettl.inPolicyRangeAmount = getDecimalFee(jo, "extData.preSetl.inscp_scp_amt");
  588. MSettl.actualPayDeductible = getDecimalFee(jo, "extData.preSetl.act_pay_dedc");
  589. MSettl.healthInsurancePay = getDecimalFee(jo, "extData.preSetl.hifp_pay");
  590. MSettl.healthInsuranceRatio = getDecimalFee(jo, "extData.preSetl.pool_prop_selfpay");
  591. MSettl.enterpriseSupplementPay = getDecimalFee(jo, "extData.preSetl.hifes_pay");
  592. MSettl.seriousIllnessPay = getDecimalFee(jo, "extData.preSetl.hifmi_pay");
  593. MSettl.largeExpensesSupplementPay = getDecimalFee(jo, "extData.preSetl.hifob_pay");
  594. MSettl.medicalAssistPay = getDecimalFee(jo, "extData.preSetl.maf_pay");
  595. MSettl.hospitalPartAmount = getDecimalFee(jo, "extData.preSetl.hosp_part_amt");
  596. MSettl.otherPay = getDecimalFee(jo, "extData.preSetl.oth_pay");
  597. MSettl.personPaySumamt = getDecimalFee(jo, "extData.preSetl.psn_part_amt");
  598. MSettl.balance = getDecimalFee(jo, "extData.preSetl.balc");
  599. MSettl.accountMutualAidAmount = getDecimalFee(jo, "extData.preSetl.acct_mulaid_pay");
  600. }
  601. public void setSettlementsBy6301Rtn(JObject jo)
  602. {
  603. MSettl.settlID = JsonHelper.getDestValue(jo, "setl_id");
  604. MPat.psn_no = JsonHelper.getDestValue(jo, "psn_no");
  605. MPat.naty = JsonHelper.getDestValue(jo, "naty");
  606. //MPat.name = JsonHelper.getDestValue(jo, "name");
  607. MPat.age = JsonHelper.getDestValue(jo, "age");
  608. MPat.gend = JsonHelper.getDestValue(jo, "gend");
  609. MPat.certNO = JsonHelper.getDestValue(jo, "certno");
  610. MPat.brdy = JsonHelper.getDestValue(jo, "brdy");
  611. MPat.insuType = JsonHelper.getDestValue(jo, "insutype");
  612. MPat.psn_type = JsonHelper.getDestValue(jo, "psn_type");
  613. MPat.mdtrtcertType = JsonHelper.getDestValue(jo, "mdtrt_cert_type");
  614. MPat.medType = JsonHelper.getDestValue(jo, "med_type");
  615. //MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuplc_admdvs");
  616. //MPat.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
  617. MSettl.ordStas = JsonHelper.getDestValue(jo, "ordStas");
  618. MSettl.sumamt = getDecimalFee(jo, "medfee_sumamt");
  619. MSettl.personCashPay = getDecimalFee(jo, "psn_cash_pay");
  620. MSettl.accountPaySumamt = getDecimalFee(jo, "acct_pay");
  621. MSettl.fundPaySumamt = getDecimalFee(jo, "fund_pay_sumamt");
  622. //MSettl.deposit = getDecimalFee(jo, "deposit");
  623. MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "clr_optins");
  624. MSettl.clearingType = JsonHelper.getDestValue(jo, "clr_type");
  625. MSettl.clearingWay = JsonHelper.getDestValue(jo, "clr_way");
  626. MSettl.civilserviceAllowancePay = getDecimalFee(jo, "cvlserv_pay");
  627. MSettl.ownPayAmount = getDecimalFee(jo, "fulamt_ownpay_amt");
  628. MSettl.overLimitAmountmt = getDecimalFee(jo, "overlmt_selfpay");
  629. MSettl.preSelfPayAmount = getDecimalFee(jo, "preselfpay_amt");
  630. MSettl.inPolicyRangeAmount = getDecimalFee(jo, "inscp_scp_amt");
  631. MSettl.actualPayDeductible = getDecimalFee(jo, "act_pay_dedc");
  632. MSettl.healthInsurancePay = getDecimalFee(jo, "hifp_pay");
  633. MSettl.healthInsuranceRatio = getDecimalFee(jo, "pool_prop_selfpay");
  634. MSettl.enterpriseSupplementPay = getDecimalFee(jo, "hifes_pay");
  635. MSettl.seriousIllnessPay = getDecimalFee(jo, "hifmi_pay");
  636. MSettl.largeExpensesSupplementPay = getDecimalFee(jo, "hifob_pay");
  637. MSettl.medicalAssistPay = getDecimalFee(jo, "maf_pay");
  638. MSettl.hospitalPartAmount = getDecimalFee(jo, "hosp_part_amt");
  639. MSettl.otherPay = getDecimalFee(jo, "oth_pay");
  640. MSettl.personPaySumamt = getDecimalFee(jo, "psn_part_amt");
  641. MSettl.balance = getDecimalFee(jo, "balc");
  642. MSettl.accountMutualAidAmount = getDecimalFee(jo, "acct_mulaid_pay");
  643. }
  644. public void setSettlementsByInPar()
  645. {
  646. MSettl.clearingWay = JsonHelper.getDestValue(joInsuAdmObj, "psnSetlway");
  647. MSettl.settlID = JsonHelper.getDestValue(joInsuAdmObj, "payOrdId");
  648. MSettl.payOrdId = JsonHelper.getDestValue(joInsuAdmObj, "payOrdId");
  649. }
  650. #endregion
  651. #region 组织入参
  652. public int GetPatientInfo(out string outparam)
  653. {
  654. string errMsg = "";
  655. outparam = "";
  656. try
  657. {
  658. JObject joInpar = new JObject();
  659. //查询患者基本信息
  660. if (hIS.GetHisPatBaseInfo(out errMsg) != 0)
  661. {
  662. outparam = errMsg;
  663. return -1;
  664. }
  665. setPatientByHisBaseInfo(JObject.Parse(errMsg));
  666. //入参
  667. joInpar.Add("mdtrt_cert_type", "02");//就诊凭证类型
  668. joInpar.Add("mdtrt_cert_no", MPat.certNO);//就诊凭证编号
  669. joInpar.Add("card_sn", "");//卡识别码
  670. joInpar.Add("begntime", "");//开始时间 获取历史参保信息时传入
  671. joInpar.Add("psn_cert_type", "01");//就诊凭证类型为“ 02” 时默认传 01 代表身份 证,其他证件类型按实际上传
  672. joInpar.Add("certno", MPat.certNO);//证件号码
  673. joInpar.Add("psn_name", MPat.name);//姓名
  674. JObject joData = new JObject();
  675. joData.Add("data", joInpar);
  676. outparam = joData.ToString();
  677. return 0;
  678. }
  679. catch (Exception ex)
  680. {
  681. outparam = "GetPatientInfo:" + ex.Message;
  682. return -1;
  683. }
  684. finally
  685. {
  686. Global.writeLog("GetPatientInfo", "", outparam);
  687. }
  688. }
  689. //组织YH6201入参
  690. public int GetYH6201Inpar(out string outparam)
  691. {
  692. string errMsg = "";
  693. outparam = "";
  694. try
  695. {
  696. JObject joInpar = new JObject();
  697. //查询患者基本信息
  698. if (hIS.GetHisPatBaseInfo(out errMsg) != 0)
  699. {
  700. outparam = errMsg;
  701. return -1;
  702. }
  703. setPatientByHisBaseInfo(JObject.Parse(errMsg));
  704. JObject joPatBaseInfo = JObject.Parse(JsonHelper.getDestValue(JObject.Parse(errMsg),"result"));
  705. //获取诊断
  706. if (getDiagnoses(out errMsg) != 0)
  707. {
  708. outparam = errMsg;
  709. return -1;
  710. }
  711. JObject joDiagnoses = JObject.Parse(errMsg);
  712. JArray jaDiseinfoList = JArray.Parse(JsonHelper.getDestValue(joDiagnoses, "diseinfoList"));
  713. JObject joMdtrtinfo = JObject.Parse(JsonHelper.getDestValue(joDiagnoses, "mdtrtinfo"));
  714. setPatientByDiagnoseInfo(joMdtrtinfo);
  715. //获取费用
  716. if (GetFee(out errMsg) != 0)
  717. {
  718. outparam = errMsg;
  719. return -1;
  720. }
  721. JObject joFee = JObject.Parse(errMsg);
  722. JArray jaFeedetailList = JArray.Parse(JsonHelper.getDestValue(joFee, "feedetailList"));
  723. for (int i = 0; i < jaFeedetailList.Count; i++)
  724. {
  725. JObject joTmp = new JObject();
  726. joTmp.Add("act_purc_pric", jaFeedetailList[i]["pric"]);
  727. joTmp.Add("sin_dos", jaFeedetailList[i]["sinDosDscr"]);
  728. joTmp.Add("medins_list_name", jaFeedetailList[i]["medListName"]);
  729. ((JObject)jaFeedetailList[i]).Property("chrgBchno").Remove();
  730. ((JObject)jaFeedetailList[i]).Property("diseCodg").Remove();
  731. ((JObject)jaFeedetailList[i]).Property("rxno").Remove();
  732. ((JObject)jaFeedetailList[i]).Property("feeOcurTime").Remove();
  733. ((JObject)jaFeedetailList[i]).Property("sinDosDscr").Remove();
  734. ((JObject)jaFeedetailList[i]).Property("usedFrquDscr").Remove();
  735. ((JObject)jaFeedetailList[i]).Property("prdDays").Remove();
  736. ((JObject)jaFeedetailList[i]).Property("medcWayDscr").Remove();
  737. //((JObject)jaFeedetailList[i]).Property("bilgDeptCodg").Remove();
  738. ((JObject)jaFeedetailList[i]).Property("acordDeptCodg").Remove();
  739. ((JObject)jaFeedetailList[i]).Property("acordDeptName").Remove();
  740. ((JObject)jaFeedetailList[i]).Property("ordersDrCode").Remove();
  741. ((JObject)jaFeedetailList[i]).Property("ordersDrName").Remove();
  742. ((JObject)jaFeedetailList[i]).Property("tcmdrugUsedWay").Remove();
  743. ((JObject)jaFeedetailList[i]).Property("etipFlag").Remove();
  744. ((JObject)jaFeedetailList[i]).Property("etipHospCode").Remove();
  745. ((JObject)jaFeedetailList[i]).Property("dscgTkdrugFlag").Remove();
  746. ((JObject)jaFeedetailList[i]).Property("matnFeeFlag").Remove();
  747. ((JObject)jaFeedetailList[i]).Property("initFeedetlSn").Remove();
  748. ((JObject)jaFeedetailList[i]).Property("medType").Remove();
  749. ((JObject)jaFeedetailList[i]).Property("memo").Remove();
  750. //((JObject)jaFeedetailList[i]).Property("expContent").Remove();
  751. ((JObject)jaFeedetailList[i]).Property("medListName").Remove();
  752. ((JObject)jaFeedetailList[i]).Property("medListSpc").Remove();
  753. ((JObject)jaFeedetailList[i]).Property("combNo").Remove();
  754. //jaFeedetailList[i]["chrgBchno"] = MPat.adm_Dr.ToString();
  755. jaFeedetailList[i]["expContent"] = joTmp.ToString().Replace("\r\n","");
  756. jaFeedetailList[i]["medType"] = JsonHelper.getDestValue(joInsuAdmObj, "medType");
  757. jaFeedetailList[i]["psnNo"] = new JObject();
  758. jaFeedetailList[i]["psnNo"] = MPat.psn_no;
  759. }
  760. //入参
  761. joInpar.Add("orgCodg", Global.inf.hospitalNO);//机构编码
  762. //joInpar.Add("orgId", "");//电子凭证机构号
  763. joInpar.Add("psnNo", MPat.psn_no);//人员编号
  764. joInpar.Add("insutype", MPat.insuType);//险种类型
  765. joInpar.Add("medOrgOrd", MPat.recordID);//医疗机构订单号 前端传入
  766. //joInpar.Add("initRxOrd", JsonHelper.getDestValue(joInsuAdmObj, "initRxOrd"));//要续方的原处方流水 前端传入
  767. //joInpar.Add("rxCircFlag", JsonHelper.getDestValue(joInsuAdmObj, "rxCircFlag"));//电子处方流转标志 前端传入
  768. MSettl.settlTime = Convert.ToDateTime(JsonHelper.getDestValue(joMdtrtinfo, "begntime"));
  769. //joInpar.Add("begntime", JsonHelper.getDestValue(joMdtrtinfo, "begntime"));//开始时间
  770. joInpar.Add("idNo", JsonHelper.getDestValue(joPatBaseInfo, "credNo"));//证件号码
  771. joInpar.Add("userName", JsonHelper.getDestValue(joPatBaseInfo, "patName"));//用户姓名
  772. joInpar.Add("idType", JsonHelper.getDestValue(joPatBaseInfo, "credCode"));//证件类别
  773. joInpar.Add("ecToken", JsonHelper.getDestValue(joInsuAdmObj, "ecToken"));//电子凭证授权ecToken 前端传入
  774. joInpar.Add("insuCode", Global.inf.areaCode);//就诊参保地行政区划
  775. joInpar.Add("insuplcAdmdvs", Global.pat.insuplc_admdvs);//
  776. joInpar.Add("iptOtpNo", JsonHelper.getDestValue(joMdtrtinfo, "ipt_no"));//住院/门诊号
  777. joInpar.Add("atddrNo", JsonHelper.getDestValue(joMdtrtinfo, "atddr_no"));//医师编码
  778. joInpar.Add("drName", JsonHelper.getDestValue(joMdtrtinfo, "chfpdr_name"));//医师姓名
  779. joInpar.Add("deptCode", JsonHelper.getDestValue(joMdtrtinfo, "adm_dept_codg"));//科室编码
  780. joInpar.Add("deptName", JsonHelper.getDestValue(joMdtrtinfo, "adm_dept_name"));//科室名称
  781. joInpar.Add("caty", "A10");//科别
  782. joInpar.Add("mdtrtId", JsonHelper.getDestValue(joMdtrtinfo, "mdtrtId"));//就诊ID
  783. joInpar.Add("medType", MPat.medType);//医疗类别 前端传入
  784. joInpar.Add("feeType", JsonHelper.getDestValue(joInsuAdmObj, "feeType"));//费用类型 前端传入
  785. joInpar.Add("medfeeSumamt", JsonHelper.getDestValue(joFee, "medfeeSumamt"));//医疗费总额
  786. //joInpar.Add("acctUsedFlag", JsonHelper.getDestValue(joInsuAdmObj, "acctUsedFlag"));//个人账户使用标志 前端传入
  787. //joInpar.Add("mainCondDscr", JsonHelper.getDestValue(joMdtrtinfo, "mainCondDscr"));//主要病情描述
  788. //joInpar.Add("diseCodg", JsonHelper.getDestValue(joMdtrtinfo, "diseCodg"));//病种编码
  789. //joInpar.Add("diseName", JsonHelper.getDestValue(joMdtrtinfo, "diseName"));//病种名称
  790. //joInpar.Add("psnSetlway", JsonHelper.getDestValue(joInsuAdmObj, "psnSetlway"));//个人结算方式 前端传入
  791. joInpar.Add("chrgBchno", JsonHelper.getDestValue(joFee, "chrgBchno"));//收费批次号
  792. //joInpar.Add("pubHospRfomFlag", JsonHelper.getDestValue(joInsuAdmObj, "pubHospRfomFlag"));//公立医院改革标志
  793. //joInpar.Add("invono", JsonHelper.getDestValue(joMdtrtinfo, "invono"));//发票号
  794. //joInpar.Add("endtime", JsonHelper.getDestValue(joMdtrtinfo, "endtime"));//出院时间
  795. //joInpar.Add("fulamtOwnpayAmt", JsonHelper.getDestValue(joMdtrtinfo, "fulamtOwnpayAmt"));//全自费金额
  796. //joInpar.Add("overlmtSelfpay", JsonHelper.getDestValue(joMdtrtinfo, "overlmtSelfpay"));//超限价金额
  797. //joInpar.Add("preselfpayAmt", JsonHelper.getDestValue(joMdtrtinfo, "preselfpayAmt"));//先行自付金额
  798. //joInpar.Add("inscpScpAmt", JsonHelper.getDestValue(joMdtrtinfo, "inscpScpAmt"));//符合政策范围金额
  799. //joInpar.Add("oprnOprtCode", JsonHelper.getDestValue(joMdtrtinfo, "oprnOprtCode"));//手术操作代码
  800. //joInpar.Add("oprnOprtName", JsonHelper.getDestValue(joMdtrtinfo, "oprnOprtName"));//手术操作名称
  801. //joInpar.Add("fpscNo", JsonHelper.getDestValue(joMdtrtinfo, "fpscNo"));//计划生育服务证号
  802. //joInpar.Add("latechbFlag", JsonHelper.getDestValue(joMdtrtinfo, "latechbFlag"));//晚育标志
  803. joInpar.Add("gesoVal", JsonHelper.getDestValue(joMdtrtinfo, "gesoVal"));//孕周数
  804. joInpar.Add("fetts", JsonHelper.getDestValue(joMdtrtinfo, "fetts"));//胎次
  805. joInpar.Add("fetusCnt", JsonHelper.getDestValue(joMdtrtinfo, "fetusCnt"));//胎儿数
  806. //joInpar.Add("pretFlag", JsonHelper.getDestValue(joMdtrtinfo, "pretFlag"));//早产标志
  807. //joInpar.Add("birctrlType", JsonHelper.getDestValue(joMdtrtinfo, "birctrlType"));//计划生育手术类别
  808. //joInpar.Add("birctrlMatnDate", JsonHelper.getDestValue(joMdtrtinfo, "birctrlMatnDate"));//计划生育手术或生育日期
  809. //joInpar.Add("copFlag", JsonHelper.getDestValue(joMdtrtinfo, "copFlag"));//伴有并发症标志
  810. //joInpar.Add("dscgDeptCodg", JsonHelper.getDestValue(joMdtrtinfo, "dscgDeptCodg"));//出院科室编码
  811. //joInpar.Add("dscgDeptName", JsonHelper.getDestValue(joMdtrtinfo, "dscgDeptName"));//出院科室名称
  812. //joInpar.Add("dscgDed", JsonHelper.getDestValue(joMdtrtinfo, "dscgDed"));//出院床位
  813. //joInpar.Add("dscgWay", JsonHelper.getDestValue(joMdtrtinfo, "dscgWay"));//离院方式
  814. //joInpar.Add("dieDate", JsonHelper.getDestValue(joMdtrtinfo, "dieDate"));//死亡日期
  815. //joInpar.Add("matnType", JsonHelper.getDestValue(joMdtrtinfo, "matnType"));//生育类别
  816. //joInpar.Add("expContent", JsonHelper.getDestValue(joInsuAdmObj, "expContent"));//扩展参数 前端传入
  817. //joInpar.Add("midSetlFlag", JsonHelper.getDestValue(joInsuAdmObj, "midSetlFlag"));//中途结算标志 前端传入
  818. joInpar.Add("diseinfoList", jaDiseinfoList);//诊断或症状明细
  819. joInpar.Add("feedetailList", jaFeedetailList);//费用明细
  820. //joInpar.Add("admDiagDscr", JsonHelper.getDestValue(joMdtrtinfo, "admDiagDscr"));//入院诊断描述
  821. //joInpar.Add("admDeptCodg", JsonHelper.getDestValue(joMdtrtinfo, "admDeptCodg"));//入院科室编码
  822. //joInpar.Add("admDeptName", JsonHelper.getDestValue(joMdtrtinfo, "admDeptName"));//入院科室名称
  823. //joInpar.Add("admBed", JsonHelper.getDestValue(joMdtrtinfo, "admBed"));//入院床位
  824. joInpar.Add("payAuthNo", JsonHelper.getDestValue(joInsuAdmObj, "payAuthNo"));//支付授权码 前端传入
  825. joInpar.Add("uldLatlnt", JsonHelper.getDestValue(joInsuAdmObj, "uldLatlnt"));//经纬度 前端传入
  826. joInpar.Add("mdtrtCertType", JsonHelper.getDestValue(joInsuAdmObj, "mdtrtCertType"));//就诊凭证类型 前端传入
  827. //joInpar.Add("insuplcAdmdvs", MPat.insuplc_admdvs);//用户参保地行政区划
  828. JObject joData = new JObject();
  829. joData.Add("data",joInpar);
  830. outparam = joInpar.ToString();
  831. return 0;
  832. }
  833. catch (Exception ex)
  834. {
  835. outparam = "GetYH6201Inpar:" + ex.Message;
  836. return -1;
  837. }
  838. finally
  839. {
  840. Global.writeLog("GetYH6201Inpar","",outparam);
  841. }
  842. }
  843. //获取入参,入参基本为类局部变量
  844. public int GetYH6202Inpar(JObject joYH6201Inpar, out string outparam)
  845. {
  846. outparam = "";
  847. try
  848. {
  849. //获取其他入参
  850. JObject joInpar = new JObject();
  851. joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
  852. joInpar.Add("payOrdId", MPat.payOrdId);//待支付订单号
  853. joInpar.Add("payToken", MPat.payToken);//支付订单对应的token
  854. joInpar.Add("orgCodg", Global.inf.hospitalNO);//定点机构编码
  855. joInpar.Add("orgBizSer", DateTime.Now.ToString("yyyyMMddHHmmssffff"));//业务流水号 前端传入
  856. joInpar.Add("ecAuthCode", "");
  857. joInpar.Add("ecChnlAppId", "");
  858. joInpar.Add("ecChnlUserId", "");
  859. joInpar.Add("mdtrtId", MPat.mdtrtID);
  860. joInpar.Add("chrgBchno", JsonHelper.getDestValue(joYH6201Inpar, "chrgBchno"));//收费批次号
  861. joInpar.Add("feeType", JsonHelper.getDestValue(joYH6201Inpar, "feeType"));//费用类别
  862. //joInpar.Add("deposit", JsonHelper.getDestValue(joInsuAdmObj, "deposit"));//住院押金
  863. joInpar.Add("expContent", "");//扩展数据
  864. //joInpar.Add("acctUsedFlag", "");//个账使用标识
  865. //JObject joData = new JObject();
  866. //joData.Add("data",joInpar);
  867. outparam = joInpar.ToString();
  868. return 0;
  869. }
  870. catch (Exception ex)
  871. {
  872. outparam = "GetYH6202Inpar:" + ex.Message;
  873. return -1;
  874. }
  875. finally
  876. {
  877. Global.writeLog("GetYH6202Inpar", "", outparam);
  878. }
  879. }
  880. //组织YH6203入参
  881. public int GetYH6203Inpar(out string outparam)
  882. {
  883. string errMsg = "";
  884. outparam = "";
  885. try
  886. {
  887. JObject joInpar = new JObject();
  888. //获取医保平台结算信息
  889. if (QuerySettleInfo(out errMsg) != 0)
  890. {
  891. outparam = errMsg;
  892. return -1;
  893. }
  894. JObject joRtn = JObject.Parse(errMsg);
  895. JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "result.data[0]"));
  896. MPat.settlID = JsonHelper.getDestValue(joSettl, "SettlementID");
  897. //MPat.mdtrtID = JsonHelper.getDestValue(joSettl, "MdtrtID");
  898. //入参
  899. joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "PayOrdID"));//支付订单号
  900. joInpar.Add("appRefdSn", MPat.recordID);//应用退款流水号
  901. joInpar.Add("appRefdTime", DateTime.Now.ToString("yyyyMMddHHmmss"));//应用退费时间
  902. joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
  903. joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
  904. joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
  905. joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joSettl, "PersonCashPay"));//现金退费金额
  906. joInpar.Add("ecToken", MPat.token);//电子凭证授权Token 前端传入
  907. joInpar.Add("refdType", "HI");//退费类型 前端传入
  908. joInpar.Add("expContent", "");//扩展数据 前端传入
  909. joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
  910. //JObject joData = new JObject();
  911. //joData.Add("data", joInpar);
  912. outparam = joInpar.ToString();
  913. return 0;
  914. }
  915. catch (Exception ex)
  916. {
  917. outparam = "GetYH6203Inpar:" + ex.Message;
  918. return -1;
  919. }
  920. finally
  921. {
  922. Global.writeLog("GetYH6203Inpar", "", outparam);
  923. }
  924. }
  925. //获取入参,入参基本为类局部变量
  926. public int GetYH6301Inpar(out string outparam)
  927. {
  928. outparam = "";
  929. try
  930. {
  931. string errMsg;
  932. //查询登记信息
  933. if (mIS.queryRegisterInfo(4,out errMsg) != 0)
  934. {
  935. outparam = errMsg;
  936. return -1;
  937. }
  938. setPatientByMiRegInfo(JObject.Parse(errMsg));
  939. //获取其他入参
  940. JObject joInpar = new JObject();
  941. joInpar.Add("payOrdId", MPat.payOrdId);//待支付订单号
  942. joInpar.Add("payToken", MPat.payToken);//支付订单对应的token
  943. joInpar.Add("orgCodg", Global.inf.hospitalNO);//定点机构编码
  944. joInpar.Add("idNo", MPat.IDNO);//业务流水号 前端传入
  945. joInpar.Add("userName", MPat.name);
  946. joInpar.Add("idType", "01");
  947. joInpar.Add("expContent", "");
  948. outparam = joInpar.ToString();
  949. return 0;
  950. }
  951. catch (Exception ex)
  952. {
  953. outparam = "GetYH6301Inpar:" + ex.Message;
  954. return -1;
  955. }
  956. finally
  957. {
  958. Global.writeLog("GetYH6301Inpar", "", outparam);
  959. }
  960. }
  961. public int GetYH6401Inpar(out string outparam)
  962. {
  963. string errMsg = "";
  964. outparam = "";
  965. try
  966. {
  967. JObject joInpar = new JObject();
  968. //获取医保平台结算信息
  969. if (QuerySettleInfo(out errMsg) != 0)
  970. {
  971. outparam = errMsg;
  972. return -1;
  973. }
  974. JObject joRtn = JObject.Parse(errMsg);
  975. JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "data"));
  976. //入参
  977. joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "SettlementID"));//支付订单号
  978. joInpar.Add("appRefdSn", JsonHelper.getDestValue(joSettl, ""));//应用退款流水号
  979. joInpar.Add("appRefdTime", JsonHelper.getDestValue(joSettl, ""));//应用退费时间
  980. joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
  981. joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
  982. joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
  983. joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joInsuAdmObj, "PersonCashPay"));//现金退费金额
  984. joInpar.Add("ecToken", MPat.token);//电子凭证授权Token 前端传入
  985. joInpar.Add("refdType", "ALL");//退费类型 前端传入
  986. joInpar.Add("expContent", "");//扩展数据 前端传入
  987. joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
  988. outparam = joInpar.ToString();
  989. return 0;
  990. }
  991. catch (Exception ex)
  992. {
  993. outparam = "GetYH6203Inpar:" + ex.Message;
  994. return -1;
  995. }
  996. finally
  997. {
  998. Global.writeLog("GetYH6203Inpar", "", outparam);
  999. }
  1000. }
  1001. //获取入参,入参基本为类局部变量
  1002. public int Get6301Inpar(out string outparam)
  1003. {
  1004. outparam = "";
  1005. try
  1006. {
  1007. string errMsg;
  1008. //查询登记信息
  1009. if (mIS.queryRegisterInfo(4, out errMsg) != 0)
  1010. {
  1011. outparam = errMsg;
  1012. return -1;
  1013. }
  1014. setPatientByMiRegInfo(JObject.Parse(errMsg));
  1015. //获取其他入参
  1016. JObject joInpar = new JObject();
  1017. joInpar.Add("payOrdId", MPat.payOrdId);//待支付订单号
  1018. joInpar.Add("payToken", MPat.payToken);//支付订单对应的token
  1019. joInpar.Add("orgCodg", Global.inf.hospitalNO);//定点机构编码
  1020. joInpar.Add("idNo", MPat.IDNO);//业务流水号 前端传入
  1021. joInpar.Add("userName", MPat.name);
  1022. joInpar.Add("idType", "01");
  1023. joInpar.Add("expData", "");
  1024. //JObject joData = new JObject();
  1025. //joData.Add("data", joInpar);
  1026. outparam = joInpar.ToString();
  1027. return 0;
  1028. }
  1029. catch (Exception ex)
  1030. {
  1031. outparam = "Get6301Inpar:" + ex.Message;
  1032. return -1;
  1033. }
  1034. finally
  1035. {
  1036. Global.writeLog("Get6301Inpar", "", outparam);
  1037. }
  1038. }
  1039. #endregion
  1040. #region 诊断
  1041. //获取诊断信息
  1042. public int getDiagnoses(out string errMsg)
  1043. {
  1044. errMsg = "";
  1045. try
  1046. {
  1047. //调用服务获取门诊诊断信息
  1048. string outparam = "";
  1049. if (hIS.getPatDiagnoses(MPat, out outparam) != 0)
  1050. {
  1051. return -1;
  1052. }
  1053. JObject joRtn = JObject.Parse(outparam);
  1054. JObject joMdtrtInfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "mdtrtinfo"));
  1055. JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joRtn, "diseinfo"));
  1056. //组织门诊结算诊断入参
  1057. JArray jaRow = new JArray();
  1058. for (int i = 0; i < jaDiagnoses.Count; i++)
  1059. {
  1060. JObject joTmp = new JObject();
  1061. joTmp.Add("diagType", jaDiagnoses[i]["diag_type"]);//
  1062. joTmp.Add("diagSrtNo", jaDiagnoses[i]["diag_srt_no"]);//
  1063. joTmp.Add("diagCode", jaDiagnoses[i]["diag_code"]);//
  1064. joTmp.Add("diagName", jaDiagnoses[i]["diag_name"]);//
  1065. joTmp.Add("diagDept", jaDiagnoses[i]["diag_dept"]);//
  1066. joTmp.Add("diseDorNo", jaDiagnoses[i]["dise_dor_no"]);//
  1067. joTmp.Add("diseDorName", jaDiagnoses[i]["dise_dor_name"]);//
  1068. joTmp.Add("diagTime", jaDiagnoses[i]["diag_time"]);//
  1069. joTmp.Add("valiFlag", "1");//
  1070. jaRow.Add(joTmp);
  1071. }
  1072. JObject joDiagRow = new JObject();
  1073. joDiagRow.Add("diseinfoList", jaRow);
  1074. joDiagRow.Add("mdtrtinfo", joMdtrtInfo);
  1075. outparam = joDiagRow.ToString();
  1076. errMsg = outparam;
  1077. return 0;
  1078. }
  1079. catch (Exception ex)
  1080. {
  1081. errMsg = "getDiagnoses:" + ex.Message;
  1082. return -1;
  1083. }
  1084. }
  1085. #endregion
  1086. #region 费用
  1087. private int GetFee(out string outparam)
  1088. {
  1089. string hisFee, chrgBchno ="";
  1090. JObject jo = new JObject();
  1091. JObject joRow = new JObject();
  1092. JArray jaRow = new JArray();
  1093. try
  1094. {
  1095. //获取HIS费用
  1096. if (hIS.getHisFee(MPat, out hisFee) != 0)
  1097. {
  1098. outparam = hisFee;
  1099. return -1;
  1100. }
  1101. JObject joFee = JObject.Parse(hisFee);
  1102. //处理
  1103. //调用医保平台转换HIS费用(转换医保编码等)
  1104. JObject joHisFee = JObject.Parse(hisFee);
  1105. if (mIS.convertHisFeeWithInsuCodeOfMobilePay(MPat,joHisFee, out outparam) != 0)
  1106. {
  1107. return -1;
  1108. }
  1109. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outparam), "data"));
  1110. jaFee = (JArray)jaFeeDetail.DeepClone();
  1111. decimal sumFee = 0;
  1112. //转换
  1113. for (int i = 0; i < jaFeeDetail.Count; i++)
  1114. {
  1115. decimal cnt = decimal.Parse(jaFeeDetail[i]["cnt"].ToString());
  1116. decimal pric = decimal.Parse(jaFeeDetail[i]["pric"].ToString());
  1117. decimal sumamt = decimal.Parse(jaFeeDetail[i]["det_item_fee_sumamt"].ToString());
  1118. sumFee = sumFee + sumamt;
  1119. JObject joTmp = new JObject();
  1120. joTmp.Add("feedetlSn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
  1121. joTmp.Add("mdtrtId", jaFeeDetail[i]["mdtrt_id"]);//就诊ID
  1122. //joTmp.Add("psnNo", jaFeeDetail[i]["psnNo"]);//人员编号
  1123. chrgBchno = jaFeeDetail[i]["chrg_bchno"].ToString();
  1124. joTmp.Add("chrgBchno", jaFeeDetail[i]["chrg_bchno"]);//收费批次号
  1125. joTmp.Add("diseCodg", "");//病种编码
  1126. joTmp.Add("rxno", jaFeeDetail[i]["rxno"]);//处方号
  1127. joTmp.Add("rxCircFlag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
  1128. joTmp.Add("feeOcurTime", jaFeeDetail[i]["fee_ocur_time"]);//费用发生时间
  1129. joTmp.Add("medListCodg", jaFeeDetail[i]["med_list_codg"]);//医疗目录编码
  1130. joTmp.Add("medinsListCodg", jaFeeDetail[i]["medins_list_codg"]);//医药机构目录编码
  1131. joTmp.Add("detItemFeeSumamt", sumamt.ToString("#0.00"));//明细项目费用总额
  1132. joTmp.Add("cnt", cnt.ToString("#0.0000"));//数量
  1133. joTmp.Add("pric", pric.ToString("#0.000000"));//单价
  1134. joTmp.Add("sinDosDscr", jaFeeDetail[i]["sin_dos_dscr"]);//单次剂量描述
  1135. joTmp.Add("usedFrquDscr", jaFeeDetail[i]["used_frqu_dscr"]);//使用频次描述
  1136. joTmp.Add("prdDays", jaFeeDetail[i]["prd_days"]);//周期天数
  1137. joTmp.Add("medcWayDscr", jaFeeDetail[i]["medc_way_dscr"]);//用药途径描述
  1138. joTmp.Add("bilgDeptCodg", jaFeeDetail[i]["bilg_dept_codg"]);//开单科室编码
  1139. joTmp.Add("bilgDeptName", jaFeeDetail[i]["bilg_dept_name"]);//开单科室名称
  1140. joTmp.Add("bilgDrCodg", jaFeeDetail[i]["bilg_dr_codg"]);//开单医生编码
  1141. joTmp.Add("bilgDrName", jaFeeDetail[i]["bilg_dr_name"]);//开单医师姓名
  1142. joTmp.Add("acordDeptCodg", jaFeeDetail[i]["acord_dept_codg"]);//受单科室编码
  1143. joTmp.Add("acordDeptName", jaFeeDetail[i]["acord_dept_name"]);//受单科室名称
  1144. joTmp.Add("ordersDrCode", jaFeeDetail[i]["orders_dr_code"]);//受单医生编码
  1145. joTmp.Add("ordersDrName", jaFeeDetail[i]["orders_dr_name"]);//受单医生姓名
  1146. joTmp.Add("hospApprFlag", jaFeeDetail[i]["hosp_appr_flag"]);//医院审批标志
  1147. joTmp.Add("tcmdrugUsedWay", jaFeeDetail[i]["tcmdrug_used_way"]);//中药使用方式
  1148. joTmp.Add("etipFlag", jaFeeDetail[i]["etip_flag"]);//外检标志
  1149. joTmp.Add("etipHospCode", jaFeeDetail[i]["etip_hosp_code"]);//外检医院编码
  1150. joTmp.Add("dscgTkdrugFlag", jaFeeDetail[i]["dscg_tkdrug_flag"]);//出院带药标志
  1151. joTmp.Add("matnFeeFlag", jaFeeDetail[i]["matn_fee_flag"]);//生育费用标志
  1152. joTmp.Add("initFeedetlSn", jaFeeDetail[i]["init_feedetl_sn"]);//原费用流水号
  1153. joTmp.Add("drordNo", jaFeeDetail[i]["drord_no"]);//医嘱号
  1154. joTmp.Add("medType", jaFeeDetail[i]["med_type"]);//医疗类别
  1155. joTmp.Add("memo", "");//备注
  1156. joTmp.Add("expContent", jaFeeDetail[i]["expContent"]);//扩展字段
  1157. joTmp.Add("medListName", jaFeeDetail[i]["medins_list_name"]);//医疗目录名称
  1158. joTmp.Add("medListSpc", jaFeeDetail[i]["med_list_spc"]);//医疗目录规格
  1159. joTmp.Add("combNo", jaFeeDetail[i]["comb_no"]);//组套编号
  1160. jaRow.Add(joTmp);
  1161. }
  1162. jo.Add("medfeeSumamt", sumFee.ToString("#0.00"));
  1163. jo.Add("chrgBchno", chrgBchno);
  1164. jo.Add("feedetailList", jaRow);
  1165. outparam = jo.ToString();
  1166. return 0;
  1167. }
  1168. catch (Exception ex)
  1169. {
  1170. outparam = "获取费用异常:" + ex.Message;
  1171. Global.writeLog("GetFee", jo.ToString(), "获取费用异常:" + ex.Message);
  1172. return -1;
  1173. }
  1174. }
  1175. /// <summary>
  1176. /// 汇总医保返回的结算金额(按照HIS的原则汇总,后期HIS按照这个来进行勾稽关系判断)
  1177. /// </summary>
  1178. /// <param name="jo"></param>
  1179. /// <returns></returns>
  1180. public int sumInsuRtnSettlInfo(JObject jo, out JObject joSumFee, out string errMsg)
  1181. {
  1182. // 医疗费总额是患者在医药机构花费的所有诊疗、药品、耗材、服务设施等项目费用的总和 = 基金支付总额 + 个人负担总金额 + 其他(如医院负担金额);
  1183. //3、基金支付总额 = 基本医保统筹基金支出(含职工基本医疗保险、居民基本医疗保险)+补充医疗保险基金支出 (含覆盖全体参保人的居民大病保险和大额医疗费用补助、覆盖部分参保人的企业职工大额医疗费用补助和公务员医疗补助等)+医疗救助基金支出 + 其他支出(如伤残人员医疗保障基金支出);
  1184. //5、个人账户支出中包含账户共济支付金额
  1185. joSumFee = new JObject();
  1186. errMsg = "";
  1187. decimal ybAmt, psnAcctAmt, hospAmt, psnCashAmt, medFee;
  1188. try
  1189. {
  1190. ybAmt = 0; psnAcctAmt = 0; hospAmt = 0; psnCashAmt = 0; medFee = 0;
  1191. ybAmt = MSettl.fundPaySumamt;
  1192. psnAcctAmt = MSettl.accountPaySumamt;
  1193. psnCashAmt =MSettl.personCashPay;
  1194. hospAmt = MSettl.hospitalPartAmount;
  1195. medFee = MSettl.sumamt;
  1196. joSumFee.Add("sumamt", medFee);
  1197. joSumFee.Add("ybAmt", ybAmt);
  1198. joSumFee.Add("psnAcctAmt", psnAcctAmt);
  1199. joSumFee.Add("hospAmt", hospAmt);
  1200. joSumFee.Add("psnCashAmt", psnCashAmt);
  1201. if (medFee != (ybAmt + psnAcctAmt + psnCashAmt + hospAmt))
  1202. {
  1203. errMsg = "ybAmt(" + ybAmt.ToString() + ")+" + "psnAcctAmt(" + psnAcctAmt.ToString() + ")+" + "psnCashAmt(" + psnCashAmt.ToString() + ")+" + "hospAmt(" + hospAmt.ToString() + ")" + "!=medFee(" + medFee.ToString() + ")";
  1204. return -1;
  1205. }
  1206. return 0;
  1207. }
  1208. catch (Exception ex)
  1209. {
  1210. errMsg = ex.Message;
  1211. return 1;
  1212. }
  1213. }
  1214. /// <summary>
  1215. /// 获取结算费用的封装
  1216. /// </summary>
  1217. /// <param name="jo"></param>
  1218. /// <param name="path"></param>
  1219. /// <returns></returns>
  1220. private decimal getDecimalFee(JObject jo, string path)
  1221. {
  1222. try
  1223. {
  1224. string temp = JsonHelper.getDestValue(jo, path);
  1225. if (temp == "")
  1226. {
  1227. return 0;
  1228. }
  1229. else
  1230. {
  1231. return decimal.Parse(temp);
  1232. }
  1233. }
  1234. catch (Exception ex)
  1235. {
  1236. Global.writeLog("getFee异常:" + ex.Message);
  1237. return 0;
  1238. }
  1239. }
  1240. #endregion
  1241. #region 结算
  1242. /// <summary>
  1243. /// 返回移动支付结算信息给HIS
  1244. /// </summary>
  1245. /// <param name="joSetlInpar"></param>
  1246. /// <param name="joSetlinfo"></param>中心返回的信息
  1247. /// <param name="outParam"></param>
  1248. /// <returns></returns>
  1249. public int returnMPSettlementInfo(JObject joReg, JObject joSettl, out string outParam)
  1250. {
  1251. string errMsg;
  1252. try
  1253. {
  1254. JObject joSumFee = new JObject();
  1255. if (sumInsuRtnSettlInfo(joSettl, out joSumFee, out errMsg) != 0)
  1256. {
  1257. outParam = "返回结算结果给HIS失败,请联系管理员!" + errMsg;
  1258. return -1;
  1259. }
  1260. dynamic joTmp = new JObject();
  1261. joTmp.settleInfo = joSettl;
  1262. joTmp.updateUserID = Global.user.ID;
  1263. joTmp.regInfo = joReg;
  1264. joTmp.middleSettleFlag = "";
  1265. joTmp.interfaceDr = Global.inf.interfaceDr;
  1266. dynamic joHisInfo = new JObject();
  1267. joHisInfo.admID = MPat.adm_Dr;
  1268. joHisInfo.billID = MPat.billID;
  1269. joHisInfo.recordID = MPat.recordID;
  1270. joTmp.hisInfo = joHisInfo;
  1271. joTmp.psn_type = MPat.psn_type;
  1272. joTmp.mobilePayFlag = "Y";
  1273. joTmp.sumFeeObj = joSumFee;
  1274. joTmp.mdtrtinfo = MPat.mdtrtID;
  1275. JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110018", joTmp).ToString(), "返回移动支付结算结果给HIS");
  1276. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1277. {
  1278. outParam = "返回移动支付结算结果给HIS失败,请联系管理员!" + errMsg;
  1279. return -1;
  1280. }
  1281. else
  1282. {
  1283. joSumFee.Add("payAuthNo",MPat.payAuthNo);
  1284. joSumFee.Add("payOrdId", MPat.payOrdId);
  1285. joSumFee.Add("setlLatlnt", MPat.uldLatlnt);
  1286. joSumFee.Add("org_no", Global.inf.hospitalNO);
  1287. joSumFee.Add("medOrgOrd", MPat.recordID);
  1288. joSumFee.Add("mdtrtId", MPat.mdtrtID);
  1289. joSumFee.Add("gmt_out_create", MSettl.settlTime.ToString("yyyy-MM-dd HH:mm:ss"));
  1290. joRtn["result"]= joSumFee;
  1291. outParam = joRtn.ToString();
  1292. return 0;
  1293. }
  1294. }
  1295. catch (Exception ex)
  1296. {
  1297. outParam = "返回移动支付结算结果给HIS出现异常:!" + ex.Message;
  1298. return -1;
  1299. }
  1300. }
  1301. //查询结算信息
  1302. public int QuerySettleInfo(out string errMsg)
  1303. {
  1304. errMsg = "";
  1305. try
  1306. {
  1307. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr= " + Global.inf.hospitalDr;
  1308. sqlStr = sqlStr + " and AdmType = 3 and Adm_Dr= " + MPat.adm_Dr + " and PayOrdID= '" + MPat.payOrdId + "'";
  1309. JObject joSqlstr = new JObject();
  1310. joSqlstr.Add("sqlStr", sqlStr);
  1311. JObject joRtn = mIS.DynamicQuerySettlInfo(joSqlstr);
  1312. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1313. {
  1314. return -1;
  1315. }
  1316. else
  1317. {
  1318. errMsg = joRtn.ToString();
  1319. return 0;
  1320. }
  1321. }
  1322. catch (Exception ex)
  1323. {
  1324. errMsg = ex.Message;
  1325. return -1;
  1326. }
  1327. }
  1328. #endregion
  1329. #region 存入MI
  1330. /// <summary>
  1331. /// 插入患者该次就诊参保信息
  1332. /// </summary>
  1333. /// <param name="joBaseInfo"></param>
  1334. /// <param name="joInsuInfo"></param>
  1335. /// <param name="joIdetInfo"></param>
  1336. /// <param name="outParam"></param>
  1337. /// <returns></returns>
  1338. private int insertPatCurInsuInfo( out string outParam)
  1339. {
  1340. JObject joTmp = new JObject();
  1341. string errMsg = "";
  1342. try
  1343. {
  1344. joTmp.Add("HospitalDr", Global.inf.hospitalDr);
  1345. joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
  1346. joTmp.Add("AdmID", MPat.adm_Dr);
  1347. joTmp.Add("PatientName", MPat.name);
  1348. joTmp.Add("PersonalNO", MPat.psn_no);
  1349. joTmp.Add("MdtrtID", MPat.mdtrtID);
  1350. joTmp.Add("PsnCertType", "");
  1351. joTmp.Add("PsnCertNO", MPat.certNO);
  1352. joTmp.Add("Gend", MPat.gend);
  1353. joTmp.Add("Naty", "");
  1354. joTmp.Add("Brdy", MPat.brdy);
  1355. joTmp.Add("Age", MPat.age);
  1356. joTmp.Add("Balc", MPat.balc);
  1357. joTmp.Add("Insutype", MPat.insuType);
  1358. joTmp.Add("PsnType", MPat.psn_type);
  1359. joTmp.Add("PsnInsuStas", "");
  1360. joTmp.Add("PsnInsuDate", "");
  1361. joTmp.Add("PausInsuDate", "");
  1362. joTmp.Add("Cvlservflag", "");
  1363. joTmp.Add("insuplcAdmdvs", MPat.insuplc_admdvs);
  1364. joTmp.Add("EmpName", MPat.emp_name);
  1365. joTmp.Add("PsnIdettype", "");
  1366. joTmp.Add("PsnTypeLv", "");
  1367. joTmp.Add("IdetBegntime", "");
  1368. joTmp.Add("IdetEndtime", "");
  1369. if (string.IsNullOrEmpty(Global.user.ID)) Global.user.ID = "0";
  1370. joTmp.Add("updateUserID", Global.user.ID);
  1371. string serviceCode = "09010070";
  1372. string inpar = JsonHelper.setIrisInpar(serviceCode, joTmp).ToString();
  1373. JObject joRtn = invoker.invokeInsuService(inpar, "插入患者该次就诊参保信息");
  1374. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1375. {
  1376. outParam = errMsg;
  1377. return -1;
  1378. }
  1379. else
  1380. {
  1381. outParam = joRtn.ToString();
  1382. return 0;
  1383. }
  1384. }
  1385. catch (Exception ex)
  1386. {
  1387. outParam = "医保平台插入患者该次就诊参保信息:" + ex.Message;
  1388. return -1;
  1389. }
  1390. }
  1391. /// <summary>
  1392. /// 插入登记信息
  1393. /// </summary>
  1394. /// <param name="joInpar"></param> 48交易入参
  1395. /// <param name="joOutpar"></param>48交易出参
  1396. /// <param name="outParam"></param>
  1397. /// <returns></returns>
  1398. private int saveRegisterInfo(out string outParam)
  1399. {
  1400. //插入云医保平台
  1401. JObject joTmp = new JObject();
  1402. string errMsg = "";
  1403. try
  1404. {
  1405. joTmp.Add("HospitalDr", Global.inf.hospitalDr);
  1406. joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
  1407. joTmp.Add("AdmDr", MPat.adm_Dr);
  1408. joTmp.Add("PatientName", MPat.name);
  1409. joTmp.Add("PersonalNO", MPat.psn_no);
  1410. joTmp.Add("InsuRegID", MPat.mdtrtID);
  1411. joTmp.Add("RegDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1412. joTmp.Add("InsuType", MPat.insuType);
  1413. joTmp.Add("CertificateType", MPat.certType);
  1414. joTmp.Add("CertificateNO", MPat.certNO);
  1415. joTmp.Add("MedicalType", MPat.medType);
  1416. joTmp.Add("AttendDoctorNO",MPat.admAttendDoctorNO);
  1417. joTmp.Add("ChiefPhyDocName", "");
  1418. joTmp.Add("AdmInDiagDesc", "");
  1419. joTmp.Add("AdmInDepCode", MPat.AdmInDepCode);
  1420. joTmp.Add("AdmInDepName", "");
  1421. joTmp.Add("AdmBed", "");
  1422. joTmp.Add("MainDiagCode", MPat.admDiagCode);
  1423. joTmp.Add("MainDiagName", MPat.admDiagName);
  1424. joTmp.Add("MainConditionDesc", "");
  1425. joTmp.Add("DiseasecCode", "");
  1426. joTmp.Add("DiseasecName", "");
  1427. joTmp.Add("OperationCode", "");
  1428. joTmp.Add("OperationName", "");
  1429. joTmp.Add("DiseasecTypeCode", "");
  1430. joTmp.Add("InsuranceAreaCode", MPat.insuplc_admdvs);
  1431. joTmp.Add("TreatmentAreaCode", Global.inf.areaCode);
  1432. joTmp.Add("payOrdId", MPat.payOrdId);
  1433. joTmp.Add("payToken", MPat.payToken);
  1434. joTmp.Add("RegState", "1");
  1435. joTmp.Add("ValidFlag", "1");
  1436. joTmp.Add("Type", "4");//线上支付门诊
  1437. joTmp.Add("updateUserID", Global.user.ID);
  1438. joTmp.Add("msgid", Global.curEvt.msgid);
  1439. joTmp.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1440. string serviceCode = "09010044";
  1441. string inpar = JsonHelper.setIrisInpar(serviceCode, joTmp).ToString();
  1442. JObject joRtn = invoker.invokeInsuService(inpar, "新增门诊登记信息");
  1443. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1444. {
  1445. outParam = joRtn.ToString();
  1446. return -1;
  1447. }
  1448. else
  1449. {
  1450. outParam = joRtn.ToString();
  1451. return 0;
  1452. }
  1453. }
  1454. catch (Exception ex)
  1455. {
  1456. outParam = "保存门诊登记信息异常:" + ex.Message;
  1457. return -1;
  1458. }
  1459. }
  1460. /// <summary>
  1461. /// 插入结算信息
  1462. /// </summary>
  1463. /// <param name="joSettlement"></param>
  1464. /// <param name="outParam"></param>
  1465. /// <returns></returns>
  1466. public int saveSettlement(out string outParam)
  1467. {
  1468. JObject joTmp = new JObject();
  1469. string errMsg = "";
  1470. try
  1471. {
  1472. JObject joSetlinfo = new JObject();
  1473. joSetlinfo.Add("HospitalDr", Global.inf.hospitalDr);
  1474. joSetlinfo.Add("admID", MPat.adm_Dr);
  1475. joSetlinfo.Add("mdtrt_id", MPat.mdtrtID);
  1476. joSetlinfo.Add("setl_id", MSettl.settlID);//
  1477. joSetlinfo.Add("pay_ord_id", MSettl.payOrdId);
  1478. joSetlinfo.Add("psn_no", MPat.psn_no);
  1479. joSetlinfo.Add("psn_name", MPat.name);
  1480. //joSetlinfo.Add("mdtrt_cert_type", JsonHelper.getDestValue(joRtnSetlinfo, "mdtrt_cert_type"));
  1481. joSetlinfo.Add("certno", MPat.certNO);
  1482. joSetlinfo.Add("gend", MPat.gend);
  1483. joSetlinfo.Add("naty", MPat.naty);
  1484. joSetlinfo.Add("brdy", MPat.brdy);
  1485. joSetlinfo.Add("age", MPat.age);
  1486. joSetlinfo.Add("insutype", MPat.insuType);
  1487. joSetlinfo.Add("psn_type", MPat.psn_type);
  1488. joSetlinfo.Add("cvlserv_flag", "");
  1489. joSetlinfo.Add("setl_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1490. joSetlinfo.Add("mdtrt_cert_type", MPat.mdtrtcertType);
  1491. joSetlinfo.Add("med_type", MPat.medType);
  1492. joSetlinfo.Add("medfee_sumamt", MSettl.sumamt);//总费用
  1493. joSetlinfo.Add("fulamt_ownpay_amt", MSettl.ownPayAmount);//全自费金额
  1494. joSetlinfo.Add("overlmt_selfpay", MSettl.overLimitAmountmt);//超限价自费费用
  1495. joSetlinfo.Add("preselfpay_amt", MSettl.preSelfPayAmount);//先行自付金额
  1496. joSetlinfo.Add("inscp_scp_amt", MSettl.inPolicyRangeAmount);//符合政策范围金额
  1497. joSetlinfo.Add("act_pay_dedc", MSettl.actualPayDeductible);//实际支付起付线
  1498. joSetlinfo.Add("hifp_pay", MSettl.healthInsurancePay);//基本医疗保险统筹基金支出
  1499. joSetlinfo.Add("pool_prop_selfpay", MSettl.healthInsuranceRatio);//基本医疗保险统筹基金支付比例
  1500. joSetlinfo.Add("cvlserv_pay", MSettl.civilserviceAllowancePay);//公务员医疗补助资金支出
  1501. joSetlinfo.Add("hifes_pay", MSettl.enterpriseSupplementPay);//企业支付 占用 大病报销金额
  1502. joSetlinfo.Add("hifmi_pay", MSettl.seriousIllnessPay);// 居民大病保险资金支出
  1503. joSetlinfo.Add("hifob_pay", MSettl.largeExpensesSupplementPay);//职工大额医疗费用补助基金支出
  1504. joSetlinfo.Add("maf_pay", MSettl.medicalAssistPay);//医疗救助基金支出
  1505. joSetlinfo.Add("hosp_part_amt", MSettl.hospitalPartAmount);//医院负担金额
  1506. joSetlinfo.Add("oth_pay", MSettl.otherPay);//其他支出
  1507. joSetlinfo.Add("fund_pay_sumamt", MSettl.fundPaySumamt);//基金支付总额
  1508. joSetlinfo.Add("psn_part_amt", MSettl.personPaySumamt);//个人负担总金额
  1509. joSetlinfo.Add("acct_pay", MSettl.accountPaySumamt);//个人账户支出
  1510. joSetlinfo.Add("psn_cash_pay", MSettl.personCashPay);//个人现金支出
  1511. joSetlinfo.Add("balc", MSettl.balance);// 余额
  1512. joSetlinfo.Add("acct_mulaid_pay", "");//个人账户共济支付金额
  1513. joSetlinfo.Add("medins_setl_id", "");//医药机构结算ID
  1514. joSetlinfo.Add("clr_optins", MSettl.clearingOrgan);//清算经办机构
  1515. joSetlinfo.Add("clr_way", MSettl.clearingWay);//清算方式
  1516. joSetlinfo.Add("clr_type", MSettl.clearingType);//清算类别
  1517. joSetlinfo.Add("ValidFlag", 1);
  1518. joSetlinfo.Add("BillType", 1);
  1519. joSetlinfo.Add("msgid", Global.curEvt.msgid);
  1520. joSetlinfo.Add("admType", "3");
  1521. joSetlinfo.Add("billID", MPat.billID);
  1522. joSetlinfo.Add("recordID", MPat.recordID);
  1523. joSetlinfo.Add("interfaceDr", Global.inf.interfaceDr);
  1524. joSetlinfo.Add("insuplc_admdvs", MPat.insuplc_admdvs);
  1525. joSetlinfo.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1526. joSetlinfo.Add("HospitalizationsDays", MSettl.hospitalizationsDays);
  1527. joSetlinfo.Add("HospitalizationsTimes", MSettl.hospitalizationsTimes);
  1528. joSetlinfo.Add("HISAdmTime", MSettl.hisAdmTime);
  1529. joSetlinfo.Add("HISDischargeTime", MSettl.hisDischargeTime);
  1530. joSetlinfo.Add("updateUserID", Global.user.ID);
  1531. joSetlinfo.Add("ConfirmFlag", MSettl.confirmFlag);
  1532. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010051", joSetlinfo).ToString(), "插入结算信息");
  1533. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1534. {
  1535. outParam = errMsg;
  1536. return -1;
  1537. }
  1538. else
  1539. {
  1540. outParam = joSetlinfo.ToString();
  1541. return 0;
  1542. }
  1543. }
  1544. catch (Exception ex)
  1545. {
  1546. outParam = "插入结算信息:" + ex.Message;
  1547. return -1;
  1548. }
  1549. }
  1550. public int updateSettlement(out string outParam)
  1551. {
  1552. JObject joTmp = new JObject();
  1553. string errMsg = "";
  1554. try
  1555. {
  1556. JObject joSetlinfo = new JObject();
  1557. joSetlinfo.Add("HospitalDr", Global.inf.hospitalDr);
  1558. joSetlinfo.Add("AdmDr", MPat.adm_Dr);
  1559. joSetlinfo.Add("MdtrtID", MPat.mdtrtID);
  1560. joSetlinfo.Add("SettlementID", MSettl.settlID);//
  1561. joSetlinfo.Add("PayOrdID", MSettl.payOrdId);
  1562. joSetlinfo.Add("PersonnelNO", MPat.psn_no);
  1563. joSetlinfo.Add("PatientName", MPat.name);
  1564. //joSetlinfo.Add("CertificateType", JsonHelper.getDestValue(joRtnSetlinfo, "mdtrt_cert_type"));
  1565. joSetlinfo.Add("CertificateNO", MPat.certNO);
  1566. joSetlinfo.Add("Gender", MPat.gend);
  1567. joSetlinfo.Add("Nation", MPat.naty);
  1568. joSetlinfo.Add("BirthDay", MPat.brdy);
  1569. joSetlinfo.Add("Age", MPat.age);
  1570. joSetlinfo.Add("InsuranceType", MPat.insuType);
  1571. joSetlinfo.Add("PersonType", MPat.psn_type);
  1572. joSetlinfo.Add("CivilserviceFlag", "");
  1573. joSetlinfo.Add("SettlementDateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1574. joSetlinfo.Add("MdtrtCertType", MPat.mdtrtcertType);
  1575. joSetlinfo.Add("MedicalType", MPat.medType);
  1576. joSetlinfo.Add("Sumamt", MSettl.sumamt);//总费用
  1577. joSetlinfo.Add("OwnPayAmount", MSettl.ownPayAmount);//全自费金额
  1578. joSetlinfo.Add("OverLimitAmount", MSettl.overLimitAmountmt);//超限价自费费用
  1579. joSetlinfo.Add("PreSelfPayAmount", MSettl.preSelfPayAmount);//先行自付金额
  1580. joSetlinfo.Add("InPolicyRangeAmount", MSettl.inPolicyRangeAmount);//符合政策范围金额
  1581. joSetlinfo.Add("ActualPayDeductible", MSettl.actualPayDeductible);//实际支付起付线
  1582. joSetlinfo.Add("HealthInsurancePay", MSettl.healthInsurancePay);//基本医疗保险统筹基金支出
  1583. joSetlinfo.Add("HealthInsuranceRatio", MSettl.healthInsuranceRatio);//基本医疗保险统筹基金支付比例
  1584. joSetlinfo.Add("CivilserviceAllowancePay", MSettl.civilserviceAllowancePay);//公务员医疗补助资金支出
  1585. joSetlinfo.Add("EnterpriseSupplementPay", MSettl.enterpriseSupplementPay);//企业支付
  1586. joSetlinfo.Add("SeriousIllnessPay", MSettl.seriousIllnessPay);// 居民大病保险资金支出
  1587. joSetlinfo.Add("LargeExpensesSupplementPay", MSettl.largeExpensesSupplementPay);//职工大额医疗费用补助基金支出
  1588. joSetlinfo.Add("MedicalAssistPay", MSettl.medicalAssistPay);//医疗救助基金支出
  1589. joSetlinfo.Add("HospitalPartAmount", MSettl.hospitalPartAmount);//医院负担金额
  1590. joSetlinfo.Add("OtherPay", MSettl.otherPay);//其他支出
  1591. joSetlinfo.Add("FundPaySumamt", MSettl.fundPaySumamt);//基金支付总额
  1592. joSetlinfo.Add("PersonPaySumamt", MSettl.personPaySumamt);//个人负担总金额
  1593. joSetlinfo.Add("AccountPaySumamt", MSettl.accountPaySumamt);//个人账户支出
  1594. joSetlinfo.Add("PersonCashPay", MSettl.personCashPay);//个人现金支出
  1595. joSetlinfo.Add("Balance", MSettl.balance);// 余额
  1596. joSetlinfo.Add("AccountMutualAidAmount", "");//个人账户共济支付金额
  1597. joSetlinfo.Add("OrganSettlementID", "");//医药机构结算ID
  1598. joSetlinfo.Add("ClearingOrgan", MSettl.clearingOrgan);//清算经办机构
  1599. joSetlinfo.Add("ClearingWay", MSettl.clearingWay);//清算方式
  1600. joSetlinfo.Add("ClearingType", MSettl.clearingType);//清算类别
  1601. joSetlinfo.Add("ValidFlag", 1);
  1602. joSetlinfo.Add("BillType", 1);
  1603. joSetlinfo.Add("ConfirmFlag", MSettl.confirmFlag);
  1604. joSetlinfo.Add("MSGID", Global.curEvt.msgid);
  1605. joSetlinfo.Add("AdmType", "3");
  1606. joSetlinfo.Add("BillID", MPat.billID);
  1607. joSetlinfo.Add("RecordID", MPat.recordID);
  1608. joSetlinfo.Add("InterfaceDr", Global.inf.interfaceDr);
  1609. joSetlinfo.Add("InsuranceAreaCode", MPat.insuplc_admdvs);
  1610. joSetlinfo.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1611. joSetlinfo.Add("HospitalizationsDays", MSettl.hospitalizationsDays);
  1612. joSetlinfo.Add("HospitalizationsTimes", MSettl.hospitalizationsTimes);
  1613. joSetlinfo.Add("HISAdmTime", MSettl.hisAdmTime);
  1614. joSetlinfo.Add("HISDischargeTime", MSettl.hisDischargeTime);
  1615. joSetlinfo.Add("updateUserID", Global.user.ID);
  1616. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010089", joSetlinfo).ToString(), "通过订单号更新结算信息");
  1617. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1618. {
  1619. outParam = errMsg;
  1620. return -1;
  1621. }
  1622. else
  1623. {
  1624. outParam = joSetlinfo.ToString();
  1625. return 0;
  1626. }
  1627. }
  1628. catch (Exception ex)
  1629. {
  1630. outParam = "插入结算信息:" + ex.Message;
  1631. return -1;
  1632. }
  1633. }
  1634. /// <summary>
  1635. /// 取消结算
  1636. /// </summary>
  1637. /// <param name="outParam"></param>
  1638. /// <returns></returns>
  1639. public int cancleSettlement(string newSettlID, out string outParam)
  1640. {
  1641. JObject joTmp = new JObject();
  1642. string errMsg = "";
  1643. try
  1644. {
  1645. joTmp.Add("HospitalDr", Global.inf.hospitalDr);
  1646. joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
  1647. joTmp.Add("admID", MPat.adm_Dr);
  1648. joTmp.Add("mdtrt_id", MPat.mdtrtID);
  1649. joTmp.Add("setl_id", MPat.settlID);
  1650. joTmp.Add("new_setl_id", newSettlID);
  1651. joTmp.Add("updateUserID", Global.user.ID);
  1652. joTmp.Add("msgid", Global.curEvt.msgid);
  1653. joTmp.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1654. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010052", joTmp).ToString(), "取消结算信息");
  1655. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1656. {
  1657. outParam = errMsg;
  1658. return -1;
  1659. }
  1660. else
  1661. {
  1662. outParam = JsonHelper.setExceptionJson(0, "云医保平台","取消结算成功").ToString();
  1663. return 0;
  1664. }
  1665. }
  1666. catch (Exception ex)
  1667. {
  1668. outParam = "取消结算信息:" + ex.Message;
  1669. return -1;
  1670. }
  1671. }
  1672. /// <summary>
  1673. /// 插入医保费用
  1674. /// </summary>
  1675. /// <param name="jaTmp"></param>
  1676. /// <param name="outParam"></param>
  1677. /// <returns></returns>
  1678. public int insertFee(JArray jaTmp, out string outParam)
  1679. {
  1680. try
  1681. {
  1682. outParam = "";
  1683. string errMsg;
  1684. dynamic joTmp = new JObject();
  1685. joTmp = new JObject();
  1686. joTmp.code = "09010046";
  1687. joTmp.HospitalDr = Global.inf.hospitalDr;
  1688. joTmp.admID = MPat.adm_Dr;
  1689. joTmp.mdtrt_id = MPat.mdtrtID;
  1690. joTmp.updateUserID = Global.user.ID;
  1691. joTmp.Add("params", jaTmp);
  1692. ;
  1693. JObject joRtn = invoker.invokeInsuService(joTmp.ToString(), "插入2301明细");
  1694. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1695. {
  1696. outParam = errMsg;
  1697. return -1;
  1698. }
  1699. else
  1700. {
  1701. outParam = joRtn.ToString();
  1702. return 0;
  1703. }
  1704. }
  1705. catch (Exception ex)
  1706. {
  1707. outParam = "insertFee 异常:" + ex.Message;
  1708. return -1;
  1709. }
  1710. }
  1711. private int saveToMi( out string errMsg)
  1712. {
  1713. errMsg = "";
  1714. try
  1715. {
  1716. //存储参保信息
  1717. if (insertPatCurInsuInfo( out errMsg) != 0)
  1718. {
  1719. return -1;
  1720. }
  1721. //存储登记信息
  1722. if (saveRegisterInfo( out errMsg) != 0)
  1723. {
  1724. return -1;
  1725. }
  1726. //处理jaFee
  1727. foreach (var jo in jaFee)
  1728. {
  1729. jo["mdtrt_id"] = MPat.mdtrtID;
  1730. jo["psn_no"] = MPat.psn_no;
  1731. }
  1732. //存储费用信息
  1733. if (insertFee(jaFee, out errMsg) != 0)
  1734. {
  1735. return -1;
  1736. }
  1737. return 0;
  1738. }
  1739. catch (Exception ex)
  1740. {
  1741. errMsg = "saveToMi:" + ex.Message;
  1742. return -1;
  1743. }
  1744. }
  1745. #endregion
  1746. #region 解析中心返回
  1747. /// <summary>
  1748. /// 解析银海移动支付返参
  1749. /// </summary>
  1750. /// <param name="joRtn"></param>
  1751. /// <param name="errorMsg"></param>
  1752. /// <returns></returns>
  1753. public int ParseCenterRtnValue(JObject joRtn, out string errorMsg)
  1754. {
  1755. try
  1756. {
  1757. errorMsg =JsonHelper.getDestValue(joRtn, "message");
  1758. return int.Parse(JsonHelper.getDestValue(joRtn, "code")); //0 成功-1 失败
  1759. }
  1760. catch (Exception ex)
  1761. {
  1762. errorMsg = "解析移动支付返参发生异常:" + ex.Message;
  1763. return -1;
  1764. }
  1765. }
  1766. #endregion
  1767. }
  1768. }