MobilePay.cs 85 KB

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