AbstractMobilePay.cs 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561
  1. using PTMedicalInsurance.Entity.Mobile;
  2. using Newtonsoft.Json.Linq;
  3. using PTMedicalInsurance.Business;
  4. using PTMedicalInsurance.Entity;
  5. using PTMedicalInsurance.Helper;
  6. using PTMedicalInsurance.Variables;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using PTMedicalInsurance.Entity.Insu.Request;
  13. namespace PTMedicalInsurance.Business
  14. {
  15. abstract class AbstractMobilePay : IMobilePay
  16. {
  17. private HisIrisServices hIS = new HisIrisServices();
  18. private MIIrisServices mIS = new MIIrisServices();
  19. private CenterBusiness cBus = new CenterBusiness();
  20. private InvokeHelper invoker = new InvokeHelper();
  21. private Patients MPat;
  22. PatientInfo patientInfo;
  23. private Settlements MSettl;
  24. private JArray jaFee;
  25. private JObject joParam;
  26. private JObject joInsuAdmObj;
  27. public JObject cancelPay(string inParam)
  28. {
  29. throw new NotImplementedException();
  30. }
  31. #region 医保接口参数构建
  32. /// <summary>
  33. /// 明细上传入参
  34. /// </summary>
  35. /// <returns></returns>
  36. public int Get6201Input(out string outparam)
  37. {
  38. string errMsg = "";
  39. outparam = "";
  40. try
  41. {
  42. JObject joInpar = new JObject();
  43. //查询患者基本信息
  44. if (hIS.GetHisPatBaseInfo(out errMsg) != 0)
  45. {
  46. outparam = errMsg;
  47. return -1;
  48. }
  49. HisPatientInfo patientInfo = JsonHelper.getResult<HisPatientInfo>(JObject.Parse(errMsg));
  50. //setPatientByHisBaseInfo(JObject.Parse(errMsg));
  51. //JObject joPatBaseInfo = JObject.Parse(JsonHelper.getDestValue(JObject.Parse(errMsg), "result"));
  52. //获取诊断
  53. if (getDiagnoses(out errMsg) != 0)
  54. {
  55. outparam = errMsg;
  56. return -1;
  57. }
  58. JObject joDiagnoses = JObject.Parse(errMsg);
  59. JArray jaDiseinfoList = JArray.Parse(JsonHelper.getDestValue(joDiagnoses, "diseinfoList"));
  60. JObject joMdtrtinfo = JObject.Parse(JsonHelper.getDestValue(joDiagnoses, "mdtrtinfo"));
  61. setPatientByDiagnoseInfo(joMdtrtinfo);
  62. //获取费用
  63. if (GetFee(out errMsg) != 0)
  64. {
  65. outparam = errMsg;
  66. return -1;
  67. }
  68. JObject joFee = JObject.Parse(errMsg);
  69. JArray jaFeedetailList = JArray.Parse(JsonHelper.getDestValue(joFee, "feedetailList"));
  70. for (int i = 0; i < jaFeedetailList.Count; i++)
  71. {
  72. JObject joTmp = new JObject();
  73. joTmp.Add("act_purc_pric", jaFeedetailList[i]["pric"]);
  74. joTmp.Add("sin_dos", jaFeedetailList[i]["sinDosDscr"]);
  75. joTmp.Add("medins_list_name", jaFeedetailList[i]["medListName"]);
  76. ((JObject)jaFeedetailList[i]).Property("chrgBchno").Remove();
  77. ((JObject)jaFeedetailList[i]).Property("diseCodg").Remove();
  78. ((JObject)jaFeedetailList[i]).Property("rxno").Remove();
  79. ((JObject)jaFeedetailList[i]).Property("feeOcurTime").Remove();
  80. ((JObject)jaFeedetailList[i]).Property("sinDosDscr").Remove();
  81. ((JObject)jaFeedetailList[i]).Property("usedFrquDscr").Remove();
  82. ((JObject)jaFeedetailList[i]).Property("prdDays").Remove();
  83. ((JObject)jaFeedetailList[i]).Property("medcWayDscr").Remove();
  84. //((JObject)jaFeedetailList[i]).Property("bilgDeptCodg").Remove();
  85. ((JObject)jaFeedetailList[i]).Property("acordDeptCodg").Remove();
  86. ((JObject)jaFeedetailList[i]).Property("acordDeptName").Remove();
  87. ((JObject)jaFeedetailList[i]).Property("ordersDrCode").Remove();
  88. ((JObject)jaFeedetailList[i]).Property("ordersDrName").Remove();
  89. ((JObject)jaFeedetailList[i]).Property("tcmdrugUsedWay").Remove();
  90. ((JObject)jaFeedetailList[i]).Property("etipFlag").Remove();
  91. ((JObject)jaFeedetailList[i]).Property("etipHospCode").Remove();
  92. ((JObject)jaFeedetailList[i]).Property("dscgTkdrugFlag").Remove();
  93. ((JObject)jaFeedetailList[i]).Property("matnFeeFlag").Remove();
  94. ((JObject)jaFeedetailList[i]).Property("initFeedetlSn").Remove();
  95. ((JObject)jaFeedetailList[i]).Property("medType").Remove();
  96. ((JObject)jaFeedetailList[i]).Property("memo").Remove();
  97. //((JObject)jaFeedetailList[i]).Property("expContent").Remove();
  98. ((JObject)jaFeedetailList[i]).Property("medListName").Remove();
  99. ((JObject)jaFeedetailList[i]).Property("medListSpc").Remove();
  100. ((JObject)jaFeedetailList[i]).Property("combNo").Remove();
  101. //jaFeedetailList[i]["chrgBchno"] = MPat.adm_Dr.ToString();
  102. jaFeedetailList[i]["expContent"] = joTmp.ToString();
  103. jaFeedetailList[i]["medType"] = JsonHelper.getDestValue(joInsuAdmObj, "medType");
  104. jaFeedetailList[i]["psnNo"] = new JObject();
  105. jaFeedetailList[i]["psnNo"] = MPat.psn_no;
  106. }
  107. //入参
  108. joInpar.Add("orgCodg", Global.inf.hospitalNO);//机构编码
  109. //joInpar.Add("orgId", "");//电子凭证机构号
  110. joInpar.Add("psnNo", MPat.psn_no);//人员编号
  111. joInpar.Add("insutype", MPat.insuType);//险种类型
  112. joInpar.Add("medOrgOrd", MPat.recordID);//医疗机构订单号 前端传入
  113. //joInpar.Add("initRxOrd", JsonHelper.getDestValue(joInsuAdmObj, "initRxOrd"));//要续方的原处方流水 前端传入
  114. //joInpar.Add("rxCircFlag", JsonHelper.getDestValue(joInsuAdmObj, "rxCircFlag"));//电子处方流转标志 前端传入
  115. MSettl.settlTime = Convert.ToDateTime(JsonHelper.getDestValue(joMdtrtinfo, "begntime"));
  116. //joInpar.Add("begntime", JsonHelper.getDestValue(joMdtrtinfo, "begntime"));//开始时间
  117. joInpar.Add("idNo", patientInfo.IDNo);//证件号码
  118. joInpar.Add("userName", patientInfo.Name);//用户姓名
  119. joInpar.Add("idType", patientInfo.IDType);//证件类别
  120. joInpar.Add("ecToken", JsonHelper.getDestValue(joInsuAdmObj, "ecToken"));//电子凭证授权ecToken 前端传入
  121. joInpar.Add("insuCode", Global.inf.areaCode);//就诊参保地行政区划
  122. joInpar.Add("iptOtpNo", JsonHelper.getDestValue(joMdtrtinfo, "ipt_no"));//住院/门诊号
  123. joInpar.Add("atddrNo", JsonHelper.getDestValue(joMdtrtinfo, "atddr_no"));//医师编码
  124. joInpar.Add("drName", JsonHelper.getDestValue(joMdtrtinfo, "chfpdr_name"));//医师姓名
  125. joInpar.Add("deptCode", JsonHelper.getDestValue(joMdtrtinfo, "adm_dept_codg"));//科室编码
  126. joInpar.Add("deptName", JsonHelper.getDestValue(joMdtrtinfo, "adm_dept_name"));//科室名称
  127. joInpar.Add("caty", "A10");//科别
  128. joInpar.Add("mdtrtId", JsonHelper.getDestValue(joMdtrtinfo, "mdtrtId"));//就诊ID
  129. joInpar.Add("medType", MPat.medType);//医疗类别 前端传入
  130. joInpar.Add("feeType", JsonHelper.getDestValue(joInsuAdmObj, "feeType"));//费用类型 前端传入
  131. joInpar.Add("medfeeSumamt", JsonHelper.getDestValue(joFee, "medfeeSumamt"));//医疗费总额
  132. //joInpar.Add("acctUsedFlag", JsonHelper.getDestValue(joInsuAdmObj, "acctUsedFlag"));//个人账户使用标志 前端传入
  133. //joInpar.Add("mainCondDscr", JsonHelper.getDestValue(joMdtrtinfo, "mainCondDscr"));//主要病情描述
  134. //joInpar.Add("diseCodg", JsonHelper.getDestValue(joMdtrtinfo, "diseCodg"));//病种编码
  135. //joInpar.Add("diseName", JsonHelper.getDestValue(joMdtrtinfo, "diseName"));//病种名称
  136. //joInpar.Add("psnSetlway", JsonHelper.getDestValue(joInsuAdmObj, "psnSetlway"));//个人结算方式 前端传入
  137. joInpar.Add("chrgBchno", JsonHelper.getDestValue(joFee, "chrgBchno"));//收费批次号
  138. //joInpar.Add("pubHospRfomFlag", JsonHelper.getDestValue(joInsuAdmObj, "pubHospRfomFlag"));//公立医院改革标志
  139. //joInpar.Add("invono", JsonHelper.getDestValue(joMdtrtinfo, "invono"));//发票号
  140. //joInpar.Add("endtime", JsonHelper.getDestValue(joMdtrtinfo, "endtime"));//出院时间
  141. //joInpar.Add("fulamtOwnpayAmt", JsonHelper.getDestValue(joMdtrtinfo, "fulamtOwnpayAmt"));//全自费金额
  142. //joInpar.Add("overlmtSelfpay", JsonHelper.getDestValue(joMdtrtinfo, "overlmtSelfpay"));//超限价金额
  143. //joInpar.Add("preselfpayAmt", JsonHelper.getDestValue(joMdtrtinfo, "preselfpayAmt"));//先行自付金额
  144. //joInpar.Add("inscpScpAmt", JsonHelper.getDestValue(joMdtrtinfo, "inscpScpAmt"));//符合政策范围金额
  145. //joInpar.Add("oprnOprtCode", JsonHelper.getDestValue(joMdtrtinfo, "oprnOprtCode"));//手术操作代码
  146. //joInpar.Add("oprnOprtName", JsonHelper.getDestValue(joMdtrtinfo, "oprnOprtName"));//手术操作名称
  147. //joInpar.Add("fpscNo", JsonHelper.getDestValue(joMdtrtinfo, "fpscNo"));//计划生育服务证号
  148. //joInpar.Add("latechbFlag", JsonHelper.getDestValue(joMdtrtinfo, "latechbFlag"));//晚育标志
  149. joInpar.Add("gesoVal", JsonHelper.getDestValue(joMdtrtinfo, "gesoVal"));//孕周数
  150. joInpar.Add("fetts", JsonHelper.getDestValue(joMdtrtinfo, "fetts"));//胎次
  151. joInpar.Add("fetusCnt", JsonHelper.getDestValue(joMdtrtinfo, "fetusCnt"));//胎儿数
  152. //joInpar.Add("pretFlag", JsonHelper.getDestValue(joMdtrtinfo, "pretFlag"));//早产标志
  153. //joInpar.Add("birctrlType", JsonHelper.getDestValue(joMdtrtinfo, "birctrlType"));//计划生育手术类别
  154. //joInpar.Add("birctrlMatnDate", JsonHelper.getDestValue(joMdtrtinfo, "birctrlMatnDate"));//计划生育手术或生育日期
  155. //joInpar.Add("copFlag", JsonHelper.getDestValue(joMdtrtinfo, "copFlag"));//伴有并发症标志
  156. //joInpar.Add("dscgDeptCodg", JsonHelper.getDestValue(joMdtrtinfo, "dscgDeptCodg"));//出院科室编码
  157. //joInpar.Add("dscgDeptName", JsonHelper.getDestValue(joMdtrtinfo, "dscgDeptName"));//出院科室名称
  158. //joInpar.Add("dscgDed", JsonHelper.getDestValue(joMdtrtinfo, "dscgDed"));//出院床位
  159. //joInpar.Add("dscgWay", JsonHelper.getDestValue(joMdtrtinfo, "dscgWay"));//离院方式
  160. //joInpar.Add("dieDate", JsonHelper.getDestValue(joMdtrtinfo, "dieDate"));//死亡日期
  161. //joInpar.Add("matnType", JsonHelper.getDestValue(joMdtrtinfo, "matnType"));//生育类别
  162. //joInpar.Add("expContent", JsonHelper.getDestValue(joInsuAdmObj, "expContent"));//扩展参数 前端传入
  163. //joInpar.Add("midSetlFlag", JsonHelper.getDestValue(joInsuAdmObj, "midSetlFlag"));//中途结算标志 前端传入
  164. joInpar.Add("diseinfoList", jaDiseinfoList);//诊断或症状明细
  165. joInpar.Add("feedetailList", jaFeedetailList);//费用明细
  166. //joInpar.Add("admDiagDscr", JsonHelper.getDestValue(joMdtrtinfo, "admDiagDscr"));//入院诊断描述
  167. //joInpar.Add("admDeptCodg", JsonHelper.getDestValue(joMdtrtinfo, "admDeptCodg"));//入院科室编码
  168. //joInpar.Add("admDeptName", JsonHelper.getDestValue(joMdtrtinfo, "admDeptName"));//入院科室名称
  169. //joInpar.Add("admBed", JsonHelper.getDestValue(joMdtrtinfo, "admBed"));//入院床位
  170. joInpar.Add("payAuthNo", JsonHelper.getDestValue(joInsuAdmObj, "payAuthNo"));//支付授权码 前端传入
  171. joInpar.Add("uldLatlnt", JsonHelper.getDestValue(joInsuAdmObj, "uldLatlnt"));//经纬度 前端传入
  172. joInpar.Add("mdtrtCertType", JsonHelper.getDestValue(joInsuAdmObj, "mdtrtCertType"));//就诊凭证类型 前端传入
  173. //joInpar.Add("insuplcAdmdvs", MPat.insuplc_admdvs);//用户参保地行政区划
  174. JObject joData = new JObject();
  175. joData.Add("data", joInpar);
  176. outparam = joInpar.ToString();
  177. return 0;
  178. }
  179. catch (Exception ex)
  180. {
  181. outparam = "GetYH6201Inpar:" + ex.Message;
  182. return -1;
  183. }
  184. finally
  185. {
  186. Global.writeLog("GetYH6201Inpar", "", outparam);
  187. }
  188. }
  189. public int Get6202Input(JObject joYH6201Inpar,out string outparam)
  190. {
  191. outparam = "";
  192. try
  193. {
  194. //获取其他入参
  195. JObject joInpar = new JObject();
  196. joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
  197. joInpar.Add("payOrdId", MPat.payOrdId);//待支付订单号
  198. joInpar.Add("payToken", MPat.payToken);//支付订单对应的token
  199. joInpar.Add("orgCodg", Global.inf.hospitalNO);//定点机构编码
  200. joInpar.Add("orgBizSer", DateTime.Now.ToString("yyyyMMddHHmmssffff"));//业务流水号 前端传入
  201. joInpar.Add("ecAuthCode", "");
  202. joInpar.Add("ecChnlAppId", "");
  203. joInpar.Add("ecChnlUserId", "");
  204. joInpar.Add("mdtrtId", MPat.mdtrtID);
  205. joInpar.Add("chrgBchno", JsonHelper.getDestValue(joYH6201Inpar, "chrgBchno"));//收费批次号
  206. joInpar.Add("feeType", JsonHelper.getDestValue(joYH6201Inpar, "feeType"));//费用类别
  207. //joInpar.Add("deposit", JsonHelper.getDestValue(joInsuAdmObj, "deposit"));//住院押金
  208. joInpar.Add("expContent", "");//扩展数据
  209. //joInpar.Add("acctUsedFlag", "");//个账使用标识
  210. //JObject joData = new JObject();
  211. //joData.Add("data",joInpar);
  212. outparam = joInpar.ToString();
  213. return 0;
  214. }
  215. catch (Exception ex)
  216. {
  217. outparam = "GetYH6202Inpar:" + ex.Message;
  218. return -1;
  219. }
  220. finally
  221. {
  222. Global.writeLog("GetYH6202Inpar", "", outparam);
  223. }
  224. }
  225. public int Get6203Input(out string outparam)
  226. {
  227. string errMsg = "";
  228. outparam = "";
  229. try
  230. {
  231. JObject joInpar = new JObject();
  232. //获取医保平台结算信息
  233. if (QuerySettleInfo(out errMsg) != 0)
  234. {
  235. outparam = errMsg;
  236. return -1;
  237. }
  238. JObject joRtn = JObject.Parse(errMsg);
  239. JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "data"));
  240. //入参
  241. joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "SettlementID"));//支付订单号
  242. joInpar.Add("appRefdSn", JsonHelper.getDestValue(joSettl, ""));//应用退款流水号
  243. joInpar.Add("appRefdTime", JsonHelper.getDestValue(joSettl, ""));//应用退费时间
  244. joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
  245. joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
  246. joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
  247. joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joInsuAdmObj, "PersonCashPay"));//现金退费金额
  248. joInpar.Add("ecToken", MPat.token);//电子凭证授权Token 前端传入
  249. joInpar.Add("refdType", "ALL");//退费类型 前端传入
  250. joInpar.Add("expContent", "");//扩展数据 前端传入
  251. joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
  252. outparam = joInpar.ToString();
  253. return 0;
  254. }
  255. catch (Exception ex)
  256. {
  257. outparam = "GetYH6203Inpar:" + ex.Message;
  258. return -1;
  259. }
  260. finally
  261. {
  262. Global.writeLog("GetYH6203Inpar", "", outparam);
  263. }
  264. }
  265. /// <summary>
  266. /// 订单结果查询入参
  267. /// </summary>
  268. /// <param name="outparam"></param>
  269. /// <returns></returns>
  270. public int Get6301Input(out string outparam)
  271. {
  272. outparam = "";
  273. try
  274. {
  275. string errMsg;
  276. //查询登记信息
  277. if (mIS.queryRegisterInfo(4, out errMsg) != 0)
  278. {
  279. outparam = errMsg;
  280. return -1;
  281. }
  282. setPatientByMiRegInfo(JObject.Parse(errMsg));
  283. //获取其他入参
  284. JObject joInpar = new JObject();
  285. joInpar.Add("payOrdId", MPat.payOrdId);//待支付订单号
  286. joInpar.Add("payToken", MPat.payToken);//支付订单对应的token
  287. joInpar.Add("orgCodg", Global.inf.hospitalNO);//定点机构编码
  288. joInpar.Add("idNo", MPat.IDNO);
  289. joInpar.Add("userName", MPat.name);
  290. joInpar.Add("idType", "01");
  291. joInpar.Add("expContent", "");
  292. outparam = joInpar.ToString();
  293. return 0;
  294. }
  295. catch (Exception ex)
  296. {
  297. outparam = "GetYH6301Inpar:" + ex.Message;
  298. return -1;
  299. }
  300. finally
  301. {
  302. Global.writeLog("GetYH6301Inpar", "", outparam);
  303. }
  304. }
  305. public int Get6401Input(out string outparam)
  306. {
  307. string errMsg = "";
  308. outparam = "";
  309. try
  310. {
  311. JObject joInpar = new JObject();
  312. //获取医保平台结算信息
  313. if (QuerySettleInfo(out errMsg) != 0)
  314. {
  315. outparam = errMsg;
  316. return -1;
  317. }
  318. JObject joRtn = JObject.Parse(errMsg);
  319. JObject joSettl = JObject.Parse(JsonHelper.getDestValue(joRtn, "data"));
  320. //入参
  321. joInpar.Add("payOrdId", JsonHelper.getDestValue(joSettl, "SettlementID"));//支付订单号
  322. joInpar.Add("appRefdSn", JsonHelper.getDestValue(joSettl, ""));//应用退款流水号
  323. joInpar.Add("appRefdTime", JsonHelper.getDestValue(joSettl, ""));//应用退费时间
  324. joInpar.Add("totlRefdAmt", JsonHelper.getDestValue(joSettl, "Sumamt"));//总退费金额
  325. joInpar.Add("psnAcctRefdAmt", JsonHelper.getDestValue(joSettl, "AccountPaySumamt"));//医保个人账户支付
  326. joInpar.Add("fundRefdAmt", JsonHelper.getDestValue(joSettl, "FundPaySumamt"));//基金支付
  327. joInpar.Add("cashRefdAmt", JsonHelper.getDestValue(joInsuAdmObj, "PersonCashPay"));//现金退费金额
  328. joInpar.Add("ecToken", MPat.token);//电子凭证授权Token 前端传入
  329. joInpar.Add("refdType", "ALL");//退费类型 前端传入
  330. joInpar.Add("expContent", "");//扩展数据 前端传入
  331. joInpar.Add("payAuthNo", MPat.payAuthNo);//支付授权码 前端传入
  332. outparam = joInpar.ToString();
  333. return 0;
  334. }
  335. catch (Exception ex)
  336. {
  337. outparam = "GetYH6203Inpar:" + ex.Message;
  338. return -1;
  339. }
  340. finally
  341. {
  342. Global.writeLog("GetYH6203Inpar", "", outparam);
  343. }
  344. }
  345. #endregion
  346. #region 医保接口返回结果解析
  347. /// <summary>
  348. /// 支付订单查询
  349. /// </summary>
  350. /// <param name="jo"></param>
  351. public void parseOrderQuery(JObject jo)
  352. {
  353. // 直接转换
  354. //PatientInfo patient = JsonHelper.toObject<PatientInfo>(jo);
  355. //MPat.settlID = JsonHelper.getDestValue(jo, "setl_id");
  356. MPat.psn_no = JsonHelper.getDestValue(jo, "psn_no");
  357. MPat.naty = JsonHelper.getDestValue(jo, "naty");
  358. //MPat.name = JsonHelper.getDestValue(jo, "name");
  359. MPat.age = JsonHelper.getDestValue(jo, "age");
  360. MPat.gend = JsonHelper.getDestValue(jo, "gend");
  361. MPat.certNO = JsonHelper.getDestValue(jo, "certno");
  362. MPat.brdy = JsonHelper.getDestValue(jo, "brdy");
  363. MPat.insuType = JsonHelper.getDestValue(jo, "insutype");
  364. MPat.psn_type = JsonHelper.getDestValue(jo, "psn_type");
  365. MPat.mdtrtcertType = JsonHelper.getDestValue(jo, "mdtrt_cert_type");
  366. MPat.medType = JsonHelper.getDestValue(jo, "med_type");
  367. //MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuplc_admdvs");
  368. //MPat.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
  369. MSettl.ordStas = JsonHelper.getDestValue(jo, "ordStas");
  370. MSettl.sumamt = getDecimalFee(jo, "medfee_sumamt");
  371. MSettl.personCashPay = getDecimalFee(jo, "psn_cash_pay");
  372. MSettl.accountPaySumamt = getDecimalFee(jo, "acct_pay");
  373. MSettl.fundPaySumamt = getDecimalFee(jo, "fund_pay_sumamt");
  374. //MSettl.deposit = getDecimalFee(jo, "deposit");
  375. MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "clr_optins");
  376. MSettl.clearingType = JsonHelper.getDestValue(jo, "clr_type");
  377. MSettl.clearingWay = JsonHelper.getDestValue(jo, "clr_way");
  378. MSettl.civilserviceAllowancePay = getDecimalFee(jo, "cvlserv_pay");
  379. MSettl.ownPayAmount = getDecimalFee(jo, "fulamt_ownpay_amt");
  380. MSettl.overLimitAmountmt = getDecimalFee(jo, "overlmt_selfpay");
  381. MSettl.preSelfPayAmount = getDecimalFee(jo, "preselfpay_amt");
  382. MSettl.inPolicyRangeAmount = getDecimalFee(jo, "inscp_scp_amt");
  383. MSettl.actualPayDeductible = getDecimalFee(jo, "act_pay_dedc");
  384. MSettl.healthInsurancePay = getDecimalFee(jo, "hifp_pay");
  385. MSettl.healthInsuranceRatio = getDecimalFee(jo, "pool_prop_selfpay");
  386. MSettl.enterpriseSupplementPay = getDecimalFee(jo, "hifes_pay");
  387. MSettl.seriousIllnessPay = getDecimalFee(jo, "hifmi_pay");
  388. MSettl.largeExpensesSupplementPay = getDecimalFee(jo, "hifob_pay");
  389. MSettl.medicalAssistPay = getDecimalFee(jo, "maf_pay");
  390. MSettl.hospitalPartAmount = getDecimalFee(jo, "hosp_part_amt");
  391. MSettl.otherPay = getDecimalFee(jo, "oth_pay");
  392. MSettl.personPaySumamt = getDecimalFee(jo, "psn_part_amt");
  393. MSettl.balance = getDecimalFee(jo, "balc");
  394. MSettl.accountMutualAidAmount = getDecimalFee(jo, "acct_mulaid_pay");
  395. }
  396. /// <summary>
  397. /// 费用明细上传返回[6201]
  398. /// </summary>
  399. /// <param name="jo"></param>
  400. public void parseUploadFeeDetails(JObject jo)
  401. {
  402. MPat.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
  403. MPat.payToken = JsonHelper.getDestValue(jo, "payToken");
  404. //MPat.psn_no = JsonHelper.getDestValue(jo, "psn_no");
  405. //MPat.insuType = JsonHelper.getDestValue(jo, "insutype");
  406. //MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuplc_admdvs");
  407. MPat.mdtrtID = JsonHelper.getDestValue(jo, "extData.mdtrtId");
  408. }
  409. /// <summary>
  410. /// 支付下单返回[6202]
  411. /// </summary>
  412. /// <param name="jo"></param>
  413. public void parsePayOrder(JObject jo)
  414. {
  415. MSettl.settlID = JsonHelper.getDestValue(jo, "payOrdId");
  416. MPat.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
  417. MSettl.ordStas = JsonHelper.getDestValue(jo, "ordStas");
  418. MSettl.sumamt = getDecimalFee(jo, "feeSumamt");
  419. MSettl.personCashPay = getDecimalFee(jo, "ownPayAmt");
  420. MSettl.accountPaySumamt = getDecimalFee(jo, "psnAcctPay");
  421. MSettl.fundPaySumamt = getDecimalFee(jo, "fundPay");
  422. MSettl.deposit = getDecimalFee(jo, "deposit");
  423. MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "extData.preSetl.clr_optins");
  424. MSettl.clearingType = JsonHelper.getDestValue(jo, "extData.preSetl.clr_type");
  425. MSettl.clearingWay = JsonHelper.getDestValue(jo, "extData.preSetl.clr_way");
  426. MSettl.civilserviceAllowancePay = getDecimalFee(jo, "extData.preSetl.cvlserv_pay");
  427. MSettl.ownPayAmount = getDecimalFee(jo, "extData.preSetl.fulamt_ownpay_amt");
  428. MSettl.overLimitAmountmt = getDecimalFee(jo, "extData.preSetl.overlmt_selfpay");
  429. MSettl.preSelfPayAmount = getDecimalFee(jo, "extData.preSetl.preselfpay_amt");
  430. MSettl.inPolicyRangeAmount = getDecimalFee(jo, "extData.preSetl.inscp_scp_amt");
  431. MSettl.actualPayDeductible = getDecimalFee(jo, "extData.preSetl.act_pay_dedc");
  432. MSettl.healthInsurancePay = getDecimalFee(jo, "extData.preSetl.hifp_pay");
  433. MSettl.healthInsuranceRatio = getDecimalFee(jo, "extData.preSetl.pool_prop_selfpay");
  434. MSettl.enterpriseSupplementPay = getDecimalFee(jo, "extData.preSetl.hifes_pay");
  435. MSettl.seriousIllnessPay = getDecimalFee(jo, "extData.preSetl.hifmi_pay");
  436. MSettl.largeExpensesSupplementPay = getDecimalFee(jo, "extData.preSetl.hifob_pay");
  437. MSettl.medicalAssistPay = getDecimalFee(jo, "extData.preSetl.maf_pay");
  438. MSettl.hospitalPartAmount = getDecimalFee(jo, "extData.preSetl.hosp_part_amt");
  439. MSettl.otherPay = getDecimalFee(jo, "extData.preSetl.oth_pay");
  440. MSettl.personPaySumamt = getDecimalFee(jo, "extData.preSetl.psn_part_amt");
  441. MSettl.balance = getDecimalFee(jo, "extData.preSetl.balc");
  442. MSettl.accountMutualAidAmount = getDecimalFee(jo, "extData.preSetl.acct_mulaid_pay");
  443. }
  444. #endregion
  445. #region 核心结算流程
  446. public void setPatientByMiRegInfo(JObject jo)
  447. {
  448. patientInfo = JsonHelper.parseObject<PatientInfo>(jo, "data");
  449. MPat.name = JsonHelper.getDestValue(jo, "data.PatientName");
  450. MPat.psn_no = JsonHelper.getDestValue(jo, "data.PersonalNO");
  451. MPat.certNO = JsonHelper.getDestValue(jo, "data.CertificateNO");
  452. MPat.IDNO = MPat.certNO;
  453. MPat.certType = JsonHelper.getDestValue(jo, "data.CertificateType");
  454. MPat.payToken = JsonHelper.getDestValue(jo, "data.payToken");
  455. MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "data.InsuranceAreaCode");
  456. }
  457. public void setPatientByDiagnoseInfo(JObject jo)
  458. {
  459. MPat.admAttendDoctorNO = JsonHelper.getDestValue(jo, "atddr_no");
  460. MPat.admDiagCode = JsonHelper.getDestValue(jo, "dscg_maindiag_code");
  461. MPat.admDiagName = JsonHelper.getDestValue(jo, "dscg_maindiag_name");
  462. MPat.AdmInDepCode = JsonHelper.getDestValue(jo, "adm_dept_codg");
  463. }
  464. private void setPatientByHisBaseInfo(JObject jo)
  465. {
  466. // 新方法
  467. HisPatientInfo hpi = JsonHelper.getResult<HisPatientInfo>(jo);
  468. // 旧方法
  469. //MPat.name = JsonHelper.getDestValue(jo, "result.patName");
  470. //MPat.brdy = JsonHelper.getDestValue(jo, "result.patBirthdate");
  471. //MPat.gend = JsonHelper.getDestValue(jo, "result.patSex");
  472. //MPat.age = JsonHelper.getDestValue(jo, "result.Age");
  473. //MPat.naty = JsonHelper.getDestValue(jo, "result.naty");
  474. //MPat.certNO = JsonHelper.getDestValue(jo, "result.credNo");
  475. //MPat.IDNO = MPat.certNO;
  476. //MPat.certType = JsonHelper.getDestValue(jo, "result.credCode");
  477. }
  478. private int GetPatientInfo(out string outparam)
  479. {
  480. string errMsg = "";
  481. outparam = "";
  482. try
  483. {
  484. //查询患者基本信息
  485. if (hIS.GetHisPatBaseInfo(out errMsg) != 0)
  486. {
  487. outparam = errMsg;
  488. return -1;
  489. }
  490. HisPatientInfo patientInfo = JsonHelper.getResult<HisPatientInfo>(JObject.Parse(errMsg));
  491. Request1101 request = new Request1101();
  492. // 就诊凭证类型
  493. request.MdtrtcertType = "02";
  494. // 就诊凭证编号
  495. request.MdtrtcertNo = patientInfo.IDNo; //?
  496. // 就诊凭证类型为“ 02” 时默认传 01 代表身份 证,其他证件类型按实际上传
  497. request.CertType = "01";
  498. request.CertNo = patientInfo.IDNo;
  499. request.Name = patientInfo.Name;
  500. JObject joData = new JObject();
  501. joData.Add("data", JObject.FromObject(request));
  502. outparam = joData.ToString();
  503. return 0;
  504. }
  505. catch (Exception ex)
  506. {
  507. outparam = "GetPatientInfo:" + ex.Message;
  508. return -1;
  509. }
  510. finally
  511. {
  512. Global.writeLog("GetPatientInfo", "", outparam);
  513. }
  514. }
  515. /// <summary>
  516. /// 预结算(下单、明细上传、结算结果查询)
  517. /// </summary>
  518. /// <param name="outPar"></param>
  519. /// <returns></returns>
  520. public int PrepareSettlement(out string outPar)
  521. {
  522. string errMsg, patInfo, YH6201Inpar, YH6202Inpar;
  523. outPar = "";
  524. try
  525. {
  526. EncryptHelper eh = new EncryptHelper();
  527. if (Get6201Input(out errMsg) != 0)
  528. {
  529. outPar = errMsg;
  530. return -1;
  531. }
  532. Global.writeLog(errMsg);
  533. YH6201Inpar = errMsg;
  534. JObject joYH6201Rtn = invoker.invokeMPService("6201", eh.encrypt(errMsg));
  535. if (JsonHelper.parseMPRtnValue(joYH6201Rtn, out errMsg) != 0)
  536. {
  537. outPar = errMsg;
  538. return -1;
  539. }
  540. JObject joEncData = JObject.Parse(eh.decrypt(errMsg));
  541. Global.writeLog(JsonHelper.Compress(joEncData));
  542. //设置
  543. parseUploadFeeDetails(joEncData);
  544. //存入MI 患者表,登记表,费用表
  545. if (saveToMi(out errMsg) != 0)
  546. {
  547. outPar = errMsg;
  548. return -1;
  549. }
  550. //YH6202
  551. if (Get6202Input(JObject.Parse(YH6201Inpar), out errMsg) != 0)
  552. {
  553. outPar = errMsg;
  554. return -1;
  555. }
  556. YH6202Inpar = errMsg;
  557. JObject joYH6202Rtn = invoker.invokeMPService("6202", eh.encrypt(YH6202Inpar));
  558. if (JsonHelper.parseMPRtnValue(joYH6202Rtn, out errMsg) != 0)
  559. {
  560. outPar = errMsg;
  561. return -1;
  562. }
  563. joEncData = JObject.Parse(eh.decrypt(errMsg));
  564. Global.writeLog(JsonHelper.Compress(joEncData));
  565. //设置
  566. parsePayOrder(joEncData);
  567. MSettl.confirmFlag = 0;
  568. //存入MI 结算表
  569. if (saveSettlement(out errMsg) != 0)
  570. {
  571. outPar = errMsg;
  572. return -1;
  573. }
  574. //6301查询具体明细信息
  575. //if (GetYH6301Inpar(out errMsg) != 0)
  576. //{
  577. // outPar = errMsg;
  578. // return -1;
  579. //}
  580. //YH6301Inpar = errMsg;
  581. //JObject joYH6301Rtn = invoker.invokeMPService("6301", eh.encrypt(YH6301Inpar));
  582. //if (JsonHelper.parseMPRtnValue(joYH6301Rtn, out errMsg) != 0)
  583. //{
  584. // outPar = errMsg;
  585. // return -1;
  586. //}
  587. //joEncData = JObject.Parse(eh.decrypt(errMsg));
  588. //JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
  589. //Global.writeLog(JsonHelper.Compress(joEncData));
  590. ////设置
  591. //setSettlementsBy6301Rtn(joSettlInfo);
  592. ////存入MI 结算表
  593. //if (saveSettlement(out errMsg) != 0)
  594. //{
  595. // outPar = errMsg;
  596. //}
  597. //返回给HIS后端
  598. JObject joPreSettl = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.preSetl"));
  599. //JObject joTmp = JObject.Parse(JsonHelper.getDestValue(joYH6201Rtn, "encData"));
  600. JObject joTmp = new JObject();
  601. joTmp.Add("insutype", MPat.insuType);
  602. joTmp.Add("psn_no", MPat.psn_no);
  603. joTmp.Add("insuplc_admdvs", MPat.insuplc_admdvs);
  604. joTmp.Add("mdtrtId", MPat.mdtrtID);
  605. joTmp.Add("mdtrt_id", MPat.mdtrtID);
  606. joPreSettl.Add("setl_id", MPat.payOrdId);
  607. joTmp.Add("mdtrt_cert_type", JsonHelper.getDestValue(joPreSettl, "mdtrt_cert_type"));
  608. joTmp.Add("mdtrt_cert_no", JsonHelper.getDestValue(joPreSettl, "certno"));
  609. joTmp.Add("med_type", JsonHelper.getDestValue(joPreSettl, "med_type"));
  610. if (returnMPSettlementInfo(joTmp, joPreSettl, out errMsg) != 0)
  611. {
  612. outPar = errMsg;
  613. return -1;
  614. }
  615. //返回给HIS前端
  616. outPar = errMsg;
  617. return 0;
  618. }
  619. catch (Exception ex)
  620. {
  621. outPar = ex.Message;
  622. return -1;
  623. }
  624. }
  625. /// <summary>
  626. /// 确认结算
  627. /// </summary>
  628. /// <param name="outPar"></param>
  629. /// <returns></returns>
  630. public int ConfirmSettlement(out string outPar)
  631. {
  632. string errMsg, YH6301Inpar;
  633. outPar = "";
  634. try
  635. {
  636. //6301查询具体明细信息
  637. if (Get6301Input(out errMsg) != 0)
  638. {
  639. outPar = errMsg;
  640. return -1;
  641. }
  642. YH6301Inpar = errMsg;
  643. JObject joYH6301Rtn = invoker.invokeMPService("6301",(YH6301Inpar));
  644. if (JsonHelper.parseMPRtnValue(joYH6301Rtn, out errMsg) != 0)
  645. {
  646. outPar = errMsg;
  647. return -1;
  648. }
  649. JObject joEncData = JObject.Parse((errMsg));
  650. JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
  651. Global.writeLog(JsonHelper.Compress(joEncData));
  652. //解析结算信息
  653. parseOrderQuery(joSettlInfo);
  654. MSettl.confirmFlag = 1;
  655. //存入MI 结算表
  656. if (updateSettlement(out errMsg) != 0)
  657. {
  658. outPar = errMsg;
  659. return -1;
  660. }
  661. else
  662. {
  663. //返回给HIS前端
  664. outPar = JsonHelper.setExceptionJson(0, "云医保平台", "确认成功!").ToString();
  665. return 0;
  666. }
  667. }
  668. catch (Exception ex)
  669. {
  670. outPar = ex.Message;
  671. return -1;
  672. }
  673. }
  674. /// <summary>
  675. /// 取消结算
  676. /// </summary>
  677. /// <param name="outPar"></param>
  678. /// <returns></returns>
  679. public int CancelSettlement(out string outPar)
  680. {
  681. string errMsg;
  682. outPar = "";
  683. try
  684. {
  685. /**目前从微信那边处理退费
  686. if (GetYH6203Inpar(out errMsg) != 0)
  687. {
  688. }
  689. YH6203Inpar = errMsg;
  690. JObject jo6203Rtn = invoker.invokeMPService("6203", YH6203Inpar);
  691. //YH6202
  692. if (ParseCenterRtnValue(jo6203Rtn, out errMsg) != 0)
  693. {
  694. }
  695. else
  696. {
  697. string newSettlID = JsonHelper.getDestValue(jo6203Rtn,"");
  698. //撤销医保平台结算数据
  699. cancleSettlement(newSettlID,out errMsg);
  700. //撤销医保平台费用,登记,
  701. }
  702. **/
  703. //处理撤销数据
  704. if (cancleSettlement(MPat.settlID, out errMsg) != 0)
  705. {
  706. outPar = errMsg;
  707. return -1;
  708. }
  709. else
  710. {
  711. outPar = errMsg;
  712. return 0;
  713. }
  714. }
  715. catch (Exception ex)
  716. {
  717. return -1;
  718. }
  719. }
  720. #endregion
  721. public JObject orderNotify(string inParam)
  722. {
  723. throw new NotImplementedException();
  724. }
  725. public JObject orderQuery(string inParam)
  726. {
  727. throw new NotImplementedException();
  728. }
  729. public JObject parseEcCode(string inParam)
  730. {
  731. throw new NotImplementedException();
  732. }
  733. public JObject payNotify(string inParam)
  734. {
  735. throw new NotImplementedException();
  736. }
  737. public JObject payOrder(string inParam)
  738. {
  739. throw new NotImplementedException();
  740. }
  741. public JObject uploadFeeDetails(string inParam)
  742. {
  743. throw new NotImplementedException();
  744. }
  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. }