MobilePay.cs 86 KB

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