MobilePay.cs 78 KB

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