MobilePay.cs 79 KB

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