MobilePay.cs 79 KB

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