AbstractMobilePay.cs 74 KB

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