MobilePay.cs 81 KB

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