MobilePay.cs 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.Common;
  3. using PTMedicalInsurance.Helper;
  4. using PTMedicalInsurance.Variables;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. 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. public int MobilePaySettlement(out string outPar)
  46. {
  47. string errMsg,patInfo,YH6201Inpar,YH6201Rtn, YH6202Inpar, YH6202Rtn,YH6301Inpar,YH6301Rtn;
  48. outPar = "";
  49. try
  50. {
  51. EncryptHelper eh = new EncryptHelper(Global.inf.MobilePay.appid, Global.inf.MobilePay.secretKey, Global.inf.MobilePay.publicKey, Global.inf.MobilePay.privateKey);
  52. if (GetPatientInfo(out errMsg) != 0)
  53. {
  54. outPar = errMsg;
  55. return -1;
  56. }
  57. patInfo = errMsg;
  58. JObject jo1194Rtn = invoker.invokeCenterService("1194", JsonHelper.setCenterInpar("1194", patInfo));
  59. if (JsonHelper.parseCenterRtnValue(jo1194Rtn, out errMsg) != 0)
  60. {
  61. outPar = errMsg;
  62. return -1;
  63. }
  64. setPatientInsuInfo(jo1194Rtn);
  65. if (GetYH6201Inpar(out errMsg) != 0)
  66. {
  67. outPar = errMsg;
  68. return -1;
  69. }
  70. Global.writeLog(errMsg);
  71. YH6201Inpar = errMsg;
  72. string signText = "";
  73. JObject joYH6201Rtn = invoker.invokeMPService("6201", eh.encrypt(errMsg,ref signText));
  74. if (JsonHelper.parseMPRtnValue(joYH6201Rtn, out errMsg) != 0)
  75. {
  76. outPar = errMsg;
  77. return -1;
  78. }
  79. JObject joEncData = JObject.Parse(eh.decrypt(errMsg));
  80. Global.writeLog(JsonHelper.Compress(joEncData));
  81. //设置
  82. setPatientBy6201Rtn(joEncData);
  83. //存入MI 患者表,登记表,费用表
  84. if (saveToMi(out errMsg) != 0)
  85. {
  86. outPar = errMsg;
  87. return -1;
  88. }
  89. //YH6202
  90. if (GetYH6202Inpar(JObject.Parse(YH6201Inpar), out errMsg) != 0)
  91. {
  92. outPar = errMsg;
  93. return -1;
  94. }
  95. YH6202Inpar = errMsg;
  96. JObject joYH6202Rtn = invoker.invokeMPService("6202", eh.encrypt(YH6202Inpar,ref signText));
  97. if (JsonHelper.parseMPRtnValue(joYH6202Rtn, out errMsg) != 0)
  98. {
  99. outPar = errMsg;
  100. return -1;
  101. }
  102. joEncData = JObject.Parse(eh.decrypt(errMsg));
  103. Global.writeLog(JsonHelper.Compress(joEncData));
  104. //设置
  105. setSettlementsBy6202Rtn(joEncData);
  106. MSettl.confirmFlag = 0;
  107. //存入MI 结算表
  108. if (saveSettlement (out errMsg) != 0)
  109. {
  110. outPar = errMsg;
  111. return -1;
  112. }
  113. //6301查询具体明细信息
  114. //if (GetYH6301Inpar(out errMsg) != 0)
  115. //{
  116. // outPar = errMsg;
  117. // return -1;
  118. //}
  119. //YH6301Inpar = errMsg;
  120. //JObject joYH6301Rtn = invoker.invokeMPService("6301", eh.encrypt(YH6301Inpar));
  121. //if (JsonHelper.parseMPRtnValue(joYH6301Rtn, out errMsg) != 0)
  122. //{
  123. // outPar = errMsg;
  124. // return -1;
  125. //}
  126. //joEncData = JObject.Parse(eh.decrypt(errMsg));
  127. //JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
  128. //Global.writeLog(JsonHelper.Compress(joEncData));
  129. ////设置
  130. //setSettlementsBy6301Rtn(joSettlInfo);
  131. ////存入MI 结算表
  132. //if (saveSettlement(out errMsg) != 0)
  133. //{
  134. // outPar = errMsg;
  135. //}
  136. //返回给HIS后端
  137. JObject joPreSettl = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.preSetl"));
  138. //JObject joTmp = JObject.Parse(JsonHelper.getDestValue(joYH6201Rtn, "encData"));
  139. JObject joTmp = new JObject();
  140. joTmp.Add("insutype", MPat.insuType);
  141. joTmp.Add("psn_no", MPat.psn_no);
  142. joTmp.Add("insuplc_admdvs", MPat.insuplc_admdvs);
  143. joTmp.Add("mdtrtId", MPat.mdtrtID);
  144. joTmp.Add("mdtrt_id", MPat.mdtrtID);
  145. joPreSettl.Add("setl_id", MPat.payOrdId);
  146. joTmp.Add("mdtrt_cert_type", JsonHelper.getDestValue(joPreSettl, "mdtrt_cert_type"));
  147. joTmp.Add("mdtrt_cert_no", JsonHelper.getDestValue(joPreSettl, "certno"));
  148. joTmp.Add("med_type", JsonHelper.getDestValue(joPreSettl, "med_type"));
  149. if (returnMPSettlementInfo(joTmp, joPreSettl, out errMsg) != 0)
  150. {
  151. outPar = errMsg;
  152. return -1;
  153. }
  154. //返回给HIS前端
  155. outPar = errMsg;
  156. return 0;
  157. }
  158. catch (Exception ex)
  159. {
  160. outPar = ex.Message;
  161. return -1;
  162. }
  163. }
  164. public int MobilePayQuery(out string outPar)
  165. {
  166. string errMsg, M6301Inpar;
  167. outPar = "";
  168. //6301查询具体明细信息
  169. if (GetYH6301Inpar(out errMsg) != 0)
  170. {
  171. outPar = errMsg;
  172. return -1;
  173. }
  174. M6301Inpar = errMsg;
  175. JObject joM6301Rtn = invoker.invokeMPService("6301", M6301Inpar);
  176. if (JsonHelper.parseMPRtnValue(joM6301Rtn, out errMsg) != 0)
  177. {
  178. outPar = errMsg;
  179. return -1;
  180. }
  181. outPar = joM6301Rtn.ToString();
  182. return 0;
  183. }
  184. public int MobilePayConfirmSettlement(out string outPar)
  185. {
  186. string errMsg, YH6301Inpar, YH6301Rtn;
  187. outPar = "";
  188. try
  189. {
  190. EncryptHelper eh = new EncryptHelper(Global.inf.MobilePay.appid, Global.inf.MobilePay.secretKey, Global.inf.MobilePay.publicKey, Global.inf.MobilePay.privateKey);
  191. //6301查询具体明细信息
  192. if (GetYH6301Inpar(out errMsg) != 0)
  193. {
  194. outPar = errMsg;
  195. return -1;
  196. }
  197. YH6301Inpar = errMsg;
  198. string signText = "";
  199. JObject joYH6301Rtn = invoker.invokeMPService("6301", eh.encrypt(YH6301Inpar,ref signText));
  200. if (JsonHelper.parseMPRtnValue(joYH6301Rtn, out errMsg) != 0)
  201. {
  202. outPar = errMsg;
  203. return -1;
  204. }
  205. JObject joEncData = JObject.Parse(eh.decrypt(errMsg));
  206. JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
  207. Global.writeLog(JsonHelper.Compress(joEncData));
  208. //设置
  209. setSettlementsBy6301Rtn(joSettlInfo);
  210. MSettl.confirmFlag = 1;
  211. //存入MI 结算表
  212. if (updateSettlement(out errMsg) != 0)
  213. {
  214. outPar = errMsg;
  215. return -1;
  216. }
  217. else
  218. {
  219. //返回给HIS前端
  220. outPar = JsonHelper.setExceptionJson(0,"云医保平台","确认成功!").ToString();
  221. return 0;
  222. }
  223. }
  224. catch (Exception ex)
  225. {
  226. outPar = ex.Message;
  227. return -1;
  228. }
  229. }
  230. public int MobilePayCancelSettlement(out string outPar)
  231. {
  232. string errMsg, YH6203Inpar, YH6203Rtn;
  233. outPar = "";
  234. try
  235. {
  236. EncryptHelper eh = new EncryptHelper(Global.inf.MobilePay.appid, Global.inf.MobilePay.secretKey, Global.inf.MobilePay.publicKey, Global.inf.MobilePay.privateKey);
  237. if (MSettl.onlineYBFalg != "Y")
  238. {
  239. //读电子凭证
  240. if (ReadEc(out errMsg) != 0)
  241. {
  242. outPar = errMsg;
  243. return -1;
  244. }
  245. }
  246. //获取6203入参
  247. if (GetYH6203Inpar(out errMsg) != 0)
  248. {
  249. outPar = errMsg;
  250. return -1;
  251. }
  252. YH6203Inpar = errMsg;
  253. string signText = "";
  254. JObject jo6203Rtn = invoker.invokeMPService("6203", eh.encrypt(YH6203Inpar,ref signText));
  255. //YH6202
  256. if (JsonHelper.parseMPRtnValue(jo6203Rtn, out errMsg) != 0)
  257. {
  258. outPar = errMsg;
  259. return -1;
  260. }
  261. else
  262. {
  263. JObject joEncData = JObject.Parse(errMsg);
  264. string newSettlID = JsonHelper.getDestValue(joEncData, "extData.setlInfo.setl_id");
  265. //处理撤销数据
  266. if (cancleSettlement(MPat.settlID, out errMsg) != 0)
  267. {
  268. outPar = errMsg;
  269. return -1;
  270. }
  271. //joParam.Add("mdtrt_id", MPat.mdtrtID);
  272. //joParam.Add("insuplc_admdvs", MPat.insuplc_admdvs);
  273. //joParam.Add("setl_id", MPat.settlID);
  274. joParam.Add("middleSettleFlag", "");
  275. //退HIS结算
  276. if (hIS.cancleSettlementInfo(joParam, out errMsg) != 0)
  277. {
  278. outPar = errMsg;
  279. return -1;
  280. }
  281. else
  282. {
  283. outPar = errMsg;
  284. return 0;
  285. }
  286. }
  287. }
  288. catch (Exception ex)
  289. {
  290. Global.writeLog("MobilePayCancelSettlement:" + ex.Message);
  291. outPar = ex.Message;
  292. return -1;
  293. }
  294. }
  295. public int ReadEc(out string outPar)
  296. {
  297. outPar = "";
  298. try
  299. {
  300. Global.pat.mdtrtcertType = "01";
  301. Global.businessType = "01301"; //结算
  302. string errorMsg = "";
  303. if (cBus.Authenticate(out errorMsg) != 0)
  304. {
  305. outPar = "身份认证失败:" + errorMsg;
  306. return -1;
  307. }
  308. else
  309. {
  310. JObject joRtn = JObject.Parse(errorMsg);
  311. JObject joEncData = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.ecinfo"));
  312. outPar = joEncData.ToString();
  313. setPatientByEc(joEncData);
  314. return 0;
  315. }
  316. ///
  317. }
  318. catch (Exception ex)
  319. {
  320. outPar = ex.Message;
  321. return -1;
  322. }
  323. }
  324. #region 赋值MPat,Msettle结构体
  325. public void setPatientByInPar()
  326. {
  327. MPat.adm_Dr = int.Parse(JsonHelper.getDestValue(joParam, "admID"));
  328. Global.pat.adm_Dr = MPat.adm_Dr;
  329. MPat.recordID = JsonHelper.getDestValue(joParam, "recordID");
  330. MPat.billID = JsonHelper.getDestValue(joParam, "billID");
  331. MPat.medType = JsonHelper.getDestValue(joInsuAdmObj, "medType");
  332. MPat.certType = JsonHelper.getDestValue(joInsuAdmObj, "mdtrtCertType");
  333. MPat.token = JsonHelper.getDestValue(joInsuAdmObj, "ecToken");
  334. MPat.payAuthNo = JsonHelper.getDestValue(joInsuAdmObj, "payAuthNo");
  335. MPat.uldLatlnt = JsonHelper.getDestValue(joInsuAdmObj, "uldLatlnt");
  336. MPat.payOrdId = JsonHelper.getDestValue(joInsuAdmObj, "payOrdId");
  337. MPat.mdtrtID = JsonHelper.getDestValue(joInsuAdmObj, "mdtrt_id");
  338. Global.pat.mdtrtID = MPat.mdtrtID;
  339. }
  340. public void setPatientByEc(JObject jo)
  341. {
  342. MPat.name = JsonHelper.getDestValue(jo, "username");
  343. MPat.IDNO = JsonHelper.getDestValue(jo, "idno");
  344. MPat.certType = JsonHelper.getDestValue(jo, "psn_cert_type");
  345. MPat.token = JsonHelper.getDestValue(jo, "ectoken");
  346. MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuorg");
  347. //MPat.payAuthNo = JsonHelper.getDestValue(jo, "authNo");
  348. //MPat.gend = JsonHelper.getDestValue(jo, "gender");
  349. //MPat.brdy = JsonHelper.getDestValue(jo, "birthday");
  350. //MPat.naty = JsonHelper.getDestValue(jo, "nationality");
  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.baseinfo.insuplc_admdvs");
  386. MPat.psn_no = JsonHelper.getDestValue(jo, "output.baseinfo.psn_no");
  387. MPat.insuType = JsonHelper.getDestValue(jo, "output.baseinfo.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 = JsonHelper.getDestValue(jo, "payOrdId");
  403. MSettl.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
  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. MSettl.payOrdId = JsonHelper.getDestValue(joInsuAdmObj, "payOrdId");
  479. }
  480. #endregion
  481. #region 组织入参
  482. public int GetPatientInfo(out string outparam)
  483. {
  484. string errMsg = "";
  485. outparam = "";
  486. try
  487. {
  488. JObject joInpar = new JObject();
  489. //查询患者基本信息
  490. if (hIS.GetHisPatBaseInfo(out errMsg) != 0)
  491. {
  492. outparam = errMsg;
  493. return -1;
  494. }
  495. setPatientByHisBaseInfo(JObject.Parse(errMsg));
  496. //入参
  497. joInpar.Add("mdtrt_cert_type", "02");//就诊凭证类型
  498. joInpar.Add("mdtrt_cert_no", MPat.certNO);//就诊凭证编号
  499. joInpar.Add("card_sn", "");//卡识别码
  500. joInpar.Add("begntime", "");//开始时间 获取历史参保信息时传入
  501. joInpar.Add("psn_cert_type", "01");//就诊凭证类型为“ 02” 时默认传 01 代表身份 证,其他证件类型按实际上传
  502. joInpar.Add("certno", MPat.certNO);//证件号码
  503. joInpar.Add("psn_name", MPat.name);//姓名
  504. JObject joData = new JObject();
  505. joData.Add("data", joInpar);
  506. outparam = joData.ToString();
  507. return 0;
  508. }
  509. catch (Exception ex)
  510. {
  511. outparam = "GetPatientInfo:" + ex.Message;
  512. return -1;
  513. }
  514. finally
  515. {
  516. Global.writeLog("GetPatientInfo", "", outparam);
  517. }
  518. }
  519. //组织YH6201入参
  520. public int GetYH6201Inpar(out string outparam)
  521. {
  522. string errMsg = "";
  523. outparam = "";
  524. try
  525. {
  526. JObject joInpar = new JObject();
  527. //查询患者基本信息
  528. if (hIS.GetHisPatBaseInfo(out errMsg) != 0)
  529. {
  530. outparam = errMsg;
  531. return -1;
  532. }
  533. setPatientByHisBaseInfo(JObject.Parse(errMsg));
  534. JObject joPatBaseInfo = JObject.Parse(JsonHelper.getDestValue(JObject.Parse(errMsg),"result"));
  535. //获取诊断
  536. if (getDiagnoses(out errMsg) != 0)
  537. {
  538. outparam = errMsg;
  539. return -1;
  540. }
  541. JObject joDiagnoses = JObject.Parse(errMsg);
  542. JArray jaDiseinfoList = JArray.Parse(JsonHelper.getDestValue(joDiagnoses, "diseinfoList"));
  543. JObject joMdtrtinfo = JObject.Parse(JsonHelper.getDestValue(joDiagnoses, "mdtrtinfo"));
  544. setPatientByDiagnoseInfo(joMdtrtinfo);
  545. //获取费用
  546. if (GetFee(out errMsg) != 0)
  547. {
  548. outparam = errMsg;
  549. return -1;
  550. }
  551. JObject joFee = JObject.Parse(errMsg);
  552. JArray jaFeedetailList = JArray.Parse(JsonHelper.getDestValue(joFee, "feedetailList"));
  553. for (int i = 0; i < jaFeedetailList.Count; i++)
  554. {
  555. JObject joTmp = new JObject();
  556. joTmp.Add("act_purc_pric", jaFeedetailList[i]["pric"]);
  557. joTmp.Add("sin_dos", jaFeedetailList[i]["sinDosDscr"]);
  558. joTmp.Add("medins_list_name", jaFeedetailList[i]["medListName"]);
  559. ((JObject)jaFeedetailList[i]).Property("chrgBchno").Remove();
  560. ((JObject)jaFeedetailList[i]).Property("diseCodg").Remove();
  561. ((JObject)jaFeedetailList[i]).Property("rxno").Remove();
  562. ((JObject)jaFeedetailList[i]).Property("feeOcurTime").Remove();
  563. ((JObject)jaFeedetailList[i]).Property("sinDosDscr").Remove();
  564. ((JObject)jaFeedetailList[i]).Property("usedFrquDscr").Remove();
  565. ((JObject)jaFeedetailList[i]).Property("prdDays").Remove();
  566. ((JObject)jaFeedetailList[i]).Property("medcWayDscr").Remove();
  567. //((JObject)jaFeedetailList[i]).Property("bilgDeptCodg").Remove();
  568. ((JObject)jaFeedetailList[i]).Property("acordDeptCodg").Remove();
  569. ((JObject)jaFeedetailList[i]).Property("acordDeptName").Remove();
  570. ((JObject)jaFeedetailList[i]).Property("ordersDrCode").Remove();
  571. ((JObject)jaFeedetailList[i]).Property("ordersDrName").Remove();
  572. ((JObject)jaFeedetailList[i]).Property("tcmdrugUsedWay").Remove();
  573. ((JObject)jaFeedetailList[i]).Property("etipFlag").Remove();
  574. ((JObject)jaFeedetailList[i]).Property("etipHospCode").Remove();
  575. ((JObject)jaFeedetailList[i]).Property("dscgTkdrugFlag").Remove();
  576. ((JObject)jaFeedetailList[i]).Property("matnFeeFlag").Remove();
  577. ((JObject)jaFeedetailList[i]).Property("initFeedetlSn").Remove();
  578. ((JObject)jaFeedetailList[i]).Property("medType").Remove();
  579. ((JObject)jaFeedetailList[i]).Property("memo").Remove();
  580. //((JObject)jaFeedetailList[i]).Property("expContent").Remove();
  581. ((JObject)jaFeedetailList[i]).Property("medListName").Remove();
  582. ((JObject)jaFeedetailList[i]).Property("medListSpc").Remove();
  583. ((JObject)jaFeedetailList[i]).Property("combNo").Remove();
  584. //jaFeedetailList[i]["chrgBchno"] = MPat.adm_Dr.ToString();
  585. jaFeedetailList[i]["expContent"] = joTmp.ToString().Replace("\r\n","");
  586. jaFeedetailList[i]["medType"] = JsonHelper.getDestValue(joInsuAdmObj, "medType");
  587. jaFeedetailList[i]["psnNo"] = new JObject();
  588. jaFeedetailList[i]["psnNo"] = MPat.psn_no;
  589. }
  590. //入参
  591. joInpar.Add("orgCodg", Global.inf.hospitalNO);//机构编码
  592. //joInpar.Add("orgId", "");//电子凭证机构号
  593. joInpar.Add("psnNo", MPat.psn_no);//人员编号
  594. joInpar.Add("insutype", MPat.insuType);//险种类型
  595. joInpar.Add("medOrgOrd", MPat.recordID);//医疗机构订单号 前端传入
  596. //joInpar.Add("initRxOrd", JsonHelper.getDestValue(joInsuAdmObj, "initRxOrd"));//要续方的原处方流水 前端传入
  597. //joInpar.Add("rxCircFlag", JsonHelper.getDestValue(joInsuAdmObj, "rxCircFlag"));//电子处方流转标志 前端传入
  598. MSettl.settlTime = Convert.ToDateTime(JsonHelper.getDestValue(joMdtrtinfo, "begntime"));
  599. //joInpar.Add("begntime", JsonHelper.getDestValue(joMdtrtinfo, "begntime"));//开始时间
  600. joInpar.Add("idNo", JsonHelper.getDestValue(joPatBaseInfo, "credNo"));//证件号码
  601. joInpar.Add("userName", JsonHelper.getDestValue(joPatBaseInfo, "patName"));//用户姓名
  602. joInpar.Add("idType", JsonHelper.getDestValue(joPatBaseInfo, "credCode"));//证件类别
  603. joInpar.Add("ecToken", JsonHelper.getDestValue(joInsuAdmObj, "ecToken"));//电子凭证授权ecToken 前端传入
  604. joInpar.Add("insuCode", Global.inf.areaCode);//就诊参保地行政区划
  605. joInpar.Add("iptOtpNo", JsonHelper.getDestValue(joMdtrtinfo, "ipt_no"));//住院/门诊号
  606. joInpar.Add("atddrNo", JsonHelper.getDestValue(joMdtrtinfo, "atddr_no"));//医师编码
  607. joInpar.Add("drName", JsonHelper.getDestValue(joMdtrtinfo, "chfpdr_name"));//医师姓名
  608. joInpar.Add("deptCode", JsonHelper.getDestValue(joMdtrtinfo, "adm_dept_codg"));//科室编码
  609. joInpar.Add("deptName", JsonHelper.getDestValue(joMdtrtinfo, "adm_dept_name"));//科室名称
  610. joInpar.Add("caty", "A10");//科别
  611. joInpar.Add("mdtrtId", JsonHelper.getDestValue(joMdtrtinfo, "mdtrtId"));//就诊ID
  612. joInpar.Add("medType", MPat.medType);//医疗类别 前端传入
  613. joInpar.Add("feeType", JsonHelper.getDestValue(joInsuAdmObj, "feeType"));//费用类型 前端传入
  614. joInpar.Add("medfeeSumamt", JsonHelper.getDestValue(joFee, "medfeeSumamt"));//医疗费总额
  615. //joInpar.Add("acctUsedFlag", JsonHelper.getDestValue(joInsuAdmObj, "acctUsedFlag"));//个人账户使用标志 前端传入
  616. //joInpar.Add("mainCondDscr", JsonHelper.getDestValue(joMdtrtinfo, "mainCondDscr"));//主要病情描述
  617. //joInpar.Add("diseCodg", JsonHelper.getDestValue(joMdtrtinfo, "diseCodg"));//病种编码
  618. //joInpar.Add("diseName", JsonHelper.getDestValue(joMdtrtinfo, "diseName"));//病种名称
  619. //joInpar.Add("psnSetlway", JsonHelper.getDestValue(joInsuAdmObj, "psnSetlway"));//个人结算方式 前端传入
  620. joInpar.Add("chrgBchno", JsonHelper.getDestValue(joFee, "chrgBchno"));//收费批次号
  621. //joInpar.Add("pubHospRfomFlag", JsonHelper.getDestValue(joInsuAdmObj, "pubHospRfomFlag"));//公立医院改革标志
  622. //joInpar.Add("invono", JsonHelper.getDestValue(joMdtrtinfo, "invono"));//发票号
  623. //joInpar.Add("endtime", JsonHelper.getDestValue(joMdtrtinfo, "endtime"));//出院时间
  624. //joInpar.Add("fulamtOwnpayAmt", JsonHelper.getDestValue(joMdtrtinfo, "fulamtOwnpayAmt"));//全自费金额
  625. //joInpar.Add("overlmtSelfpay", JsonHelper.getDestValue(joMdtrtinfo, "overlmtSelfpay"));//超限价金额
  626. //joInpar.Add("preselfpayAmt", JsonHelper.getDestValue(joMdtrtinfo, "preselfpayAmt"));//先行自付金额
  627. //joInpar.Add("inscpScpAmt", JsonHelper.getDestValue(joMdtrtinfo, "inscpScpAmt"));//符合政策范围金额
  628. //joInpar.Add("oprnOprtCode", JsonHelper.getDestValue(joMdtrtinfo, "oprnOprtCode"));//手术操作代码
  629. //joInpar.Add("oprnOprtName", JsonHelper.getDestValue(joMdtrtinfo, "oprnOprtName"));//手术操作名称
  630. //joInpar.Add("fpscNo", JsonHelper.getDestValue(joMdtrtinfo, "fpscNo"));//计划生育服务证号
  631. //joInpar.Add("latechbFlag", JsonHelper.getDestValue(joMdtrtinfo, "latechbFlag"));//晚育标志
  632. joInpar.Add("gesoVal", JsonHelper.getDestValue(joMdtrtinfo, "gesoVal"));//孕周数
  633. joInpar.Add("fetts", JsonHelper.getDestValue(joMdtrtinfo, "fetts"));//胎次
  634. joInpar.Add("fetusCnt", JsonHelper.getDestValue(joMdtrtinfo, "fetusCnt"));//胎儿数
  635. //joInpar.Add("pretFlag", JsonHelper.getDestValue(joMdtrtinfo, "pretFlag"));//早产标志
  636. //joInpar.Add("birctrlType", JsonHelper.getDestValue(joMdtrtinfo, "birctrlType"));//计划生育手术类别
  637. //joInpar.Add("birctrlMatnDate", JsonHelper.getDestValue(joMdtrtinfo, "birctrlMatnDate"));//计划生育手术或生育日期
  638. //joInpar.Add("copFlag", JsonHelper.getDestValue(joMdtrtinfo, "copFlag"));//伴有并发症标志
  639. //joInpar.Add("dscgDeptCodg", JsonHelper.getDestValue(joMdtrtinfo, "dscgDeptCodg"));//出院科室编码
  640. //joInpar.Add("dscgDeptName", JsonHelper.getDestValue(joMdtrtinfo, "dscgDeptName"));//出院科室名称
  641. //joInpar.Add("dscgDed", JsonHelper.getDestValue(joMdtrtinfo, "dscgDed"));//出院床位
  642. //joInpar.Add("dscgWay", JsonHelper.getDestValue(joMdtrtinfo, "dscgWay"));//离院方式
  643. //joInpar.Add("dieDate", JsonHelper.getDestValue(joMdtrtinfo, "dieDate"));//死亡日期
  644. //joInpar.Add("matnType", JsonHelper.getDestValue(joMdtrtinfo, "matnType"));//生育类别
  645. //joInpar.Add("expContent", JsonHelper.getDestValue(joInsuAdmObj, "expContent"));//扩展参数 前端传入
  646. //joInpar.Add("midSetlFlag", JsonHelper.getDestValue(joInsuAdmObj, "midSetlFlag"));//中途结算标志 前端传入
  647. joInpar.Add("diseinfoList", jaDiseinfoList);//诊断或症状明细
  648. joInpar.Add("feedetailList", jaFeedetailList);//费用明细
  649. //joInpar.Add("admDiagDscr", JsonHelper.getDestValue(joMdtrtinfo, "admDiagDscr"));//入院诊断描述
  650. //joInpar.Add("admDeptCodg", JsonHelper.getDestValue(joMdtrtinfo, "admDeptCodg"));//入院科室编码
  651. //joInpar.Add("admDeptName", JsonHelper.getDestValue(joMdtrtinfo, "admDeptName"));//入院科室名称
  652. //joInpar.Add("admBed", JsonHelper.getDestValue(joMdtrtinfo, "admBed"));//入院床位
  653. joInpar.Add("payAuthNo", JsonHelper.getDestValue(joInsuAdmObj, "payAuthNo"));//支付授权码 前端传入
  654. joInpar.Add("uldLatlnt", JsonHelper.getDestValue(joInsuAdmObj, "uldLatlnt"));//经纬度 前端传入
  655. joInpar.Add("mdtrtCertType", JsonHelper.getDestValue(joInsuAdmObj, "mdtrtCertType"));//就诊凭证类型 前端传入
  656. //joInpar.Add("insuplcAdmdvs", MPat.insuplc_admdvs);//用户参保地行政区划
  657. JObject joData = new JObject();
  658. joData.Add("data",joInpar);
  659. outparam = joInpar.ToString();
  660. return 0;
  661. }
  662. catch (Exception ex)
  663. {
  664. outparam = "GetYH6201Inpar:" + ex.Message;
  665. return -1;
  666. }
  667. finally
  668. {
  669. Global.writeLog("GetYH6201Inpar","",outparam);
  670. }
  671. }
  672. //获取入参,入参基本为类局部变量
  673. public int GetYH6202Inpar(JObject joYH6201Inpar, out string outparam)
  674. {
  675. outparam = "";
  676. try
  677. {
  678. //获取其他入参
  679. JObject joInpar = new JObject();
  680. joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
  681. joInpar.Add("payOrdId", MPat.payOrdId);//待支付订单号
  682. joInpar.Add("payToken", MPat.payToken);//支付订单对应的token
  683. joInpar.Add("orgCodg", Global.inf.hospitalNO);//定点机构编码
  684. joInpar.Add("orgBizSer", DateTime.Now.ToString("yyyyMMddHHmmssffff"));//业务流水号 前端传入
  685. joInpar.Add("ecAuthCode", "");
  686. joInpar.Add("ecChnlAppId", "");
  687. joInpar.Add("ecChnlUserId", "");
  688. joInpar.Add("mdtrtId", MPat.mdtrtID);
  689. joInpar.Add("chrgBchno", JsonHelper.getDestValue(joYH6201Inpar, "chrgBchno"));//收费批次号
  690. joInpar.Add("feeType", JsonHelper.getDestValue(joYH6201Inpar, "feeType"));//费用类别
  691. //joInpar.Add("deposit", JsonHelper.getDestValue(joInsuAdmObj, "deposit"));//住院押金
  692. joInpar.Add("expContent", "");//扩展数据
  693. //joInpar.Add("acctUsedFlag", "");//个账使用标识
  694. //JObject joData = new JObject();
  695. //joData.Add("data",joInpar);
  696. outparam = joInpar.ToString();
  697. return 0;
  698. }
  699. catch (Exception ex)
  700. {
  701. outparam = "GetYH6202Inpar:" + ex.Message;
  702. return -1;
  703. }
  704. finally
  705. {
  706. Global.writeLog("GetYH6202Inpar", "", outparam);
  707. }
  708. }
  709. //组织YH6203入参
  710. public int GetYH6203Inpar(out string outparam)
  711. {
  712. string errMsg = "";
  713. outparam = "";
  714. try
  715. {
  716. JObject joInpar = new JObject();
  717. //获取医保平台结算信息
  718. if (QuerySettleInfo(out errMsg) != 0)
  719. {
  720. outparam = errMsg;
  721. return -1;
  722. }
  723. JObject joRtn = JObject.Parse(errMsg);
  724. JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "result.data[0]"));
  725. MPat.settlID = JsonHelper.getDestValue(joSettl, "SettlementID");
  726. //MPat.mdtrtID = JsonHelper.getDestValue(joSettl, "MdtrtID");
  727. //入参
  728. joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "PayOrdID"));//支付订单号
  729. joInpar.Add("appRefdSn", MPat.recordID);//应用退款流水号
  730. joInpar.Add("appRefdTime", DateTime.Now.ToString("yyyyMMddHHmmss"));//应用退费时间
  731. joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
  732. joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
  733. joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
  734. joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joSettl, "PersonCashPay"));//现金退费金额
  735. joInpar.Add("ecToken", MPat.token);//电子凭证授权Token 前端传入
  736. joInpar.Add("refdType", "HI");//退费类型 前端传入
  737. joInpar.Add("expContent", "");//扩展数据 前端传入
  738. joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
  739. //JObject joData = new JObject();
  740. //joData.Add("data", joInpar);
  741. outparam = joInpar.ToString();
  742. return 0;
  743. }
  744. catch (Exception ex)
  745. {
  746. outparam = "GetYH6203Inpar:" + ex.Message;
  747. return -1;
  748. }
  749. finally
  750. {
  751. Global.writeLog("GetYH6203Inpar", "", outparam);
  752. }
  753. }
  754. //获取入参,入参基本为类局部变量
  755. public int GetYH6301Inpar(out string outparam)
  756. {
  757. outparam = "";
  758. try
  759. {
  760. string errMsg;
  761. //查询登记信息
  762. if (mIS.queryRegisterInfo(4,out errMsg) != 0)
  763. {
  764. outparam = errMsg;
  765. return -1;
  766. }
  767. setPatientByMiRegInfo(JObject.Parse(errMsg));
  768. //获取其他入参
  769. JObject joInpar = new JObject();
  770. joInpar.Add("payOrdId", MPat.payOrdId);//待支付订单号
  771. joInpar.Add("payToken", MPat.payToken);//支付订单对应的token
  772. joInpar.Add("orgCodg", Global.inf.hospitalNO);//定点机构编码
  773. joInpar.Add("idNo", MPat.IDNO);//业务流水号 前端传入
  774. joInpar.Add("userName", MPat.name);
  775. joInpar.Add("idType", "01");
  776. joInpar.Add("expContent", "");
  777. outparam = joInpar.ToString();
  778. return 0;
  779. }
  780. catch (Exception ex)
  781. {
  782. outparam = "GetYH6301Inpar:" + ex.Message;
  783. return -1;
  784. }
  785. finally
  786. {
  787. Global.writeLog("GetYH6301Inpar", "", outparam);
  788. }
  789. }
  790. public int GetYH6401Inpar(out string outparam)
  791. {
  792. string errMsg = "";
  793. outparam = "";
  794. try
  795. {
  796. JObject joInpar = new JObject();
  797. //获取医保平台结算信息
  798. if (QuerySettleInfo(out errMsg) != 0)
  799. {
  800. outparam = errMsg;
  801. return -1;
  802. }
  803. JObject joRtn = JObject.Parse(errMsg);
  804. JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "data"));
  805. //入参
  806. joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "SettlementID"));//支付订单号
  807. joInpar.Add("appRefdSn", JsonHelper.getDestValue(joSettl, ""));//应用退款流水号
  808. joInpar.Add("appRefdTime", JsonHelper.getDestValue(joSettl, ""));//应用退费时间
  809. joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
  810. joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
  811. joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
  812. joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joInsuAdmObj, "PersonCashPay"));//现金退费金额
  813. joInpar.Add("ecToken", MPat.token);//电子凭证授权Token 前端传入
  814. joInpar.Add("refdType", "ALL");//退费类型 前端传入
  815. joInpar.Add("expContent", "");//扩展数据 前端传入
  816. joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
  817. outparam = joInpar.ToString();
  818. return 0;
  819. }
  820. catch (Exception ex)
  821. {
  822. outparam = "GetYH6203Inpar:" + ex.Message;
  823. return -1;
  824. }
  825. finally
  826. {
  827. Global.writeLog("GetYH6203Inpar", "", 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", jaFeeDetail[i]["mdtrt_id"]);//就诊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 PayOrdID= '" + 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("pay_ord_id", MSettl.payOrdId);
  1269. joSetlinfo.Add("psn_no", MPat.psn_no);
  1270. joSetlinfo.Add("psn_name", MPat.name);
  1271. //joSetlinfo.Add("mdtrt_cert_type", JsonHelper.getDestValue(joRtnSetlinfo, "mdtrt_cert_type"));
  1272. joSetlinfo.Add("certno", MPat.certNO);
  1273. joSetlinfo.Add("gend", MPat.gend);
  1274. joSetlinfo.Add("naty", MPat.naty);
  1275. joSetlinfo.Add("brdy", MPat.brdy);
  1276. joSetlinfo.Add("age", MPat.age);
  1277. joSetlinfo.Add("insutype", MPat.insuType);
  1278. joSetlinfo.Add("psn_type", MPat.psn_type);
  1279. joSetlinfo.Add("cvlserv_flag", "");
  1280. joSetlinfo.Add("setl_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1281. joSetlinfo.Add("mdtrt_cert_type", MPat.mdtrtcertType);
  1282. joSetlinfo.Add("med_type", MPat.medType);
  1283. joSetlinfo.Add("medfee_sumamt", MSettl.sumamt);//总费用
  1284. joSetlinfo.Add("fulamt_ownpay_amt", MSettl.ownPayAmount);//全自费金额
  1285. joSetlinfo.Add("overlmt_selfpay", MSettl.overLimitAmountmt);//超限价自费费用
  1286. joSetlinfo.Add("preselfpay_amt", MSettl.preSelfPayAmount);//先行自付金额
  1287. joSetlinfo.Add("inscp_scp_amt", MSettl.inPolicyRangeAmount);//符合政策范围金额
  1288. joSetlinfo.Add("act_pay_dedc", MSettl.actualPayDeductible);//实际支付起付线
  1289. joSetlinfo.Add("hifp_pay", MSettl.healthInsurancePay);//基本医疗保险统筹基金支出
  1290. joSetlinfo.Add("pool_prop_selfpay", MSettl.healthInsuranceRatio);//基本医疗保险统筹基金支付比例
  1291. joSetlinfo.Add("cvlserv_pay", MSettl.civilserviceAllowancePay);//公务员医疗补助资金支出
  1292. joSetlinfo.Add("hifes_pay", MSettl.enterpriseSupplementPay);//企业支付 占用 大病报销金额
  1293. joSetlinfo.Add("hifmi_pay", MSettl.seriousIllnessPay);// 居民大病保险资金支出
  1294. joSetlinfo.Add("hifob_pay", MSettl.largeExpensesSupplementPay);//职工大额医疗费用补助基金支出
  1295. joSetlinfo.Add("maf_pay", MSettl.medicalAssistPay);//医疗救助基金支出
  1296. joSetlinfo.Add("hosp_part_amt", MSettl.hospitalPartAmount);//医院负担金额
  1297. joSetlinfo.Add("oth_pay", MSettl.otherPay);//其他支出
  1298. joSetlinfo.Add("fund_pay_sumamt", MSettl.fundPaySumamt);//基金支付总额
  1299. joSetlinfo.Add("psn_part_amt", MSettl.personPaySumamt);//个人负担总金额
  1300. joSetlinfo.Add("acct_pay", MSettl.accountPaySumamt);//个人账户支出
  1301. joSetlinfo.Add("psn_cash_pay", MSettl.personCashPay);//个人现金支出
  1302. joSetlinfo.Add("balc", MSettl.balance);// 余额
  1303. joSetlinfo.Add("acct_mulaid_pay", "");//个人账户共济支付金额
  1304. joSetlinfo.Add("medins_setl_id", "");//医药机构结算ID
  1305. joSetlinfo.Add("clr_optins", MSettl.clearingOrgan);//清算经办机构
  1306. joSetlinfo.Add("clr_way", MSettl.clearingWay);//清算方式
  1307. joSetlinfo.Add("clr_type", MSettl.clearingType);//清算类别
  1308. joSetlinfo.Add("ValidFlag", 1);
  1309. joSetlinfo.Add("BillType", 1);
  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. joSetlinfo.Add("ConfirmFlag", MSettl.confirmFlag);
  1323. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010051", joSetlinfo).ToString(), "插入结算信息");
  1324. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1325. {
  1326. outParam = errMsg;
  1327. return -1;
  1328. }
  1329. else
  1330. {
  1331. outParam = joSetlinfo.ToString();
  1332. return 0;
  1333. }
  1334. }
  1335. catch (Exception ex)
  1336. {
  1337. outParam = "插入结算信息:" + ex.Message;
  1338. return -1;
  1339. }
  1340. }
  1341. public int updateSettlement(out string outParam)
  1342. {
  1343. JObject joTmp = new JObject();
  1344. string errMsg = "";
  1345. try
  1346. {
  1347. JObject joSetlinfo = new JObject();
  1348. joSetlinfo.Add("HospitalDr", Global.inf.hospitalDr);
  1349. joSetlinfo.Add("AdmDr", MPat.adm_Dr);
  1350. joSetlinfo.Add("MdtrtID", MPat.mdtrtID);
  1351. joSetlinfo.Add("SettlementID", MSettl.settlID);//
  1352. joSetlinfo.Add("PayOrdID", MSettl.payOrdId);
  1353. joSetlinfo.Add("PersonnelNO", MPat.psn_no);
  1354. joSetlinfo.Add("PatientName", MPat.name);
  1355. //joSetlinfo.Add("CertificateType", JsonHelper.getDestValue(joRtnSetlinfo, "mdtrt_cert_type"));
  1356. joSetlinfo.Add("CertificateNO", MPat.certNO);
  1357. joSetlinfo.Add("Gender", MPat.gend);
  1358. joSetlinfo.Add("Nation", MPat.naty);
  1359. joSetlinfo.Add("BirthDay", MPat.brdy);
  1360. joSetlinfo.Add("Age", MPat.age);
  1361. joSetlinfo.Add("InsuranceType", MPat.insuType);
  1362. joSetlinfo.Add("PersonType", MPat.psn_type);
  1363. joSetlinfo.Add("CivilserviceFlag", "");
  1364. joSetlinfo.Add("SettlementDateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1365. joSetlinfo.Add("MdtrtCertType", MPat.mdtrtcertType);
  1366. joSetlinfo.Add("MedicalType", MPat.medType);
  1367. joSetlinfo.Add("Sumamt", MSettl.sumamt);//总费用
  1368. joSetlinfo.Add("OwnPayAmount", MSettl.ownPayAmount);//全自费金额
  1369. joSetlinfo.Add("OverLimitAmount", MSettl.overLimitAmountmt);//超限价自费费用
  1370. joSetlinfo.Add("PreSelfPayAmount", MSettl.preSelfPayAmount);//先行自付金额
  1371. joSetlinfo.Add("InPolicyRangeAmount", MSettl.inPolicyRangeAmount);//符合政策范围金额
  1372. joSetlinfo.Add("ActualPayDeductible", MSettl.actualPayDeductible);//实际支付起付线
  1373. joSetlinfo.Add("HealthInsurancePay", MSettl.healthInsurancePay);//基本医疗保险统筹基金支出
  1374. joSetlinfo.Add("HealthInsuranceRatio", MSettl.healthInsuranceRatio);//基本医疗保险统筹基金支付比例
  1375. joSetlinfo.Add("CivilserviceAllowancePay", MSettl.civilserviceAllowancePay);//公务员医疗补助资金支出
  1376. joSetlinfo.Add("EnterpriseSupplementPay", MSettl.enterpriseSupplementPay);//企业支付
  1377. joSetlinfo.Add("SeriousIllnessPay", MSettl.seriousIllnessPay);// 居民大病保险资金支出
  1378. joSetlinfo.Add("LargeExpensesSupplementPay", MSettl.largeExpensesSupplementPay);//职工大额医疗费用补助基金支出
  1379. joSetlinfo.Add("MedicalAssistPay", MSettl.medicalAssistPay);//医疗救助基金支出
  1380. joSetlinfo.Add("HospitalPartAmount", MSettl.hospitalPartAmount);//医院负担金额
  1381. joSetlinfo.Add("OtherPay", MSettl.otherPay);//其他支出
  1382. joSetlinfo.Add("FundPaySumamt", MSettl.fundPaySumamt);//基金支付总额
  1383. joSetlinfo.Add("PersonPaySumamt", MSettl.personPaySumamt);//个人负担总金额
  1384. joSetlinfo.Add("AccountPaySumamt", MSettl.accountPaySumamt);//个人账户支出
  1385. joSetlinfo.Add("PersonCashPay", MSettl.personCashPay);//个人现金支出
  1386. joSetlinfo.Add("Balance", MSettl.balance);// 余额
  1387. joSetlinfo.Add("AccountMutualAidAmount", "");//个人账户共济支付金额
  1388. joSetlinfo.Add("OrganSettlementID", "");//医药机构结算ID
  1389. joSetlinfo.Add("ClearingOrgan", MSettl.clearingOrgan);//清算经办机构
  1390. joSetlinfo.Add("ClearingWay", MSettl.clearingWay);//清算方式
  1391. joSetlinfo.Add("ClearingType", MSettl.clearingType);//清算类别
  1392. joSetlinfo.Add("ValidFlag", 1);
  1393. joSetlinfo.Add("BillType", 1);
  1394. joSetlinfo.Add("ConfirmFlag", MSettl.confirmFlag);
  1395. joSetlinfo.Add("MSGID", Global.curEvt.msgid);
  1396. joSetlinfo.Add("AdmType", "3");
  1397. joSetlinfo.Add("BillID", MPat.billID);
  1398. joSetlinfo.Add("RecordID", MPat.recordID);
  1399. joSetlinfo.Add("InterfaceDr", Global.inf.interfaceDr);
  1400. joSetlinfo.Add("InsuranceAreaCode", MPat.insuplc_admdvs);
  1401. joSetlinfo.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1402. joSetlinfo.Add("HospitalizationsDays", MSettl.hospitalizationsDays);
  1403. joSetlinfo.Add("HospitalizationsTimes", MSettl.hospitalizationsTimes);
  1404. joSetlinfo.Add("HISAdmTime", MSettl.hisAdmTime);
  1405. joSetlinfo.Add("HISDischargeTime", MSettl.hisDischargeTime);
  1406. joSetlinfo.Add("updateUserID", Global.user.ID);
  1407. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010089", joSetlinfo).ToString(), "通过订单号更新结算信息");
  1408. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1409. {
  1410. outParam = errMsg;
  1411. return -1;
  1412. }
  1413. else
  1414. {
  1415. outParam = joSetlinfo.ToString();
  1416. return 0;
  1417. }
  1418. }
  1419. catch (Exception ex)
  1420. {
  1421. outParam = "插入结算信息:" + ex.Message;
  1422. return -1;
  1423. }
  1424. }
  1425. /// <summary>
  1426. /// 取消结算
  1427. /// </summary>
  1428. /// <param name="outParam"></param>
  1429. /// <returns></returns>
  1430. public int cancleSettlement(string newSettlID, out string outParam)
  1431. {
  1432. JObject joTmp = new JObject();
  1433. string errMsg = "";
  1434. try
  1435. {
  1436. joTmp.Add("HospitalDr", Global.inf.hospitalDr);
  1437. joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
  1438. joTmp.Add("admID", MPat.adm_Dr);
  1439. joTmp.Add("mdtrt_id", MPat.mdtrtID);
  1440. joTmp.Add("setl_id", MPat.settlID);
  1441. joTmp.Add("new_setl_id", newSettlID);
  1442. joTmp.Add("updateUserID", Global.user.ID);
  1443. joTmp.Add("msgid", Global.curEvt.msgid);
  1444. joTmp.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1445. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010052", joTmp).ToString(), "取消结算信息");
  1446. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1447. {
  1448. outParam = errMsg;
  1449. return -1;
  1450. }
  1451. else
  1452. {
  1453. outParam = JsonHelper.setExceptionJson(0, "云医保平台","取消结算成功").ToString();
  1454. return 0;
  1455. }
  1456. }
  1457. catch (Exception ex)
  1458. {
  1459. outParam = "取消结算信息:" + ex.Message;
  1460. return -1;
  1461. }
  1462. }
  1463. /// <summary>
  1464. /// 插入医保费用
  1465. /// </summary>
  1466. /// <param name="jaTmp"></param>
  1467. /// <param name="outParam"></param>
  1468. /// <returns></returns>
  1469. public int insertFee(JArray jaTmp, out string outParam)
  1470. {
  1471. try
  1472. {
  1473. outParam = "";
  1474. string errMsg;
  1475. dynamic joTmp = new JObject();
  1476. joTmp = new JObject();
  1477. joTmp.code = "09010046";
  1478. joTmp.HospitalDr = Global.inf.hospitalDr;
  1479. joTmp.admID = MPat.adm_Dr;
  1480. joTmp.mdtrt_id = MPat.mdtrtID;
  1481. joTmp.updateUserID = Global.user.ID;
  1482. joTmp.Add("params", jaTmp);
  1483. ;
  1484. JObject joRtn = invoker.invokeInsuService(joTmp.ToString(), "插入2301明细");
  1485. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1486. {
  1487. outParam = errMsg;
  1488. return -1;
  1489. }
  1490. else
  1491. {
  1492. outParam = joRtn.ToString();
  1493. return 0;
  1494. }
  1495. }
  1496. catch (Exception ex)
  1497. {
  1498. outParam = "insertFee 异常:" + ex.Message;
  1499. return -1;
  1500. }
  1501. }
  1502. private int saveToMi( out string errMsg)
  1503. {
  1504. errMsg = "";
  1505. try
  1506. {
  1507. //存储参保信息
  1508. if (insertPatCurInsuInfo( out errMsg) != 0)
  1509. {
  1510. return -1;
  1511. }
  1512. //存储登记信息
  1513. if (saveRegisterInfo( out errMsg) != 0)
  1514. {
  1515. return -1;
  1516. }
  1517. //处理jaFee
  1518. foreach (var jo in jaFee)
  1519. {
  1520. jo["mdtrt_id"] = MPat.mdtrtID;
  1521. jo["psn_no"] = MPat.psn_no;
  1522. }
  1523. //存储费用信息
  1524. if (insertFee(jaFee, out errMsg) != 0)
  1525. {
  1526. return -1;
  1527. }
  1528. return 0;
  1529. }
  1530. catch (Exception ex)
  1531. {
  1532. errMsg = "saveToMi:" + ex.Message;
  1533. return -1;
  1534. }
  1535. }
  1536. #endregion
  1537. #region 解析中心返回
  1538. /// <summary>
  1539. /// 解析银海移动支付返参
  1540. /// </summary>
  1541. /// <param name="joRtn"></param>
  1542. /// <param name="errorMsg"></param>
  1543. /// <returns></returns>
  1544. public int ParseCenterRtnValue(JObject joRtn, out string errorMsg)
  1545. {
  1546. try
  1547. {
  1548. errorMsg =JsonHelper.getDestValue(joRtn, "message");
  1549. return int.Parse(JsonHelper.getDestValue(joRtn, "code")); //0 成功-1 失败
  1550. }
  1551. catch (Exception ex)
  1552. {
  1553. errorMsg = "解析移动支付返参发生异常:" + ex.Message;
  1554. return -1;
  1555. }
  1556. }
  1557. #endregion
  1558. }
  1559. }