MobilePay.cs 90 KB

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