MobilePay.cs 87 KB

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