MobilePay.cs 77 KB

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