MobilePay.cs 89 KB

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