MobilePay.cs 75 KB

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