MobilePay.cs 87 KB

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