MobilePay.cs 80 KB

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