MobilePay.cs 75 KB

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