MobilePay.cs 79 KB

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