MobilePay.cs 88 KB

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