MobilePay.cs 77 KB

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