InsuBusiness.cs 108 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078
  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. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  1433. }
  1434. break;
  1435. }
  1436. default:
  1437. {
  1438. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对【"+businessType+"】").ToString();
  1439. return rtnResult;
  1440. }
  1441. }
  1442. return rtnResult;
  1443. }
  1444. catch (Exception ex)
  1445. {
  1446. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
  1447. return rtnResult;
  1448. }
  1449. finally
  1450. {
  1451. Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
  1452. }
  1453. }
  1454. public string Download(string InParam)
  1455. {
  1456. Global.writeLog("Download 入参:" + JsonHelper.Compress(InParam));
  1457. //设置返回值,错误信息
  1458. int errCode;
  1459. string errMsg, rtnResult = "", outParam;
  1460. try
  1461. {
  1462. //解析入参
  1463. if (parseInparam(InParam, out errMsg) != 0)
  1464. {
  1465. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1466. return rtnResult;
  1467. }
  1468. //BS架构调用方式问题,每次调用都需要重新初始化
  1469. if (init(InParam, out outParam) != 0)
  1470. {
  1471. rtnResult = outParam;
  1472. return rtnResult;
  1473. }
  1474. dynamic joData = new JObject();
  1475. joData.data = joParam["data"];
  1476. //string code = (string)joInParam["code"];
  1477. string funNO = (string)joParam["funNO"];
  1478. switch (businessType)
  1479. {
  1480. case "DirectoryDownload":
  1481. {
  1482. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1483. rtnResult = hBus.DownloadDirectory(funNO, downloadParam).ToString();
  1484. break;
  1485. }
  1486. case "DictionayDownload":
  1487. {
  1488. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1489. rtnResult = hBus.downDictionary(downloadParam);
  1490. break;
  1491. }
  1492. }
  1493. return rtnResult;
  1494. }
  1495. catch (Exception ex)
  1496. {
  1497. rtnResult = JsonHelper.setExceptionJson(-100, "Download", ex.Message).ToString();
  1498. return rtnResult;
  1499. }
  1500. finally
  1501. {
  1502. Global.writeLog("Download 出参:" + rtnResult);
  1503. }
  1504. }
  1505. public string PlatformDirectConnect(string InParam)
  1506. {
  1507. //设置返回值,错误信息
  1508. int errCode;
  1509. string errMsg, rtnResult = "", outParam;
  1510. try
  1511. {
  1512. Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
  1513. //解析入参
  1514. if (parseInparam(InParam, out errMsg) != 0)
  1515. {
  1516. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1517. return rtnResult;
  1518. }
  1519. Global.businessType = businessType;
  1520. string funNO = JsonHelper.getDestValue(joInParam, "funNO");
  1521. //BS架构调用方式问题,每次调用都需要重新初始化
  1522. if (init(InParam, out outParam) != 0)
  1523. {
  1524. rtnResult = outParam;
  1525. return rtnResult;
  1526. }
  1527. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "insuplc_admdvs");
  1528. JObject joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joParam));
  1529. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1530. {
  1531. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
  1532. return rtnResult;
  1533. }
  1534. else
  1535. {
  1536. rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
  1537. return rtnResult;
  1538. }
  1539. }
  1540. catch (Exception ex)
  1541. {
  1542. rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
  1543. return rtnResult;
  1544. }
  1545. finally
  1546. {
  1547. Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
  1548. }
  1549. }
  1550. /// <summary>
  1551. /// 自助机
  1552. /// </summary>
  1553. /// <param name="InParam"></param>
  1554. /// <returns></returns>
  1555. public string SelfServiceMachine(string InParam)
  1556. {
  1557. Global.writeLog("SelfServiceMachine 入参:" + JsonHelper.Compress(InParam));
  1558. //设置返回值,错误信息
  1559. string errMsg, rtnResult = "", outParam;
  1560. try
  1561. {
  1562. //解析入参
  1563. if (parseInparam(InParam, out errMsg) != 0)
  1564. {
  1565. rtnResult = JsonHelper.setExceptionJson(-1, "parseInparam", errMsg).ToString();
  1566. return rtnResult;
  1567. }
  1568. //获取pat
  1569. hBus.GetSelfServiceMachineInfo(businessType, joInParam, out Global.pat);
  1570. //BS架构调用方式问题,每次调用都需要重新初始化
  1571. if (init(InParam, out errMsg) != 0)
  1572. //if (hBus.InitA(InParam, out errMsg) != 0)
  1573. {
  1574. rtnResult = JsonHelper.setExceptionJson(-1, "InitA", errMsg).ToString(); ;
  1575. return rtnResult;
  1576. }
  1577. else
  1578. {
  1579. //joInParam.Add("patInfo", errMsg);
  1580. Global.writeLog($"InitA初始化成功!");
  1581. }
  1582. switch (businessType)
  1583. {
  1584. case "GetPatientInfo"://读取患者信息,该节点无需重定向
  1585. {
  1586. //重定向
  1587. Business.Core.SelfServiceMachine.PatientService patientService = new Business.Core.SelfServiceMachine.PatientService();
  1588. rtnResult = patientService.GetPatientInfo();
  1589. break;
  1590. }
  1591. case "OPReg"://门诊挂号
  1592. {
  1593. #region 老版
  1594. //CardReader_GS CardRead_GS = new CardReader_GS();
  1595. //Global.pat.admType = 1;
  1596. //string patInfo = "";
  1597. ////打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  1598. //if (hBus.readCard(out outParam) != 0)
  1599. //{
  1600. // rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  1601. // return rtnResult;
  1602. //}
  1603. //else
  1604. //{
  1605. // patInfo = outParam;
  1606. // //展示患者信息界面
  1607. // if (hBus.showPatInfo(patInfo, out outParam) != 0)
  1608. // {
  1609. // rtnResult = outParam;
  1610. // return rtnResult;
  1611. // }
  1612. //}
  1613. ////患者信息赋值给全局变量
  1614. //patInfo = outParam;
  1615. //if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  1616. //{
  1617. // rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  1618. // return rtnResult;
  1619. //}
  1620. ////校验HIS姓名与医保姓名是否一致
  1621. //if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  1622. //{
  1623. // rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  1624. // return rtnResult;
  1625. //}
  1626. ////显示登记面板
  1627. //if (hBus.showOutPatRegisterForm(out outParam) != 0)
  1628. //{
  1629. // rtnResult = JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString();
  1630. // return rtnResult;
  1631. //}
  1632. //JObject joReg = JObject.Parse(outParam);
  1633. ////医保挂号
  1634. //JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  1635. //JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  1636. //jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
  1637. //jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2201", jo2201Inpar_plain));
  1638. ////此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
  1639. //JObject jo2203Inpar = new JObject();
  1640. //JObject jo2203Inpar_plain = new JObject();
  1641. //jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
  1642. //jo2203Inpar.Add("diseinfo", JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
  1643. //JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
  1644. //if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
  1645. //{
  1646. // rtnResult = JsonHelper.setExceptionJson(-1, "医保挂号", errMsg).ToString();
  1647. // return rtnResult;
  1648. //}
  1649. //else
  1650. //{
  1651. // Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
  1652. // //插入患者本次就诊用的参保信息
  1653. // if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
  1654. // {
  1655. // if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  1656. // {
  1657. // rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam).ToString();
  1658. // return rtnResult;
  1659. // }
  1660. // }
  1661. // jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
  1662. // jo2203Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203", jo2203Inpar));
  1663. // jo2203Inpar = JObject.Parse(JsonHelper.setCenterInpar("2203", jo2203Inpar));
  1664. // //门诊登记信息,插入云医保平台
  1665. // jo2201Rtn.Add("validflag", 1);
  1666. // jo2201Rtn.Add("regstate", 1);
  1667. // jo2201Rtn.Add("type", 3);
  1668. // Global.writeLog(jo2201Inpar_plain.ToString());
  1669. // if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203Inpar_plain, out errMsg) != 0)
  1670. // {
  1671. // rtnResult = JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString();
  1672. // return rtnResult;
  1673. // }
  1674. //}
  1675. ////门诊就诊信息上传
  1676. //JObject jo2203Rtn = invoker.invokeCenterService("2203", jo2203Inpar);
  1677. //if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
  1678. //{
  1679. // rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
  1680. // return rtnResult;
  1681. //}
  1682. //#region【门诊就诊信息上传成功后调用3101事前服务】
  1683. ////1.获取3101入参报文
  1684. //if (Global.curEvt.ext.isOpenAnalysis)
  1685. //{
  1686. // if (hIS.GetInsuPatInfo("1", Global.pat, out outParam) != 0)
  1687. // {
  1688. // rtnResult = JsonHelper.setExceptionJson(-1, "获取3101医保明细审核事前分析服务入参失败:", outParam).ToString();
  1689. // return rtnResult;
  1690. // }
  1691. // else
  1692. // {
  1693. // //2.调用医保3101明细审核事前分析服务
  1694. // JObject joInput = new JObject();
  1695. // //joInput.Add("data", JObject.Parse(outParam));
  1696. // joInput = JObject.Parse(outParam);
  1697. // JObject jo3101Rtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", joInput.ToString().Replace("\r\n", ""))); //.Replace(" ", "")
  1698. // if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
  1699. // {
  1700. // rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  1701. // return rtnResult;
  1702. // }
  1703. // else
  1704. // {
  1705. // JArray jaResult = JArray.Parse(JsonHelper.getDestValue(jo3101Rtn, "output.result"));
  1706. // if (jaResult.HasValues)
  1707. // {
  1708. // PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(jo3101Rtn);
  1709. // if (paipaForm.ShowDialog() != DialogResult.OK)
  1710. // {
  1711. // errMsg = "事前事中审核不通过,操作员取消!";
  1712. // rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  1713. // return rtnResult;
  1714. // }
  1715. // }
  1716. // }
  1717. // }
  1718. //}
  1719. //#endregion
  1720. ////费用上传
  1721. //if (hBus.uploadFee("2204", 50, out outParam) != 0)
  1722. //{
  1723. // rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
  1724. // return rtnResult;
  1725. //}
  1726. //#region【门诊预结算2206前调用3102医保明细审核事中服务】
  1727. //if (Global.curEvt.ext.isOpenAnalysis)
  1728. //{
  1729. // //1.获取3102入参报文
  1730. // if (hIS.GetInsuPatInfo("2", Global.pat, out outParam) != 0)
  1731. // {
  1732. // rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  1733. // return rtnResult;
  1734. // }
  1735. // else
  1736. // {
  1737. // //2.调用医保3102明细审核事前分析服务
  1738. // JObject joInput = new JObject();
  1739. // //joInput.Add("data", JObject.Parse(outParam));
  1740. // joInput = JObject.Parse(outParam);
  1741. // JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1742. // if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1743. // {
  1744. // rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1745. // return rtnResult;
  1746. // }
  1747. // else
  1748. // {
  1749. // JArray jaResult = JArray.Parse(JsonHelper.getDestValue(jo3102Rtn, "output.result"));
  1750. // if (jaResult.HasValues)
  1751. // {
  1752. // PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(jo3102Rtn);
  1753. // if (paipaForm.ShowDialog() != DialogResult.OK)
  1754. // {
  1755. // errMsg = "事前事中审核不通过,操作员取消!";
  1756. // rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1757. // return rtnResult;
  1758. // }
  1759. // }
  1760. // }
  1761. // }
  1762. //}
  1763. //#endregion
  1764. ////调用IRIS获取医保各项金额
  1765. //if (mIS.getSumFee(out outParam) != 0)
  1766. //{
  1767. // rtnResult = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outParam).ToString();
  1768. // return rtnResult;
  1769. //}
  1770. //JObject joSumFee = JObject.Parse(outParam);
  1771. //JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joReg, "settlement"));
  1772. ////修改joSettlement的就诊ID ,总金额等
  1773. //joSettlement["mdtrt_id"] = Global.pat.mdtrtID;
  1774. //joSettlement["medfee_sumamt"] = JsonHelper.getDestValue(joSumFee, "data.Sumamt");
  1775. ////预结算2206
  1776. //if (hBus.preSettlement_OutPat(joSettlement, out outParam) != 0)
  1777. //{
  1778. // rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1779. // return rtnResult;
  1780. //}
  1781. //#region【门诊正式结算前调用社保卡验密】
  1782. //if ((Global.pat.mdtrtcertType == "03") && (Global.pat.insuplc_admdvs.Substring(0, 2) == "62"))
  1783. //{
  1784. // if (CardRead_GS.VerifyPIN(out outParam) != 0)
  1785. // {
  1786. // rtnResult = JsonHelper.setExceptionJson(-1, "社保卡验密异常iVerifyPIN失败 ", outParam).ToString();
  1787. // return rtnResult;
  1788. // }
  1789. //}
  1790. //#endregion
  1791. ////正式结算
  1792. //JObject joData = new JObject();
  1793. //joData.Add("data", joSettlement);
  1794. //JObject joRtn = invoker.invokeCenterService("2207", JsonHelper.setCenterInpar("2207", joData));
  1795. //if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1796. //{
  1797. // rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1798. // return rtnResult;
  1799. //}
  1800. //else
  1801. //{
  1802. // //返回给云医保平台结算信息
  1803. // if (mIS.saveSettlement(joRtn, out errMsg) != 0)
  1804. // {
  1805. // rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  1806. // return rtnResult;
  1807. // }
  1808. // //返回给云医保平台结算明细信息
  1809. // if (mIS.saveSettlementDetail(joRtn, out errMsg) != 0)
  1810. // {
  1811. // rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  1812. // return rtnResult;
  1813. // }
  1814. // //返回给HIS
  1815. // JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo"));
  1816. // if (hIS.returnOutpatSettlementInfo(joSettlement, joSetlinfo, out outParam) != 0)
  1817. // {
  1818. // rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  1819. // return rtnResult;
  1820. // }
  1821. // else
  1822. // {
  1823. // JObject joHisServieRtn = JObject.Parse(outParam);
  1824. // hBus.returnToFrontEndAfterSettlement(joRtn, joHisServieRtn, out outParam);
  1825. // rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  1826. // return rtnResult;
  1827. // }
  1828. //}
  1829. #endregion
  1830. #region 链条式任务调度者
  1831. OPRegService service = new OPRegService();
  1832. rtnResult = service.Charge(operationType, joInParam);
  1833. break;
  1834. #endregion
  1835. }
  1836. case "OPSettl"://门诊结算
  1837. {
  1838. OPSettlementService service = new OPSettlementService();
  1839. rtnResult = service.Charge(operationType, joInParam);
  1840. break;
  1841. }
  1842. case "IPInReg"://入院登记
  1843. {
  1844. IPAdmRegService service = new IPAdmRegService();
  1845. rtnResult = service.Register(operationType, joInParam);
  1846. break;
  1847. }
  1848. case "IPInRegCancel"://取消入院登记
  1849. {
  1850. IPAdmRegService service = new IPAdmRegService();
  1851. rtnResult = service.CancelRegister(operationType, joInParam);
  1852. break;
  1853. }
  1854. case "IPOutReg"://出院登记
  1855. {
  1856. break;
  1857. }
  1858. case "IPUpoload"://住院费用上传
  1859. {
  1860. break;
  1861. }
  1862. case "IPPreSettl"://住院预计结算
  1863. {
  1864. break;
  1865. }
  1866. case "IPSettl"://住院结算
  1867. {
  1868. IPSettlementService service = new IPSettlementService();
  1869. rtnResult = service.Charge(joInParam);
  1870. return rtnResult;
  1871. }
  1872. case "DischargeAudit"://费用核查
  1873. {
  1874. DischargeAuditService service = new DischargeAuditService();
  1875. rtnResult = service.Audit(joInParam);
  1876. return rtnResult;
  1877. }
  1878. default:
  1879. {
  1880. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", "传入的业务编码不对!").ToString();
  1881. return rtnResult;
  1882. }
  1883. }
  1884. return rtnResult;
  1885. }
  1886. catch (Exception ex)
  1887. {
  1888. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", ex.Message).ToString();
  1889. return rtnResult;
  1890. }
  1891. finally
  1892. {
  1893. Global.writeLog("SelfServiceMachine 出参:" + JsonHelper.Compress(rtnResult));
  1894. }
  1895. }
  1896. }
  1897. }