MobilePay.cs 79 KB

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