MobilePay.cs 82 KB

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