MobilePay.cs 82 KB

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