MobilePay.cs 75 KB

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