InsuBusiness.cs 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using PTMedicalInsurance.Common;
  7. using PTMedicalInsurance.Business;
  8. using System.Windows.Forms;
  9. using PTMedicalInsurance.Helper;
  10. using Newtonsoft.Json.Linq;
  11. using PTMedicalInsurance.Variables;
  12. using PTMedicalInsurance.Forms;
  13. using System.IO;
  14. using System.Reflection;
  15. using System.Data;
  16. using PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler;
  17. using PTMedicalInsurance.Business.Core.Forms.DischargeAudit;
  18. namespace PTMedicalInsurance
  19. {
  20. public class InsuBusiness : IInsuBusiness
  21. {
  22. //定义相关的变量
  23. private Patients patient;
  24. private Fees fee;
  25. private Settlements settlement;
  26. //json对象属性
  27. private JObject joInParam;
  28. private JArray jaSession;
  29. private JArray jaParams;
  30. private JObject joParam;
  31. private JObject joInterface;
  32. private JObject joInsuAdmObj;
  33. //设置业务实例
  34. CenterBusiness cBus = new CenterBusiness();
  35. HisMainBusiness hBus = new HisMainBusiness();
  36. HisIrisServices hIS = new HisIrisServices();
  37. MIIrisServices mIS= new MIIrisServices();
  38. InvokeHelper invoker = new InvokeHelper();
  39. private string businessType;
  40. private string operationType;
  41. public InsuBusiness()
  42. {
  43. Global.curEvt.path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
  44. ComputerInfo comp = new ComputerInfo();
  45. Global.curEvt.mac = comp.GetMAC();
  46. Global.curEvt.ip = comp.GetIP(); //"10.1.4.100";
  47. Global.pat.insuplc_admdvs = ""; //如果是NULL中心会报错
  48. }
  49. private int parseInparam(string inParam,out string errMsg)
  50. {
  51. errMsg = "";
  52. try
  53. {
  54. joInParam = JObject.Parse(inParam);
  55. jaSession = JArray.Parse(JsonHelper.getDestValue(joInParam, "session"));
  56. Global.curEvt.jaSession = jaSession;
  57. jaParams = JArray.Parse(JsonHelper.getDestValue(joInParam, "params"));
  58. joParam = JObject.FromObject(jaParams[0]);
  59. if (JsonHelper.getDestValue(joInParam, "insuAdmObj") != "")
  60. joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInParam, "insuAdmObj"));
  61. joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
  62. businessType = JsonHelper.getDestValue(joInParam, "businessType");
  63. operationType = JsonHelper.getDestValue(joInParam, "operationType");
  64. if ((businessType == "M6") || (businessType == "M6C") || (businessType == "M6Confirm"))
  65. {
  66. Environment.CurrentDirectory = @"D:\HttpServerAPI\bin\libs";
  67. }
  68. return 0;
  69. }
  70. catch (Exception ex)
  71. {
  72. errMsg = "parseInparam 解析入参异常:" + errMsg;
  73. return -1;
  74. }
  75. }
  76. /// <summary>
  77. /// 签到
  78. /// </summary>
  79. /// <param name="InParam"></param>
  80. /// <returns></returns>
  81. public string Init(string InParam)
  82. {
  83. string errMsg, rtnResult ="";
  84. JObject joRtn = new JObject();
  85. try
  86. {
  87. if (hBus.initEnvironment(InParam, out errMsg) != 0)
  88. {
  89. return JsonHelper.setExceptionJson(-100, "initEnvironment 失败", errMsg).ToString();
  90. }
  91. else
  92. {
  93. if (businessType == "DischargeAudit")
  94. {
  95. rtnResult = JsonHelper.setIrisReturnValue(0, "无需签到", joRtn).ToString();
  96. return rtnResult;
  97. }
  98. if (mIS.isSigned(ref Global.curEvt.signno) != true)
  99. {
  100. //签到
  101. if (cBus.signIn(out joRtn) != 0)
  102. {
  103. rtnResult = JsonHelper.setExceptionJson(-1, "签到异常", (string)joRtn["err_msg"]).ToString();
  104. return rtnResult;
  105. }
  106. else
  107. {
  108. Global.curEvt.signno = JsonHelper.getDestValue(joRtn, "output.signinoutb.sign_no");
  109. //插入签到表
  110. if (mIS.saveSignRecord(Global.curEvt.signno, out errMsg) != 0)
  111. {
  112. rtnResult = JsonHelper.setIrisReturnValue(0, "中心签到成功但插入签到表失败:" + errMsg, null).ToString();
  113. }
  114. else
  115. {
  116. rtnResult = JsonHelper.setIrisReturnValue(0, "签到成功", joRtn).ToString();
  117. }
  118. }
  119. }
  120. else
  121. {
  122. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
  123. }
  124. return rtnResult;
  125. }
  126. }
  127. catch (Exception ex)
  128. {
  129. rtnResult = JsonHelper.setExceptionJson(-100, "Init 异常", ex.Message).ToString();
  130. return rtnResult;
  131. }
  132. finally
  133. {
  134. Global.writeLog("初始化结果:" + rtnResult);
  135. }
  136. }
  137. /// <summary>
  138. /// 初始化
  139. /// </summary>
  140. /// <param name="inParam"></param>
  141. /// <param name="outParam"></param>
  142. /// <returns></returns>
  143. private int init(string inParam, out string outParam)
  144. {
  145. string errMsg;
  146. outParam = "";
  147. try
  148. {
  149. //BS架构调用方式问题,每次调用都需要重新初始化
  150. JObject joInitRtn = JObject.Parse(Init(inParam));
  151. if (JsonHelper.parseIrisRtnValue(joInitRtn, out errMsg) != 0)
  152. {
  153. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)", errMsg).ToString();
  154. return -1;
  155. }
  156. else
  157. {
  158. return 0;
  159. }
  160. }
  161. catch (Exception ex)
  162. {
  163. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)异常", ex.Message).ToString();
  164. return -1;
  165. }
  166. }
  167. /// <summary>
  168. /// 获取患者信息
  169. /// </summary>
  170. /// <param name="InParam"></param>
  171. /// <returns></returns>
  172. public string GetPatientInfo(string InParam)
  173. {
  174. Global.writeLog("GetPatientInfo入参:" + JsonHelper.Compress(InParam));
  175. //设置返回值,错误信息
  176. int errCode;
  177. string errMsg, rtnResult = "",outParam;
  178. //BS架构调用方式问题,每次调用都需要重新初始化
  179. if (init(InParam,out outParam)!= 0)
  180. {
  181. rtnResult = outParam;
  182. return rtnResult;
  183. }
  184. JObject joInParam = JObject.Parse(InParam);
  185. string businessType = JsonHelper.getDestValue(joInParam,"businessType");
  186. try
  187. {
  188. switch (businessType)
  189. {
  190. case "M1"://门诊读卡
  191. {
  192. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  193. if (hBus.readCard(out outParam) != 0)
  194. {
  195. rtnResult = JsonHelper.setExceptionJson(-100, "门诊读卡失败!", outParam).ToString();
  196. }
  197. else
  198. {
  199. //展示患者信息界面
  200. if (hBus.showPatInfo(outParam, out outParam) != 0)
  201. {
  202. rtnResult = outParam;
  203. }
  204. else
  205. {
  206. rtnResult = JsonHelper.setIrisReturnValue(0, "", JObject.Parse(outParam)).ToString();
  207. }
  208. }
  209. break;
  210. }
  211. case "Z1"://住院读卡
  212. {
  213. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  214. if (hBus.readCard(out outParam) != 0)
  215. {
  216. rtnResult = JsonHelper.setExceptionJson(-100, "住院读卡失败!", outParam).ToString();
  217. }
  218. else
  219. {
  220. string patInfo = outParam;
  221. //展示患者信息界面
  222. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  223. {
  224. rtnResult = outParam;
  225. }
  226. else
  227. {
  228. rtnResult = JsonHelper.setIrisReturnValue(0,"",JObject.Parse(outParam)).ToString();
  229. }
  230. }
  231. break;
  232. }
  233. }
  234. return rtnResult;
  235. }
  236. catch (Exception ex)
  237. {
  238. rtnResult = JsonHelper.setIrisReturnValue(-1 , "GetPatientInfo发生异常;" + ex.Message,null).ToString();
  239. return rtnResult;
  240. }
  241. finally
  242. {
  243. Global.writeLog("GetPatientInfo出参:" + JsonHelper.Compress(rtnResult));
  244. }
  245. }
  246. /// <summary>
  247. /// 登记
  248. /// </summary>
  249. /// <param name="InParam"></param>
  250. /// <returns></returns>
  251. public string Register(string InParam)
  252. {
  253. Global.writeLog("Register 入参:" + JsonHelper.Compress(InParam));
  254. //设置返回值,错误信息
  255. string errMsg, rtnResult = "", outParam;
  256. try
  257. {
  258. //解析入参
  259. if (parseInparam(InParam, out errMsg) != 0)
  260. {
  261. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  262. return rtnResult;
  263. }
  264. //BS架构调用方式问题,每次调用都需要重新初始化
  265. if (init(InParam, out outParam) != 0)
  266. {
  267. rtnResult = outParam;
  268. return rtnResult;
  269. }
  270. //获取pat
  271. hBus.GetRegPatInfo(businessType, joInParam, out Global.pat);
  272. switch (businessType)
  273. {
  274. case "M2"://门诊登记
  275. {
  276. break;
  277. }
  278. case "M2C"://门诊登记撤销
  279. {
  280. break;
  281. }
  282. case "Z0"://住院修改
  283. {
  284. break;
  285. }
  286. case "Z2"://入院登记
  287. {
  288. Global.pat.RYorCY = "1"; //1入院2出院
  289. string regInParam = "";
  290. //校验HIS姓名与医保姓名是否一致
  291. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  292. {
  293. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  294. return rtnResult;
  295. }
  296. //显示登记面板
  297. if (hBus.showInPatRegisterForm(out regInParam) == 0)
  298. {
  299. JObject joRegIn_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2401", regInParam));
  300. JObject joRegIn = JObject.Parse(JsonHelper.setCenterInpar("2401", regInParam));
  301. //上传给中心
  302. JObject joRegOut = invoker.invokeCenterService("2401", joRegIn);
  303. //将中心返回的结果返回HIS,调用HIS服务进行保存
  304. if (JsonHelper.parseCenterRtnValue(joRegOut,out errMsg) == 0)
  305. {
  306. joRegOut.Add("validflag",1);
  307. joRegOut.Add("regstate", 1);
  308. joRegOut.Add("type", 1);
  309. Global.pat.mdtrtID = JsonHelper.getDestValue(joRegOut, "output.result.mdtrt_id");
  310. //插入患者本次就诊用的参保信息
  311. if (hBus.insertPatCurInsuInfo(JsonHelper.getDestValue(joParam, "patientInfo"), out outParam) != 0)
  312. {
  313. if (DialogResult.Yes == MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  314. {
  315. }
  316. else
  317. {
  318. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!", outParam).ToString();
  319. return rtnResult;
  320. }
  321. }
  322. //插入医保平台
  323. if (mIS.saveInpatRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  324. {
  325. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存登记信息", outParam).ToString();
  326. return rtnResult;
  327. }
  328. JObject joOutput = new JObject();
  329. joOutput.Add("output", JObject.Parse(JsonHelper.getDestValue(joParam, "patientInfo.output")));
  330. //插入医保平台全量信息表
  331. if (mIS.saveMIPatFullInsuInfo(joOutput, out outParam) != 0)
  332. {
  333. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存登记全量信息失败", outParam).ToString();
  334. return rtnResult;
  335. }
  336. //插入费用核查表 入院登记
  337. if (mIS.saveDischargeAudit(3, 2, 0, joRegIn, out outParam) != 0)
  338. {
  339. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存费用核查入院登记信息", outParam).ToString();
  340. return rtnResult;
  341. }
  342. //插入费用核查表 出院登记 默认,具体需要最终审核
  343. JObject joDisReg = (JObject)joRegIn.DeepClone();
  344. //joDisReg["input"]["mdtrtinfo"]["psn_setlway"] = new JObject();
  345. joDisReg["input"]["mdtrtinfo"]["psn_setlway"] = "01";
  346. //joDisReg["input"]["mdtrtinfo"]["acct_used_flag"] = new JObject();
  347. joDisReg["input"]["mdtrtinfo"]["acct_used_flag"] = "1";
  348. //joDisReg["input"]["mdtrtinfo"]["mid_setl_flag"] = new JObject();
  349. joDisReg["input"]["mdtrtinfo"]["mid_setl_flag"] = "0";
  350. if (mIS.saveDischargeAudit(3, 3,0,joDisReg, out outParam) != 0)
  351. {
  352. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存费用核查出院登记信息(默认)", outParam).ToString();
  353. return rtnResult;
  354. }
  355. //返回登记信息,插入HIS
  356. if (hIS.returnRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  357. {
  358. rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
  359. return rtnResult;
  360. }
  361. else
  362. {
  363. rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
  364. return rtnResult;
  365. }
  366. }
  367. else
  368. {
  369. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", errMsg).ToString();
  370. return rtnResult;
  371. }
  372. }
  373. else
  374. {
  375. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", regInParam).ToString();
  376. return rtnResult;
  377. }
  378. }
  379. case "Z2C"://入院登记取消
  380. {
  381. //if (DialogResult.Yes == MessageBox.Show("即将进行取消中心医保登记,确定继续吗?", " 询问? ", MessageBoxButtons.YesNo))
  382. //{
  383. //}
  384. //else
  385. //{
  386. // rtnResult = JsonHelper.setExceptionJson(-1, "收费员撤销取消登记操作!", outParam).ToString();
  387. // return rtnResult;
  388. //}
  389. //取消中心登记
  390. if (cBus.cancleRegister("2404", out outParam) != 0)
  391. {
  392. //如果医保中心没有HIS所传的医保登记信息则默认撤销HIS登记信息
  393. int i = outParam.IndexOf("不存在有效的就诊登记信息");
  394. if (i != 0)
  395. {
  396. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam+ ",是否强制撤销HIS医保登记信息?", "提示", MessageBoxButtons.YesNo))
  397. {
  398. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  399. return rtnResult;
  400. }
  401. }
  402. else
  403. {
  404. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  405. return rtnResult;
  406. }
  407. }
  408. //取消医保平台登记
  409. if (mIS.cancleRegister(1, out outParam) != 0)
  410. {
  411. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  412. return rtnResult;
  413. }
  414. ////取消费用审核
  415. //if (mIS.cancleRegister(1, out outParam) != 0)
  416. //{
  417. // rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  418. // return rtnResult;
  419. //}
  420. //取消HIS 登记
  421. if (hIS.cancleRegister( out outParam) != 0)
  422. {
  423. rtnResult = JsonHelper.setExceptionJson(-1, "中心和云医保平台取消登记成功,但HIS取消失败,", outParam).ToString();
  424. return rtnResult;
  425. }
  426. else
  427. {
  428. //CM 20230602 删除医保平台医保费用明细上传表数据
  429. mIS.deleteFee(out errMsg);
  430. rtnResult = JsonHelper.setIrisReturnValue(0, "取消医保登记成功", null).ToString();
  431. return rtnResult;
  432. }
  433. }
  434. case "Z6"://出院登记
  435. {
  436. break;
  437. }
  438. case "Z6C"://出院登记取消
  439. {
  440. if (cBus.cancleRegister("2405", out errMsg) != 0)
  441. {
  442. rtnResult = JsonHelper.setExceptionJson(-1, "取消出院登记", errMsg).ToString();
  443. return rtnResult;
  444. }
  445. else
  446. {
  447. rtnResult = JsonHelper.setIrisReturnValue(0, "取消出院登记成功", null).ToString();
  448. return rtnResult;
  449. }
  450. break;
  451. }
  452. default:
  453. {
  454. rtnResult = JsonHelper.setExceptionJson(-1, "Register 交易", "传入的业务编码不对!").ToString();
  455. return rtnResult;
  456. }
  457. }
  458. }
  459. catch (Exception ex)
  460. {
  461. rtnResult = JsonHelper.setIrisReturnValue(-1, "Register 发生异常;" + ex.Message, null).ToString();
  462. return rtnResult;
  463. }
  464. finally
  465. {
  466. Global.writeLog("Register 出参:" + JsonHelper.Compress(rtnResult));
  467. }
  468. return "";
  469. }
  470. /// <summary>
  471. /// 费用上传
  472. /// </summary>
  473. /// <param name="InParam"></param>
  474. /// <returns></returns>
  475. public string FeeUpload(string InParam)
  476. {
  477. Global.writeLog("FeeUpload 入参:" + JsonHelper.Compress(InParam));
  478. //设置返回值,错误信息
  479. int errCode;
  480. string errMsg, rtnResult = "", outParam;
  481. try
  482. {
  483. //解析入参
  484. if (parseInparam(InParam, out errMsg) != 0)
  485. {
  486. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  487. return rtnResult;
  488. }
  489. //BS架构调用方式问题,每次调用都需要重新初始化
  490. if (init(InParam, out outParam) != 0)
  491. {
  492. rtnResult = outParam;
  493. return rtnResult;
  494. }
  495. //获取pat
  496. hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  497. switch (businessType)
  498. {
  499. case "M3"://门诊费用上传
  500. {
  501. break;
  502. }
  503. case "M3C"://门诊费用撤销
  504. {
  505. break;
  506. }
  507. case "Z3"://入院费用上传
  508. {
  509. //从医保平台获取患者详细的医保登记信息
  510. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  511. {
  512. rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  513. return rtnResult;
  514. }
  515. JObject joReg = JObject.Parse(outParam);
  516. Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
  517. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  518. //先取消中心费用传送
  519. cBus.cancleFeeUpload("2302", out errMsg);
  520. //再删除医保传送表的数据
  521. mIS.deleteFee( out errMsg);
  522. #region【住院费用上传前调用3101事前服务】
  523. //1.获取3101入参报文
  524. //事前分析
  525. if (Global.curEvt.ext.isOpenAnalysis)
  526. {
  527. if (hBus.PreAnalysis("4", "", out errMsg) != 0)
  528. {
  529. rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  530. return rtnResult;
  531. }
  532. }
  533. #endregion
  534. //开始进行费用传送
  535. //调用HIS费用查询信息
  536. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  537. {
  538. rtnResult = JsonHelper.setExceptionJson(-1, "获取HIS费用", outParam).ToString();
  539. return rtnResult;
  540. }
  541. //调用医保平台转换
  542. JObject joHisFee = JObject.Parse(outParam);
  543. if (mIS.convertHisFeeWithInsuCode(joHisFee,out outParam) != 0)
  544. {
  545. rtnResult = JsonHelper.setExceptionJson(-1, "转换HIS费用", outParam).ToString();
  546. return rtnResult;
  547. }
  548. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  549. //按指定条数分割后上传,保存,更新
  550. if (hBus.uploadFeeToCenter("2301",10, jaFeeDetail, out outParam) != 0)
  551. {
  552. rtnResult = JsonHelper.setExceptionJson(-1, "上传费用", outParam).ToString();
  553. return rtnResult;
  554. }
  555. else
  556. {
  557. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传成功", null).ToString();
  558. return rtnResult;
  559. }
  560. }
  561. case "Z3C"://住院费用上传取消
  562. {
  563. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  564. {
  565. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  566. return rtnResult;
  567. }
  568. if (mIS.deleteFee( out errMsg) != 0)
  569. {
  570. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  571. return rtnResult;
  572. }
  573. else
  574. {
  575. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传取消成功", null).ToString();
  576. return rtnResult;
  577. }
  578. }
  579. default:
  580. {
  581. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", "传入的业务编码不对!").ToString();
  582. return rtnResult;
  583. }
  584. }
  585. return rtnResult;
  586. }
  587. catch (Exception ex)
  588. {
  589. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", ex.Message).ToString();
  590. return rtnResult;
  591. }
  592. finally
  593. {
  594. Global.writeLog("FeeUpload 出参:" + JsonHelper.Compress(rtnResult));
  595. }
  596. }
  597. /// <summary>
  598. /// 结算
  599. /// </summary>
  600. /// <param name="InParam"></param>
  601. /// <returns></returns>
  602. public string Settlement(string InParam)
  603. {
  604. Global.writeLog("Settlement 入参:" + JsonHelper.Compress(InParam));
  605. //设置返回值,错误信息
  606. string errMsg, rtnResult = "", outParam;
  607. try
  608. {
  609. //解析入参
  610. if (parseInparam(InParam, out errMsg) != 0)
  611. {
  612. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  613. return rtnResult;
  614. }
  615. //BS架构调用方式问题,每次调用都需要重新初始化
  616. if (init(InParam, out outParam) != 0)
  617. {
  618. rtnResult = outParam;
  619. return rtnResult;
  620. }
  621. //获取pat
  622. hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
  623. CardReader_GS CardRead_GS = new CardReader_GS();
  624. switch (businessType)
  625. {
  626. case "M4"://门诊预结算
  627. {
  628. OutpatientRegistration frmReg = new OutpatientRegistration();
  629. if (frmReg.ShowDialog() == DialogResult.OK)
  630. {
  631. rtnResult = "调用结束";
  632. }
  633. break;
  634. }
  635. case "M4C"://门诊预结算撤销
  636. {
  637. break;
  638. }
  639. case "M5"://门诊结算
  640. {
  641. Global.pat.admType = 1;
  642. string patInfo ="";
  643. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  644. if (hBus.readCard(out outParam) != 0)
  645. {
  646. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  647. return rtnResult;
  648. }
  649. else
  650. {
  651. patInfo = outParam;
  652. //展示患者信息界面
  653. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  654. {
  655. rtnResult = outParam;
  656. return rtnResult;
  657. }
  658. }
  659. //患者信息赋值给全局变量
  660. patInfo = outParam;
  661. if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  662. {
  663. rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  664. return rtnResult;
  665. }
  666. //校验HIS姓名与医保姓名是否一致
  667. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  668. {
  669. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  670. return rtnResult;
  671. }
  672. //显示登记面板
  673. if (hBus.showOutPatRegisterForm(out outParam) != 0)
  674. {
  675. rtnResult = JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString();
  676. return rtnResult;
  677. }
  678. JObject joReg = JObject.Parse(outParam);
  679. //医保挂号
  680. JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  681. JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  682. jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
  683. jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2201", jo2201Inpar_plain));
  684. //此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
  685. JObject jo2203Inpar = new JObject();
  686. JObject jo2203Inpar_plain = new JObject();
  687. jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
  688. jo2203Inpar.Add("diseinfo",JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
  689. JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
  690. if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
  691. {
  692. rtnResult = JsonHelper.setExceptionJson(-1, "医保挂号", errMsg).ToString();
  693. return rtnResult;
  694. }
  695. else
  696. {
  697. Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
  698. //插入患者本次就诊用的参保信息
  699. if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
  700. {
  701. if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  702. {
  703. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam).ToString();
  704. return rtnResult;
  705. }
  706. }
  707. jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
  708. jo2203Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203", jo2203Inpar));
  709. jo2203Inpar = JObject.Parse(JsonHelper.setCenterInpar("2203", jo2203Inpar));
  710. //门诊登记信息,插入云医保平台
  711. jo2201Rtn.Add("validflag", 1);
  712. jo2201Rtn.Add("regstate", 1);
  713. jo2201Rtn.Add("type", 3);
  714. Global.writeLog(jo2201Inpar_plain.ToString());
  715. if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203Inpar_plain, out errMsg) != 0)
  716. {
  717. rtnResult = JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString();
  718. return rtnResult;
  719. }
  720. }
  721. //门诊就诊信息上传
  722. JObject jo2203Rtn = invoker.invokeCenterService("2203",jo2203Inpar );
  723. if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
  724. {
  725. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
  726. return rtnResult;
  727. }
  728. #region【门诊就诊信息上传成功后调用3101事前服务】
  729. //事前分析
  730. if (Global.curEvt.ext.isOpenAnalysis)
  731. {
  732. //1.门诊挂号 2.门诊收费登记 3.住院登记 4.住院收费登记 5.住院执行医嘱 6.门诊结算 7.门诊预结算 8.住院结算 9.住院预结算 10.购药划卡
  733. if (hBus.PreAnalysis("1", "", out errMsg) != 0)
  734. {
  735. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传成功后调用3101事前服务失败:", errMsg).ToString();
  736. //return rtnResult;
  737. }
  738. }
  739. #endregion
  740. //费用上传
  741. if (hBus.uploadFee("2204", 50, out outParam) != 0)
  742. {
  743. rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
  744. return rtnResult;
  745. }
  746. //调用IRIS获取医保各项金额
  747. if (mIS.getSumFee(out outParam) != 0)
  748. {
  749. rtnResult = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outParam).ToString();
  750. return rtnResult;
  751. }
  752. JObject joSumFee = JObject.Parse(outParam);
  753. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joReg, "settlement"));
  754. //修改joSettlement的就诊ID ,总金额等
  755. joSettlement["mdtrt_id"] = Global.pat.mdtrtID;
  756. joSettlement["medfee_sumamt"] = JsonHelper.getDestValue(joSumFee, "data.Sumamt");
  757. //预结算2206
  758. if (hBus.preSettlement_OutPat(joSettlement, out outParam) != 0)
  759. {
  760. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  761. return rtnResult;
  762. }
  763. #region【门诊正式结算前调用社保卡验密】
  764. if ((Global.pat.mdtrtcertType == "03") && (Global.pat.insuplc_admdvs.Substring(0, 2) == "62"))
  765. {
  766. if (CardRead_GS.VerifyPIN(out outParam) != 0)
  767. {
  768. rtnResult = JsonHelper.setExceptionJson(-1, "社保卡验密异常iVerifyPIN失败 ", outParam).ToString();
  769. return rtnResult;
  770. }
  771. }
  772. #endregion
  773. //正式结算
  774. JObject joData = new JObject();
  775. joData.Add("data",joSettlement);
  776. JObject joRtn = invoker.invokeCenterService("2207", JsonHelper.setCenterInpar("2207", joData));
  777. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  778. {
  779. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  780. return rtnResult;
  781. }
  782. else
  783. {
  784. //返回给云医保平台结算信息
  785. if (mIS.saveSettlement(joRtn, out errMsg) != 0)
  786. {
  787. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  788. return rtnResult;
  789. }
  790. //返回给云医保平台结算明细信息
  791. if (mIS.saveSettlementDetail(joRtn, out errMsg) != 0)
  792. {
  793. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  794. return rtnResult;
  795. }
  796. //返回给HIS
  797. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo"));
  798. if (hIS.returnOutpatSettlementInfo(joSettlement, joSetlinfo, out outParam) != 0)
  799. {
  800. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  801. return rtnResult;
  802. }
  803. else
  804. {
  805. JObject joHisServieRtn = JObject.Parse(outParam);
  806. hBus.returnToFrontEndAfterSettlement(joRtn, joHisServieRtn, out outParam);
  807. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  808. return rtnResult;
  809. }
  810. }
  811. }
  812. case "M5C"://门诊结算撤销
  813. {
  814. //查询HIS医保结算记录表获取该病人的参保地
  815. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  816. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  817. sqlStr = sqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  818. JObject joSql = new JObject();
  819. joSql.Add("sqlStr", sqlStr);
  820. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  821. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  822. //{
  823. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  824. // return rtnResult;
  825. //}
  826. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  827. //退中心结算
  828. string newSettleID = "";
  829. if (cBus.cancleSettlement("2208", out outParam) != 0)
  830. {
  831. int i = outParam.IndexOf("获取到的就诊信息为无效状态,不能办理结算撤销业务");
  832. if (i != 0)
  833. {
  834. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam + ",是否强制撤销HIS结算信息?", "提示", MessageBoxButtons.YesNo))
  835. {
  836. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消结算失败,", outParam).ToString();
  837. return rtnResult;
  838. }
  839. newSettleID = "YC";
  840. }
  841. else
  842. {
  843. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算", outParam).ToString();
  844. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  845. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  846. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  847. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  848. JObject joSqlStr = new JObject();
  849. joSqlStr.Add("sqlStr", SqlStr);
  850. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  851. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  852. if (jaCancleSettlInfo.Count == 1)
  853. {
  854. //询问收款员是否继续进行HIS退费
  855. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  856. {
  857. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  858. }
  859. }
  860. else
  861. {
  862. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  863. }
  864. return rtnResult;
  865. }
  866. }
  867. else
  868. {
  869. newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  870. }
  871. //string newSettleID = "10290453";
  872. //Global.pat.mdtrtID = "202210281547480034293700000000";
  873. //Global.pat.psn_no = "YX423049577";
  874. //Global.pat.settlID = "10290445";
  875. //退云医保平台结算
  876. if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
  877. {
  878. rtnResult = JsonHelper.setExceptionJson(-1, "取消平台结算信息", outParam).ToString();
  879. //return rtnResult;
  880. }
  881. if (newSettleID != "YC")
  882. {
  883. //中心取消传送
  884. if (cBus.cancleFeeUpload("2205", out errMsg) != 0)
  885. {
  886. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  887. return rtnResult;
  888. }
  889. //云平台取消传送
  890. if (mIS.deleteFee(out errMsg) != 0)
  891. {
  892. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  893. return rtnResult;
  894. }
  895. //取消中心登记
  896. if (cBus.cancleRegister("2202", out outParam) != 0)
  897. {
  898. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  899. return rtnResult;
  900. }
  901. //取消医保平台登记
  902. if (mIS.cancleRegister(3, out outParam) != 0)
  903. {
  904. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  905. return rtnResult;
  906. }
  907. }
  908. //退HIS结算
  909. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  910. {
  911. rtnResult = JsonHelper.setExceptionJson(-1, "取消HIS结算信息", outParam).ToString();
  912. return rtnResult;
  913. }
  914. else
  915. {
  916. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  917. return rtnResult;
  918. }
  919. }
  920. case "M6"://门诊移动支付结算
  921. {
  922. MobilePay mp = new MobilePay(InParam, out errMsg);
  923. if (errMsg != "")
  924. {
  925. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易1", errMsg).ToString();
  926. return rtnResult;
  927. }
  928. if (mp.MobilePaySettlement(out outParam) != 0)
  929. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易2", outParam).ToString();
  930. else
  931. rtnResult = outParam;
  932. return rtnResult;
  933. }
  934. case "M6C"://门诊移动支付结算撤销
  935. {
  936. string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
  937. MobilePay mp = new MobilePay(InParam, out errMsg);
  938. if (errMsg != "")
  939. {
  940. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易3", errMsg).ToString();
  941. return rtnResult;
  942. }
  943. if (String.IsNullOrEmpty(onlineYBFalg))
  944. mp.MSettl.onlineYBFalg = "N";
  945. else
  946. mp.MSettl.onlineYBFalg = onlineYBFalg;
  947. if (mp.MobilePayCancelSettlement(out outParam) != 0)
  948. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易4", outParam).ToString();
  949. else
  950. rtnResult = JsonHelper.setExceptionJson(0, "Settlement 交易5", outParam).ToString();
  951. return rtnResult;
  952. }
  953. case "M6Confirm"://门诊移动支付确认
  954. {
  955. MobilePay mp = new MobilePay(InParam, out errMsg);
  956. if (errMsg != "")
  957. {
  958. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易6", errMsg).ToString();
  959. return rtnResult;
  960. }
  961. if (mp.MobilePayConfirmSettlement(out outParam) != 0)
  962. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易7", outParam).ToString();
  963. else
  964. rtnResult = outParam;
  965. return rtnResult;
  966. }
  967. case "M6CallBack"://门诊移动支付回调
  968. {
  969. JObject jo = JObject.Parse(InParam);
  970. joInsuAdmObj = new JObject();
  971. joInsuAdmObj.Add("payOrdId", "");
  972. jo.Add("insuAdmObj", joInsuAdmObj);
  973. MobilePay mp = new MobilePay(jo.ToString(), out errMsg);
  974. if (errMsg != "")
  975. {
  976. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易8", errMsg).ToString();
  977. return rtnResult;
  978. }
  979. if (mp.MobilePayCallbackSettlement(out outParam) != 0)
  980. rtnResult = outParam;
  981. else
  982. rtnResult = outParam;
  983. return rtnResult;
  984. }
  985. case "Z4"://住院预结算
  986. {
  987. #region【住院预结算2303前调用3102医保明细审核事中服务】
  988. //1.获取3102入参报文
  989. /*
  990. if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
  991. {
  992. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  993. return rtnResult;
  994. }
  995. else
  996. {
  997. //2.调用医保3102明细审核事前分析服务
  998. JObject joInput = new JObject();
  999. joInput = JObject.Parse(outParam);
  1000. JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1001. if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1002. {
  1003. DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果2:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1004. if (dr != DialogResult.OK)
  1005. {
  1006. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1007. return rtnResult;
  1008. }
  1009. }
  1010. }
  1011. */
  1012. #endregion
  1013. Global.pat.RYorCY = "2";
  1014. Global.pat.admType = 2;
  1015. JObject joSettle = new JObject();
  1016. if (hBus.preSettlement("2303",out joSettle, out outParam) != 0)
  1017. {
  1018. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1019. return rtnResult;
  1020. }
  1021. else
  1022. {
  1023. rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
  1024. return rtnResult;
  1025. }
  1026. }
  1027. case "Z4C"://住院预结算撤销
  1028. {
  1029. rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
  1030. return rtnResult;
  1031. }
  1032. case "Z5"://住院结算
  1033. {
  1034. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  1035. string patInfo = "";
  1036. if (hBus.readCard(out outParam) != 0)
  1037. {
  1038. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  1039. return rtnResult;
  1040. }
  1041. else
  1042. {
  1043. patInfo = outParam;
  1044. //展示患者信息界面
  1045. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  1046. {
  1047. rtnResult = outParam;
  1048. return rtnResult;
  1049. }
  1050. else
  1051. {
  1052. if (hBus.setGlobalPatAfaterShowPatInfo(outParam, out errMsg) != 0)
  1053. {
  1054. rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  1055. return rtnResult;
  1056. }
  1057. //校验HIS姓名与医保姓名是否一致
  1058. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  1059. {
  1060. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  1061. return rtnResult;
  1062. }
  1063. }
  1064. }
  1065. #region【住院正式结算前调用社保卡验密】
  1066. if ((Global.pat.mdtrtcertType == "03") && (Global.pat.insuplc_admdvs.Substring(0, 2) == "62"))
  1067. {
  1068. if (CardRead_GS.VerifyPIN(out outParam) != 0)
  1069. {
  1070. rtnResult = JsonHelper.setExceptionJson(-1, "社保卡验密异常iVerifyPIN失败 ", outParam).ToString();
  1071. return rtnResult;
  1072. }
  1073. }
  1074. #endregion
  1075. Global.pat.admType = 2;
  1076. Global.pat.RYorCY = "2";
  1077. JObject joPreSetOutpar ;
  1078. if (hBus.preSettlement("2303",out joPreSetOutpar, out outParam) != 0)
  1079. {
  1080. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1081. return rtnResult;
  1082. }
  1083. else
  1084. {
  1085. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "Settlement"));
  1086. //正式结算
  1087. joSettlement.Add("data", joSettlement);
  1088. JObject jo2304Rtn = invoker.invokeCenterService("2304",JsonHelper.setCenterInpar("2304",joSettlement));
  1089. if (JsonHelper.parseCenterRtnValue(jo2304Rtn, out errMsg) != 0)
  1090. {
  1091. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1092. cBus.cancleRegister("2405", out errMsg);
  1093. return rtnResult;
  1094. }
  1095. else
  1096. {
  1097. //返回给云医保平台结算信息
  1098. if (mIS.saveSettlement(jo2304Rtn, out errMsg) != 0)
  1099. {
  1100. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  1101. return rtnResult;
  1102. }
  1103. //返回给云医保平台结算明细信息
  1104. if (mIS.saveSettlementDetail(jo2304Rtn, out errMsg) != 0)
  1105. {
  1106. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  1107. Global.writeLog(rtnResult);
  1108. MessageBox.Show(errMsg);
  1109. }
  1110. //返回给HIS
  1111. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo"));
  1112. if (hIS.returnInpatSettlementInfo(joParam, joSetlinfo, out outParam) != 0)
  1113. {
  1114. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  1115. return rtnResult;
  1116. }
  1117. else
  1118. {
  1119. //返回给前端
  1120. JObject joHisServieRtn = JObject.Parse(outParam);
  1121. hBus.returnToFrontEndAfterSettlement(jo2304Rtn, joHisServieRtn, out outParam);
  1122. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  1123. return rtnResult;
  1124. }
  1125. }
  1126. }
  1127. }
  1128. case "Z5C"://住院结算撤销
  1129. {
  1130. //查询结算表
  1131. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and Hospital_Dr=" + Global.inf.hospitalDr
  1132. + " and Adm_Dr='" + Global.pat.adm_Dr + "'"
  1133. + " and MdtrtID='" + Global.pat.mdtrtID + "'"
  1134. + " Order By ID DESC ";
  1135. JObject joSql = new JObject();
  1136. joSql.Add("sqlStr", sqlStr);
  1137. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  1138. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  1139. //{
  1140. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  1141. // return rtnResult;
  1142. //}
  1143. //MessageBox.Show(joSettlInfo.ToString());
  1144. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  1145. Global.pat.SettID_YBJSB = JsonHelper.getDestValue(joSettlInfo, "result.data[0].SettlementID");
  1146. if (Global.pat.settlID != Global.pat.SettID_YBJSB)
  1147. {
  1148. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "通过09010059服务获取到的SettlementID<" + Global.pat.settlID + ">与DLL通过SQL语句" +
  1149. joSql + ",获取到的SettlementID<" + Global.pat.SettID_YBJSB + ">不同,可能存在HIS单边账,请联系医保开发人员处理该笔结算记录!").ToString();
  1150. //return rtnResult;
  1151. }
  1152. Global.pat.settlID = Global.pat.SettID_YBJSB;
  1153. //取消中心结算信息
  1154. if (cBus.cancleSettlement("2305", out outParam) != 0)
  1155. {
  1156. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算信息失败!", outParam).ToString();
  1157. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  1158. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  1159. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  1160. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  1161. JObject joSqlStr = new JObject();
  1162. joSqlStr.Add("sqlStr", SqlStr);
  1163. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  1164. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  1165. if (jaCancleSettlInfo.Count == 1)
  1166. {
  1167. //询问收款员是否继续进行HIS退费
  1168. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  1169. {
  1170. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  1171. }
  1172. }
  1173. else
  1174. {
  1175. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  1176. }
  1177. return rtnResult;
  1178. }
  1179. else
  1180. {
  1181. //退结算会返一个新的ID
  1182. string newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  1183. //取消平台结算信息
  1184. if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
  1185. {
  1186. rtnResult = JsonHelper.setExceptionJson(-1, "中心结算取消成功,医保平台结算信息取消失败!", outParam).ToString();
  1187. return rtnResult;
  1188. }
  1189. //中心取消传送
  1190. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  1191. {
  1192. //rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  1193. //return rtnResult;
  1194. }
  1195. //云平台取消传送
  1196. if (mIS.deleteFee(out errMsg) != 0)
  1197. {
  1198. //rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  1199. //return rtnResult;
  1200. }
  1201. //取消HIS医保结算信息
  1202. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  1203. {
  1204. rtnResult = JsonHelper.setExceptionJson(-1, "中心跟医保平台结算取消成功, 取消HIS结算信息失败!", outParam).ToString();
  1205. return rtnResult;
  1206. }
  1207. //取消出院登记
  1208. if (cBus.cancleRegister("2405", out outParam) != 0)
  1209. {
  1210. rtnResult = JsonHelper.setExceptionJson(0, "中心,医保平台及HIS结算信息取消成功,取消出院登记失败!请手工取消出院登记!", outParam).ToString();
  1211. return rtnResult;
  1212. }
  1213. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  1214. return rtnResult;
  1215. }
  1216. }
  1217. default:
  1218. {
  1219. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
  1220. return rtnResult;
  1221. }
  1222. }
  1223. return rtnResult;
  1224. }
  1225. catch (Exception ex)
  1226. {
  1227. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
  1228. return rtnResult;
  1229. }
  1230. finally
  1231. {
  1232. Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
  1233. }
  1234. }
  1235. //[STAThread]
  1236. //public void print(JObject joInParam)
  1237. //{
  1238. // //显示打印界面
  1239. // SettlementChecklist frmSettlList;
  1240. // string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1241. // if (insuAdmObj == "")
  1242. // {
  1243. // frmSettlList = new SettlementChecklist();
  1244. // }
  1245. // else
  1246. // {
  1247. // JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1248. // frmSettlList = new SettlementChecklist(joInsuAdmObj);
  1249. // }
  1250. // if (frmSettlList.ShowDialog() == DialogResult.OK)
  1251. // {
  1252. // };
  1253. //}
  1254. //[STAThread]
  1255. /// <summary>
  1256. /// 辅助交易
  1257. /// </summary>
  1258. /// <param name="InParam"></param>
  1259. /// <returns></returns>
  1260. public string AgentFun(string InParam)
  1261. {
  1262. Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
  1263. //设置返回值,错误信息
  1264. int errCode;
  1265. string errMsg, rtnResult = "", outParam;
  1266. try
  1267. {
  1268. //解析入参
  1269. if (parseInparam(InParam, out errMsg) != 0)
  1270. {
  1271. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1272. return rtnResult;
  1273. }
  1274. //BS架构调用方式问题,每次调用都需要重新初始化
  1275. if (init(InParam, out outParam) != 0)
  1276. {
  1277. rtnResult = outParam;
  1278. return rtnResult;
  1279. }
  1280. //获取通用目录
  1281. string sTYML = mIS.GetCommonInterface_Dr(Global.inf.interfaceDr.ToString(), "");
  1282. if (sTYML == "")
  1283. Global.inf.interfaceDr_TY = Global.inf.interfaceDr;
  1284. else
  1285. Global.inf.interfaceDr_TY = int.Parse(sTYML);
  1286. //获取pat
  1287. //hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  1288. switch (businessType)
  1289. {
  1290. case "BasicData"://基础数据维护
  1291. {
  1292. BasicData bd = new BasicData();
  1293. if (bd.ShowDialog() != DialogResult.OK)
  1294. {
  1295. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出基础数据维护界面").ToString();
  1296. return rtnResult;
  1297. }
  1298. break;
  1299. }
  1300. case "Exception"://异常处理
  1301. {
  1302. //显示异常处理界面
  1303. HandleException frmEX = new HandleException();
  1304. if (frmEX.ShowDialog() != DialogResult.OK)
  1305. {
  1306. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出异常处理界面").ToString();
  1307. return rtnResult;
  1308. }
  1309. break;
  1310. }
  1311. case "CheckAndClearing"://对账清算
  1312. {
  1313. Clearing frmEX = new Clearing();
  1314. if (frmEX.ShowDialog() != DialogResult.OK)
  1315. {
  1316. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出对账清算界面").ToString();
  1317. return rtnResult;
  1318. }
  1319. break;
  1320. }
  1321. case "Print"://打印
  1322. {
  1323. //显示打印界面
  1324. SettlementBillPrint frmSettlList;
  1325. string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1326. if (insuAdmObj == "")
  1327. {
  1328. frmSettlList = new SettlementBillPrint();
  1329. if (frmSettlList.ShowDialog() != DialogResult.OK)
  1330. {
  1331. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出打印界面").ToString();
  1332. return rtnResult;
  1333. }
  1334. }
  1335. else
  1336. {
  1337. JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1338. frmSettlList = new SettlementBillPrint(joInsuAdmObj);
  1339. string groupID = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "groupID");
  1340. string userName = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "userName");
  1341. DataTable dt = (DataTable)frmSettlList.dgvSettlRecord.DataSource;
  1342. int i = frmSettlList.dgvSettlRecord.CurrentRow.Index;
  1343. string AdmID = dt.Rows[i]["AdmID"].ToString();
  1344. string PsnNo = dt.Rows[i]["PersonnelNO"].ToString();
  1345. string MdtrtID = dt.Rows[i]["MdtrtID"].ToString();
  1346. string SettlementID = dt.Rows[i]["SettlementID"].ToString();
  1347. Global.pat.adm_Dr = int.Parse(AdmID);
  1348. if (((groupID == "3") && (dt.Rows.Count > 0)) ||
  1349. (userName == "朱振") || (userName == "朱鹏飞") ||(userName == "陈蒙") ||
  1350. (userName == "张可宁") || (userName == "史绍兴") || (userName == "陈柏全") ||
  1351. (userName == "李翔") || (userName == "王晓兵") || (userName == "史绍兴"))
  1352. {
  1353. //frmSettlList.ShowDialog();
  1354. frmSettlList.btnDesign_Click(null, null);
  1355. }
  1356. else
  1357. {
  1358. JObject joRtnFee = frmSettlList.UpdateMedInsuUploadData(AdmID, PsnNo, MdtrtID, SettlementID);
  1359. frmSettlList.btnPrint_Click(null, null);
  1360. }
  1361. }
  1362. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  1363. break;
  1364. }
  1365. case "Log"://日志
  1366. {
  1367. MessageBox.Show(businessType);
  1368. break;
  1369. }
  1370. case "RecordUpload"://上传记录
  1371. {
  1372. MessageBox.Show(businessType);
  1373. break;
  1374. }
  1375. case "HospitalRegister"://备案
  1376. {
  1377. ToRecordChoose Referral = new ToRecordChoose();
  1378. if (Referral.ShowDialog() != DialogResult.OK)
  1379. {
  1380. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出备案信息界面").ToString();
  1381. return rtnResult;
  1382. }
  1383. break;
  1384. }
  1385. case "MedInsuQuery"://医保查询
  1386. {
  1387. MedInsuQuery MedQuery = new MedInsuQuery();
  1388. if (MedQuery.ShowDialog() != DialogResult.OK)
  1389. {
  1390. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保查询界面").ToString();
  1391. return rtnResult;
  1392. }
  1393. break;
  1394. }
  1395. case "PrescribeCirculation"://医保电子处方流转
  1396. {
  1397. //PrescriptionCirculation PresCir = new PrescriptionCirculation();
  1398. PrescriptionCirculation PresCir = new PrescriptionCirculation("");
  1399. if (PresCir.ShowDialog() != DialogResult.OK)
  1400. {
  1401. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保电子处方流转界面").ToString();
  1402. return rtnResult;
  1403. }
  1404. break;
  1405. }
  1406. case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
  1407. {
  1408. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1409. Global.pat.psn_no = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].patn_id");
  1410. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].poolarea");
  1411. Global.pat.insuType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].insutype");
  1412. Global.pat.medType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].med_type");
  1413. if (string.IsNullOrEmpty(Global.pat.insuplc_admdvs))
  1414. {
  1415. //通过查询医保平台登记信息表获取参保地
  1416. if (mIS.queryRegisterInfo(3, out outParam) == 0)
  1417. {
  1418. JObject joReg = JObject.Parse(outParam);
  1419. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode");
  1420. }
  1421. }
  1422. JObject joResult = new JObject();
  1423. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  1424. //事前分析
  1425. if (Global.curEvt.ext.isOpenAnalysis)
  1426. {
  1427. if (hBus.PreAnalysis("5", joResult.ToString(), out errMsg) != 0)
  1428. {
  1429. MessageBox.Show(errMsg);
  1430. break;
  1431. }
  1432. }
  1433. break;
  1434. }
  1435. default:
  1436. {
  1437. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对【"+businessType+"】").ToString();
  1438. return rtnResult;
  1439. }
  1440. }
  1441. return rtnResult;
  1442. }
  1443. catch (Exception ex)
  1444. {
  1445. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
  1446. return rtnResult;
  1447. }
  1448. finally
  1449. {
  1450. Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
  1451. }
  1452. }
  1453. public string Download(string InParam)
  1454. {
  1455. Global.writeLog("Download 入参:" + JsonHelper.Compress(InParam));
  1456. //设置返回值,错误信息
  1457. int errCode;
  1458. string errMsg, rtnResult = "", outParam;
  1459. try
  1460. {
  1461. //解析入参
  1462. if (parseInparam(InParam, out errMsg) != 0)
  1463. {
  1464. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1465. return rtnResult;
  1466. }
  1467. //BS架构调用方式问题,每次调用都需要重新初始化
  1468. if (init(InParam, out outParam) != 0)
  1469. {
  1470. rtnResult = outParam;
  1471. return rtnResult;
  1472. }
  1473. dynamic joData = new JObject();
  1474. joData.data = joParam["data"];
  1475. //string code = (string)joInParam["code"];
  1476. string funNO = (string)joParam["funNO"];
  1477. switch (businessType)
  1478. {
  1479. case "DirectoryDownload":
  1480. {
  1481. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1482. rtnResult = hBus.DownloadDirectory(funNO, downloadParam).ToString();
  1483. break;
  1484. }
  1485. case "DictionayDownload":
  1486. {
  1487. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1488. rtnResult = hBus.downDictionary(downloadParam);
  1489. break;
  1490. }
  1491. }
  1492. return rtnResult;
  1493. }
  1494. catch (Exception ex)
  1495. {
  1496. rtnResult = JsonHelper.setExceptionJson(-100, "Download", ex.Message).ToString();
  1497. return rtnResult;
  1498. }
  1499. finally
  1500. {
  1501. Global.writeLog("Download 出参:" + rtnResult);
  1502. }
  1503. }
  1504. public string PlatformDirectConnect(string InParam)
  1505. {
  1506. //设置返回值,错误信息
  1507. int errCode;
  1508. string errMsg, rtnResult = "", outParam;
  1509. try
  1510. {
  1511. Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
  1512. //解析入参
  1513. if (parseInparam(InParam, out errMsg) != 0)
  1514. {
  1515. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1516. return rtnResult;
  1517. }
  1518. Global.businessType = businessType;
  1519. string funNO = JsonHelper.getDestValue(joInParam, "funNO");
  1520. //BS架构调用方式问题,每次调用都需要重新初始化
  1521. if (init(InParam, out outParam) != 0)
  1522. {
  1523. rtnResult = outParam;
  1524. return rtnResult;
  1525. }
  1526. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "insuplc_admdvs");
  1527. JObject joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joParam));
  1528. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1529. {
  1530. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
  1531. return rtnResult;
  1532. }
  1533. else
  1534. {
  1535. rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
  1536. return rtnResult;
  1537. }
  1538. }
  1539. catch (Exception ex)
  1540. {
  1541. rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
  1542. return rtnResult;
  1543. }
  1544. finally
  1545. {
  1546. Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
  1547. }
  1548. }
  1549. /// <summary>
  1550. /// 自助机
  1551. /// </summary>
  1552. /// <param name="InParam"></param>
  1553. /// <returns></returns>
  1554. public string SelfServiceMachine(string InParam)
  1555. {
  1556. Global.writeLog("SelfServiceMachine 入参:" + JsonHelper.Compress(InParam));
  1557. //设置返回值,错误信息
  1558. string errMsg, rtnResult = "", outParam;
  1559. try
  1560. {
  1561. //解析入参
  1562. if (parseInparam(InParam, out errMsg) != 0)
  1563. {
  1564. rtnResult = JsonHelper.setExceptionJson(-1, "parseInparam", errMsg).ToString();
  1565. return rtnResult;
  1566. }
  1567. //获取pat
  1568. hBus.GetSelfServiceMachineInfo(businessType, joInParam, out Global.pat);
  1569. //BS架构调用方式问题,每次调用都需要重新初始化
  1570. if (init(InParam, out errMsg) != 0)
  1571. //if (hBus.InitA(InParam, out errMsg) != 0)
  1572. {
  1573. rtnResult = JsonHelper.setExceptionJson(-1, "InitA", errMsg).ToString(); ;
  1574. return rtnResult;
  1575. }
  1576. else
  1577. {
  1578. //joInParam.Add("patInfo", errMsg);
  1579. Global.writeLog($"InitA初始化成功!");
  1580. }
  1581. switch (businessType)
  1582. {
  1583. case "GetPatientInfo"://读取患者信息,该节点无需重定向
  1584. {
  1585. //重定向
  1586. Business.Core.SelfServiceMachine.PatientService patientService = new Business.Core.SelfServiceMachine.PatientService();
  1587. rtnResult = patientService.GetPatientInfo();
  1588. break;
  1589. }
  1590. case "OPReg"://门诊挂号
  1591. {
  1592. #region 老版
  1593. //CardReader_GS CardRead_GS = new CardReader_GS();
  1594. //Global.pat.admType = 1;
  1595. //string patInfo = "";
  1596. ////打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  1597. //if (hBus.readCard(out outParam) != 0)
  1598. //{
  1599. // rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  1600. // return rtnResult;
  1601. //}
  1602. //else
  1603. //{
  1604. // patInfo = outParam;
  1605. // //展示患者信息界面
  1606. // if (hBus.showPatInfo(patInfo, out outParam) != 0)
  1607. // {
  1608. // rtnResult = outParam;
  1609. // return rtnResult;
  1610. // }
  1611. //}
  1612. ////患者信息赋值给全局变量
  1613. //patInfo = outParam;
  1614. //if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  1615. //{
  1616. // rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  1617. // return rtnResult;
  1618. //}
  1619. ////校验HIS姓名与医保姓名是否一致
  1620. //if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  1621. //{
  1622. // rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  1623. // return rtnResult;
  1624. //}
  1625. ////显示登记面板
  1626. //if (hBus.showOutPatRegisterForm(out outParam) != 0)
  1627. //{
  1628. // rtnResult = JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString();
  1629. // return rtnResult;
  1630. //}
  1631. //JObject joReg = JObject.Parse(outParam);
  1632. ////医保挂号
  1633. //JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  1634. //JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  1635. //jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
  1636. //jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2201", jo2201Inpar_plain));
  1637. ////此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
  1638. //JObject jo2203Inpar = new JObject();
  1639. //JObject jo2203Inpar_plain = new JObject();
  1640. //jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
  1641. //jo2203Inpar.Add("diseinfo", JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
  1642. //JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
  1643. //if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
  1644. //{
  1645. // rtnResult = JsonHelper.setExceptionJson(-1, "医保挂号", errMsg).ToString();
  1646. // return rtnResult;
  1647. //}
  1648. //else
  1649. //{
  1650. // Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
  1651. // //插入患者本次就诊用的参保信息
  1652. // if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
  1653. // {
  1654. // if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  1655. // {
  1656. // rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam).ToString();
  1657. // return rtnResult;
  1658. // }
  1659. // }
  1660. // jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
  1661. // jo2203Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203", jo2203Inpar));
  1662. // jo2203Inpar = JObject.Parse(JsonHelper.setCenterInpar("2203", jo2203Inpar));
  1663. // //门诊登记信息,插入云医保平台
  1664. // jo2201Rtn.Add("validflag", 1);
  1665. // jo2201Rtn.Add("regstate", 1);
  1666. // jo2201Rtn.Add("type", 3);
  1667. // Global.writeLog(jo2201Inpar_plain.ToString());
  1668. // if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203Inpar_plain, out errMsg) != 0)
  1669. // {
  1670. // rtnResult = JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString();
  1671. // return rtnResult;
  1672. // }
  1673. //}
  1674. ////门诊就诊信息上传
  1675. //JObject jo2203Rtn = invoker.invokeCenterService("2203", jo2203Inpar);
  1676. //if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
  1677. //{
  1678. // rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
  1679. // return rtnResult;
  1680. //}
  1681. //#region【门诊就诊信息上传成功后调用3101事前服务】
  1682. ////1.获取3101入参报文
  1683. //if (Global.curEvt.ext.isOpenAnalysis)
  1684. //{
  1685. // if (hIS.GetInsuPatInfo("1", Global.pat, out outParam) != 0)
  1686. // {
  1687. // rtnResult = JsonHelper.setExceptionJson(-1, "获取3101医保明细审核事前分析服务入参失败:", outParam).ToString();
  1688. // return rtnResult;
  1689. // }
  1690. // else
  1691. // {
  1692. // //2.调用医保3101明细审核事前分析服务
  1693. // JObject joInput = new JObject();
  1694. // //joInput.Add("data", JObject.Parse(outParam));
  1695. // joInput = JObject.Parse(outParam);
  1696. // JObject jo3101Rtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", joInput.ToString().Replace("\r\n", ""))); //.Replace(" ", "")
  1697. // if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
  1698. // {
  1699. // rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  1700. // return rtnResult;
  1701. // }
  1702. // else
  1703. // {
  1704. // JArray jaResult = JArray.Parse(JsonHelper.getDestValue(jo3101Rtn, "output.result"));
  1705. // if (jaResult.HasValues)
  1706. // {
  1707. // PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(jo3101Rtn);
  1708. // if (paipaForm.ShowDialog() != DialogResult.OK)
  1709. // {
  1710. // errMsg = "事前事中审核不通过,操作员取消!";
  1711. // rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  1712. // return rtnResult;
  1713. // }
  1714. // }
  1715. // }
  1716. // }
  1717. //}
  1718. //#endregion
  1719. ////费用上传
  1720. //if (hBus.uploadFee("2204", 50, out outParam) != 0)
  1721. //{
  1722. // rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
  1723. // return rtnResult;
  1724. //}
  1725. //#region【门诊预结算2206前调用3102医保明细审核事中服务】
  1726. //if (Global.curEvt.ext.isOpenAnalysis)
  1727. //{
  1728. // //1.获取3102入参报文
  1729. // if (hIS.GetInsuPatInfo("2", Global.pat, out outParam) != 0)
  1730. // {
  1731. // rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  1732. // return rtnResult;
  1733. // }
  1734. // else
  1735. // {
  1736. // //2.调用医保3102明细审核事前分析服务
  1737. // JObject joInput = new JObject();
  1738. // //joInput.Add("data", JObject.Parse(outParam));
  1739. // joInput = JObject.Parse(outParam);
  1740. // JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1741. // if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1742. // {
  1743. // rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1744. // return rtnResult;
  1745. // }
  1746. // else
  1747. // {
  1748. // JArray jaResult = JArray.Parse(JsonHelper.getDestValue(jo3102Rtn, "output.result"));
  1749. // if (jaResult.HasValues)
  1750. // {
  1751. // PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(jo3102Rtn);
  1752. // if (paipaForm.ShowDialog() != DialogResult.OK)
  1753. // {
  1754. // errMsg = "事前事中审核不通过,操作员取消!";
  1755. // rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1756. // return rtnResult;
  1757. // }
  1758. // }
  1759. // }
  1760. // }
  1761. //}
  1762. //#endregion
  1763. ////调用IRIS获取医保各项金额
  1764. //if (mIS.getSumFee(out outParam) != 0)
  1765. //{
  1766. // rtnResult = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outParam).ToString();
  1767. // return rtnResult;
  1768. //}
  1769. //JObject joSumFee = JObject.Parse(outParam);
  1770. //JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joReg, "settlement"));
  1771. ////修改joSettlement的就诊ID ,总金额等
  1772. //joSettlement["mdtrt_id"] = Global.pat.mdtrtID;
  1773. //joSettlement["medfee_sumamt"] = JsonHelper.getDestValue(joSumFee, "data.Sumamt");
  1774. ////预结算2206
  1775. //if (hBus.preSettlement_OutPat(joSettlement, out outParam) != 0)
  1776. //{
  1777. // rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1778. // return rtnResult;
  1779. //}
  1780. //#region【门诊正式结算前调用社保卡验密】
  1781. //if ((Global.pat.mdtrtcertType == "03") && (Global.pat.insuplc_admdvs.Substring(0, 2) == "62"))
  1782. //{
  1783. // if (CardRead_GS.VerifyPIN(out outParam) != 0)
  1784. // {
  1785. // rtnResult = JsonHelper.setExceptionJson(-1, "社保卡验密异常iVerifyPIN失败 ", outParam).ToString();
  1786. // return rtnResult;
  1787. // }
  1788. //}
  1789. //#endregion
  1790. ////正式结算
  1791. //JObject joData = new JObject();
  1792. //joData.Add("data", joSettlement);
  1793. //JObject joRtn = invoker.invokeCenterService("2207", JsonHelper.setCenterInpar("2207", joData));
  1794. //if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1795. //{
  1796. // rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1797. // return rtnResult;
  1798. //}
  1799. //else
  1800. //{
  1801. // //返回给云医保平台结算信息
  1802. // if (mIS.saveSettlement(joRtn, out errMsg) != 0)
  1803. // {
  1804. // rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  1805. // return rtnResult;
  1806. // }
  1807. // //返回给云医保平台结算明细信息
  1808. // if (mIS.saveSettlementDetail(joRtn, out errMsg) != 0)
  1809. // {
  1810. // rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  1811. // return rtnResult;
  1812. // }
  1813. // //返回给HIS
  1814. // JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo"));
  1815. // if (hIS.returnOutpatSettlementInfo(joSettlement, joSetlinfo, out outParam) != 0)
  1816. // {
  1817. // rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  1818. // return rtnResult;
  1819. // }
  1820. // else
  1821. // {
  1822. // JObject joHisServieRtn = JObject.Parse(outParam);
  1823. // hBus.returnToFrontEndAfterSettlement(joRtn, joHisServieRtn, out outParam);
  1824. // rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  1825. // return rtnResult;
  1826. // }
  1827. //}
  1828. #endregion
  1829. #region 链条式任务调度者
  1830. OPRegService service = new OPRegService();
  1831. rtnResult = service.Charge(operationType, joInParam);
  1832. break;
  1833. #endregion
  1834. }
  1835. case "OPSettl"://门诊结算
  1836. {
  1837. OPSettlementService service = new OPSettlementService();
  1838. rtnResult = service.Charge(operationType, joInParam);
  1839. break;
  1840. }
  1841. case "IPInReg"://入院登记
  1842. {
  1843. IPAdmRegService service = new IPAdmRegService();
  1844. rtnResult = service.Register(operationType, joInParam);
  1845. break;
  1846. }
  1847. case "IPInRegCancel"://取消入院登记
  1848. {
  1849. IPAdmRegService service = new IPAdmRegService();
  1850. rtnResult = service.CancelRegister(operationType, joInParam);
  1851. break;
  1852. }
  1853. case "IPOutReg"://出院登记
  1854. {
  1855. break;
  1856. }
  1857. case "IPUpoload"://住院费用上传
  1858. {
  1859. break;
  1860. }
  1861. case "IPPreSettl"://住院预计结算
  1862. {
  1863. break;
  1864. }
  1865. case "IPSettl"://住院结算
  1866. {
  1867. IPSettlementService service = new IPSettlementService();
  1868. rtnResult = service.Charge(joInParam);
  1869. return rtnResult;
  1870. }
  1871. case "DischargeAudit"://费用核查
  1872. {
  1873. DischargeAuditService service = new DischargeAuditService();
  1874. rtnResult = service.Audit(joInParam);
  1875. return rtnResult;
  1876. }
  1877. default:
  1878. {
  1879. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", "传入的业务编码不对!").ToString();
  1880. return rtnResult;
  1881. }
  1882. }
  1883. return rtnResult;
  1884. }
  1885. catch (Exception ex)
  1886. {
  1887. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", ex.Message).ToString();
  1888. return rtnResult;
  1889. }
  1890. finally
  1891. {
  1892. Global.writeLog("SelfServiceMachine 出参:" + JsonHelper.Compress(rtnResult));
  1893. }
  1894. }
  1895. }
  1896. }