MobilePay.cs 78 KB

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