MobilePay.cs 88 KB

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