MobilePay.cs 79 KB

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