AbstractMobilePay.cs 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560
  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, YH6201Inpar, YH6202Inpar;
  523. outPar = "";
  524. try
  525. {
  526. EncryptHelper eh = new EncryptHelper(Global.inf.MobilePay.appid,Global.inf.MobilePay.secretKey,Global.inf.MobilePay.publicKey,Global.inf.MobilePay.privateKey);
  527. if (Get6201Input(out errMsg) != 0)
  528. {
  529. outPar = errMsg;
  530. return -1;
  531. }
  532. YH6201Inpar = errMsg;
  533. JObject joYH6201Rtn = invoker.invokeMPService("6201", errMsg);
  534. if (JsonHelper.parseMPRtnValue(joYH6201Rtn, out errMsg) != 0)
  535. {
  536. outPar = errMsg;
  537. return -1;
  538. }
  539. JObject joEncData = JObject.Parse(eh.decrypt(errMsg));
  540. Global.writeLog(JsonHelper.Compress(joEncData));
  541. //设置
  542. parseUploadFeeDetails(joEncData);
  543. //存入MI 患者表,登记表,费用表
  544. if (saveToMi(out errMsg) != 0)
  545. {
  546. outPar = errMsg;
  547. return -1;
  548. }
  549. //YH6202
  550. if (Get6202Input(JObject.Parse(YH6201Inpar), out errMsg) != 0)
  551. {
  552. outPar = errMsg;
  553. return -1;
  554. }
  555. YH6202Inpar = errMsg;
  556. JObject joYH6202Rtn = invoker.invokeMPService("6202", YH6202Inpar);
  557. if (JsonHelper.parseMPRtnValue(joYH6202Rtn, out errMsg) != 0)
  558. {
  559. outPar = errMsg;
  560. return -1;
  561. }
  562. joEncData = JObject.Parse(eh.decrypt(errMsg));
  563. Global.writeLog(JsonHelper.Compress(joEncData));
  564. //设置
  565. parsePayOrder(joEncData);
  566. MSettl.confirmFlag = 0;
  567. //存入MI 结算表
  568. if (saveSettlement(out errMsg) != 0)
  569. {
  570. outPar = errMsg;
  571. return -1;
  572. }
  573. //6301查询具体明细信息
  574. //if (GetYH6301Inpar(out errMsg) != 0)
  575. //{
  576. // outPar = errMsg;
  577. // return -1;
  578. //}
  579. //YH6301Inpar = errMsg;
  580. //JObject joYH6301Rtn = invoker.invokeMPService("6301", eh.encrypt(YH6301Inpar));
  581. //if (JsonHelper.parseMPRtnValue(joYH6301Rtn, out errMsg) != 0)
  582. //{
  583. // outPar = errMsg;
  584. // return -1;
  585. //}
  586. //joEncData = JObject.Parse(eh.decrypt(errMsg));
  587. //JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
  588. //Global.writeLog(JsonHelper.Compress(joEncData));
  589. ////设置
  590. //setSettlementsBy6301Rtn(joSettlInfo);
  591. ////存入MI 结算表
  592. //if (saveSettlement(out errMsg) != 0)
  593. //{
  594. // outPar = errMsg;
  595. //}
  596. //返回给HIS后端
  597. JObject joPreSettl = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.preSetl"));
  598. //JObject joTmp = JObject.Parse(JsonHelper.getDestValue(joYH6201Rtn, "encData"));
  599. JObject joTmp = new JObject();
  600. joTmp.Add("insutype", MPat.insuType);
  601. joTmp.Add("psn_no", MPat.psn_no);
  602. joTmp.Add("insuplc_admdvs", MPat.insuplc_admdvs);
  603. joTmp.Add("mdtrtId", MPat.mdtrtID);
  604. joTmp.Add("mdtrt_id", MPat.mdtrtID);
  605. joPreSettl.Add("setl_id", MPat.payOrdId);
  606. joTmp.Add("mdtrt_cert_type", JsonHelper.getDestValue(joPreSettl, "mdtrt_cert_type"));
  607. joTmp.Add("mdtrt_cert_no", JsonHelper.getDestValue(joPreSettl, "certno"));
  608. joTmp.Add("med_type", JsonHelper.getDestValue(joPreSettl, "med_type"));
  609. if (returnMPSettlementInfo(joTmp, joPreSettl, out errMsg) != 0)
  610. {
  611. outPar = errMsg;
  612. return -1;
  613. }
  614. //返回给HIS前端
  615. outPar = errMsg;
  616. return 0;
  617. }
  618. catch (Exception ex)
  619. {
  620. outPar = ex.Message;
  621. return -1;
  622. }
  623. }
  624. /// <summary>
  625. /// 确认结算
  626. /// </summary>
  627. /// <param name="outPar"></param>
  628. /// <returns></returns>
  629. public int ConfirmSettlement(out string outPar)
  630. {
  631. string errMsg, YH6301Inpar;
  632. outPar = "";
  633. try
  634. {
  635. //6301查询具体明细信息
  636. if (Get6301Input(out errMsg) != 0)
  637. {
  638. outPar = errMsg;
  639. return -1;
  640. }
  641. YH6301Inpar = errMsg;
  642. JObject joYH6301Rtn = invoker.invokeMPService("6301",(YH6301Inpar));
  643. if (JsonHelper.parseMPRtnValue(joYH6301Rtn, out errMsg) != 0)
  644. {
  645. outPar = errMsg;
  646. return -1;
  647. }
  648. JObject joEncData = JObject.Parse((errMsg));
  649. JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
  650. Global.writeLog(JsonHelper.Compress(joEncData));
  651. //解析结算信息
  652. parseOrderQuery(joSettlInfo);
  653. MSettl.confirmFlag = 1;
  654. //存入MI 结算表
  655. if (updateSettlement(out errMsg) != 0)
  656. {
  657. outPar = errMsg;
  658. return -1;
  659. }
  660. else
  661. {
  662. //返回给HIS前端
  663. outPar = JsonHelper.setExceptionJson(0, "云医保平台", "确认成功!").ToString();
  664. return 0;
  665. }
  666. }
  667. catch (Exception ex)
  668. {
  669. outPar = ex.Message;
  670. return -1;
  671. }
  672. }
  673. /// <summary>
  674. /// 取消结算
  675. /// </summary>
  676. /// <param name="outPar"></param>
  677. /// <returns></returns>
  678. public int CancelSettlement(out string outPar)
  679. {
  680. string errMsg;
  681. outPar = "";
  682. try
  683. {
  684. /**目前从微信那边处理退费
  685. if (GetYH6203Inpar(out errMsg) != 0)
  686. {
  687. }
  688. YH6203Inpar = errMsg;
  689. JObject jo6203Rtn = invoker.invokeMPService("6203", YH6203Inpar);
  690. //YH6202
  691. if (ParseCenterRtnValue(jo6203Rtn, out errMsg) != 0)
  692. {
  693. }
  694. else
  695. {
  696. string newSettlID = JsonHelper.getDestValue(jo6203Rtn,"");
  697. //撤销医保平台结算数据
  698. cancleSettlement(newSettlID,out errMsg);
  699. //撤销医保平台费用,登记,
  700. }
  701. **/
  702. //处理撤销数据
  703. if (cancleSettlement(MPat.settlID, out errMsg) != 0)
  704. {
  705. outPar = errMsg;
  706. return -1;
  707. }
  708. else
  709. {
  710. outPar = errMsg;
  711. return 0;
  712. }
  713. }
  714. catch (Exception )
  715. {
  716. return -1;
  717. }
  718. }
  719. #endregion
  720. public JObject orderNotify(string inParam)
  721. {
  722. throw new NotImplementedException();
  723. }
  724. public JObject orderQuery(string inParam)
  725. {
  726. throw new NotImplementedException();
  727. }
  728. public JObject parseEcCode(string inParam)
  729. {
  730. throw new NotImplementedException();
  731. }
  732. public JObject payNotify(string inParam)
  733. {
  734. throw new NotImplementedException();
  735. }
  736. public JObject payOrder(string inParam)
  737. {
  738. throw new NotImplementedException();
  739. }
  740. public JObject uploadFeeDetails(string inParam)
  741. {
  742. throw new NotImplementedException();
  743. }
  744. #region 诊断
  745. //获取诊断信息
  746. public int getDiagnoses(out string errMsg)
  747. {
  748. errMsg = "";
  749. try
  750. {
  751. //调用服务获取门诊诊断信息
  752. string outparam = "";
  753. if (hIS.getPatDiagnoses(MPat, out outparam) != 0)
  754. {
  755. return -1;
  756. }
  757. JObject joRtn = JObject.Parse(outparam);
  758. JObject joMdtrtInfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "mdtrtinfo"));
  759. JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joRtn, "diseinfo"));
  760. //组织门诊结算诊断入参
  761. JArray jaRow = new JArray();
  762. for (int i = 0; i < jaDiagnoses.Count; i++)
  763. {
  764. JObject joTmp = new JObject();
  765. joTmp.Add("diagType", jaDiagnoses[i]["diag_type"]);//
  766. joTmp.Add("diagSrtNo", jaDiagnoses[i]["diag_srt_no"]);//
  767. joTmp.Add("diagCode", jaDiagnoses[i]["diag_code"]);//
  768. joTmp.Add("diagName", jaDiagnoses[i]["diag_name"]);//
  769. joTmp.Add("diagDept", jaDiagnoses[i]["diag_dept"]);//
  770. joTmp.Add("diseDorNo", jaDiagnoses[i]["dise_dor_no"]);//
  771. joTmp.Add("diseDorName", jaDiagnoses[i]["dise_dor_name"]);//
  772. joTmp.Add("diagTime", jaDiagnoses[i]["diag_time"]);//
  773. joTmp.Add("valiFlag", "1");//
  774. jaRow.Add(joTmp);
  775. }
  776. JObject joDiagRow = new JObject();
  777. joDiagRow.Add("diseinfoList", jaRow);
  778. joDiagRow.Add("mdtrtinfo", joMdtrtInfo);
  779. outparam = joDiagRow.ToString();
  780. errMsg = outparam;
  781. return 0;
  782. }
  783. catch (Exception ex)
  784. {
  785. errMsg = "getDiagnoses:" + ex.Message;
  786. return -1;
  787. }
  788. }
  789. #endregion
  790. #region 费用
  791. private int GetFee(out string outparam)
  792. {
  793. string hisFee, chrgBchno = "";
  794. JObject jo = new JObject();
  795. JObject joRow = new JObject();
  796. JArray jaRow = new JArray();
  797. try
  798. {
  799. //获取HIS费用
  800. if (hIS.getHisFee(MPat, out hisFee) != 0)
  801. {
  802. outparam = hisFee;
  803. return -1;
  804. }
  805. JObject joFee = JObject.Parse(hisFee);
  806. //处理
  807. //调用医保平台转换HIS费用(转换医保编码等)
  808. JObject joHisFee = JObject.Parse(hisFee);
  809. if (mIS.convertHisFeeWithInsuCodeOfMobilePay(MPat, joHisFee, out outparam) != 0)
  810. {
  811. return -1;
  812. }
  813. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outparam), "data"));
  814. jaFee = (JArray)jaFeeDetail.DeepClone();
  815. decimal sumFee = 0;
  816. //转换
  817. for (int i = 0; i < jaFeeDetail.Count; i++)
  818. {
  819. decimal cnt = decimal.Parse(jaFeeDetail[i]["cnt"].ToString());
  820. decimal pric = decimal.Parse(jaFeeDetail[i]["pric"].ToString());
  821. decimal sumamt = decimal.Parse(jaFeeDetail[i]["det_item_fee_sumamt"].ToString());
  822. sumFee = sumFee + sumamt;
  823. JObject joTmp = new JObject();
  824. joTmp.Add("feedetlSn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
  825. joTmp.Add("mdtrtId", jaFeeDetail[i]["mdtrt_id"]);//就诊ID
  826. //joTmp.Add("psnNo", jaFeeDetail[i]["psnNo"]);//人员编号
  827. chrgBchno = jaFeeDetail[i]["chrg_bchno"].ToString();
  828. joTmp.Add("chrgBchno", jaFeeDetail[i]["chrg_bchno"]);//收费批次号
  829. joTmp.Add("diseCodg", "");//病种编码
  830. joTmp.Add("rxno", jaFeeDetail[i]["rxno"]);//处方号
  831. joTmp.Add("rxCircFlag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
  832. joTmp.Add("feeOcurTime", jaFeeDetail[i]["fee_ocur_time"]);//费用发生时间
  833. joTmp.Add("medListCodg", jaFeeDetail[i]["med_list_codg"]);//医疗目录编码
  834. joTmp.Add("medinsListCodg", jaFeeDetail[i]["medins_list_codg"]);//医药机构目录编码
  835. joTmp.Add("detItemFeeSumamt", sumamt.ToString("#0.00"));//明细项目费用总额
  836. joTmp.Add("cnt", cnt.ToString("#0.0000"));//数量
  837. joTmp.Add("pric", pric.ToString("#0.000000"));//单价
  838. joTmp.Add("sinDosDscr", jaFeeDetail[i]["sin_dos_dscr"]);//单次剂量描述
  839. joTmp.Add("usedFrquDscr", jaFeeDetail[i]["used_frqu_dscr"]);//使用频次描述
  840. joTmp.Add("prdDays", jaFeeDetail[i]["prd_days"]);//周期天数
  841. joTmp.Add("medcWayDscr", jaFeeDetail[i]["medc_way_dscr"]);//用药途径描述
  842. joTmp.Add("bilgDeptCodg", jaFeeDetail[i]["bilg_dept_codg"]);//开单科室编码
  843. joTmp.Add("bilgDeptName", jaFeeDetail[i]["bilg_dept_name"]);//开单科室名称
  844. joTmp.Add("bilgDrCodg", jaFeeDetail[i]["bilg_dr_codg"]);//开单医生编码
  845. joTmp.Add("bilgDrName", jaFeeDetail[i]["bilg_dr_name"]);//开单医师姓名
  846. joTmp.Add("acordDeptCodg", jaFeeDetail[i]["acord_dept_codg"]);//受单科室编码
  847. joTmp.Add("acordDeptName", jaFeeDetail[i]["acord_dept_name"]);//受单科室名称
  848. joTmp.Add("ordersDrCode", jaFeeDetail[i]["orders_dr_code"]);//受单医生编码
  849. joTmp.Add("ordersDrName", jaFeeDetail[i]["orders_dr_name"]);//受单医生姓名
  850. joTmp.Add("hospApprFlag", jaFeeDetail[i]["hosp_appr_flag"]);//医院审批标志
  851. joTmp.Add("tcmdrugUsedWay", jaFeeDetail[i]["tcmdrug_used_way"]);//中药使用方式
  852. joTmp.Add("etipFlag", jaFeeDetail[i]["etip_flag"]);//外检标志
  853. joTmp.Add("etipHospCode", jaFeeDetail[i]["etip_hosp_code"]);//外检医院编码
  854. joTmp.Add("dscgTkdrugFlag", jaFeeDetail[i]["dscg_tkdrug_flag"]);//出院带药标志
  855. joTmp.Add("matnFeeFlag", jaFeeDetail[i]["matn_fee_flag"]);//生育费用标志
  856. joTmp.Add("initFeedetlSn", jaFeeDetail[i]["init_feedetl_sn"]);//原费用流水号
  857. joTmp.Add("drordNo", jaFeeDetail[i]["drord_no"]);//医嘱号
  858. joTmp.Add("medType", jaFeeDetail[i]["med_type"]);//医疗类别
  859. joTmp.Add("memo", "");//备注
  860. joTmp.Add("expContent", jaFeeDetail[i]["expContent"]);//扩展字段
  861. joTmp.Add("medListName", jaFeeDetail[i]["medins_list_name"]);//医疗目录名称
  862. joTmp.Add("medListSpc", jaFeeDetail[i]["med_list_spc"]);//医疗目录规格
  863. joTmp.Add("combNo", jaFeeDetail[i]["comb_no"]);//组套编号
  864. jaRow.Add(joTmp);
  865. }
  866. jo.Add("medfeeSumamt", sumFee.ToString("#0.00"));
  867. jo.Add("chrgBchno", chrgBchno);
  868. jo.Add("feedetailList", jaRow);
  869. outparam = jo.ToString();
  870. return 0;
  871. }
  872. catch (Exception ex)
  873. {
  874. outparam = "获取费用异常:" + ex.Message;
  875. Global.writeLog("GetFee", jo.ToString(), "获取费用异常:" + ex.Message);
  876. return -1;
  877. }
  878. }
  879. /// <summary>
  880. /// 汇总医保返回的结算金额(按照HIS的原则汇总,后期HIS按照这个来进行勾稽关系判断)
  881. /// </summary>
  882. /// <param name="jo"></param>
  883. /// <returns></returns>
  884. public int sumInsuRtnSettlInfo(JObject jo, out JObject joSumFee, out string errMsg)
  885. {
  886. // 医疗费总额是患者在医药机构花费的所有诊疗、药品、耗材、服务设施等项目费用的总和 = 基金支付总额 + 个人负担总金额 + 其他(如医院负担金额);
  887. //3、基金支付总额 = 基本医保统筹基金支出(含职工基本医疗保险、居民基本医疗保险)+补充医疗保险基金支出 (含覆盖全体参保人的居民大病保险和大额医疗费用补助、覆盖部分参保人的企业职工大额医疗费用补助和公务员医疗补助等)+医疗救助基金支出 + 其他支出(如伤残人员医疗保障基金支出);
  888. //5、个人账户支出中包含账户共济支付金额
  889. joSumFee = new JObject();
  890. errMsg = "";
  891. decimal ybAmt, psnAcctAmt, hospAmt, psnCashAmt, medFee;
  892. try
  893. {
  894. ybAmt = 0; psnAcctAmt = 0; hospAmt = 0; psnCashAmt = 0; medFee = 0;
  895. ybAmt = MSettl.fundPaySumamt;
  896. psnAcctAmt = MSettl.accountPaySumamt;
  897. psnCashAmt = MSettl.personCashPay;
  898. hospAmt = MSettl.hospitalPartAmount;
  899. medFee = MSettl.sumamt;
  900. joSumFee.Add("sumamt", medFee);
  901. joSumFee.Add("ybAmt", ybAmt);
  902. joSumFee.Add("psnAcctAmt", psnAcctAmt);
  903. joSumFee.Add("hospAmt", hospAmt);
  904. joSumFee.Add("psnCashAmt", psnCashAmt);
  905. if (medFee != (ybAmt + psnAcctAmt + psnCashAmt + hospAmt))
  906. {
  907. errMsg = "ybAmt(" + ybAmt.ToString() + ")+" + "psnAcctAmt(" + psnAcctAmt.ToString() + ")+" + "psnCashAmt(" + psnCashAmt.ToString() + ")+" + "hospAmt(" + hospAmt.ToString() + ")" + "!=medFee(" + medFee.ToString() + ")";
  908. return -1;
  909. }
  910. return 0;
  911. }
  912. catch (Exception ex)
  913. {
  914. errMsg = ex.Message;
  915. return 1;
  916. }
  917. }
  918. /// <summary>
  919. /// 获取结算费用的封装
  920. /// </summary>
  921. /// <param name="jo"></param>
  922. /// <param name="path"></param>
  923. /// <returns></returns>
  924. private decimal getDecimalFee(JObject jo, string path)
  925. {
  926. try
  927. {
  928. string temp = JsonHelper.getDestValue(jo, path);
  929. if (temp == "")
  930. {
  931. return 0;
  932. }
  933. else
  934. {
  935. return decimal.Parse(temp);
  936. }
  937. }
  938. catch (Exception ex)
  939. {
  940. Global.writeLog("getFee异常:" + ex.Message);
  941. return 0;
  942. }
  943. }
  944. #endregion
  945. #region 结算
  946. /// <summary>
  947. /// 返回移动支付结算信息给HIS
  948. /// </summary>
  949. /// <param name="joSetlInpar"></param>
  950. /// <param name="joSetlinfo"></param>中心返回的信息
  951. /// <param name="outParam"></param>
  952. /// <returns></returns>
  953. public int returnMPSettlementInfo(JObject joReg, JObject joSettl, out string outParam)
  954. {
  955. string errMsg;
  956. try
  957. {
  958. JObject joSumFee = new JObject();
  959. if (sumInsuRtnSettlInfo(joSettl, out joSumFee, out errMsg) != 0)
  960. {
  961. outParam = "返回结算结果给HIS失败,请联系管理员!" + errMsg;
  962. return -1;
  963. }
  964. dynamic joTmp = new JObject();
  965. joTmp.settleInfo = joSettl;
  966. joTmp.updateUserID = Global.user.ID;
  967. joTmp.regInfo = joReg;
  968. joTmp.middleSettleFlag = "";
  969. joTmp.interfaceDr = Global.inf.interfaceDr;
  970. dynamic joHisInfo = new JObject();
  971. joHisInfo.admID = MPat.adm_Dr;
  972. joHisInfo.billID = MPat.billID;
  973. joHisInfo.recordID = MPat.recordID;
  974. joTmp.hisInfo = joHisInfo;
  975. joTmp.psn_type = MPat.psn_type;
  976. joTmp.mobilePayFlag = "Y";
  977. joTmp.sumFeeObj = joSumFee;
  978. joTmp.mdtrtinfo = MPat.mdtrtID;
  979. JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110018", joTmp).ToString(), "返回移动支付结算结果给HIS");
  980. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  981. {
  982. outParam = "返回移动支付结算结果给HIS失败,请联系管理员!" + errMsg;
  983. return -1;
  984. }
  985. else
  986. {
  987. joSumFee.Add("payAuthNo", MPat.payAuthNo);
  988. joSumFee.Add("payOrdId", MPat.payOrdId);
  989. joSumFee.Add("setlLatlnt", MPat.uldLatlnt);
  990. joSumFee.Add("org_no", Global.inf.hospitalNO);
  991. joSumFee.Add("medOrgOrd", MPat.recordID);
  992. joSumFee.Add("mdtrtId", MPat.mdtrtID);
  993. joSumFee.Add("gmt_out_create", MSettl.settlTime.ToString("yyyy-MM-dd HH:mm:ss"));
  994. joRtn["result"] = joSumFee;
  995. outParam = joRtn.ToString();
  996. return 0;
  997. }
  998. }
  999. catch (Exception ex)
  1000. {
  1001. outParam = "返回移动支付结算结果给HIS出现异常:!" + ex.Message;
  1002. return -1;
  1003. }
  1004. }
  1005. //查询结算信息
  1006. public int QuerySettleInfo(out string errMsg)
  1007. {
  1008. errMsg = "";
  1009. try
  1010. {
  1011. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr= " + Global.inf.hospitalDr;
  1012. sqlStr = sqlStr + " and AdmType = 3 and Adm_Dr= " + MPat.adm_Dr + " and SettlementID= '" + MPat.payOrdId + "'";
  1013. JObject joSqlstr = new JObject();
  1014. joSqlstr.Add("sqlStr", sqlStr);
  1015. JObject joRtn = mIS.DynamicQuerySettlInfo(joSqlstr);
  1016. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1017. {
  1018. return -1;
  1019. }
  1020. else
  1021. {
  1022. errMsg = joRtn.ToString();
  1023. return 0;
  1024. }
  1025. }
  1026. catch (Exception ex)
  1027. {
  1028. errMsg = ex.Message;
  1029. return -1;
  1030. }
  1031. }
  1032. #endregion
  1033. #region 存入MI
  1034. /// <summary>
  1035. /// 插入患者该次就诊参保信息
  1036. /// </summary>
  1037. /// <param name="joBaseInfo"></param>
  1038. /// <param name="joInsuInfo"></param>
  1039. /// <param name="joIdetInfo"></param>
  1040. /// <param name="outParam"></param>
  1041. /// <returns></returns>
  1042. private int insertPatCurInsuInfo(out string outParam)
  1043. {
  1044. JObject joTmp = new JObject();
  1045. string errMsg = "";
  1046. try
  1047. {
  1048. joTmp.Add("HospitalDr", Global.inf.hospitalDr);
  1049. joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
  1050. joTmp.Add("AdmID", MPat.adm_Dr);
  1051. joTmp.Add("PatientName", MPat.name);
  1052. joTmp.Add("PersonalNO", MPat.psn_no);
  1053. joTmp.Add("MdtrtID", MPat.mdtrtID);
  1054. joTmp.Add("PsnCertType", "");
  1055. joTmp.Add("PsnCertNO", MPat.certNO);
  1056. joTmp.Add("Gend", MPat.gend);
  1057. joTmp.Add("Naty", "");
  1058. joTmp.Add("Brdy", MPat.brdy);
  1059. joTmp.Add("Age", MPat.age);
  1060. joTmp.Add("Balc", MPat.balc);
  1061. joTmp.Add("Insutype", MPat.insuType);
  1062. joTmp.Add("PsnType", MPat.psn_type);
  1063. joTmp.Add("PsnInsuStas", "");
  1064. joTmp.Add("PsnInsuDate", "");
  1065. joTmp.Add("PausInsuDate", "");
  1066. joTmp.Add("Cvlservflag", "");
  1067. joTmp.Add("insuplcAdmdvs", MPat.insuplc_admdvs);
  1068. joTmp.Add("EmpName", MPat.emp_name);
  1069. joTmp.Add("PsnIdettype", "");
  1070. joTmp.Add("PsnTypeLv", "");
  1071. joTmp.Add("IdetBegntime", "");
  1072. joTmp.Add("IdetEndtime", "");
  1073. if (string.IsNullOrEmpty(Global.user.ID)) Global.user.ID = "0";
  1074. joTmp.Add("updateUserID", Global.user.ID);
  1075. string serviceCode = "09010070";
  1076. string inpar = JsonHelper.setIrisInpar(serviceCode, joTmp).ToString();
  1077. JObject joRtn = invoker.invokeInsuService(inpar, "插入患者该次就诊参保信息");
  1078. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1079. {
  1080. outParam = errMsg;
  1081. return -1;
  1082. }
  1083. else
  1084. {
  1085. outParam = joRtn.ToString();
  1086. return 0;
  1087. }
  1088. }
  1089. catch (Exception ex)
  1090. {
  1091. outParam = "医保平台插入患者该次就诊参保信息:" + ex.Message;
  1092. return -1;
  1093. }
  1094. }
  1095. /// <summary>
  1096. /// 插入登记信息
  1097. /// </summary>
  1098. /// <param name="joInpar"></param> 48交易入参
  1099. /// <param name="joOutpar"></param>48交易出参
  1100. /// <param name="outParam"></param>
  1101. /// <returns></returns>
  1102. private int saveRegisterInfo(out string outParam)
  1103. {
  1104. //插入云医保平台
  1105. JObject joTmp = new JObject();
  1106. string errMsg = "";
  1107. try
  1108. {
  1109. joTmp.Add("HospitalDr", Global.inf.hospitalDr);
  1110. joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
  1111. joTmp.Add("AdmDr", MPat.adm_Dr);
  1112. joTmp.Add("PatientName", MPat.name);
  1113. joTmp.Add("PersonalNO", MPat.psn_no);
  1114. joTmp.Add("InsuRegID", MPat.mdtrtID);
  1115. joTmp.Add("RegDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1116. joTmp.Add("InsuType", MPat.insuType);
  1117. joTmp.Add("CertificateType", MPat.certType);
  1118. joTmp.Add("CertificateNO", MPat.certNO);
  1119. joTmp.Add("MedicalType", MPat.medType);
  1120. joTmp.Add("AttendDoctorNO", MPat.admAttendDoctorNO);
  1121. joTmp.Add("ChiefPhyDocName", "");
  1122. joTmp.Add("AdmInDiagDesc", "");
  1123. joTmp.Add("AdmInDepCode", MPat.AdmInDepCode);
  1124. joTmp.Add("AdmInDepName", "");
  1125. joTmp.Add("AdmBed", "");
  1126. joTmp.Add("MainDiagCode", MPat.admDiagCode);
  1127. joTmp.Add("MainDiagName", MPat.admDiagName);
  1128. joTmp.Add("MainConditionDesc", "");
  1129. joTmp.Add("DiseasecCode", "");
  1130. joTmp.Add("DiseasecName", "");
  1131. joTmp.Add("OperationCode", "");
  1132. joTmp.Add("OperationName", "");
  1133. joTmp.Add("DiseasecTypeCode", "");
  1134. joTmp.Add("InsuranceAreaCode", MPat.insuplc_admdvs);
  1135. joTmp.Add("TreatmentAreaCode", Global.inf.areaCode);
  1136. joTmp.Add("payOrdId", MPat.payOrdId);
  1137. joTmp.Add("payToken", MPat.payToken);
  1138. joTmp.Add("RegState", "1");
  1139. joTmp.Add("ValidFlag", "1");
  1140. joTmp.Add("Type", "4");//线上支付门诊
  1141. joTmp.Add("updateUserID", Global.user.ID);
  1142. joTmp.Add("msgid", Global.curEvt.msgid);
  1143. joTmp.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1144. string serviceCode = "09010044";
  1145. string inpar = JsonHelper.setIrisInpar(serviceCode, joTmp).ToString();
  1146. JObject joRtn = invoker.invokeInsuService(inpar, "新增门诊登记信息");
  1147. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1148. {
  1149. outParam = joRtn.ToString();
  1150. return -1;
  1151. }
  1152. else
  1153. {
  1154. outParam = joRtn.ToString();
  1155. return 0;
  1156. }
  1157. }
  1158. catch (Exception ex)
  1159. {
  1160. outParam = "保存门诊登记信息异常:" + ex.Message;
  1161. return -1;
  1162. }
  1163. }
  1164. /// <summary>
  1165. /// 插入结算信息
  1166. /// </summary>
  1167. /// <param name="joSettlement"></param>
  1168. /// <param name="outParam"></param>
  1169. /// <returns></returns>
  1170. public int saveSettlement(out string outParam)
  1171. {
  1172. JObject joTmp = new JObject();
  1173. string errMsg = "";
  1174. try
  1175. {
  1176. JObject joSetlinfo = new JObject();
  1177. joSetlinfo.Add("HospitalDr", Global.inf.hospitalDr);
  1178. joSetlinfo.Add("admID", MPat.adm_Dr);
  1179. joSetlinfo.Add("mdtrt_id", MPat.mdtrtID);
  1180. joSetlinfo.Add("setl_id", MSettl.settlID);//
  1181. joSetlinfo.Add("psn_no", MPat.psn_no);
  1182. joSetlinfo.Add("psn_name", MPat.name);
  1183. //joSetlinfo.Add("mdtrt_cert_type", JsonHelper.getDestValue(joRtnSetlinfo, "mdtrt_cert_type"));
  1184. joSetlinfo.Add("certno", MPat.certNO);
  1185. joSetlinfo.Add("gend", MPat.gend);
  1186. joSetlinfo.Add("naty", MPat.naty);
  1187. joSetlinfo.Add("brdy", MPat.brdy);
  1188. joSetlinfo.Add("age", MPat.age);
  1189. joSetlinfo.Add("insutype", MPat.insuType);
  1190. joSetlinfo.Add("psn_type", MPat.psn_type);
  1191. joSetlinfo.Add("cvlserv_flag", "");
  1192. joSetlinfo.Add("setl_time", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1193. joSetlinfo.Add("mdtrt_cert_type", MPat.mdtrtcertType);
  1194. joSetlinfo.Add("med_type", MPat.medType);
  1195. joSetlinfo.Add("medfee_sumamt", MSettl.sumamt);//总费用
  1196. joSetlinfo.Add("fulamt_ownpay_amt", MSettl.fundPaySumamt);//全自费金额
  1197. joSetlinfo.Add("overlmt_selfpay", MSettl.overLimitAmountmt);//超限价自费费用
  1198. joSetlinfo.Add("preselfpay_amt", MSettl.preSelfPayAmount);//先行自付金额
  1199. joSetlinfo.Add("inscp_scp_amt", MSettl.inPolicyRangeAmount);//符合政策范围金额
  1200. joSetlinfo.Add("act_pay_dedc", MSettl.actualPayDeductible);//实际支付起付线
  1201. joSetlinfo.Add("hifp_pay", MSettl.healthInsurancePay);//基本医疗保险统筹基金支出
  1202. joSetlinfo.Add("pool_prop_selfpay", MSettl.healthInsuranceRatio);//基本医疗保险统筹基金支付比例
  1203. joSetlinfo.Add("cvlserv_pay", MSettl.civilserviceAllowancePay);//公务员医疗补助资金支出
  1204. joSetlinfo.Add("hifes_pay", MSettl.enterpriseSupplementPay);//企业支付 占用 大病报销金额
  1205. joSetlinfo.Add("hifmi_pay", MSettl.seriousIllnessPay);// 居民大病保险资金支出
  1206. joSetlinfo.Add("hifob_pay", MSettl.largeExpensesSupplementPay);//职工大额医疗费用补助基金支出
  1207. joSetlinfo.Add("maf_pay", MSettl.medicalAssistPay);//医疗救助基金支出
  1208. joSetlinfo.Add("hosp_part_amt", MSettl.hospitalPartAmount);//医院负担金额
  1209. joSetlinfo.Add("oth_pay", MSettl.otherPay);//其他支出
  1210. joSetlinfo.Add("fund_pay_sumamt", MSettl.fundPaySumamt);//基金支付总额
  1211. joSetlinfo.Add("psn_part_amt", MSettl.personPaySumamt);//个人负担总金额
  1212. joSetlinfo.Add("acct_pay", MSettl.accountMutualAidAmount);//个人账户支出
  1213. joSetlinfo.Add("psn_cash_pay", MSettl.personCashPay);//个人现金支出
  1214. joSetlinfo.Add("balc", MSettl.balance);// 余额
  1215. joSetlinfo.Add("acct_mulaid_pay", "");//个人账户共济支付金额
  1216. joSetlinfo.Add("medins_setl_id", "");//医药机构结算ID
  1217. joSetlinfo.Add("clr_optins", MSettl.clearingOrgan);//清算经办机构
  1218. joSetlinfo.Add("clr_way", MSettl.clearingWay);//清算方式
  1219. joSetlinfo.Add("clr_type", MSettl.clearingType);//清算类别
  1220. joSetlinfo.Add("ValidFlag", 1);
  1221. joSetlinfo.Add("BillType", 1);
  1222. joSetlinfo.Add("ConfirmFlag", MSettl.confirmFlag);
  1223. joSetlinfo.Add("msgid", Global.curEvt.msgid);
  1224. joSetlinfo.Add("admType", "3");
  1225. joSetlinfo.Add("billID", MPat.billID);
  1226. joSetlinfo.Add("recordID", MPat.recordID);
  1227. joSetlinfo.Add("interfaceDr", Global.inf.interfaceDr);
  1228. joSetlinfo.Add("insuplc_admdvs", MPat.insuplc_admdvs);
  1229. joSetlinfo.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1230. joSetlinfo.Add("HospitalizationsDays", MSettl.hospitalizationsDays);
  1231. joSetlinfo.Add("HospitalizationsTimes", MSettl.hospitalizationsTimes);
  1232. joSetlinfo.Add("HISAdmTime", MSettl.hisAdmTime);
  1233. joSetlinfo.Add("HISDischargeTime", MSettl.hisDischargeTime);
  1234. joSetlinfo.Add("updateUserID", Global.user.ID);
  1235. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010051", joSetlinfo).ToString(), "插入结算信息");
  1236. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1237. {
  1238. outParam = errMsg;
  1239. return -1;
  1240. }
  1241. else
  1242. {
  1243. outParam = joSetlinfo.ToString();
  1244. return 0;
  1245. }
  1246. }
  1247. catch (Exception ex)
  1248. {
  1249. outParam = "插入结算信息:" + ex.Message;
  1250. return -1;
  1251. }
  1252. }
  1253. public int updateSettlement(out string outParam)
  1254. {
  1255. JObject joTmp = new JObject();
  1256. string errMsg = "";
  1257. try
  1258. {
  1259. JObject joSetlinfo = new JObject();
  1260. joSetlinfo.Add("HospitalDr", Global.inf.hospitalDr);
  1261. joSetlinfo.Add("AdmDr", MPat.adm_Dr);
  1262. joSetlinfo.Add("MdtrtID", MPat.mdtrtID);
  1263. joSetlinfo.Add("SettlementID", MSettl.settlID);//
  1264. joSetlinfo.Add("PersonnelNO", MPat.psn_no);
  1265. joSetlinfo.Add("PatientName", MPat.name);
  1266. //joSetlinfo.Add("CertificateType", JsonHelper.getDestValue(joRtnSetlinfo, "mdtrt_cert_type"));
  1267. joSetlinfo.Add("CertificateNO", MPat.certNO);
  1268. joSetlinfo.Add("Gender", MPat.gend);
  1269. joSetlinfo.Add("Nation", MPat.naty);
  1270. joSetlinfo.Add("BirthDay", MPat.brdy);
  1271. joSetlinfo.Add("Age", MPat.age);
  1272. joSetlinfo.Add("InsuranceType", MPat.insuType);
  1273. joSetlinfo.Add("PersonType", MPat.psn_type);
  1274. joSetlinfo.Add("CivilserviceFlag", "");
  1275. joSetlinfo.Add("SettlementDateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1276. joSetlinfo.Add("MdtrtCertType", MPat.mdtrtcertType);
  1277. joSetlinfo.Add("MedicalType", MPat.medType);
  1278. joSetlinfo.Add("Sumamt", MSettl.sumamt);//总费用
  1279. joSetlinfo.Add("OwnPayAmount", MSettl.fundPaySumamt);//全自费金额
  1280. joSetlinfo.Add("OverLimitAmount", MSettl.overLimitAmountmt);//超限价自费费用
  1281. joSetlinfo.Add("PreSelfPayAmount", MSettl.preSelfPayAmount);//先行自付金额
  1282. joSetlinfo.Add("InPolicyRangeAmount", MSettl.inPolicyRangeAmount);//符合政策范围金额
  1283. joSetlinfo.Add("ActualPayDeductible", MSettl.actualPayDeductible);//实际支付起付线
  1284. joSetlinfo.Add("HealthInsurancePay", MSettl.healthInsurancePay);//基本医疗保险统筹基金支出
  1285. joSetlinfo.Add("HealthInsuranceRatio", MSettl.healthInsuranceRatio);//基本医疗保险统筹基金支付比例
  1286. joSetlinfo.Add("CivilserviceAllowancePay", MSettl.civilserviceAllowancePay);//公务员医疗补助资金支出
  1287. joSetlinfo.Add("EnterpriseSupplementPay", MSettl.enterpriseSupplementPay);//企业支付
  1288. joSetlinfo.Add("SeriousIllnessPay", MSettl.seriousIllnessPay);// 居民大病保险资金支出
  1289. joSetlinfo.Add("LargeExpensesSupplementPay", MSettl.largeExpensesSupplementPay);//职工大额医疗费用补助基金支出
  1290. joSetlinfo.Add("MedicalAssistPay", MSettl.medicalAssistPay);//医疗救助基金支出
  1291. joSetlinfo.Add("HospitalPartAmount", MSettl.hospitalPartAmount);//医院负担金额
  1292. joSetlinfo.Add("OtherPay", MSettl.otherPay);//其他支出
  1293. joSetlinfo.Add("FundPaySumamt", MSettl.fundPaySumamt);//基金支付总额
  1294. joSetlinfo.Add("PersonPaySumamt", MSettl.personPaySumamt);//个人负担总金额
  1295. joSetlinfo.Add("AccountPaySumamt", MSettl.accountMutualAidAmount);//个人账户支出
  1296. joSetlinfo.Add("PersonCashPay", MSettl.personCashPay);//个人现金支出
  1297. joSetlinfo.Add("Balance", MSettl.balance);// 余额
  1298. joSetlinfo.Add("AccountMutualAidAmount", "");//个人账户共济支付金额
  1299. joSetlinfo.Add("OrganSettlementID", "");//医药机构结算ID
  1300. joSetlinfo.Add("ClearingOrgan", MSettl.clearingOrgan);//清算经办机构
  1301. joSetlinfo.Add("ClearingWay", MSettl.clearingWay);//清算方式
  1302. joSetlinfo.Add("ClearingType", MSettl.clearingType);//清算类别
  1303. joSetlinfo.Add("ValidFlag", 1);
  1304. joSetlinfo.Add("BillType", 1);
  1305. joSetlinfo.Add("ConfirmFlag", MSettl.confirmFlag);
  1306. joSetlinfo.Add("MSGID", Global.curEvt.msgid);
  1307. joSetlinfo.Add("AdmType", "3");
  1308. joSetlinfo.Add("BillID", MPat.billID);
  1309. joSetlinfo.Add("RecordID", MPat.recordID);
  1310. joSetlinfo.Add("InterfaceDr", Global.inf.interfaceDr);
  1311. joSetlinfo.Add("InsuranceAreaCode", MPat.insuplc_admdvs);
  1312. joSetlinfo.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1313. joSetlinfo.Add("HospitalizationsDays", MSettl.hospitalizationsDays);
  1314. joSetlinfo.Add("HospitalizationsTimes", MSettl.hospitalizationsTimes);
  1315. joSetlinfo.Add("HISAdmTime", MSettl.hisAdmTime);
  1316. joSetlinfo.Add("HISDischargeTime", MSettl.hisDischargeTime);
  1317. joSetlinfo.Add("updateUserID", Global.user.ID);
  1318. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010080", joSetlinfo).ToString(), "更新结算信息");
  1319. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1320. {
  1321. outParam = errMsg;
  1322. return -1;
  1323. }
  1324. else
  1325. {
  1326. outParam = joSetlinfo.ToString();
  1327. return 0;
  1328. }
  1329. }
  1330. catch (Exception ex)
  1331. {
  1332. outParam = "插入结算信息:" + ex.Message;
  1333. return -1;
  1334. }
  1335. }
  1336. /// <summary>
  1337. /// 取消结算
  1338. /// </summary>
  1339. /// <param name="outParam"></param>
  1340. /// <returns></returns>
  1341. public int cancleSettlement(string newSettlID, out string outParam)
  1342. {
  1343. JObject joTmp = new JObject();
  1344. string errMsg = "";
  1345. try
  1346. {
  1347. joTmp.Add("HospitalDr", Global.inf.hospitalDr);
  1348. joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
  1349. joTmp.Add("admID", MPat.adm_Dr);
  1350. joTmp.Add("mdtrt_id", MPat.mdtrtID);
  1351. joTmp.Add("setl_id", MPat.settlID);
  1352. joTmp.Add("new_setl_id", newSettlID);
  1353. joTmp.Add("updateUserID", Global.user.ID);
  1354. joTmp.Add("msgid", Global.curEvt.msgid);
  1355. joTmp.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1356. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010052", joTmp).ToString(), "取消结算信息");
  1357. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1358. {
  1359. outParam = errMsg;
  1360. return -1;
  1361. }
  1362. else
  1363. {
  1364. outParam = JsonHelper.setExceptionJson(0, "云医保平台", "取消结算成功").ToString();
  1365. return 0;
  1366. }
  1367. }
  1368. catch (Exception ex)
  1369. {
  1370. outParam = "取消结算信息:" + ex.Message;
  1371. return -1;
  1372. }
  1373. }
  1374. /// <summary>
  1375. /// 插入医保费用
  1376. /// </summary>
  1377. /// <param name="jaTmp"></param>
  1378. /// <param name="outParam"></param>
  1379. /// <returns></returns>
  1380. public int insertFee(JArray jaTmp, out string outParam)
  1381. {
  1382. try
  1383. {
  1384. outParam = "";
  1385. string errMsg;
  1386. dynamic joTmp = new JObject();
  1387. joTmp = new JObject();
  1388. joTmp.code = "09010046";
  1389. joTmp.HospitalDr = Global.inf.hospitalDr;
  1390. joTmp.admID = MPat.adm_Dr;
  1391. joTmp.mdtrt_id = MPat.mdtrtID;
  1392. joTmp.updateUserID = Global.user.ID;
  1393. joTmp.Add("params", jaTmp);
  1394. ;
  1395. JObject joRtn = invoker.invokeInsuService(joTmp.ToString(), "插入2301明细");
  1396. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1397. {
  1398. outParam = errMsg;
  1399. return -1;
  1400. }
  1401. else
  1402. {
  1403. outParam = joRtn.ToString();
  1404. return 0;
  1405. }
  1406. }
  1407. catch (Exception ex)
  1408. {
  1409. outParam = "insertFee 异常:" + ex.Message;
  1410. return -1;
  1411. }
  1412. }
  1413. private int saveToMi(out string errMsg)
  1414. {
  1415. errMsg = "";
  1416. try
  1417. {
  1418. //存储参保信息
  1419. if (insertPatCurInsuInfo(out errMsg) != 0)
  1420. {
  1421. return -1;
  1422. }
  1423. //存储登记信息
  1424. if (saveRegisterInfo(out errMsg) != 0)
  1425. {
  1426. return -1;
  1427. }
  1428. //处理jaFee
  1429. foreach (var jo in jaFee)
  1430. {
  1431. jo["mdtrt_id"] = MPat.mdtrtID;
  1432. jo["psn_no"] = MPat.psn_no;
  1433. }
  1434. //存储费用信息
  1435. if (insertFee(jaFee, out errMsg) != 0)
  1436. {
  1437. return -1;
  1438. }
  1439. return 0;
  1440. }
  1441. catch (Exception ex)
  1442. {
  1443. errMsg = "saveToMi:" + ex.Message;
  1444. return -1;
  1445. }
  1446. }
  1447. #endregion
  1448. #region 解析中心返回
  1449. /// <summary>
  1450. /// 解析银海移动支付返参
  1451. /// </summary>
  1452. /// <param name="joRtn"></param>
  1453. /// <param name="errorMsg"></param>
  1454. /// <returns></returns>
  1455. public int ParseCenterRtnValue(JObject joRtn, out string errorMsg)
  1456. {
  1457. try
  1458. {
  1459. errorMsg = JsonHelper.getDestValue(joRtn, "message");
  1460. return int.Parse(JsonHelper.getDestValue(joRtn, "code")); //0 成功-1 失败
  1461. }
  1462. catch (Exception ex)
  1463. {
  1464. errorMsg = "解析银海移动支付返参发生异常:" + ex.Message;
  1465. return -1;
  1466. }
  1467. }
  1468. #endregion
  1469. }
  1470. }