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