AbstractMobilePay.cs 74 KB

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