InsuBusiness.cs 129 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542
  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 HuBeiMI.Forms;
  17. using System.Collections;
  18. using System.Data.SqlTypes;
  19. using PTMedicalInsurance.Forms.ElectronicSettlementCertificates;
  20. //using PTMedicalInsurance.Forms.ElectronicSettlementCertificates;
  21. using System.Threading;
  22. using FastReport.Editor;
  23. using PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler;
  24. using PTMedicalInsurance.Business.Core.Forms.DischargeAudit;
  25. namespace PTMedicalInsurance
  26. {
  27. public class InsuBusiness : IInsuBusiness
  28. {
  29. //定义相关的变量
  30. private Patients patient;
  31. private Fees fee;
  32. private Settlements settlement;
  33. //json对象属性
  34. private JObject joInParam;
  35. private JArray jaSession ;
  36. private JArray jaParams;
  37. private JObject joParam;
  38. private JObject joInterface;
  39. private JObject joInsuAdmObj;
  40. private JObject joParamA;//临时进销存使用
  41. JObject joParam992001;//临时进销存使用
  42. JObject joParam992002;//临时进销存使用
  43. JObject joParam992004;//临时进销存使用
  44. //设置业务实例
  45. CenterBusiness cBus = new CenterBusiness();
  46. HisMainBusiness hBus = new HisMainBusiness();
  47. HisIrisServices hIS = new HisIrisServices();
  48. MIIrisServices mIS= new MIIrisServices();
  49. InvokeHelper invoker = new InvokeHelper();
  50. //
  51. private string businessType;
  52. private string operationType;
  53. public InsuBusiness()
  54. {
  55. Global.curEvt.path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
  56. ComputerInfo comp = new ComputerInfo();
  57. Global.curEvt.mac = comp.GetMAC();
  58. Global.curEvt.ip = comp.GetIP(); //"10.1.4.100";
  59. Global.pat.insuplc_admdvs = ""; //如果是NULL中心会报错
  60. }
  61. private int parseInparam(string inParam,out string errMsg)
  62. {
  63. errMsg = "";
  64. try
  65. {
  66. joInParam = JObject.Parse(inParam);
  67. jaSession = JArray.Parse(JsonHelper.getDestValue(joInParam, "session"));
  68. Global.curEvt.jaSession = jaSession;
  69. jaParams = JArray.Parse(JsonHelper.getDestValue(joInParam, "params"));
  70. joParam = JObject.FromObject(jaParams[0]);
  71. if (JsonHelper.getDestValue(joInParam, "insuAdmObj") != "")
  72. joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInParam, "insuAdmObj"));
  73. joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
  74. Global.pat.insuplc_admdvs= JsonHelper.getDestValue(joInParam, "insuplc_admdvs");
  75. businessType = JsonHelper.getDestValue(joInParam, "businessType");
  76. return 0;
  77. }
  78. catch (Exception ex)
  79. {
  80. errMsg = "parseInparam 解析入参异常:" + errMsg;
  81. return -1;
  82. }
  83. }
  84. /// <summary>
  85. /// 签到
  86. /// </summary>
  87. /// <param name="InParam"></param>
  88. /// <returns></returns>
  89. public string Init(string InParam)
  90. {
  91. string errMsg, rtnResult ="";
  92. JObject joRtn = new JObject();
  93. try
  94. {
  95. if (hBus.initEnvironment(InParam, out errMsg) != 0)
  96. {
  97. return JsonHelper.setExceptionJson(-100, "initEnvironment 失败", errMsg).ToString();
  98. }
  99. else
  100. {
  101. //if (businessType != "BasicData") //医保对照不需要调用签到交易
  102. if ((businessType != "BasicData") && (businessType != "M6") && (businessType != "M6C") && (businessType != "M6Confirm") && (businessType != "M6CallBack"))
  103. {
  104. if (mIS.isSigned(ref Global.curEvt.signno) != true)
  105. {
  106. //签到
  107. if (cBus.signIn(out joRtn) != 0)
  108. {
  109. rtnResult = JsonHelper.setExceptionJson(-1, "签到异常", (string)joRtn["err_msg"]).ToString();
  110. return rtnResult;
  111. }
  112. else
  113. {
  114. Global.curEvt.signno = JsonHelper.getDestValue(joRtn, "output.signinoutb.sign_no");
  115. //插入签到表
  116. if (mIS.saveSignRecord(Global.curEvt.signno, out errMsg) != 0)
  117. {
  118. rtnResult = JsonHelper.setIrisReturnValue(0, "中心签到成功但插入签到表失败:" + errMsg, null).ToString();
  119. }
  120. else
  121. {
  122. rtnResult = JsonHelper.setIrisReturnValue(0, "签到成功", joRtn).ToString();
  123. }
  124. }
  125. }
  126. else
  127. {
  128. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
  129. }
  130. }
  131. else
  132. {
  133. Global.curEvt.signno = "abc123";
  134. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
  135. }
  136. return rtnResult;
  137. }
  138. }
  139. catch (Exception ex)
  140. {
  141. rtnResult = JsonHelper.setExceptionJson(-100, "Init 异常", ex.Message).ToString();
  142. return rtnResult;
  143. }
  144. finally
  145. {
  146. Global.writeLog("初始化结果:" + rtnResult);
  147. }
  148. }
  149. /// <summary>
  150. /// 初始化
  151. /// </summary>
  152. /// <param name="inParam"></param>
  153. /// <param name="outParam"></param>
  154. /// <returns></returns>
  155. private int init(string inParam, out string outParam)
  156. {
  157. string errMsg;
  158. outParam = "";
  159. try
  160. {
  161. //BS架构调用方式问题,每次调用都需要重新初始化
  162. JObject joInitRtn = JObject.Parse(Init(inParam));
  163. if (JsonHelper.parseIrisRtnValue(joInitRtn, out errMsg) != 0)
  164. {
  165. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)", errMsg).ToString();
  166. return -1;
  167. }
  168. else
  169. {
  170. return 0;
  171. }
  172. }
  173. catch (Exception ex)
  174. {
  175. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)异常", ex.Message).ToString();
  176. return -1;
  177. }
  178. }
  179. /// <summary>
  180. /// 获取患者信息
  181. /// </summary>
  182. /// <param name="InParam"></param>
  183. /// <returns></returns>
  184. public string GetPatientInfo(string InParam)
  185. {
  186. Global.writeLog("GetPatientInfo入参:" + JsonHelper.Compress(InParam));
  187. //设置返回值,错误信息
  188. int errCode;
  189. string errMsg, rtnResult = "",outParam;
  190. //BS架构调用方式问题,每次调用都需要重新初始化
  191. if (init(InParam,out outParam)!= 0)
  192. {
  193. rtnResult = outParam;
  194. return rtnResult;
  195. }
  196. JObject joInParam = JObject.Parse(InParam);
  197. string businessType = JsonHelper.getDestValue(joInParam,"businessType");
  198. try
  199. {
  200. switch (businessType)
  201. {
  202. case "M1"://门诊读卡
  203. {
  204. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  205. if (hBus.readCard(out outParam) != 0)
  206. {
  207. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  208. }
  209. else
  210. {
  211. //展示患者信息界面
  212. if (hBus.showPatInfo(outParam, out outParam) != 0)
  213. {
  214. rtnResult = outParam;
  215. }
  216. else
  217. {
  218. rtnResult = JsonHelper.setIrisReturnValue(0, "", JObject.Parse(outParam)).ToString();
  219. }
  220. }
  221. break;
  222. }
  223. case "Z1"://住院读卡
  224. {
  225. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  226. if (hBus.readCard(out outParam) != 0)
  227. {
  228. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  229. }
  230. else
  231. {
  232. //住院提示特殊人员标识:JsonHelper.getDestValue(JObject.Parse(outParam), "output.exp_content.ectoken");
  233. string patInfo = outParam;
  234. //展示患者信息界面
  235. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  236. {
  237. string idtype = JsonHelper.getDestValue(JObject.Parse(outParam), "output.selectedIdInfo.psn_idet_type");
  238. if (idtype != null)
  239. {
  240. string[] s1 = new string[8] { "9937", "230705", "211112", "236022", "230508", "236018", "2304", "2303" };//武汉乡村振兴人员身份类别
  241. if (s1.Contains(idtype))
  242. {
  243. MessageBox.Show("该人员存在特殊人员身份为" + idtype);
  244. }
  245. }
  246. rtnResult = outParam;
  247. }
  248. else
  249. {
  250. rtnResult = JsonHelper.setIrisReturnValue(0,"",JObject.Parse(outParam)).ToString();
  251. }
  252. }
  253. break;
  254. }
  255. }
  256. return rtnResult;
  257. }
  258. catch (Exception ex)
  259. {
  260. rtnResult = JsonHelper.setIrisReturnValue(-1 , "GetPatientInfo发生异常;" + ex.Message,null).ToString();
  261. return rtnResult;
  262. }
  263. finally
  264. {
  265. Global.writeLog("GetPatientInfo出参:" + JsonHelper.Compress(rtnResult));
  266. }
  267. }
  268. /// <summary>
  269. /// 登记
  270. /// </summary>
  271. /// <param name="InParam"></param>
  272. /// <returns></returns>
  273. public string Register(string InParam)
  274. {
  275. Global.writeLog("Register 入参:" + JsonHelper.Compress(InParam));
  276. //设置返回值,错误信息
  277. string errMsg, rtnResult = "", outParam;
  278. try
  279. {
  280. //解析入参
  281. if (parseInparam(InParam, out errMsg) != 0)
  282. {
  283. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  284. return rtnResult;
  285. }
  286. //BS架构调用方式问题,每次调用都需要重新初始化
  287. if (init(InParam, out outParam) != 0)
  288. {
  289. rtnResult = outParam;
  290. return rtnResult;
  291. }
  292. //获取pat
  293. hBus.GetRegPatInfo(businessType, joInParam, out Global.pat);
  294. switch (businessType)
  295. {
  296. case "M2"://门诊登记
  297. {
  298. break;
  299. }
  300. case "M2C"://门诊登记撤销
  301. {
  302. break;
  303. }
  304. case "Z0"://住院修改
  305. {
  306. break;
  307. }
  308. case "Z2"://入院登记
  309. {
  310. Global.writeLog(Global.pat.insuType);
  311. string regInParam = "";
  312. //校验HIS姓名与医保姓名是否一致
  313. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  314. {
  315. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  316. return rtnResult;
  317. }
  318. //显示登记面板
  319. if (hBus.showInPatRegisterForm( out regInParam) == 0)
  320. {
  321. Global.writeLog(regInParam);
  322. JObject joRegIn_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2401", regInParam));
  323. JObject joRegIn = JObject.Parse(JsonHelper.setCenterInpar("2401", regInParam));
  324. //上传给中心
  325. JObject joRegOut = invoker.invokeCenterService("2401", joRegIn);
  326. //将中心返回的结果返回HIS,调用HIS服务进行保存
  327. if (JsonHelper.parseCenterRtnValue(joRegOut,out errMsg) == 0)
  328. {
  329. joRegOut.Add("validflag",1);
  330. joRegOut.Add("regstate", 1);
  331. joRegOut.Add("type", 1);
  332. Global.pat.mdtrtID = JsonHelper.getDestValue(joRegOut, "output.result.mdtrt_id");
  333. //插入患者本次就诊用的参保信息
  334. if (hBus.insertPatCurInsuInfo(JsonHelper.getDestValue(joParam, "patientInfo"), out outParam) != 0)
  335. {
  336. if (DialogResult.Yes == MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  337. {
  338. }
  339. else
  340. {
  341. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!", outParam).ToString();
  342. return rtnResult;
  343. }
  344. }
  345. //插入医保平台
  346. if (mIS.saveInpatRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  347. {
  348. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存登记信息", outParam).ToString();
  349. return rtnResult;
  350. }
  351. //返回登记信息,插入HIS
  352. if (hIS.returnRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  353. {
  354. rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
  355. return rtnResult;
  356. }
  357. else
  358. {
  359. rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
  360. return rtnResult;
  361. }
  362. }
  363. else
  364. {
  365. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", errMsg).ToString();
  366. return rtnResult;
  367. }
  368. }
  369. else
  370. {
  371. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", regInParam).ToString();
  372. return rtnResult;
  373. }
  374. }
  375. case "Z2C"://入院登记取消
  376. {
  377. //if (DialogResult.Yes == MessageBox.Show("即将进行取消中心医保登记,确定继续吗?", " 询问? ", MessageBoxButtons.YesNo))
  378. //{
  379. //}
  380. //else
  381. //{
  382. // rtnResult = JsonHelper.setExceptionJson(-1, "收费员撤销取消登记操作!", outParam).ToString();
  383. // return rtnResult;
  384. //}
  385. //取消中心登记
  386. if (cBus.cancleRegister("2404", out outParam) != 0)
  387. {
  388. //如果医保中心没有HIS所传的医保登记信息则默认撤销HIS登记信息
  389. int i = outParam.IndexOf("不存在有效的就诊登记信息");
  390. if (i != 0)
  391. {
  392. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam+ ",是否强制撤销HIS医保登记信息?", "提示", MessageBoxButtons.YesNo))
  393. {
  394. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  395. return rtnResult;
  396. } else
  397. {
  398. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  399. return rtnResult;
  400. }
  401. }
  402. }
  403. //取消医保平台登记
  404. if (mIS.cancleRegister(1, out outParam) != 0)
  405. {
  406. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  407. return rtnResult;
  408. }
  409. //取消HIS 登记
  410. if (hIS.cancleRegister( out outParam) != 0)
  411. {
  412. rtnResult = JsonHelper.setExceptionJson(-1, "中心和云医保平台取消登记成功,但HIS取消失败,", outParam).ToString();
  413. return rtnResult;
  414. }
  415. else
  416. {
  417. //CM 20230602 删除医保平台医保费用明细上传表数据
  418. mIS.deleteFee(out errMsg);
  419. rtnResult = JsonHelper.setIrisReturnValue(0, "取消医保登记成功", null).ToString();
  420. return rtnResult;
  421. }
  422. }
  423. case "Z6"://出院登记
  424. {
  425. break;
  426. }
  427. case "Z6C"://出院登记取消
  428. {
  429. if (cBus.cancleRegister("2405", out errMsg) != 0)
  430. {
  431. rtnResult = JsonHelper.setExceptionJson(-1, "取消出院登记", errMsg).ToString();
  432. return rtnResult;
  433. }
  434. else
  435. {
  436. rtnResult = JsonHelper.setIrisReturnValue(0, "取消出院登记成功", null).ToString();
  437. return rtnResult;
  438. }
  439. break;
  440. }
  441. default:
  442. {
  443. rtnResult = JsonHelper.setExceptionJson(-1, "Register 交易", "传入的业务编码不对!").ToString();
  444. return rtnResult;
  445. }
  446. }
  447. }
  448. catch (Exception ex)
  449. {
  450. rtnResult = JsonHelper.setIrisReturnValue(-1, "Register 发生异常;" + ex.Message, null).ToString();
  451. return rtnResult;
  452. }
  453. finally
  454. {
  455. Global.writeLog("Register 出参:" + JsonHelper.Compress(rtnResult));
  456. }
  457. return "";
  458. }
  459. /// <summary>
  460. /// 费用上传
  461. /// </summary>
  462. /// <param name="InParam"></param>
  463. /// <returns></returns>
  464. public string FeeUpload(string InParam)
  465. {
  466. Global.writeLog("FeeUpload 入参:" + JsonHelper.Compress(InParam));
  467. //设置返回值,错误信息
  468. int errCode;
  469. string errMsg, rtnResult = "", outParam;
  470. try
  471. {
  472. //解析入参
  473. if (parseInparam(InParam, out errMsg) != 0)
  474. {
  475. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  476. return rtnResult;
  477. }
  478. //BS架构调用方式问题,每次调用都需要重新初始化
  479. if (init(InParam, out outParam) != 0)
  480. {
  481. rtnResult = outParam;
  482. return rtnResult;
  483. }
  484. //获取pat
  485. hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  486. switch (businessType)
  487. {
  488. case "M3"://门诊费用上传
  489. {
  490. break;
  491. }
  492. case "M3C"://门诊费用撤销
  493. {
  494. break;
  495. }
  496. case "Z3"://入院费用上传
  497. {
  498. ////事前分析
  499. if (Global.curEvt.ext.isOpenAnalysis)
  500. {
  501. if (hBus.PreAnalysis("4", "", out errMsg) != 0)
  502. {
  503. //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  504. //return rtnResult;
  505. DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  506. if (dr != DialogResult.OK)
  507. {
  508. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  509. return rtnResult;
  510. }
  511. }
  512. }
  513. //从医保平台获取患者详细的医保登记信息
  514. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  515. {
  516. rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  517. return rtnResult;
  518. }
  519. JObject joReg = JObject.Parse(outParam);
  520. Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
  521. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  522. //先取消中心费用传送
  523. cBus.cancleFeeUpload("2302", out errMsg);
  524. //再删除医保传送表的数据
  525. mIS.deleteFee( out errMsg);
  526. #region【住院费用上传前调用3101事前服务】
  527. //1.获取3101入参报文
  528. /* 20221207 CM 朱鹏飞要求屏蔽调用事前事中服务交易
  529. if (hIS.GetInsuPatInfo("5", Global.pat, out outParam) != 0)
  530. {
  531. rtnResult = JsonHelper.setExceptionJson(-1, "获取3101医保明细审核事前分析服务入参失败:", outParam).ToString();
  532. return rtnResult;
  533. }
  534. else
  535. {
  536. //2.调用医保3101明细审核事前分析服务
  537. JObject joInput = new JObject();
  538. joInput = JObject.Parse(outParam);
  539. JObject jo3101Rtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", joInput.ToString().Replace("\r\n", "")));
  540. if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
  541. {
  542. DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  543. if (dr != DialogResult.OK)
  544. {
  545. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  546. return rtnResult;
  547. }
  548. }
  549. }
  550. */
  551. #endregion
  552. //开始进行费用传送
  553. //调用HIS费用查询信息
  554. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  555. {
  556. rtnResult = JsonHelper.setExceptionJson(-1, "获取HIS费用", outParam).ToString();
  557. return rtnResult;
  558. }
  559. //调用医保平台转换
  560. JObject joHisFee = JObject.Parse(outParam);
  561. if (mIS.convertHisFeeWithInsuCode(joHisFee,out outParam) != 0)
  562. {
  563. rtnResult = JsonHelper.setExceptionJson(-1, "转换HIS费用", outParam).ToString();
  564. return rtnResult;
  565. }
  566. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  567. //按指定条数分割后上传,保存,更新
  568. if (hBus.uploadFeeToCenter("2301",10, jaFeeDetail, out outParam) != 0)
  569. {
  570. rtnResult = JsonHelper.setExceptionJson(-1, "上传费用", outParam).ToString();
  571. return rtnResult;
  572. }
  573. else
  574. {
  575. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传成功", null).ToString();
  576. return rtnResult;
  577. }
  578. }
  579. case "Z3C"://住院费用上传取消
  580. {
  581. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  582. {
  583. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  584. return rtnResult;
  585. }
  586. if (mIS.deleteFee( out errMsg) != 0)
  587. {
  588. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  589. return rtnResult;
  590. }
  591. else
  592. {
  593. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传取消成功", null).ToString();
  594. return rtnResult;
  595. }
  596. }
  597. default:
  598. {
  599. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", "传入的业务编码不对!").ToString();
  600. return rtnResult;
  601. }
  602. }
  603. return rtnResult;
  604. }
  605. catch (Exception ex)
  606. {
  607. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", ex.Message).ToString();
  608. return rtnResult;
  609. }
  610. finally
  611. {
  612. Global.writeLog("FeeUpload 出参:" + JsonHelper.Compress(rtnResult));
  613. }
  614. }
  615. /// <summary>
  616. /// 结算
  617. /// </summary>
  618. /// <param name="InParam"></param>
  619. /// <returns></returns>
  620. public string Settlement(string InParam)
  621. {
  622. Global.writeLog("Settlement 入参:" + JsonHelper.Compress(InParam));
  623. //设置返回值,错误信息
  624. string errMsg, rtnResult = "", outParam;
  625. try
  626. {
  627. //解析入参
  628. if (parseInparam(InParam, out errMsg) != 0)
  629. {
  630. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  631. return rtnResult;
  632. }
  633. //BS架构调用方式问题,每次调用都需要重新初始化
  634. if (init(InParam, out outParam) != 0)
  635. {
  636. rtnResult = outParam;
  637. return rtnResult;
  638. }
  639. //获取pat
  640. hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
  641. switch (businessType)
  642. {
  643. case "M4"://门诊预结算
  644. {
  645. OutpatientRegistration frmReg = new OutpatientRegistration();
  646. if (frmReg.ShowDialog() == DialogResult.OK)
  647. {
  648. rtnResult = "调用结束";
  649. }
  650. break;
  651. }
  652. case "M4C"://门诊预结算撤销
  653. {
  654. break;
  655. }
  656. case "M5"://门诊结算
  657. {
  658. Global.pat.admType = 1;
  659. string patInfo ="";
  660. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  661. if (hBus.readCard(out outParam) != 0)
  662. {
  663. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  664. return rtnResult;
  665. }
  666. else
  667. {
  668. patInfo = outParam;
  669. //展示患者信息界面
  670. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  671. {
  672. rtnResult = outParam;
  673. return rtnResult;
  674. }
  675. }
  676. //患者信息赋值给全局变量
  677. patInfo = outParam;
  678. if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  679. {
  680. rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  681. return rtnResult;
  682. }
  683. //校验HIS姓名与医保姓名是否一致
  684. if (hBus.checkName(Global.pat.name,out errMsg) != 0)
  685. {
  686. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  687. return rtnResult;
  688. }
  689. //弹窗提示患者是否正常参保
  690. hBus.InsuMessage(out string InsuMess);
  691. MessageBox.Show(InsuMess,"参保信息提示");
  692. ////事前分析
  693. if (Global.curEvt.ext.isOpenAnalysis)
  694. {
  695. if (hBus.PreAnalysis("2", "", out errMsg) != 0) //事前事中:门诊挂号1 门诊收费登记2 住院登记3 住院收费登记4 住院执行医嘱5 门诊结算6 门诊预结算7 住院结算8 住院预结算9 购药划卡10
  696. {
  697. //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  698. //return rtnResult;
  699. DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  700. if (dr != DialogResult.OK)
  701. {
  702. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  703. return rtnResult;
  704. }
  705. }
  706. }
  707. //显示登记面板
  708. if (hBus.showOutPatRegisterForm(out outParam) != 0)
  709. {
  710. rtnResult = JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString();
  711. return rtnResult;
  712. }
  713. JObject joReg = JObject.Parse(outParam);
  714. //医保挂号
  715. JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  716. JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  717. jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
  718. jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2201", jo2201Inpar_plain));
  719. //此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
  720. JObject jo2203Inpar = new JObject();
  721. JObject jo2203Inpar_plain = new JObject();
  722. jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
  723. jo2203Inpar.Add("diseinfo",JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
  724. JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
  725. if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
  726. {
  727. rtnResult = JsonHelper.setExceptionJson(-1, "医保挂号", errMsg).ToString();
  728. return rtnResult;
  729. }
  730. else
  731. {
  732. Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
  733. //插入患者本次就诊用的参保信息
  734. if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
  735. {
  736. if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  737. {
  738. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam).ToString();
  739. return rtnResult;
  740. }
  741. }
  742. jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
  743. jo2203Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203", jo2203Inpar));
  744. jo2203Inpar = JObject.Parse(JsonHelper.setCenterInpar("2203", jo2203Inpar));
  745. //门诊登记信息,插入云医保平台
  746. jo2201Rtn.Add("validflag", 1);
  747. jo2201Rtn.Add("regstate", 1);
  748. jo2201Rtn.Add("type", 3);
  749. Global.writeLog(jo2201Inpar_plain.ToString());
  750. if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203Inpar_plain, out errMsg) != 0)
  751. {
  752. rtnResult = JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString();
  753. return rtnResult;
  754. }
  755. //返回登记信息,插入HIS
  756. /* if (hIS.returnRegisterInfo(jo2201Inpar_plain, jo2201Rtn, out outParam) != 0)
  757. {
  758. rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
  759. return rtnResult;
  760. }
  761. else
  762. {
  763. rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
  764. return rtnResult;
  765. }*/
  766. }
  767. //门诊就诊信息上传
  768. JObject jo2203Rtn = invoker.invokeCenterService("2203",jo2203Inpar );
  769. if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
  770. {
  771. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
  772. return rtnResult;
  773. }
  774. #region【门诊就诊信息上传成功后调用3101事前服务】
  775. //1.获取3101入参报文
  776. /*
  777. if (hIS.GetInsuPatInfo("1", Global.pat, out outParam) != 0)
  778. {
  779. rtnResult = JsonHelper.setExceptionJson(-1, "获取3101医保明细审核事前分析服务入参失败:", outParam).ToString();
  780. return rtnResult;
  781. }
  782. else
  783. {
  784. //2.调用医保3101明细审核事前分析服务
  785. JObject joInput = new JObject();
  786. //joInput.Add("data", JObject.Parse(outParam));
  787. joInput = JObject.Parse(outParam);
  788. JObject jo3101Rtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", joInput.ToString().Replace("\r\n", ""))); //.Replace(" ", "")
  789. if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
  790. {
  791. DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  792. if (dr != DialogResult.OK)
  793. {
  794. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  795. return rtnResult;
  796. }
  797. }
  798. }
  799. */
  800. #endregion
  801. //费用上传
  802. if (hBus.uploadFee("2204", 50, out outParam) != 0)
  803. {
  804. rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
  805. return rtnResult;
  806. }
  807. #region【门诊预结算2206前调用3102医保明细审核事中服务】
  808. //1.获取3102入参报文
  809. /*
  810. if (hIS.GetInsuPatInfo("2", Global.pat, out outParam) != 0)
  811. {
  812. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  813. return rtnResult;
  814. }
  815. else
  816. {
  817. //2.调用医保3102明细审核事前分析服务
  818. JObject joInput = new JObject();
  819. //joInput.Add("data", JObject.Parse(outParam));
  820. joInput = JObject.Parse(outParam);
  821. JObject jo3101Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  822. if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
  823. {
  824. DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  825. if (dr != DialogResult.OK)
  826. {
  827. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  828. return rtnResult;
  829. }
  830. }
  831. }
  832. */
  833. #endregion
  834. ////事中分析
  835. if (Global.curEvt.ext.isOpenAnalysis)
  836. {
  837. if (hBus.PreAnalysis("7", "", out errMsg) != 0) //事前事中:门诊挂号1 门诊收费登记2 住院登记3 住院收费登记4 住院执行医嘱5 门诊结算6 门诊预结算7 住院结算8 住院预结算9 购药划卡10
  838. {
  839. //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  840. //return rtnResult;
  841. DialogResult dr = MessageBox.Show("【3102】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  842. if (dr != DialogResult.OK)
  843. {
  844. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  845. return rtnResult;
  846. }
  847. }
  848. }
  849. //调用IRIS获取医保各项金额
  850. if (mIS.getSumFee(out outParam) != 0)
  851. {
  852. rtnResult = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outParam).ToString();
  853. return rtnResult;
  854. }
  855. JObject joSumFee = JObject.Parse(outParam);
  856. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joReg, "settlement"));
  857. //修改joSettlement的就诊ID ,总金额等
  858. joSettlement["mdtrt_id"] = Global.pat.mdtrtID;
  859. joSettlement["medfee_sumamt"] = JsonHelper.getDestValue(joSumFee, "data.Sumamt");
  860. //预结算2206
  861. if (hBus.preSettlement_OutPat(joSettlement, out outParam) != 0)
  862. {
  863. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  864. return rtnResult;
  865. }
  866. //正式结算
  867. JObject joData = new JObject();
  868. joData.Add("data",joSettlement);
  869. JObject joRtn = invoker.invokeCenterService("2207", JsonHelper.setCenterInpar("2207", joData));
  870. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  871. {
  872. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  873. return rtnResult;
  874. }
  875. else
  876. {
  877. //返回给云医保平台结算信息
  878. if (mIS.saveSettlement(joRtn, out errMsg) != 0)
  879. {
  880. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  881. return rtnResult;
  882. }
  883. //返回给云医保平台结算明细信息
  884. if (mIS.saveSettlementDetail(joRtn, out errMsg) != 0)
  885. {
  886. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  887. return rtnResult;
  888. }
  889. //返回给HIS
  890. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo"));
  891. if (hIS.returnOutpatSettlementInfo(joSettlement, joSetlinfo, out outParam) != 0)
  892. {
  893. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  894. return rtnResult;
  895. }
  896. else
  897. {
  898. JObject joHisServieRtn = JObject.Parse(outParam);
  899. hBus.returnToFrontEndAfterSettlement(joRtn, joHisServieRtn, out outParam);
  900. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  901. return rtnResult;
  902. }
  903. }
  904. }
  905. case "M5C"://门诊结算撤销
  906. {
  907. //查询HIS医保结算记录表获取该病人的参保地
  908. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  909. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  910. sqlStr = sqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  911. JObject joSql = new JObject();
  912. joSql.Add("sqlStr", sqlStr);
  913. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  914. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  915. //{
  916. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  917. // return rtnResult;
  918. //}
  919. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  920. //退中心结算
  921. string newSettleID = "";
  922. string balc = "";
  923. string setl_time = "";
  924. if (cBus.cancleSettlement("2208", out outParam) != 0)
  925. {
  926. int i = outParam.IndexOf("获取到的就诊信息为无效状态,不能办理结算撤销业务");
  927. if (i != 0)
  928. {
  929. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam + ",是否强制撤销HIS结算信息?", "提示", MessageBoxButtons.YesNo))
  930. {
  931. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消结算失败,", outParam).ToString();
  932. return rtnResult;
  933. }
  934. newSettleID = "YC";
  935. }
  936. else
  937. {
  938. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算", outParam).ToString();
  939. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  940. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  941. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  942. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  943. JObject joSqlStr = new JObject();
  944. joSqlStr.Add("sqlStr", SqlStr);
  945. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  946. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  947. if (jaCancleSettlInfo.Count == 1)
  948. {
  949. //询问收款员是否继续进行HIS退费
  950. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  951. {
  952. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  953. }
  954. }
  955. else
  956. {
  957. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  958. }
  959. return rtnResult;
  960. }
  961. }
  962. else
  963. {
  964. newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  965. balc = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.balc");
  966. setl_time = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_time");
  967. }
  968. //string newSettleID = "10290453";
  969. //Global.pat.mdtrtID = "202210281547480034293700000000";
  970. //Global.pat.psn_no = "YX423049577";
  971. //Global.pat.settlID = "10290445";
  972. //退云医保平台结算
  973. if (mIS.cancleSettlement(newSettleID, balc, setl_time ,out outParam) != 0)
  974. {
  975. rtnResult = JsonHelper.setExceptionJson(-1, "取消平台结算信息", outParam).ToString();
  976. //return rtnResult;
  977. }
  978. if (newSettleID != "YC")
  979. {
  980. //中心取消传送
  981. if (cBus.cancleFeeUpload("2205", out errMsg) != 0)
  982. {
  983. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  984. //return rtnResult;
  985. }
  986. //云平台取消传送
  987. if (mIS.deleteFee(out errMsg) != 0)
  988. {
  989. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  990. return rtnResult;
  991. }
  992. //取消中心登记
  993. if (cBus.cancleRegister("2202", out outParam) != 0)
  994. {
  995. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  996. //return rtnResult;
  997. }
  998. //取消医保平台登记
  999. if (mIS.cancleRegister(3, out outParam) != 0)
  1000. {
  1001. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  1002. return rtnResult;
  1003. }
  1004. }
  1005. //退HIS结算
  1006. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  1007. {
  1008. rtnResult = JsonHelper.setExceptionJson(-1, "取消HIS结算信息", outParam).ToString();
  1009. return rtnResult;
  1010. }
  1011. else
  1012. {
  1013. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  1014. return rtnResult;
  1015. }
  1016. }
  1017. case "M6"://门诊移动支付结算
  1018. {
  1019. MobilePay mp = new MobilePay(InParam, out errMsg);
  1020. if (errMsg != "")
  1021. {
  1022. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易1", errMsg).ToString();
  1023. return rtnResult;
  1024. }
  1025. if (mp.MobilePaySettlement(out outParam) != 0)
  1026. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易2", outParam).ToString();
  1027. else
  1028. rtnResult = outParam;
  1029. return rtnResult;
  1030. }
  1031. case "M6C"://门诊移动支付结算撤销
  1032. {
  1033. string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
  1034. MobilePay mp = new MobilePay(InParam, out errMsg);
  1035. if (errMsg != "")
  1036. {
  1037. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易3", errMsg).ToString();
  1038. return rtnResult;
  1039. }
  1040. if (String.IsNullOrEmpty(onlineYBFalg))
  1041. mp.MSettl.onlineYBFalg = "N";
  1042. else
  1043. mp.MSettl.onlineYBFalg = onlineYBFalg;
  1044. if (mp.MobilePayCancelSettlement(out outParam) != 0)
  1045. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易4", outParam).ToString();
  1046. else
  1047. rtnResult = JsonHelper.setExceptionJson(0, "Settlement 交易5", outParam).ToString();
  1048. return rtnResult;
  1049. }
  1050. case "M6Confirm"://门诊移动支付确认
  1051. {
  1052. MobilePay mp = new MobilePay(InParam, out errMsg);
  1053. if (errMsg != "")
  1054. {
  1055. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易6", errMsg).ToString();
  1056. return rtnResult;
  1057. }
  1058. if (mp.MobilePayConfirmSettlement(out outParam) != 0)
  1059. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易7", outParam).ToString();
  1060. else
  1061. rtnResult = outParam;
  1062. return rtnResult;
  1063. }
  1064. case "M6CallBack"://门诊移动支付回调
  1065. {
  1066. JObject jo = JObject.Parse(InParam);
  1067. joInsuAdmObj = new JObject();
  1068. joInsuAdmObj.Add("payOrdId", "");
  1069. jo.Add("insuAdmObj", joInsuAdmObj);
  1070. MobilePay mp = new MobilePay(jo.ToString(), out errMsg);
  1071. if (errMsg != "")
  1072. {
  1073. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易8", errMsg).ToString();
  1074. return rtnResult;
  1075. }
  1076. if (mp.MobilePayCallbackSettlement(out outParam) != 0)
  1077. rtnResult = outParam;
  1078. else
  1079. rtnResult = outParam;
  1080. return rtnResult;
  1081. }
  1082. case "Z4"://住院预结算
  1083. {
  1084. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1085. //1.获取3102入参报文
  1086. /*
  1087. if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
  1088. {
  1089. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  1090. return rtnResult;
  1091. }
  1092. else
  1093. {
  1094. //2.调用医保3102明细审核事前分析服务
  1095. JObject joInput = new JObject();
  1096. joInput = JObject.Parse(outParam);
  1097. JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1098. if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1099. {
  1100. DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果2:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1101. if (dr != DialogResult.OK)
  1102. {
  1103. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1104. return rtnResult;
  1105. }
  1106. }
  1107. }
  1108. */
  1109. #endregion
  1110. Global.pat.RYorCY = "2";
  1111. Global.pat.admType = 2;
  1112. JObject joSettle = new JObject();
  1113. if (hBus.preSettlement("2303",out joSettle, out outParam) != 0)
  1114. {
  1115. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1116. return rtnResult;
  1117. }
  1118. else
  1119. {
  1120. rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
  1121. return rtnResult;
  1122. }
  1123. }
  1124. case "Z4C"://住院预结算撤销
  1125. {
  1126. rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
  1127. return rtnResult;
  1128. }
  1129. case "Z5"://住院结算
  1130. {
  1131. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1132. //1.获取3102入参报文
  1133. /*
  1134. if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
  1135. {
  1136. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  1137. return rtnResult;
  1138. }
  1139. else
  1140. {
  1141. //2.调用医保3102明细审核事前分析服务
  1142. JObject joInput = new JObject();
  1143. joInput = JObject.Parse(outParam);
  1144. JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1145. if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1146. {
  1147. DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果1:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1148. if (dr != DialogResult.OK)
  1149. {
  1150. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1151. return rtnResult;
  1152. }
  1153. }
  1154. }
  1155. */
  1156. #endregion
  1157. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1158. ////事中分析
  1159. if (Global.curEvt.ext.isOpenAnalysis)
  1160. {
  1161. if (hBus.PreAnalysis("9", "", out errMsg) != 0) //事前事中:门诊挂号1 门诊收费登记2 住院登记3 住院收费登记4 住院执行医嘱5 门诊结算6 门诊预结算7 住院结算8 住院预结算9 购药划卡10
  1162. {
  1163. //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  1164. //return rtnResult;
  1165. DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1166. if (dr != DialogResult.OK)
  1167. {
  1168. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  1169. return rtnResult;
  1170. }
  1171. }
  1172. }
  1173. #endregion
  1174. Global.pat.admType = 2;
  1175. Global.pat.RYorCY = "2";
  1176. JObject joPreSetOutpar ;
  1177. if (hBus.preSettlement("2303",out joPreSetOutpar, out outParam) != 0)
  1178. {
  1179. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1180. return rtnResult;
  1181. }
  1182. else
  1183. {
  1184. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "Settlement"));
  1185. ////出院登记
  1186. //JObject joDischargeRegister = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "DischargeRegister"));
  1187. //JObject jo2402Rtn = invoker.invokeCenterService("2402", JsonHelper.setCenterInpar("2402", joDischargeRegister));
  1188. //if (JsonHelper.parseCenterRtnValue(jo2402Rtn, out errMsg) != 0)
  1189. //{
  1190. // rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1191. // return rtnResult;
  1192. //}
  1193. //正式结算
  1194. joSettlement.Add("data", joSettlement);
  1195. JObject jo2304Rtn = invoker.invokeCenterService("2304",JsonHelper.setCenterInpar("2304",joSettlement));
  1196. if (JsonHelper.parseCenterRtnValue(jo2304Rtn, out errMsg) != 0)
  1197. {
  1198. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1199. cBus.cancleRegister("2405", out errMsg);
  1200. return rtnResult;
  1201. }
  1202. else
  1203. {
  1204. //返回给云医保平台结算信息
  1205. if (mIS.saveSettlement(jo2304Rtn, out errMsg) != 0)
  1206. {
  1207. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  1208. return rtnResult;
  1209. }
  1210. //返回给云医保平台结算明细信息
  1211. if (mIS.saveSettlementDetail(jo2304Rtn, out errMsg) != 0)
  1212. {
  1213. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  1214. Global.writeLog(rtnResult);
  1215. MessageBox.Show(errMsg);
  1216. }
  1217. //返回给HIS
  1218. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo"));
  1219. if (hIS.returnInpatSettlementInfo(joParam, joSetlinfo, out outParam) != 0)
  1220. {
  1221. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  1222. return rtnResult;
  1223. }
  1224. else
  1225. {
  1226. //返回给前端
  1227. JObject joHisServieRtn = JObject.Parse(outParam);
  1228. hBus.returnToFrontEndAfterSettlement(jo2304Rtn, joHisServieRtn, out outParam);
  1229. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  1230. return rtnResult;
  1231. }
  1232. }
  1233. }
  1234. }
  1235. case "Z5C"://住院结算撤销
  1236. {
  1237. //查询结算表
  1238. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and Hospital_Dr=" + Global.inf.hospitalDr
  1239. + " and Adm_Dr='" + Global.pat.adm_Dr + "'"
  1240. + " and MdtrtID='" + Global.pat.mdtrtID + "'"
  1241. + " Order By ID DESC ";
  1242. JObject joSql = new JObject();
  1243. joSql.Add("sqlStr", sqlStr);
  1244. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  1245. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  1246. //{
  1247. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  1248. // return rtnResult;
  1249. //}
  1250. //MessageBox.Show(joSettlInfo.ToString());
  1251. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  1252. Global.pat.SettID_YBJSB = JsonHelper.getDestValue(joSettlInfo, "result.data[0].SettlementID");
  1253. if (Global.pat.settlID != Global.pat.SettID_YBJSB)
  1254. {
  1255. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "通过09010059服务获取到的SettlementID<" + Global.pat.settlID + ">与DLL通过SQL语句" +
  1256. joSql + ",获取到的SettlementID<" + Global.pat.SettID_YBJSB + ">不同,可能存在HIS单边账,请联系医保开发人员处理该笔结算记录!").ToString();
  1257. //return rtnResult;
  1258. }
  1259. Global.pat.settlID = Global.pat.SettID_YBJSB;
  1260. //取消中心结算信息
  1261. if (cBus.cancleSettlement("2305", out outParam) != 0)
  1262. {
  1263. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算信息失败!", outParam).ToString();
  1264. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  1265. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  1266. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  1267. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  1268. JObject joSqlStr = new JObject();
  1269. joSqlStr.Add("sqlStr", SqlStr);
  1270. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  1271. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  1272. if (jaCancleSettlInfo.Count == 1)
  1273. {
  1274. //询问收款员是否继续进行HIS退费
  1275. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  1276. {
  1277. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  1278. }
  1279. }
  1280. else
  1281. {
  1282. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  1283. }
  1284. return rtnResult;
  1285. }
  1286. else
  1287. {
  1288. //退结算会返一个新的ID
  1289. string newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  1290. string balc = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.balc");
  1291. string setl_time = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_time");
  1292. //取消平台结算信息
  1293. if (mIS.cancleSettlement(newSettleID, balc, setl_time, out outParam) != 0)
  1294. {
  1295. rtnResult = JsonHelper.setExceptionJson(-1, "中心结算取消成功,医保平台结算信息取消失败!", outParam).ToString();
  1296. return rtnResult;
  1297. }
  1298. //中心取消传送
  1299. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  1300. {
  1301. //rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  1302. //return rtnResult;
  1303. }
  1304. //云平台取消传送
  1305. if (mIS.deleteFee(out errMsg) != 0)
  1306. {
  1307. //rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  1308. //return rtnResult;
  1309. }
  1310. //取消HIS医保结算信息
  1311. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  1312. {
  1313. rtnResult = JsonHelper.setExceptionJson(-1, "中心跟医保平台结算取消成功, 取消HIS结算信息失败!", outParam).ToString();
  1314. return rtnResult;
  1315. }
  1316. //取消出院登记
  1317. if (cBus.cancleRegister("2405", out outParam) != 0)
  1318. {
  1319. rtnResult = JsonHelper.setExceptionJson(0, "中心,医保平台及HIS结算信息取消成功,取消出院登记失败!请手工取消出院登记!", outParam).ToString();
  1320. return rtnResult;
  1321. }
  1322. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  1323. return rtnResult;
  1324. }
  1325. }
  1326. default:
  1327. {
  1328. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
  1329. return rtnResult;
  1330. }
  1331. }
  1332. return rtnResult;
  1333. }
  1334. catch (Exception ex)
  1335. {
  1336. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
  1337. return rtnResult;
  1338. }
  1339. finally
  1340. {
  1341. Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
  1342. }
  1343. }
  1344. //[STAThread]
  1345. //public void print(JObject joInParam)
  1346. //{
  1347. // //显示打印界面
  1348. // SettlementChecklist frmSettlList;
  1349. // string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1350. // if (insuAdmObj == "")
  1351. // {
  1352. // frmSettlList = new SettlementChecklist();
  1353. // }
  1354. // else
  1355. // {
  1356. // JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1357. // frmSettlList = new SettlementChecklist(joInsuAdmObj);
  1358. // }
  1359. // if (frmSettlList.ShowDialog() == DialogResult.OK)
  1360. // {
  1361. // };
  1362. //}
  1363. //[STAThread]
  1364. /// <summary>
  1365. /// 辅助交易
  1366. /// </summary>
  1367. /// <param name="InParam"></param>
  1368. /// <returns></returns>
  1369. public string AgentFun(string InParam)
  1370. {
  1371. Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
  1372. //设置返回值,错误信息
  1373. int errCode;
  1374. string errMsg, rtnResult = "", outParam;
  1375. try
  1376. {
  1377. //解析入参
  1378. if (parseInparam(InParam, out errMsg) != 0)
  1379. {
  1380. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1381. return rtnResult;
  1382. }
  1383. //BS架构调用方式问题,每次调用都需要重新初始化
  1384. if (init(InParam, out outParam) != 0)
  1385. {
  1386. rtnResult = outParam;
  1387. return rtnResult;
  1388. }
  1389. //获取pat
  1390. //hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  1391. switch (businessType)
  1392. {
  1393. case "BasicData"://基础数据维护
  1394. {
  1395. BasicData bd = new BasicData();
  1396. if (bd.ShowDialog() != DialogResult.OK)
  1397. {
  1398. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出基础数据维护界面").ToString();
  1399. return rtnResult;
  1400. }
  1401. break;
  1402. }
  1403. case "Exception"://异常处理1
  1404. {
  1405. //显示异常处理界面
  1406. HandleException frmEX = new HandleException();
  1407. if (frmEX.ShowDialog() != DialogResult.OK)
  1408. {
  1409. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出异常处理界面").ToString();
  1410. return rtnResult;
  1411. }
  1412. break;
  1413. }
  1414. case "CheckAndClearing"://对账清算
  1415. {
  1416. Clearing frmEX = new Clearing();
  1417. if (frmEX.ShowDialog() != DialogResult.OK)
  1418. {
  1419. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出对账清算界面").ToString();
  1420. return rtnResult;
  1421. }
  1422. break;
  1423. }
  1424. case "Print"://打印
  1425. {
  1426. //显示打印界面
  1427. SettlementChecklist frmSettlList;
  1428. string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1429. if (insuAdmObj == "")
  1430. {
  1431. frmSettlList = new SettlementChecklist();
  1432. if (frmSettlList.ShowDialog() != DialogResult.OK)
  1433. {
  1434. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出打印界面").ToString();
  1435. return rtnResult;
  1436. }
  1437. }
  1438. else
  1439. {
  1440. JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1441. frmSettlList = new SettlementChecklist(joInsuAdmObj);
  1442. string groupID = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "groupID");
  1443. string userName = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "userName");
  1444. DataTable dt = (DataTable)frmSettlList.dgvSettlRecord.DataSource;
  1445. if (dt.Rows.Count != 1)
  1446. {
  1447. frmSettlList.ShowDialog();
  1448. }
  1449. else
  1450. {
  1451. frmSettlList.btnPrint_Click(null, null);
  1452. }
  1453. }
  1454. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  1455. break;
  1456. }
  1457. case "Log"://日志
  1458. {
  1459. MessageBox.Show(businessType);
  1460. break;
  1461. }
  1462. case "RecordUpload"://上传记录
  1463. {
  1464. MessageBox.Show(businessType);
  1465. break;
  1466. }
  1467. case "HospitalRegister"://备案
  1468. {
  1469. ToRecordChoose Referral = new ToRecordChoose();
  1470. Referral.ShowDialog();
  1471. break;
  1472. }
  1473. case "MedInsuQuery"://医保查询
  1474. {
  1475. MedInsuQuery MedQuery = new MedInsuQuery();
  1476. if (MedQuery.ShowDialog() != DialogResult.OK)
  1477. {
  1478. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保查询界面").ToString();
  1479. return rtnResult;
  1480. }
  1481. break;
  1482. }
  1483. case "Appeal"://医保申诉
  1484. {
  1485. HopitalAppeal appeal = new HopitalAppeal();
  1486. if (appeal.ShowDialog() != DialogResult.OK)
  1487. {
  1488. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保申诉界面").ToString();
  1489. return rtnResult;
  1490. }
  1491. break;
  1492. }
  1493. case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
  1494. {
  1495. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1496. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1497. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1498. JObject joResult = new JObject();
  1499. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  1500. //事前分析
  1501. if (Global.curEvt.ext.isOpenAnalysis)
  1502. {
  1503. if (hBus.PreAnalysis("5", joResult.ToString(), out errMsg) != 0)
  1504. {
  1505. MessageBox.Show(errMsg);
  1506. break;
  1507. }
  1508. }
  1509. break;
  1510. }
  1511. case "PrescribeCirculation"://医保处方流转
  1512. {
  1513. ////显示医保处方流转界面
  1514. //PrescriptionCirculation PresCir = new PrescriptionCirculation("");
  1515. //if (PresCir.ShowDialog() != DialogResult.OK)
  1516. //{
  1517. // rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保电子处方流转界面").ToString();
  1518. // return rtnResult;
  1519. //}
  1520. STA sta = new STA();
  1521. Thread thread = new Thread(sta.PrescribeCirculation);
  1522. thread.SetApartmentState(ApartmentState.STA); //重点
  1523. thread.IsBackground = true;
  1524. thread.Start();
  1525. thread.Join();
  1526. break;
  1527. }
  1528. case "PrescriptionCirculation_Pharmacy"://医保处方流转
  1529. {
  1530. //显示医保处方流转界面
  1531. PrescriptionCirculation_Pharmacy PresCir = new PrescriptionCirculation_Pharmacy();
  1532. if (PresCir.ShowDialog() != DialogResult.OK)
  1533. {
  1534. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保电子处方流转-取药机构界面").ToString();
  1535. return rtnResult;
  1536. }
  1537. break;
  1538. }
  1539. case "Special"://就医特殊属性上传
  1540. {
  1541. SpecialPsn spec = new SpecialPsn();
  1542. if (spec.ShowDialog() != DialogResult.OK)
  1543. {
  1544. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出就医特殊属性上传界面").ToString();
  1545. return rtnResult;
  1546. }
  1547. break;
  1548. }
  1549. case "ElectronicSettlementCertificate":// 电子结算凭证上传
  1550. {
  1551. EcSettlCertMainForm ecCert = new EcSettlCertMainForm();
  1552. ecCert.ShowDialog();
  1553. break;
  1554. }
  1555. default:
  1556. {
  1557. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对!").ToString();
  1558. return rtnResult;
  1559. }
  1560. }
  1561. return rtnResult;
  1562. }
  1563. catch (Exception ex)
  1564. {
  1565. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
  1566. return rtnResult;
  1567. }
  1568. finally
  1569. {
  1570. Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
  1571. }
  1572. }
  1573. public string Download(string InParam)
  1574. {
  1575. Global.writeLog("Download 入参:" + JsonHelper.Compress(InParam));
  1576. //设置返回值,错误信息
  1577. int errCode;
  1578. string errMsg, rtnResult = "", outParam;
  1579. try
  1580. {
  1581. //解析入参
  1582. if (parseInparam(InParam, out errMsg) != 0)
  1583. {
  1584. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1585. return rtnResult;
  1586. }
  1587. //BS架构调用方式问题,每次调用都需要重新初始化
  1588. if (init(InParam, out outParam) != 0)
  1589. {
  1590. rtnResult = outParam;
  1591. return rtnResult;
  1592. }
  1593. dynamic joData = new JObject();
  1594. joData.data = joParam["data"];
  1595. //string code = (string)joInParam["code"];
  1596. string funNO = (string)joParam["funNO"];
  1597. switch (businessType)
  1598. {
  1599. case "DirectoryDownload":
  1600. {
  1601. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1602. rtnResult = hBus.DownloadDirectory(funNO, downloadParam).ToString();
  1603. break;
  1604. }
  1605. case "DictionayDownload":
  1606. {
  1607. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1608. rtnResult = hBus.downDictionary(downloadParam);
  1609. break;
  1610. }
  1611. }
  1612. return rtnResult;
  1613. }
  1614. catch (Exception ex)
  1615. {
  1616. rtnResult = JsonHelper.setExceptionJson(-100, "Download", ex.Message).ToString();
  1617. return rtnResult;
  1618. }
  1619. finally
  1620. {
  1621. Global.writeLog("Download 出参:" + rtnResult);
  1622. }
  1623. }
  1624. public string PlatformDirectConnect(string InParam)
  1625. {
  1626. //设置返回值,错误信息
  1627. int errCode;
  1628. string errMsg, rtnResult = "", outParam;
  1629. try
  1630. {
  1631. Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
  1632. //解析入参
  1633. if (parseInparam(InParam, out errMsg) != 0)
  1634. {
  1635. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1636. return rtnResult;
  1637. }
  1638. Global.businessType = businessType;
  1639. string funNO = JsonHelper.getDestValue(joInParam, "funNO");
  1640. //BS架构调用方式问题,每次调用都需要重新初始化
  1641. if (init(InParam, out outParam) != 0)
  1642. {
  1643. rtnResult = outParam;
  1644. return rtnResult;
  1645. }
  1646. JObject joRtn;
  1647. string[] strArr = { "3501", "3502", "3503", "3504", "3505", "3506", "3507" };//进销存交易
  1648. bool exists = ((IList)strArr).Contains(funNO);
  1649. if (exists)
  1650. {
  1651. //解析入参
  1652. if (parsejoParam(joParam, funNO, out errMsg) != 0)
  1653. {
  1654. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1655. return rtnResult;
  1656. }
  1657. //if (funNO == "3505")
  1658. //{
  1659. // //解析入参
  1660. // if (parsejoParamSet(joParam, funNO, out errMsg) != 0)
  1661. // {
  1662. // rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1663. // return rtnResult;
  1664. // }
  1665. // invoker.invokeCenterServiceJXC("992001", JObject.Parse(JsonHelper.setCenterInpar("992001", joParam992001)));//结算信息上传
  1666. // invoker.invokeCenterServiceJXC("992004", JObject.Parse(JsonHelper.setCenterInpar("992004", joParam992004)));//结算费用明细上传
  1667. //}
  1668. //if (funNO == "3506")
  1669. //{
  1670. // invoker.invokeCenterServiceJXC("992002", JObject.Parse(JsonHelper.setCenterInpar("992002", joParam992001)));//结算退费信息上传
  1671. // invoker.invokeCenterServiceJXC("992004", JObject.Parse(JsonHelper.setCenterInpar("992004", joParam992004)));//结算退费费用明细上传
  1672. //}
  1673. joRtn = invoker.invokeCenterServiceJXC(funNO, JObject.Parse(JsonHelper.setCenterInpar(funNO, joParam)));
  1674. //joRtn = invoker.invokeCenterServiceJXC2(funNO, JObject.Parse(JsonHelper.setCenterInpar(funNO, joParam)));】】
  1675. if (funNO == "3505" || funNO == "3506")
  1676. {
  1677. if (!string.IsNullOrEmpty(joParam["selinfo"]["setl_id"].ToString()))
  1678. {
  1679. if (joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4299" || joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4201")
  1680. {
  1681. joParam["selinfo"]["hi_feesetl_type"] = "1";
  1682. joRtn = invoker.invokeCenterService(funNO + 'A', JsonHelper.setCenterInpar(funNO + 'A', joParamA));
  1683. }
  1684. }
  1685. else
  1686. {
  1687. joRtn = invoker.invokeCenterService(funNO + 'A', JsonHelper.setCenterInpar(funNO + 'A', joParamA));
  1688. }
  1689. }
  1690. else
  1691. {
  1692. joRtn = invoker.invokeCenterService(funNO + 'A', JsonHelper.setCenterInpar(funNO + 'A', joParamA));
  1693. }
  1694. }
  1695. else //非进销存交易
  1696. {
  1697. if (funNO== "I2002")
  1698. {
  1699. joRtn = invoker.invokeCenterServiceFZJK("I2002", joParam);//追溯码辅助接口
  1700. }
  1701. else
  1702. {
  1703. joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joParam));//正常交易走医保COM组件
  1704. }
  1705. }
  1706. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1707. {
  1708. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
  1709. return rtnResult;
  1710. }
  1711. else
  1712. {
  1713. rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
  1714. return rtnResult;
  1715. }
  1716. }
  1717. catch (Exception ex)
  1718. {
  1719. rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
  1720. return rtnResult;
  1721. }
  1722. finally
  1723. {
  1724. Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
  1725. }
  1726. }
  1727. private int parsejoParam(JObject joParam,string funno,out string errMsg)
  1728. {
  1729. errMsg = "";
  1730. try
  1731. {
  1732. if (funno == "3505"|| funno == "3506")
  1733. {
  1734. if (!string.IsNullOrEmpty(joParam["selinfo"]["setl_id"].ToString()))
  1735. {
  1736. if (joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4299" || joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4201")
  1737. {
  1738. joParam["selinfo"]["hi_feesetl_type"] = "1";
  1739. }
  1740. else
  1741. {
  1742. joParam["selinfo"]["hi_feesetl_type"] = "2";
  1743. }
  1744. }
  1745. else
  1746. {
  1747. joParam["selinfo"]["hi_feesetl_type"] = "0";
  1748. }
  1749. if(funno == "3506")
  1750. {
  1751. joParam["selinfo"]["fixmedins_bchno"] = joParam["selinfo"]["fixmedins_bchno"].ToString()+"-1".ToString();
  1752. joParam["selinfo"]["rtal_docno"] = joParam["selinfo"]["init_rtal_docno"].ToString();
  1753. }
  1754. JObject joRtn = JObject.Parse(joParam["selinfo"].ToString());
  1755. //if (!string.IsNullOrEmpty(joParam["selinfo"]["drugtracinfo"].ToString()))
  1756. //{
  1757. // joRtn.Add("drug_trac_info", joParam["selinfo"]["drugtracinfo"]);
  1758. // joParam["selinfo"] = joRtn;
  1759. //}
  1760. //MessageBox.Show("111");
  1761. //MessageBox.Show(joParam.ToString());
  1762. JArray selDtl = new JArray();
  1763. selDtl.Add(JObject.Parse(joParam["selinfo"].ToString()));
  1764. //MessageBox.Show(selDtl.ToString());
  1765. joParamA = new JObject();
  1766. joParamA.Add("selinfoDetail", selDtl);
  1767. //MessageBox.Show(joParamA.ToString());
  1768. return 0;
  1769. }
  1770. else if (funno == "3501")
  1771. {
  1772. JObject joRtn = JObject.Parse(joParam["invinfo"].ToString());
  1773. //if (!string.IsNullOrEmpty(joParam["invinfo"]["drugtracinfo"].ToString()))
  1774. //{
  1775. // joRtn.Add("drug_trac_info", joParam["invinfo"]["drugtracinfo"]);
  1776. // joParam["invinfo"] = joRtn;
  1777. //}
  1778. JArray selDtl = new JArray();
  1779. selDtl.Add(JObject.Parse(joParam["invinfo"].ToString()));
  1780. //MessageBox.Show(selDtl.ToString());
  1781. joParamA = new JObject();
  1782. joParamA.Add("invinfoDetail", selDtl);
  1783. return 0;
  1784. }
  1785. else if (funno == "3502")
  1786. {
  1787. JObject joRtn = JObject.Parse(joParam["invinfo"].ToString());
  1788. //if (!string.IsNullOrEmpty(joParam["invinfo"]["drugtracinfo"].ToString()))
  1789. //{
  1790. // joRtn.Add("drug_trac_info", joParam["invinfo"]["drugtracinfo"]);
  1791. // joParam["invinfo"] = joRtn;
  1792. //}
  1793. JArray selDtl = new JArray();
  1794. selDtl.Add(JObject.Parse(joParam["invinfo"].ToString()));
  1795. //MessageBox.Show(selDtl.ToString());
  1796. joParamA = new JObject();
  1797. joParamA.Add("invinfoDetail", selDtl);
  1798. return 0;
  1799. }
  1800. else if (funno == "3503")
  1801. {
  1802. JObject joRtn = JObject.Parse(joParam["purcinfo"].ToString());
  1803. //if (!string.IsNullOrEmpty(joParam["purcinfo"]["drugtracinfo"].ToString()))
  1804. //{
  1805. // joRtn.Add("drug_trac_info", joParam["purcinfo"]["drugtracinfo"]);
  1806. // joParam["purcinfo"] = joRtn;
  1807. //}
  1808. JArray selDtl = new JArray();
  1809. selDtl.Add(JObject.Parse(joParam["purcinfo"].ToString()));
  1810. //MessageBox.Show(selDtl.ToString());
  1811. joParamA = new JObject();
  1812. joParamA.Add("purcinfoDetail", selDtl);
  1813. return 0;
  1814. }
  1815. else if ( funno == "3504")
  1816. {
  1817. JObject joRtn = JObject.Parse(joParam["purcinfo"].ToString());
  1818. //if (!string.IsNullOrEmpty(joParam["purcinfo"]["drugtracinfo"].ToString()))
  1819. //{
  1820. // joRtn.Add("drug_trac_info", joParam["purcinfo"]["drugtracinfo"]);
  1821. // joParam["purcinfo"] = joRtn;
  1822. //}
  1823. JArray selDtl = new JArray();
  1824. selDtl.Add(JObject.Parse(joParam["purcinfo"].ToString()));
  1825. //MessageBox.Show(selDtl.ToString());
  1826. joParamA = new JObject();
  1827. joParamA.Add("purcinfoDetail", selDtl);
  1828. return 0;
  1829. }
  1830. else if (funno == "3507")
  1831. {
  1832. JObject joRtn = JObject.Parse(joParam["data"].ToString());
  1833. //if (!string.IsNullOrEmpty(joParam["purcinfo"]["drugtracinfo"].ToString()))
  1834. //{
  1835. // joRtn.Add("drug_trac_info", joParam["purcinfo"]["drugtracinfo"]);
  1836. // joParam["purcinfo"] = joRtn;
  1837. //}
  1838. JArray selDtl = new JArray();
  1839. selDtl.Add(JObject.Parse(joParam["data"].ToString()));
  1840. //MessageBox.Show(selDtl.ToString());
  1841. joParamA = new JObject();
  1842. joParamA.Add("goodDetail", selDtl);
  1843. return 0;
  1844. }
  1845. else { return -1; }
  1846. }
  1847. catch (Exception ex)
  1848. {
  1849. errMsg = "parsejoParam 解析入参异常1:" + errMsg;
  1850. return -1;
  1851. }
  1852. }
  1853. private int parsejoParamSet(JObject joParam, string funno, out string errMsg)
  1854. {
  1855. errMsg = "";
  1856. try
  1857. {
  1858. if (funno == "3505")
  1859. {
  1860. string setl_id = joParam["selinfo"]["setl_id"].ToString();
  1861. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 ";
  1862. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  1863. sqlStr = sqlStr + " AND SettlementID ='" + setl_id + "'";
  1864. JObject joSql = new JObject();
  1865. joSql.Add("sqlStr", sqlStr);
  1866. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  1867. //查询结算信息
  1868. JObject Outpam = JObject.Parse(joSettlInfo["result"]["data"][0].ToString());
  1869. dynamic setlinfo = new JObject();//结算信息节点
  1870. setlinfo.setl_id = Outpam["SettlementID"];//结算ID
  1871. setlinfo.mdtrt_id = Outpam["MdtrtID"];//就诊ID
  1872. setlinfo.psn_no = Outpam["PersonnelNO"];//人员编号
  1873. setlinfo.psn_name = Outpam["PatientName"];//人员姓名
  1874. setlinfo.psn_cert_type = Outpam["MdtrtCertType"];//凭证类型
  1875. setlinfo.certno = Outpam["CertificateNO"];//证件号码
  1876. setlinfo.gend = Outpam["Gender"];//性别
  1877. setlinfo.naty = Outpam["Nation"];//民族
  1878. setlinfo.brdy = Outpam["BirthDay"];//出生日期
  1879. setlinfo.age = Outpam["Age"];//年龄
  1880. setlinfo.insutype = Outpam["InsuranceType"];//险种类型
  1881. setlinfo.psn_type = Outpam["PersonType"];//人员类别
  1882. setlinfo.cvlserv_flag = Outpam["CivilserviceFlag"];//公务员标志
  1883. setlinfo.setl_time = Outpam["SettlementTime"];//结算时间
  1884. setlinfo.mdtrt_cert_type = Outpam["MdtrtCertType"];//就诊凭证类型
  1885. setlinfo.med_type = Outpam["MedicalType"];//医疗类别
  1886. setlinfo.medfee_sumamt = Outpam["Sumamt"];//医疗费总额
  1887. setlinfo.fulamt_ownpay_amt = Outpam["OwnPayAmount"];//全自费金额
  1888. setlinfo.overlmt_selfpay = Outpam["OverLimitAmount"];//超限价自费费用
  1889. setlinfo.preselfpay_amt = Outpam["PreSelfPayAmount"];//先行自付金额
  1890. setlinfo.inscp_scp_amt = Outpam["InPolicyRangeAmount"];//符合政策范围金额
  1891. setlinfo.act_pay_dedc = Outpam["ActualPayDeductible"];//实际支付起付线
  1892. setlinfo.hifp_pay = Outpam["HealthInsurancePay"];//基本医疗保险统筹基金支出
  1893. setlinfo.pool_prop_selfpay = Outpam["HealthInsuranceRatio"];//基本医疗保险统筹基金支付比例
  1894. setlinfo.cvlserv_pay = Outpam["CivilserviceAllowancePay"];//公务员医疗补助资金支出
  1895. setlinfo.hifes_pay = Outpam["EnterpriseSupplementPay"];//企业补充医疗保险基金支出
  1896. setlinfo.hifmi_pay = Outpam["SeriousIllnessPay"];//居民大病保险资金支出
  1897. setlinfo.hifob_pay = Outpam["LargeExpensesSupplementPay"];//职工大额医疗费用补助基金支出
  1898. setlinfo.maf_pay = Outpam["MedicalAssistPay"];//医疗救助基金支出
  1899. setlinfo.oth_pay = Outpam["OtherPay"];//结算ID
  1900. setlinfo.fund_pay_sumamt = Outpam["FundPaySumamt"];//基金支付总额
  1901. setlinfo.psn_part_amt = Outpam["PersonPaySumamt"];//个人负担总金额
  1902. setlinfo.acct_pay = Outpam["AccountPaySumamt"];//个人账户支出
  1903. setlinfo.psn_cash_pay = Outpam["PersonCashPay"];//个人现金支出
  1904. setlinfo.balc = Outpam["Balance"];//余额
  1905. setlinfo.acct_mulaid_pay = Outpam["AccountMutualAidAmount"];//个人账户共济支付金额
  1906. setlinfo.medins_setl_id = Outpam["OrganSettlementID"];//医药机构结算结算ID
  1907. setlinfo.clr_optins = Outpam["ClearingOrgan"];//clr_optins
  1908. setlinfo.clr_way = Outpam["ClearingWay"];//clr_way
  1909. setlinfo.clr_type = Outpam["ClearingType"];//clr_type
  1910. setlinfo.exp_content = "";//exp_content
  1911. setlinfo.hosp_part_amt = Outpam["HospitalPartAmount"];//医院负担金额
  1912. setlinfo.hifdm_pay = 0;//伤残人员医疗保障基金支出
  1913. dynamic setlinfo1 = new JObject();//结算信息节点
  1914. setlinfo1.setl_id = Outpam["SettlementID"];//结算ID
  1915. string outParam = "";
  1916. string AdmID = Outpam["AdmID"].ToString();
  1917. string billID = Outpam["BillID"].ToString();
  1918. string recordID = Outpam["RecordID"].ToString();
  1919. Global.pat.adm_Dr = int.Parse(AdmID);
  1920. Global.pat.billID = billID;
  1921. Global.pat.recordID = recordID;
  1922. //获取IS费用
  1923. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  1924. {
  1925. MessageBox.Show("获取HIS费用失败");
  1926. }
  1927. //调用医保平台转换HIS费用(转换医保编码等)
  1928. JObject joHisFee = JObject.Parse(outParam);
  1929. if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0)
  1930. {
  1931. MessageBox.Show("获取HIS费用医保对照关系失败");
  1932. }
  1933. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  1934. MessageBox.Show("11111");
  1935. JObject jaFeeOne = new JObject();
  1936. for (int i = 0; i < jaFeeDetail.Count; i++)
  1937. {
  1938. jaFeeOne.Add("feedetl_sn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
  1939. jaFeeOne.Add("rxno", "");//处方号
  1940. if (string.IsNullOrEmpty(jaFeeDetail[i]["rx_circ_flag"].ToString()))
  1941. {
  1942. jaFeeOne.Add("rx_circ_flag", "");//外购处方标志
  1943. }
  1944. else
  1945. {
  1946. jaFeeOne.Add("rx_circ_flag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
  1947. }
  1948. jaFeeOne.Add("fee_ocur_time", jaFeeDetail[i]["fee_ocur_time"]);
  1949. jaFeeOne.Add("med_list_codg", jaFeeDetail[i]["med_list_codg"]);
  1950. jaFeeOne.Add("medins_list_codg", jaFeeDetail[i]["medins_list_codg"]);
  1951. jaFeeOne.Add("medins_list_name", jaFeeDetail[i]["medins_list_desc"]);
  1952. jaFeeOne.Add("prodname", jaFeeDetail[i]["medins_list_desc"]);
  1953. if (string.IsNullOrEmpty(jaFeeDetail[i]["spec"].ToString()))
  1954. {
  1955. jaFeeOne.Add("spec", "");
  1956. }
  1957. else
  1958. {
  1959. jaFeeOne.Add("spec", jaFeeDetail[i]["spec"]);
  1960. }
  1961. if (string.IsNullOrEmpty(jaFeeDetail[i]["doseForm"].ToString()))
  1962. {
  1963. jaFeeOne.Add("dosform_name", "");
  1964. }
  1965. else
  1966. {
  1967. jaFeeOne.Add("dosform_name", jaFeeDetail[i]["doseForm"]);
  1968. }
  1969. jaFeeOne.Add(" det_item_fee_sumamt", jaFeeDetail[i]["det_item_fee_sumamt"]);
  1970. jaFeeOne.Add("cnt", jaFeeDetail[i]["cnt"]);
  1971. jaFeeOne.Add("pric", jaFeeDetail[i]["pric"]);
  1972. if (string.IsNullOrEmpty(jaFeeDetail[i]["sin_dos_dscr"].ToString()))
  1973. {
  1974. jaFeeOne.Add("sin_dos_dscr", "");
  1975. }
  1976. else
  1977. {
  1978. jaFeeOne.Add("sin_dos_dscr", jaFeeDetail[i]["sin_dos_dscr"]);
  1979. }
  1980. if (string.IsNullOrEmpty(jaFeeDetail[i]["used_frqu_dscr"].ToString()))
  1981. {
  1982. jaFeeOne.Add("used_frqu_dscr", "");
  1983. }
  1984. else
  1985. {
  1986. jaFeeOne.Add("used_frqu_dscr", jaFeeDetail[i]["used_frqu_dscr"]);
  1987. }
  1988. if (string.IsNullOrEmpty(jaFeeDetail[i]["prd_days"].ToString()))
  1989. {
  1990. jaFeeOne.Add("prd_days", "");
  1991. }
  1992. else
  1993. {
  1994. jaFeeOne.Add("prd_days", jaFeeDetail[i]["prd_days"]);
  1995. }
  1996. if (string.IsNullOrEmpty(jaFeeDetail[i]["medc_way_dscr"].ToString()))
  1997. {
  1998. jaFeeOne.Add("medc_way_dscr", "");
  1999. }
  2000. else
  2001. {
  2002. jaFeeOne.Add("medc_way_dscr", jaFeeDetail[i]["medc_way_dscr"]);
  2003. }
  2004. if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_codg"].ToString()))
  2005. {
  2006. jaFeeOne.Add("bilg_dr_codg", "");
  2007. }
  2008. else
  2009. {
  2010. jaFeeOne.Add("bilg_dr_codg", jaFeeDetail[i]["bilg_dr_codg"]);
  2011. }
  2012. if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_name"].ToString()))
  2013. {
  2014. jaFeeOne.Add("bilg_dr_name", "");
  2015. }
  2016. else
  2017. {
  2018. jaFeeOne.Add("bilg_dr_name", jaFeeDetail[i]["bilg_dr_name"]);
  2019. }
  2020. jaFeeOne.Add("phar_name", "");
  2021. jaFeeOne.Add("phar_prac_cert_no", "");
  2022. jaFeeOne.Add("tcmdrug_used_way", ""); //中药使用方式 1复方 2单方 必填
  2023. jaFeeOne.Add("trdn_flag", "1");//拆零标志 必填 0否 1是
  2024. jaFeeDetail.Add(jaFeeOne);
  2025. jaFeeOne = new JObject();
  2026. }
  2027. MessageBox.Show("22222");
  2028. joParam992001.Add("setlinfo", JObject.Parse(setlinfo));//结算信息节点
  2029. joParam992004.Add("setlinfo", JObject.Parse(setlinfo1));
  2030. joParam992004.Add("drugdetail", jaFeeDetail);//购药明细节点
  2031. //JObject OutJo = invoker.invokeCenterServiceJXC("992001", JObject.Parse(JsonHelper.setCenterInpar("992001", Jo992001)));
  2032. //MessageBox.Show("上传返回:" + OutJo.ToString());
  2033. }
  2034. if (funno == "3506")
  2035. {
  2036. string setl_id = joParam["selinfo"]["setl_id"].ToString();
  2037. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = -1 ";
  2038. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  2039. sqlStr = sqlStr + " AND SettlementID ='" + setl_id + "'";
  2040. JObject joSql = new JObject();
  2041. joSql.Add("sqlStr", sqlStr);
  2042. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  2043. //查询结算信息
  2044. JObject Outpam = JObject.Parse(joSettlInfo["result"]["data"][0].ToString());
  2045. string mdtrt_id = Outpam["MdtrtID"].ToString();//ADMID
  2046. string sqlStr1 = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 ";
  2047. sqlStr1 = sqlStr1 + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  2048. sqlStr1 = sqlStr1 + " AND MdtrtID ='" + mdtrt_id + "'";
  2049. JObject joSql1 = new JObject();
  2050. joSql1.Add("sqlStr1", sqlStr);
  2051. JObject joSettlInfo1 = mIS.QuerySettlementInfo(joSql1);
  2052. JObject Outpam1= JObject.Parse(joSettlInfo1["result"]["data"][0].ToString());
  2053. dynamic setlinfo = new JObject();//结算信息节点
  2054. setlinfo.setl_id = Outpam["SettlementID"];//结算ID
  2055. setlinfo.init_setl_id = Outpam1["SettlementID"]; ;//结算ID
  2056. setlinfo.setl_time = Outpam["SettlementTime"];//结算时间
  2057. setlinfo.mdtrt_id = Outpam["MdtrtID"];//就诊ID
  2058. setlinfo.psn_no = Outpam["PersonnelNO"];//人员编号
  2059. setlinfo.exp_content = "";//人员姓名
  2060. dynamic setlinfo1 = new JObject();//结算信息节点
  2061. setlinfo1.setl_id = Outpam["SettlementID"];//结算ID
  2062. joParam992002.Add("data", JObject.Parse(setlinfo));//结算信息节点
  2063. string AdmID = Outpam["AdmID"].ToString();
  2064. string billID = Outpam["BillID"].ToString();
  2065. string recordID = Outpam["RecordID"].ToString();
  2066. Global.pat.adm_Dr = int.Parse(AdmID);
  2067. Global.pat.billID = billID;
  2068. Global.pat.recordID = recordID;
  2069. string outParam = "";
  2070. //获取IS费用
  2071. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  2072. {
  2073. MessageBox.Show("获取HIS费用失败");
  2074. }
  2075. //调用医保平台转换HIS费用(转换医保编码等)
  2076. JObject joHisFee = JObject.Parse(outParam);
  2077. if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0)
  2078. {
  2079. MessageBox.Show("获取HIS费用医保对照关系失败");
  2080. }
  2081. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  2082. JObject jaFeeOne = new JObject();
  2083. for (int i = 0; i < jaFeeDetail.Count; i++)
  2084. {
  2085. jaFeeOne.Add("feedetl_sn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
  2086. jaFeeOne.Add("rxno", "");//处方号
  2087. if (string.IsNullOrEmpty(jaFeeDetail[i]["rx_circ_flag"].ToString()))
  2088. {
  2089. jaFeeOne.Add("rx_circ_flag", "");//外购处方标志
  2090. }else {
  2091. jaFeeOne.Add("rx_circ_flag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
  2092. }
  2093. jaFeeOne.Add("fee_ocur_time", jaFeeDetail[i]["fee_ocur_time"]);
  2094. jaFeeOne.Add("med_list_codg", jaFeeDetail[i]["med_list_codg"]);
  2095. jaFeeOne.Add("medins_list_codg", jaFeeDetail[i]["medins_list_codg"]);
  2096. jaFeeOne.Add("medins_list_name", jaFeeDetail[i]["medins_list_desc"]);
  2097. jaFeeOne.Add("prodname", jaFeeDetail[i]["medins_list_desc"]);
  2098. if (string.IsNullOrEmpty(jaFeeDetail[i]["spec"].ToString()))
  2099. {
  2100. jaFeeOne.Add("spec", "");
  2101. }
  2102. else
  2103. {
  2104. jaFeeOne.Add("spec", jaFeeDetail[i]["spec"]);
  2105. }
  2106. if (string.IsNullOrEmpty(jaFeeDetail[i]["doseForm"].ToString()))
  2107. {
  2108. jaFeeOne.Add("dosform_name", "");
  2109. }
  2110. else
  2111. {
  2112. jaFeeOne.Add("dosform_name", jaFeeDetail[i]["doseForm"]);
  2113. }
  2114. jaFeeOne.Add(" det_item_fee_sumamt", jaFeeDetail[i]["det_item_fee_sumamt"]);
  2115. jaFeeOne.Add("cnt", jaFeeDetail[i]["cnt"]);
  2116. jaFeeOne.Add("pric", jaFeeDetail[i]["pric"]);
  2117. if (string.IsNullOrEmpty(jaFeeDetail[i]["sin_dos_dscr"].ToString()))
  2118. {
  2119. jaFeeOne.Add("sin_dos_dscr", "");
  2120. }
  2121. else
  2122. {
  2123. jaFeeOne.Add("sin_dos_dscr", jaFeeDetail[i]["sin_dos_dscr"]);
  2124. }
  2125. if (string.IsNullOrEmpty(jaFeeDetail[i]["used_frqu_dscr"].ToString()))
  2126. {
  2127. jaFeeOne.Add("used_frqu_dscr", "");
  2128. }
  2129. else
  2130. {
  2131. jaFeeOne.Add("used_frqu_dscr", jaFeeDetail[i]["used_frqu_dscr"]);
  2132. }
  2133. if (string.IsNullOrEmpty(jaFeeDetail[i]["prd_days"].ToString()))
  2134. {
  2135. jaFeeOne.Add("prd_days", "");
  2136. }
  2137. else
  2138. {
  2139. jaFeeOne.Add("prd_days", jaFeeDetail[i]["prd_days"]);
  2140. }
  2141. if (string.IsNullOrEmpty(jaFeeDetail[i]["medc_way_dscr"].ToString()))
  2142. {
  2143. jaFeeOne.Add("medc_way_dscr", "");
  2144. }
  2145. else
  2146. {
  2147. jaFeeOne.Add("medc_way_dscr", jaFeeDetail[i]["medc_way_dscr"]);
  2148. }
  2149. if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_codg"].ToString()))
  2150. {
  2151. jaFeeOne.Add("bilg_dr_codg", "");
  2152. }
  2153. else
  2154. {
  2155. jaFeeOne.Add("bilg_dr_codg", jaFeeDetail[i]["bilg_dr_codg"]);
  2156. }
  2157. if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_name"].ToString()))
  2158. {
  2159. jaFeeOne.Add("bilg_dr_name", "");
  2160. }
  2161. else
  2162. {
  2163. jaFeeOne.Add("bilg_dr_name", jaFeeDetail[i]["bilg_dr_name"]);
  2164. }
  2165. jaFeeOne.Add("phar_name", "");
  2166. jaFeeOne.Add("phar_prac_cert_no", "");
  2167. jaFeeOne.Add("tcmdrug_used_way", ""); //中药使用方式 1复方 2单方 必填
  2168. jaFeeOne.Add("trdn_flag", "1");//拆零标志 必填 0否 1是
  2169. jaFeeDetail.Add(jaFeeOne);
  2170. jaFeeOne = new JObject();
  2171. }
  2172. joParam992004.Add("setlinfo", JObject.Parse(setlinfo1));
  2173. joParam992004.Add("drugdetail", jaFeeDetail);//购药明细节点
  2174. }
  2175. return 0;
  2176. }
  2177. catch (Exception ex)
  2178. {
  2179. errMsg = "parsejoParam 解析入参异常2:" + errMsg;
  2180. return -1;
  2181. }
  2182. }
  2183. /// <summary>
  2184. /// 自助机
  2185. /// </summary>
  2186. /// <param name="InParam"></param>
  2187. /// <returns></returns>
  2188. public string SelfServiceMachine(string InParam)
  2189. {
  2190. Global.writeLog("SelfServiceMachine 入参:" + JsonHelper.Compress(InParam));
  2191. //设置返回值,错误信息
  2192. string errMsg, rtnResult = "", outParam;
  2193. try
  2194. {
  2195. //解析入参
  2196. if (parseInparam(InParam, out errMsg) != 0)
  2197. {
  2198. rtnResult = JsonHelper.setExceptionJson(-1, "parseInparam", errMsg).ToString();
  2199. return rtnResult;
  2200. }
  2201. //获取pat
  2202. hBus.GetSelfServiceMachineInfo(businessType, joInParam, out Global.pat);
  2203. //BS架构调用方式问题,每次调用都需要重新初始化
  2204. if (init(InParam, out errMsg) != 0)
  2205. //if (hBus.InitA(InParam, out errMsg) != 0)
  2206. {
  2207. rtnResult = JsonHelper.setExceptionJson(-1, "InitA", errMsg).ToString(); ;
  2208. return rtnResult;
  2209. }
  2210. else
  2211. {
  2212. //joInParam.Add("patInfo", errMsg);
  2213. Global.writeLog($"InitA初始化成功!");
  2214. }
  2215. switch (businessType)
  2216. {
  2217. case "GetPatientInfo"://读取患者信息,该节点无需重定向
  2218. {
  2219. //重定向
  2220. Business.Core.SelfServiceMachine.PatientService patientService = new Business.Core.SelfServiceMachine.PatientService();
  2221. rtnResult = patientService.GetPatientInfo();
  2222. break;
  2223. }
  2224. case "OPReg"://门诊挂号
  2225. {
  2226. #region 链条式任务调度者
  2227. OPRegService service = new OPRegService();
  2228. rtnResult = service.Charge(operationType, joInParam);
  2229. break;
  2230. #endregion
  2231. }
  2232. case "OPSettl"://门诊结算
  2233. {
  2234. OPSettlementService service = new OPSettlementService();
  2235. rtnResult = service.Charge(operationType, joInParam);
  2236. break;
  2237. }
  2238. case "IPInReg"://入院登记
  2239. {
  2240. IPAdmRegService service = new IPAdmRegService();
  2241. rtnResult = service.Register(operationType, joInParam);
  2242. break;
  2243. }
  2244. case "IPInRegCancel"://取消入院登记
  2245. {
  2246. IPAdmRegService service = new IPAdmRegService();
  2247. rtnResult = service.CancelRegister(operationType, joInParam);
  2248. break;
  2249. }
  2250. case "IPOutReg"://出院登记
  2251. {
  2252. break;
  2253. }
  2254. case "IPUpoload"://住院费用上传
  2255. {
  2256. break;
  2257. }
  2258. case "IPPreSettl"://住院预计结算
  2259. {
  2260. break;
  2261. }
  2262. case "IPSettl"://住院结算
  2263. {
  2264. IPSettlementService service = new IPSettlementService();
  2265. rtnResult = service.Charge(joInParam);
  2266. return rtnResult;
  2267. }
  2268. case "DischargeAudit"://费用核查
  2269. {
  2270. DischargeAuditService service = new DischargeAuditService();
  2271. rtnResult = service.Audit(joInParam);
  2272. return rtnResult;
  2273. }
  2274. default:
  2275. {
  2276. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", "传入的业务编码不对!").ToString();
  2277. return rtnResult;
  2278. }
  2279. }
  2280. return rtnResult;
  2281. }
  2282. catch (Exception ex)
  2283. {
  2284. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", ex.Message).ToString();
  2285. return rtnResult;
  2286. }
  2287. finally
  2288. {
  2289. Global.writeLog("SelfServiceMachine 出参:" + JsonHelper.Compress(rtnResult));
  2290. }
  2291. }
  2292. }
  2293. }