MobilePay.cs 86 KB

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