MobilePay.cs 81 KB

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