MobilePay.cs 78 KB

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