InsuBusiness.cs 89 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.Business;
  3. using PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler;
  4. using PTMedicalInsurance.Common;
  5. using PTMedicalInsurance.Forms;
  6. using PTMedicalInsurance.Helper;
  7. using PTMedicalInsurance.Variables;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Reflection;
  14. using System.Text;
  15. using System.Threading;
  16. using System.Threading.Tasks;
  17. using System.Windows.Forms;
  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. //
  40. private string businessType;
  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();
  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. //if ((businessType == "M6") || (businessType == "M6Confirm"))
  64. //{
  65. // Environment.CurrentDirectory = @"D:\HttpServerAPI\bin\libs";
  66. //}
  67. return 0;
  68. }
  69. catch (Exception ex)
  70. {
  71. errMsg = "parseInparam 解析入参异常:" + ex.Message;
  72. return -1;
  73. }
  74. }
  75. /// <summary>
  76. /// 签到
  77. /// </summary>
  78. /// <param name="InParam"></param>
  79. /// <returns></returns>
  80. public string Init(string InParam)
  81. {
  82. string errMsg, rtnResult ="";
  83. JObject joRtn = new JObject();
  84. try
  85. {
  86. if (hBus.initEnvironment(InParam, out errMsg) != 0)
  87. {
  88. return JsonHelper.setExceptionJson(-100, "initEnvironment 失败", errMsg).ToString();
  89. }
  90. else
  91. {
  92. if (mIS.isSigned(ref Global.curEvt.signno) != true)
  93. {
  94. if (businessType != "BasicData")//如果是打开数据对照界面不调用初始化
  95. {
  96. //签到
  97. if (cBus.signIn(out joRtn) != 0)
  98. {
  99. rtnResult = JsonHelper.setExceptionJson(-1, "签到异常", (string)joRtn["err_msg"]).ToString();
  100. return rtnResult;
  101. }
  102. else
  103. {
  104. Global.curEvt.signno = JsonHelper.getDestValue(joRtn, "output.signinoutb.sign_no");
  105. //插入签到表
  106. if (mIS.saveSignRecord(Global.curEvt.signno, out errMsg) != 0)
  107. {
  108. rtnResult = JsonHelper.setIrisReturnValue(0, "中心签到成功但插入签到表失败:" + errMsg, null).ToString();
  109. }
  110. else
  111. {
  112. rtnResult = JsonHelper.setIrisReturnValue(0, "签到成功", joRtn).ToString();
  113. }
  114. }
  115. }
  116. else
  117. {
  118. Global.curEvt.signno = "ABC123";
  119. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功(医保对照不初始化)!", null).ToString();
  120. }
  121. }
  122. else
  123. {
  124. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
  125. }
  126. return rtnResult;
  127. }
  128. }
  129. catch (Exception ex)
  130. {
  131. rtnResult = JsonHelper.setExceptionJson(-100, "Init 异常", ex.Message).ToString();
  132. return rtnResult;
  133. }
  134. finally
  135. {
  136. Global.writeLog("初始化结果:" + rtnResult);
  137. }
  138. }
  139. /// <summary>
  140. /// 初始化
  141. /// </summary>
  142. /// <param name="inParam"></param>
  143. /// <param name="outParam"></param>
  144. /// <returns></returns>
  145. private int init(string inParam, out string outParam)
  146. {
  147. string errMsg;
  148. outParam = "";
  149. try
  150. {
  151. //BS架构调用方式问题,每次调用都需要重新初始化
  152. JObject joInitRtn = JObject.Parse(Init(inParam));
  153. if (JsonHelper.parseIrisRtnValue(joInitRtn, out errMsg) != 0)
  154. {
  155. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)", errMsg).ToString();
  156. return -1;
  157. }
  158. else
  159. {
  160. return 0;
  161. }
  162. }
  163. catch (Exception ex)
  164. {
  165. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)异常", ex.Message).ToString();
  166. return -1;
  167. }
  168. }
  169. /// <summary>
  170. /// 获取患者信息
  171. /// </summary>
  172. /// <param name="InParam"></param>
  173. /// <returns></returns>
  174. public string GetPatientInfo(string InParam)
  175. {
  176. Global.writeLog("GetPatientInfo入参:" + JsonHelper.Compress(InParam));
  177. //设置返回值,错误信息
  178. int errCode;
  179. string errMsg, rtnResult = "",outParam;
  180. //BS架构调用方式问题,每次调用都需要重新初始化
  181. if (init(InParam,out outParam)!= 0)
  182. {
  183. rtnResult = outParam;
  184. return rtnResult;
  185. }
  186. JObject joInParam = JObject.Parse(InParam);
  187. string businessType = JsonHelper.getDestValue(joInParam,"businessType");
  188. try
  189. {
  190. switch (businessType)
  191. {
  192. case "M1"://门诊读卡
  193. {
  194. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  195. if (hBus.readCard(out outParam) != 0)
  196. {
  197. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  198. }
  199. else
  200. {
  201. //展示患者信息界面
  202. if (hBus.showPatInfo(outParam, out outParam) != 0)
  203. {
  204. rtnResult = outParam;
  205. }
  206. else
  207. {
  208. rtnResult = JsonHelper.setIrisReturnValue(0, "", JObject.Parse(outParam)).ToString();
  209. }
  210. }
  211. break;
  212. }
  213. case "Z1"://住院读卡
  214. {
  215. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  216. if (hBus.readCard(out outParam) != 0)
  217. {
  218. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  219. }
  220. else
  221. {
  222. string patInfo = outParam;
  223. //展示患者信息界面
  224. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  225. {
  226. rtnResult = outParam;
  227. }
  228. else
  229. {
  230. rtnResult = JsonHelper.setIrisReturnValue(0,"",JObject.Parse(outParam)).ToString();
  231. }
  232. }
  233. break;
  234. }
  235. }
  236. return rtnResult;
  237. }
  238. catch (Exception ex)
  239. {
  240. rtnResult = JsonHelper.setIrisReturnValue(-1 , "GetPatientInfo发生异常;" + ex.Message,null).ToString();
  241. return rtnResult;
  242. }
  243. finally
  244. {
  245. Global.writeLog("GetPatientInfo出参:" + JsonHelper.Compress(rtnResult));
  246. }
  247. }
  248. /// <summary>
  249. /// 登记
  250. /// </summary>
  251. /// <param name="InParam"></param>
  252. /// <returns></returns>
  253. public string Register(string InParam)
  254. {
  255. Global.writeLog("Register 入参:" + JsonHelper.Compress(InParam));
  256. //设置返回值,错误信息
  257. string errMsg, rtnResult = "", outParam;
  258. try
  259. {
  260. //解析入参
  261. if (parseInparam(InParam, out errMsg) != 0)
  262. {
  263. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  264. return rtnResult;
  265. }
  266. //BS架构调用方式问题,每次调用都需要重新初始化
  267. if (init(InParam, out outParam) != 0)
  268. {
  269. rtnResult = outParam;
  270. return rtnResult;
  271. }
  272. //获取pat
  273. hBus.GetRegPatInfo(businessType, joInParam, out Global.pat);
  274. switch (businessType)
  275. {
  276. case "M2"://门诊登记
  277. {
  278. break;
  279. }
  280. case "M2C"://门诊登记撤销
  281. {
  282. break;
  283. }
  284. case "Z0"://住院修改
  285. {
  286. break;
  287. }
  288. case "Z2"://入院登记
  289. {
  290. Global.pat.RYorCY = "1"; //1入院2出院
  291. Global.writeLog(Global.pat.insuType);
  292. string regInParam = "";
  293. //显示登记面板
  294. if (hBus.showInPatRegisterForm( out regInParam) == 0)
  295. {
  296. Global.writeLog(regInParam);
  297. JObject joRegIn_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2401", regInParam));
  298. JObject joRegIn = JObject.Parse(JsonHelper.setCenterInpar("2401", regInParam));
  299. //上传给中心
  300. JObject joRegOut = invoker.invokeCenterService("2401", joRegIn);
  301. //将中心返回的结果返回HIS,调用HIS服务进行保存
  302. if (JsonHelper.parseCenterRtnValue(joRegOut,out errMsg) == 0)
  303. {
  304. joRegOut.Add("validflag",1);
  305. joRegOut.Add("regstate", 1);
  306. joRegOut.Add("type", 1);
  307. Global.pat.mdtrtID = JsonHelper.getDestValue(joRegOut, "output.result.mdtrt_id");
  308. //插入患者本次就诊用的参保信息
  309. if (hBus.insertPatCurInsuInfo(JsonHelper.getDestValue(joParam, "patientInfo"), out outParam) != 0)
  310. {
  311. if (DialogResult.Yes == MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  312. {
  313. }
  314. else
  315. {
  316. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!", outParam).ToString();
  317. return rtnResult;
  318. }
  319. }
  320. //插入医保平台
  321. if (mIS.saveInpatRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  322. {
  323. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存登记信息", outParam).ToString();
  324. return rtnResult;
  325. }
  326. //返回登记信息,插入HIS
  327. if (hIS.returnRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  328. {
  329. rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
  330. return rtnResult;
  331. }
  332. else
  333. {
  334. rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
  335. return rtnResult;
  336. }
  337. }
  338. else
  339. {
  340. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", errMsg).ToString();
  341. return rtnResult;
  342. }
  343. }
  344. else
  345. {
  346. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", regInParam).ToString();
  347. return rtnResult;
  348. }
  349. }
  350. case "Z2C"://入院登记取消
  351. {
  352. //if (DialogResult.Yes == MessageBox.Show("即将进行取消中心医保登记,确定继续吗?", " 询问? ", MessageBoxButtons.YesNo))
  353. //{
  354. //}
  355. //else
  356. //{
  357. // rtnResult = JsonHelper.setExceptionJson(-1, "收费员撤销取消登记操作!", outParam).ToString();
  358. // return rtnResult;
  359. //}
  360. //取消中心登记
  361. if (cBus.cancleRegister("2404", out outParam) != 0)
  362. {
  363. //如果医保中心没有HIS所传的医保登记信息则默认撤销HIS登记信息
  364. int i = outParam.IndexOf("不存在有效的就诊登记信息");
  365. if (i != 0)
  366. {
  367. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam + ",是否强制撤销HIS医保登记信息?", "提示", MessageBoxButtons.YesNo))
  368. {
  369. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  370. return rtnResult;
  371. }
  372. }
  373. else
  374. {
  375. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  376. return rtnResult;
  377. }
  378. }
  379. //取消医保平台登记
  380. if (mIS.cancleRegister(1, out outParam) != 0)
  381. {
  382. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  383. return rtnResult;
  384. }
  385. //取消HIS 登记
  386. if (hIS.cancleRegister( out outParam) != 0)
  387. {
  388. rtnResult = JsonHelper.setExceptionJson(-1, "中心和云医保平台取消登记成功,但HIS取消失败,", outParam).ToString();
  389. return rtnResult;
  390. }
  391. else
  392. {
  393. //CM 20230602 删除医保平台医保费用明细上传表数据
  394. mIS.deleteFee(out errMsg);
  395. rtnResult = JsonHelper.setIrisReturnValue(0, "取消医保登记成功", null).ToString();
  396. return rtnResult;
  397. }
  398. }
  399. case "Z6"://出院登记
  400. {
  401. break;
  402. }
  403. case "Z6C"://出院登记取消
  404. {
  405. if (cBus.cancleRegister("2405", out errMsg) != 0)
  406. {
  407. rtnResult = JsonHelper.setExceptionJson(-1, "取消出院登记", errMsg).ToString();
  408. return rtnResult;
  409. }
  410. else
  411. {
  412. rtnResult = JsonHelper.setIrisReturnValue(0, "取消出院登记成功", null).ToString();
  413. return rtnResult;
  414. }
  415. break;
  416. }
  417. default:
  418. {
  419. rtnResult = JsonHelper.setExceptionJson(-1, "Register 交易", "传入的业务编码不对!").ToString();
  420. return rtnResult;
  421. }
  422. }
  423. }
  424. catch (Exception ex)
  425. {
  426. rtnResult = JsonHelper.setIrisReturnValue(-1, "Register 发生异常;" + ex.Message, null).ToString();
  427. return rtnResult;
  428. }
  429. finally
  430. {
  431. Global.writeLog("Register 出参:" + JsonHelper.Compress(rtnResult));
  432. }
  433. return "";
  434. }
  435. /// <summary>
  436. /// 费用上传
  437. /// </summary>
  438. /// <param name="InParam"></param>
  439. /// <returns></returns>1
  440. public string FeeUpload(string InParam)
  441. {
  442. Global.writeLog("FeeUpload 入参:" + JsonHelper.Compress(InParam));
  443. //设置返回值,错误信息
  444. int errCode;
  445. string errMsg, rtnResult = "", outParam;
  446. try
  447. {
  448. //解析入参
  449. if (parseInparam(InParam, out errMsg) != 0)
  450. {
  451. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  452. return rtnResult;
  453. }
  454. //BS架构调用方式问题,每次调用都需要重新初始化
  455. if (init(InParam, out outParam) != 0)
  456. {
  457. rtnResult = outParam;
  458. return rtnResult;
  459. }
  460. //获取pat
  461. hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  462. //获取事前事中配置
  463. hBus.getPreAndInProcessConfingure();
  464. switch (businessType)
  465. {
  466. case "M3"://门诊费用上传
  467. {
  468. break;
  469. }
  470. case "M3C"://门诊费用撤销
  471. {
  472. break;
  473. }
  474. case "Z3"://入院费用上传
  475. {
  476. //从医保平台获取患者详细的医保登记信息
  477. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  478. {
  479. rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  480. return rtnResult;
  481. }
  482. JObject joReg = JObject.Parse(outParam);
  483. Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
  484. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  485. //先取消中心费用传送
  486. cBus.cancleFeeUpload("2302", out errMsg);
  487. //再删除医保传送表的数据
  488. mIS.deleteFee(out errMsg);
  489. #region【住院费用上传前调用3101事前服务】
  490. //事前分析
  491. if (hBus.ShouldExecutePreAndInProcess("IPChargeRegistrationTrigScen"))
  492. {
  493. if (hBus.PreAnalysis(Global.pat.preAndInPro.IPChargeRegistrationTrigScen, "", out errMsg) != 0)
  494. {
  495. if (MessageBox.Show("医保明细审核事前分析服务调用失败!是否继续结算?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  496. {
  497. }
  498. else
  499. {
  500. rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  501. return rtnResult;
  502. }
  503. }
  504. }
  505. #endregion
  506. //开始进行费用传送
  507. //调用HIS费用查询信息
  508. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  509. {
  510. rtnResult = JsonHelper.setExceptionJson(-1, "获取HIS费用", outParam).ToString();
  511. return rtnResult;
  512. }
  513. //调用医保平台转换
  514. JObject joHisFee = JObject.Parse(outParam);
  515. if (mIS.convertHisFeeWithInsuCode(joHisFee,out outParam) != 0)
  516. {
  517. rtnResult = JsonHelper.setExceptionJson(-1, "转换HIS费用", outParam).ToString();
  518. return rtnResult;
  519. }
  520. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  521. //按指定条数分割后上传,保存,更新
  522. if (hBus.uploadFeeToCenter("2301",10, jaFeeDetail, out outParam) != 0)
  523. {
  524. rtnResult = JsonHelper.setExceptionJson(-1, "上传费用", outParam).ToString();
  525. return rtnResult;
  526. }
  527. else
  528. {
  529. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传成功", null).ToString();
  530. return rtnResult;
  531. }
  532. }
  533. case "Z3C"://住院费用上传取消
  534. {
  535. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  536. {
  537. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  538. return rtnResult;
  539. }
  540. if (mIS.deleteFee( out errMsg) != 0)
  541. {
  542. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  543. return rtnResult;
  544. }
  545. else
  546. {
  547. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传取消成功", null).ToString();
  548. return rtnResult;
  549. }
  550. }
  551. default:
  552. {
  553. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", "传入的业务编码不对!").ToString();
  554. return rtnResult;
  555. }
  556. }
  557. return rtnResult;
  558. }
  559. catch (Exception ex)
  560. {
  561. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", ex.Message).ToString();
  562. return rtnResult;
  563. }
  564. finally
  565. {
  566. Global.writeLog("FeeUpload 出参:" + JsonHelper.Compress(rtnResult));
  567. }
  568. }
  569. /// <summary>
  570. /// 结算
  571. /// </summary>
  572. /// <param name="InParam"></param>
  573. /// <returns></returns>
  574. public string Settlement(string InParam)
  575. {
  576. Global.writeLog("Settlement 入参:" + JsonHelper.Compress(InParam));
  577. //设置返回值,错误信息
  578. string errMsg, rtnResult = "", outParam;
  579. try
  580. {
  581. //解析入参
  582. if (parseInparam(InParam, out errMsg) != 0)
  583. {
  584. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  585. return rtnResult;
  586. }
  587. //BS架构调用方式问题,每次调用都需要重新初始化
  588. if (init(InParam, out outParam) != 0)
  589. {
  590. rtnResult = outParam;
  591. return rtnResult;
  592. }
  593. //获取pat
  594. hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
  595. //获取事前事中配置
  596. hBus.getPreAndInProcessConfingure();
  597. switch (businessType)
  598. {
  599. case "M4"://门诊预结算
  600. {
  601. OutpatientRegistration frmReg = new OutpatientRegistration();
  602. if (frmReg.ShowDialog() == DialogResult.OK)
  603. {
  604. rtnResult = "调用结束";
  605. }
  606. break;
  607. }
  608. case "M4C"://门诊预结算撤销
  609. {
  610. break;
  611. }
  612. case "M5"://门诊结算
  613. {
  614. string patInfo ="";
  615. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  616. if (hBus.readCard(out outParam) != 0)
  617. {
  618. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  619. return rtnResult;
  620. }
  621. else
  622. {
  623. patInfo = outParam;
  624. //展示患者信息界面
  625. if (hBus.convertPatientInfo(patInfo, out outParam) != 0)
  626. {
  627. rtnResult = outParam;
  628. return rtnResult;
  629. }
  630. }
  631. //患者信息赋值给全局变量
  632. patInfo = outParam;
  633. if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  634. {
  635. rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  636. return rtnResult;
  637. }
  638. //校验HIS姓名与医保姓名是否一致
  639. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  640. {
  641. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  642. return rtnResult;
  643. }
  644. //显示登记面板
  645. if (hBus.showOutPatRegisterForm(out outParam) != 0)
  646. {
  647. rtnResult = JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString();
  648. return rtnResult;
  649. }
  650. JObject joReg = JObject.Parse(outParam);
  651. //医保挂号
  652. JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  653. JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  654. jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
  655. jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2201", jo2201Inpar_plain));
  656. //此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
  657. JObject jo2203Inpar = new JObject();
  658. JObject jo2203Inpar_plain = new JObject();
  659. jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
  660. jo2203Inpar.Add("diseinfo",JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
  661. JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
  662. if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
  663. {
  664. rtnResult = JsonHelper.setExceptionJson(-1, "医保挂号", errMsg).ToString();
  665. return rtnResult;
  666. }
  667. else
  668. {
  669. Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
  670. //插入患者本次就诊用的参保信息
  671. if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
  672. {
  673. if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  674. {
  675. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam).ToString();
  676. return rtnResult;
  677. }
  678. }
  679. jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
  680. jo2203Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203", jo2203Inpar));
  681. jo2203Inpar = JObject.Parse(JsonHelper.setCenterInpar("2203", jo2203Inpar));
  682. //门诊登记信息,插入云医保平台
  683. jo2201Rtn.Add("validflag", 1);
  684. jo2201Rtn.Add("regstate", 1);
  685. jo2201Rtn.Add("type", 3);
  686. if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203Inpar_plain, out errMsg) != 0)
  687. {
  688. rtnResult = JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString();
  689. return rtnResult;
  690. }
  691. }
  692. //门诊就诊信息上传
  693. JObject jo2203Rtn = invoker.invokeCenterService("2203",jo2203Inpar );
  694. if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
  695. {
  696. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
  697. return rtnResult;
  698. }
  699. #region【门诊就诊信息上传成功后调用3101事前服务】
  700. //事前分析
  701. //1.门诊挂号 2.门诊收费登记 3.住院登记 4.住院收费登记 5.住院执行医嘱 6.门诊结算 7.门诊预结算 8.住院结算 9.住院预结算 10.购药划卡
  702. if (hBus.ShouldExecutePreAndInProcess("OPChargeRegistrationTrigScen"))
  703. {
  704. if (hBus.PreAnalysis(Global.pat.preAndInPro.OPChargeRegistrationTrigScen, "", out errMsg) != 0)
  705. {
  706. if (MessageBox.Show("医保明细审核事前分析服务调用失败!是否继续结算?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  707. {
  708. }
  709. else
  710. {
  711. rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  712. return rtnResult;
  713. }
  714. }
  715. }
  716. #endregion
  717. //费用上传
  718. if (hBus.uploadFee("2204", 50, out outParam) != 0)
  719. {
  720. rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
  721. return rtnResult;
  722. }
  723. #region【门诊预结算2206前调用3102医保明细审核事中服务】
  724. if (hBus.ShouldExecutePreAndInProcess("OPPreSetTrigScen"))
  725. {
  726. if (hBus.InProcessAnalysis(Global.pat.preAndInPro.OPPreSetTrigScen, out errMsg) != 0)
  727. {
  728. if (MessageBox.Show("医保明细审核事前分析服务调用失败!是否继续结算?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  729. {
  730. }
  731. else
  732. {
  733. rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  734. return rtnResult;
  735. }
  736. }
  737. }
  738. #endregion
  739. //调用IRIS获取医保各项金额
  740. if (mIS.getSumFee(out outParam) != 0)
  741. {
  742. rtnResult = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outParam).ToString();
  743. return rtnResult;
  744. }
  745. JObject joSumFee = JObject.Parse(outParam);
  746. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joReg, "settlement"));
  747. //修改joSettlement的就诊ID ,总金额等
  748. joSettlement["mdtrt_id"] = Global.pat.mdtrtID;
  749. joSettlement["medfee_sumamt"] = JsonHelper.getDestValue(joSumFee, "data.Sumamt");
  750. //预结算2206
  751. if (hBus.preSettlement_OutPat(joSettlement, out outParam) != 0)
  752. {
  753. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  754. return rtnResult;
  755. }
  756. #region【门诊正式结算前调用1192身份验证】
  757. if (hBus.IdentityVerify("2207", out errMsg) != 0)
  758. {
  759. rtnResult = JsonHelper.setExceptionJson(-1, "调用门诊正式结算2207前,身份核验1192失败", errMsg).ToString();
  760. return rtnResult;
  761. }
  762. else
  763. {
  764. JObject joDataExp = new JObject();
  765. joDataExp.Add("cardtoken", Global.pat.card.Cardtoken);
  766. joDataExp.Add("acct_payamt", Global.Set.acctPay);
  767. joDataExp.Add("elec_bill_code", "");
  768. joDataExp.Add("elec_billno_code", "");
  769. joDataExp.Add("elec_bill_chkcode", "");
  770. joSettlement["exp_content"] = joDataExp;
  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. Global.pat.admType = 1;
  785. Global.pat.ExpContent = ""; //门诊不需要保存 外伤标志等相关扩展参数
  786. //返回给云医保平台结算信息
  787. if (mIS.saveSettlement(joRtn, out errMsg) != 0)
  788. {
  789. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  790. return rtnResult;
  791. }
  792. //返回给云医保平台结算明细信息
  793. if (mIS.saveSettlementDetail(joRtn, out errMsg) != 0)
  794. {
  795. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  796. return rtnResult;
  797. }
  798. //返回给HIS
  799. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo"));
  800. if (hIS.returnOutpatSettlementInfo(joSettlement, joSetlinfo, out outParam) != 0)
  801. {
  802. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  803. return rtnResult;
  804. }
  805. else
  806. {
  807. JObject joHisServieRtn = JObject.Parse(outParam);
  808. hBus.returnToFrontEndAfterSettlement(joRtn, joHisServieRtn, out outParam);
  809. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  810. return rtnResult;
  811. }
  812. }
  813. }
  814. case "M5C"://门诊结算撤销
  815. {
  816. //查询HIS医保结算记录表获取该病人的参保地
  817. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  818. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  819. sqlStr = sqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  820. JObject joSql = new JObject();
  821. joSql.Add("sqlStr", sqlStr);
  822. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  823. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  824. //{
  825. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  826. // return rtnResult;
  827. //}
  828. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  829. //退中心结算
  830. string newSettleID = "";
  831. if (cBus.cancleSettlement("2208", out outParam) != 0)
  832. {
  833. int i = outParam.IndexOf("获取到的就诊信息为无效状态,不能办理结算撤销业务");
  834. if (i != 0)
  835. {
  836. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam + ",是否强制撤销HIS结算信息?", "提示", MessageBoxButtons.YesNo))
  837. {
  838. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消结算失败,", outParam).ToString();
  839. return rtnResult;
  840. }
  841. newSettleID = "YC";
  842. }
  843. else
  844. {
  845. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算", outParam).ToString();
  846. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  847. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  848. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  849. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  850. JObject joSqlStr = new JObject();
  851. joSqlStr.Add("sqlStr", SqlStr);
  852. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  853. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  854. if (jaCancleSettlInfo.Count == 1)
  855. {
  856. //询问收款员是否继续进行HIS退费
  857. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  858. {
  859. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  860. }
  861. }
  862. else
  863. {
  864. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  865. }
  866. return rtnResult;
  867. }
  868. }
  869. else
  870. {
  871. newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  872. }
  873. //string newSettleID = "10290453";
  874. //Global.pat.mdtrtID = "202210281547480034293700000000";
  875. //Global.pat.psn_no = "YX423049577";
  876. //Global.pat.settlID = "10290445";
  877. //退云医保平台结算
  878. if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
  879. {
  880. rtnResult = JsonHelper.setExceptionJson(-1, "取消平台结算信息", outParam).ToString();
  881. //return rtnResult;
  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. //退HIS结算
  908. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  909. {
  910. rtnResult = JsonHelper.setExceptionJson(-1, "取消HIS结算信息", outParam).ToString();
  911. return rtnResult;
  912. }
  913. else
  914. {
  915. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  916. return rtnResult;
  917. }
  918. }
  919. case "M6"://门诊移动支付结算
  920. {
  921. MobilePay mp = new MobilePay(InParam, out errMsg);
  922. if (errMsg != "")
  923. {
  924. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  925. return rtnResult;
  926. }
  927. if (mp.MobilePaySettlement(out outParam) != 0)
  928. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  929. else
  930. rtnResult = outParam;
  931. return rtnResult;
  932. }
  933. case "M6RE":
  934. {
  935. MobilePay mp = new MobilePay(InParam, out errMsg);
  936. if (errMsg != "")
  937. {
  938. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  939. return rtnResult;
  940. }
  941. mp.MobilePayReSettlement(out outParam);
  942. return outParam;
  943. }
  944. case "M6C"://门诊移动支付结算撤销
  945. {
  946. string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
  947. MobilePay mp = new MobilePay(InParam, out errMsg);
  948. if (errMsg != "")
  949. {
  950. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  951. return rtnResult;
  952. }
  953. if (String.IsNullOrEmpty(onlineYBFalg))
  954. mp.MSettl.onlineYBFalg = "N";
  955. else
  956. mp.MSettl.onlineYBFalg = onlineYBFalg;
  957. if (mp.MobilePayCancelSettlement(out outParam) != 0)
  958. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  959. else
  960. rtnResult = JsonHelper.setExceptionJson(0, "Settlement 交易", outParam).ToString();
  961. return rtnResult;
  962. }
  963. case "M6Confirm"://门诊移动支付确认
  964. {
  965. MobilePay mp = new MobilePay(InParam, out errMsg);
  966. if (errMsg != "")
  967. {
  968. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  969. return rtnResult;
  970. }
  971. if (mp.MobilePayConfirmSettlement(out outParam) != 0)
  972. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
  973. else
  974. rtnResult = outParam;
  975. return rtnResult;
  976. }
  977. case "M6Q":
  978. {
  979. MobilePay mp = new MobilePay(InParam, out errMsg);
  980. if (errMsg != "")
  981. {
  982. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
  983. return rtnResult;
  984. }
  985. mp.MobilePayQuery(out outParam);
  986. return outParam;
  987. }
  988. case "Z4"://住院预结算
  989. {
  990. Global.pat.RYorCY = "2";
  991. JObject joSettle = new JObject();
  992. if (hBus.preSettlement("2303",out joSettle, out outParam) != 0)
  993. {
  994. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  995. return rtnResult;
  996. }
  997. else
  998. {
  999. rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
  1000. return rtnResult;
  1001. }
  1002. }
  1003. case "Z4C"://住院预结算撤销
  1004. {
  1005. rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
  1006. return rtnResult;
  1007. }
  1008. case "Z5"://住院结算
  1009. {
  1010. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1011. #endregion
  1012. Global.pat.RYorCY = "2";
  1013. JObject joPreSetOutpar ;
  1014. if (hBus.preSettlement("2303",out joPreSetOutpar, out outParam) != 0)
  1015. {
  1016. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1017. return rtnResult;
  1018. }
  1019. else
  1020. {
  1021. JObject joSettlement = joSettlement = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "Settlement"));
  1022. JObject joDataExp = new JObject();
  1023. joDataExp.Add("cardtoken", Global.pat.card.Cardtoken);
  1024. joDataExp.Add("acct_payamt", Global.Set.acctPay);
  1025. joDataExp.Add("elec_bill_code", "");
  1026. joDataExp.Add("elec_billno_code", "");
  1027. joDataExp.Add("elec_bill_chkcode", "");
  1028. joSettlement["exp_content"] = joDataExp;
  1029. //正式结算
  1030. joSettlement.Add("data", joSettlement);
  1031. JObject jo2304Rtn = invoker.invokeCenterService("2304",JsonHelper.setCenterInpar("2304",joSettlement));
  1032. if (JsonHelper.parseCenterRtnValue(jo2304Rtn, out errMsg) != 0)
  1033. {
  1034. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1035. cBus.cancleRegister("2405", out errMsg);
  1036. return rtnResult;
  1037. }
  1038. else
  1039. {
  1040. Global.pat.admType = 2;
  1041. //返回给云医保平台结算信息
  1042. if (mIS.saveSettlement(jo2304Rtn, out errMsg) != 0)
  1043. {
  1044. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  1045. return rtnResult;
  1046. }
  1047. //返回给云医保平台结算明细信息
  1048. if (mIS.saveSettlementDetail(jo2304Rtn, out errMsg) != 0)
  1049. {
  1050. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  1051. Global.writeLog(rtnResult);
  1052. MessageBox.Show(errMsg);
  1053. }
  1054. //返回给HIS
  1055. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo"));
  1056. if (hIS.returnInpatSettlementInfo(joParam, joSetlinfo, out outParam) != 0)
  1057. {
  1058. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  1059. return rtnResult;
  1060. }
  1061. else
  1062. {
  1063. //返回给前端
  1064. JObject joHisServieRtn = JObject.Parse(outParam);
  1065. hBus.returnToFrontEndAfterSettlement(jo2304Rtn, joHisServieRtn, out outParam);
  1066. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  1067. return rtnResult;
  1068. }
  1069. }
  1070. }
  1071. }
  1072. case "Z5C"://住院结算撤销
  1073. {
  1074. //查询结算表
  1075. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and Hospital_Dr=" + Global.inf.hospitalDr
  1076. + " and Adm_Dr='" + Global.pat.adm_Dr + "'"
  1077. + " and MdtrtID='" + Global.pat.mdtrtID + "'"
  1078. + " Order By ID DESC ";
  1079. JObject joSql = new JObject();
  1080. joSql.Add("sqlStr", sqlStr);
  1081. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  1082. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  1083. //{
  1084. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  1085. // return rtnResult;
  1086. //}
  1087. //MessageBox.Show(joSettlInfo.ToString());
  1088. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  1089. Global.pat.SettID_YBJSB = JsonHelper.getDestValue(joSettlInfo, "result.data[0].SettlementID");
  1090. if (Global.pat.settlID != Global.pat.SettID_YBJSB)
  1091. {
  1092. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "通过09010059服务获取到的SettlementID<" + Global.pat.settlID + ">与DLL通过SQL语句" +
  1093. joSql + ",获取到的SettlementID<" + Global.pat.SettID_YBJSB + ">不同,可能存在HIS单边账,请联系医保开发人员处理该笔结算记录!").ToString();
  1094. //return rtnResult;
  1095. }
  1096. Global.pat.settlID = Global.pat.SettID_YBJSB;
  1097. //取消中心结算信息
  1098. if (cBus.cancleSettlement("2305", out outParam) != 0)
  1099. {
  1100. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算信息失败!", outParam).ToString();
  1101. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  1102. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  1103. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  1104. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  1105. JObject joSqlStr = new JObject();
  1106. joSqlStr.Add("sqlStr", SqlStr);
  1107. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  1108. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  1109. if (jaCancleSettlInfo.Count == 1)
  1110. {
  1111. //询问收款员是否继续进行HIS退费
  1112. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  1113. {
  1114. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  1115. }
  1116. }
  1117. else
  1118. {
  1119. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  1120. }
  1121. return rtnResult;
  1122. }
  1123. else
  1124. {
  1125. //退结算会返一个新的ID
  1126. string newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  1127. //取消平台结算信息
  1128. if (mIS.cancleSettlement(newSettleID, out outParam) != 0)
  1129. {
  1130. rtnResult = JsonHelper.setExceptionJson(-1, "中心结算取消成功,医保平台结算信息取消失败!", outParam).ToString();
  1131. return rtnResult;
  1132. }
  1133. //中心取消传送
  1134. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  1135. {
  1136. //rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  1137. //return rtnResult;
  1138. }
  1139. //云平台取消传送
  1140. if (mIS.deleteFee(out errMsg) != 0)
  1141. {
  1142. //rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  1143. //return rtnResult;
  1144. }
  1145. //取消HIS医保结算信息
  1146. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  1147. {
  1148. rtnResult = JsonHelper.setExceptionJson(-1, "中心跟医保平台结算取消成功, 取消HIS结算信息失败!", outParam).ToString();
  1149. return rtnResult;
  1150. }
  1151. //取消出院登记
  1152. if (cBus.cancleRegister("2405", out outParam) != 0)
  1153. {
  1154. rtnResult = JsonHelper.setExceptionJson(0, "中心,医保平台及HIS结算信息取消成功,取消出院登记失败!请手工取消出院登记!", outParam).ToString();
  1155. return rtnResult;
  1156. }
  1157. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  1158. return rtnResult;
  1159. }
  1160. }
  1161. default:
  1162. {
  1163. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
  1164. return rtnResult;
  1165. }
  1166. }
  1167. return rtnResult;
  1168. }
  1169. catch (Exception ex)
  1170. {
  1171. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
  1172. return rtnResult;
  1173. }
  1174. finally
  1175. {
  1176. Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
  1177. }
  1178. }
  1179. /// <summary>
  1180. /// 自助机
  1181. /// </summary>
  1182. /// <param name="InParam"></param>
  1183. /// <returns></returns>
  1184. public string SelfServiceMachine(string InParam)
  1185. {
  1186. Global.writeLog("SelfServiceMachine 入参:" + JsonHelper.Compress(InParam));
  1187. //设置返回值,错误信息
  1188. string errMsg, rtnResult = "", outParam;
  1189. try
  1190. {
  1191. //解析入参
  1192. if (parseInparam(InParam, out errMsg) != 0)
  1193. {
  1194. rtnResult = JsonHelper.setExceptionJson(-1, "parseInparam", errMsg).ToString();
  1195. return rtnResult;
  1196. }
  1197. //获取pat
  1198. hBus.GetSelfServiceMachineInfo(businessType, joInParam, out Global.pat);
  1199. //BS架构调用方式问题,每次调用都需要重新初始化
  1200. if (init(InParam, out errMsg) != 0)
  1201. //if (hBus.InitA(InParam, out errMsg) != 0)
  1202. {
  1203. rtnResult = JsonHelper.setExceptionJson(-1, "InitA", errMsg).ToString(); ;
  1204. return rtnResult;
  1205. }
  1206. else
  1207. {
  1208. //joInParam.Add("patInfo", errMsg);
  1209. Global.writeLog($"InitA初始化成功!");
  1210. }
  1211. switch (businessType)
  1212. {
  1213. case "GetPatientInfo"://读取患者信息,该节点无需重定向
  1214. {
  1215. //重定向
  1216. Business.Core.SelfServiceMachine.PatientService patientService = new Business.Core.SelfServiceMachine.PatientService();
  1217. rtnResult = patientService.GetPatientInfo();
  1218. break;
  1219. }
  1220. case "OPReg"://门诊挂号
  1221. {
  1222. #region 链条式任务调度者
  1223. OPRegService service = new OPRegService();
  1224. rtnResult = service.Charge(Global.Set.operationType.ToString(), joInParam);
  1225. break;
  1226. #endregion
  1227. }
  1228. case "OPSettl"://门诊结算
  1229. {
  1230. OPSettlementService service = new OPSettlementService();
  1231. rtnResult = service.Charge(Global.Set.operationType.ToString(), joInParam);
  1232. break;
  1233. }
  1234. case "IPInReg"://入院登记
  1235. {
  1236. IPAdmRegService service = new IPAdmRegService();
  1237. rtnResult = service.Register(Global.Set.operationType.ToString(), joInParam);
  1238. break;
  1239. }
  1240. case "IPInRegCancel"://取消入院登记
  1241. {
  1242. IPAdmRegService service = new IPAdmRegService();
  1243. rtnResult = service.CancelRegister(Global.Set.operationType.ToString(), joInParam);
  1244. break;
  1245. }
  1246. case "IPOutReg"://出院登记
  1247. {
  1248. break;
  1249. }
  1250. case "IPUpoload"://住院费用上传
  1251. {
  1252. break;
  1253. }
  1254. case "IPPreSettl"://住院预计结算
  1255. {
  1256. break;
  1257. }
  1258. case "IPSettl"://住院结算
  1259. {
  1260. IPSettlementService service = new IPSettlementService();
  1261. rtnResult = service.Charge(joInParam);
  1262. return rtnResult;
  1263. }
  1264. case "DischargeAudit"://费用核查
  1265. {
  1266. DischargeAuditService service = new DischargeAuditService();
  1267. rtnResult = service.Audit(joInParam);
  1268. return rtnResult;
  1269. }
  1270. default:
  1271. {
  1272. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", "传入的业务编码不对!").ToString();
  1273. return rtnResult;
  1274. }
  1275. }
  1276. return rtnResult;
  1277. }
  1278. catch (Exception ex)
  1279. {
  1280. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", ex.Message).ToString();
  1281. return rtnResult;
  1282. }
  1283. finally
  1284. {
  1285. Global.writeLog("SelfServiceMachine 出参:" + JsonHelper.Compress(rtnResult));
  1286. }
  1287. }
  1288. //[STAThread]
  1289. //public void print(JObject joInParam)
  1290. //{
  1291. // //显示打印界面
  1292. // SettlementChecklist frmSettlList;
  1293. // string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1294. // if (insuAdmObj == "")
  1295. // {
  1296. // frmSettlList = new SettlementChecklist();
  1297. // }
  1298. // else
  1299. // {
  1300. // JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1301. // frmSettlList = new SettlementChecklist(joInsuAdmObj);
  1302. // }
  1303. // if (frmSettlList.ShowDialog() == DialogResult.OK)
  1304. // {
  1305. // };
  1306. //}
  1307. //[STAThread]
  1308. /// <summary>
  1309. /// 辅助交易
  1310. /// </summary>
  1311. /// <param name="InParam"></param>
  1312. /// <returns></returns>
  1313. public string AgentFun(string InParam)
  1314. {
  1315. Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
  1316. //设置返回值,错误信息
  1317. int errCode;
  1318. string errMsg, rtnResult = "", outParam;
  1319. try
  1320. {
  1321. //解析入参
  1322. if (parseInparam(InParam, out errMsg) != 0)
  1323. {
  1324. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1325. return rtnResult;
  1326. }
  1327. //BS架构调用方式问题,每次调用都需要重新初始化
  1328. if (init(InParam, out outParam) != 0)
  1329. {
  1330. rtnResult = outParam;
  1331. return rtnResult;
  1332. }
  1333. //获取pat
  1334. //hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  1335. switch (businessType)
  1336. {
  1337. case "BasicData"://基础数据维护
  1338. {
  1339. BasicData bd = new BasicData();
  1340. bd.ShowDialog();
  1341. break;
  1342. }
  1343. case "Exception"://异常处理
  1344. {
  1345. //显示异常处理界面
  1346. HandleException frmEX = new HandleException();
  1347. if (frmEX.ShowDialog() == DialogResult.OK)
  1348. {
  1349. }
  1350. break;
  1351. }
  1352. case "CheckAndClearing"://对账清算
  1353. {
  1354. //Clearing frmEX = new Clearing();
  1355. //if (frmEX.ShowDialog() == DialogResult.OK)
  1356. //{
  1357. //}
  1358. //break;
  1359. STA sta = new STA();
  1360. Thread thread = new Thread(sta.CheckAndClearing);
  1361. thread.SetApartmentState(ApartmentState.STA); //重点
  1362. thread.IsBackground = true;
  1363. thread.Start();
  1364. thread.Join();
  1365. break;
  1366. }
  1367. case "Print"://打印
  1368. {
  1369. //显示打印界面
  1370. SettlementBillPrint frmSettlList;
  1371. string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1372. if (insuAdmObj == "")
  1373. {
  1374. frmSettlList = new SettlementBillPrint();
  1375. frmSettlList.ShowDialog();
  1376. }
  1377. else
  1378. {
  1379. JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1380. frmSettlList = new SettlementBillPrint(joInsuAdmObj);
  1381. string groupID = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "groupID");
  1382. DataTable dt = (DataTable)frmSettlList.dgvSettlRecord.DataSource;
  1383. CardReader CardRead = new CardReader();
  1384. string sOutPar;
  1385. CardRead.FastReportPrint(out sOutPar);
  1386. if (JsonHelper.getDestValue(JObject.Parse(sOutPar), "code") != "0")
  1387. {
  1388. return JsonHelper.setIrisReturnValue(0, "调用FastReportDLL失败", null).ToString();
  1389. }
  1390. if (dt.Rows.Count != 1)
  1391. {
  1392. frmSettlList.ShowDialog();
  1393. }
  1394. else
  1395. {
  1396. frmSettlList.btnPrint_Click(null, null);
  1397. }
  1398. }
  1399. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  1400. break;
  1401. }
  1402. case "Log"://日志
  1403. {
  1404. MessageBox.Show(businessType);
  1405. break;
  1406. }
  1407. case "RecordUpload"://上传记录
  1408. {
  1409. MessageBox.Show(businessType);
  1410. break;
  1411. }
  1412. case "HospitalRegister"://备案
  1413. {
  1414. ToRecordChoose Referral = new ToRecordChoose();
  1415. Referral.ShowDialog();
  1416. break;
  1417. }
  1418. case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
  1419. {
  1420. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1421. Global.pat.psn_no = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].patn_id");
  1422. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].poolarea");
  1423. Global.pat.insuType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].insutype");
  1424. Global.pat.medType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].med_type");
  1425. JObject joResult = new JObject();
  1426. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  1427. //事前分析
  1428. if (Global.curEvt.ext.isOpenAnalysis)
  1429. {
  1430. if (hBus.PreAnalysis("5", joResult.ToString(), out errMsg) != 0)
  1431. {
  1432. MessageBox.Show(errMsg);
  1433. break;
  1434. }
  1435. }
  1436. break;
  1437. }
  1438. case "PreAndInProcessAnalysisNew"://事前分析 诊间只有住院的事前分析
  1439. {
  1440. if (!Global.curEvt.ext.isOpenAnalysis)
  1441. {
  1442. rtnResult = JsonHelper.setIrisReturnValue(-1, "事前事中服务接口未开启", null).ToString();
  1443. break;
  1444. }
  1445. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1446. Global.pat.mdtrtID = JsonHelper.getDestValue(joInParam, "insuAdmObj.mdtrt_id");
  1447. Global.pat.psn_no = JsonHelper.getDestValue(joInParam, "insuAdmObj.psn_no");
  1448. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].poolarea");
  1449. Global.pat.insuType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].insutype");
  1450. //Global.pat.medType = JsonHelper.getDestValue(joInParam, "params[0].insuData.patient_dtos[0].fsi_encounter_dtos[0].med_type");
  1451. JObject joResult = new JObject();
  1452. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  1453. //场景
  1454. string scen = JsonHelper.getDestValue(joInsuAdmObj, "scen");
  1455. List<int> admTypeArr = new List<int>();
  1456. string trig_scen = "";
  1457. hBus.getPreAndInProcessConfingure();
  1458. if (scen == "门诊医嘱保存")
  1459. {
  1460. admTypeArr = new List<int> { 3, 4 };
  1461. trig_scen = Global.pat.preAndInPro.OPOrderTrigScen;
  1462. Global.pat.medType = Global.pat.preAndInPro.OPMedType;
  1463. }
  1464. else
  1465. {
  1466. admTypeArr = new List<int> { 1, 2 };
  1467. trig_scen = Global.pat.preAndInPro.IPOrderTrigScen;
  1468. Global.pat.medType = Global.pat.preAndInPro.IPMedType;
  1469. }
  1470. //查询患者的医保登记信息
  1471. if (String.IsNullOrEmpty(Global.pat.mdtrtID))
  1472. {
  1473. rtnResult = JsonHelper.setIrisReturnValue(-1, "未获取到患者的医保就诊ID.请检查该患者是否已经进行了医保登记!", null).ToString();
  1474. break;
  1475. }
  1476. if (mIS.queryRegisterInfo(admTypeArr, out errMsg) != 0)
  1477. {
  1478. rtnResult = JsonHelper.setExceptionJson(-1, "查询医保登记信息!", errMsg).ToString();
  1479. break;
  1480. }
  1481. JObject joReg = JObject.Parse(errMsg);
  1482. if ((JsonHelper.getDestValue(joReg, "data") == "") || (JsonHelper.getDestValue(joReg, "data") == "{}"))
  1483. {
  1484. rtnResult = JsonHelper.setIrisReturnValue(-1, "查询医保登记信息返回值为空!", null).ToString();
  1485. break;
  1486. }
  1487. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode");
  1488. PreAndInProcessAnalysis preAnalysis = new PreAndInProcessAnalysis(joResult.ToString());
  1489. if (preAnalysis.setPatientByHisBaseInfo(out errMsg) != 0)
  1490. {
  1491. rtnResult = JsonHelper.setIrisReturnValue(-1, "医生站事前服务" + errMsg, null).ToString();
  1492. break;
  1493. }
  1494. JObject jo3101Out = new JObject();
  1495. if (preAnalysis.Get3101Inpar(trig_scen, Global.pat, out jo3101Out, out errMsg) != 0)
  1496. {
  1497. rtnResult = JsonHelper.setIrisReturnValue(-1, "获取3101入参" + errMsg, null).ToString();
  1498. break;
  1499. }
  1500. JObject joRtn = invoker.invokeCenterService(TradeEnum.PreAnalysis, (JObject)JsonHelper.ConvertValuesToString(jo3101Out));
  1501. // 记录3101交易日志
  1502. PreAndInProcessAnalysisLogService logService = new PreAndInProcessAnalysisLogService();
  1503. string logErrMsg;
  1504. logService.LogPreInProcessAnalysis("3101", "事前分析", trig_scen, jo3101Out, joRtn, out logErrMsg);
  1505. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1506. {
  1507. rtnResult = JsonHelper.setIrisReturnValue(-1, "医生站事前服务" + errMsg, null).ToString();
  1508. break;
  1509. }
  1510. else
  1511. {
  1512. rtnResult = JsonHelper.setIrisReturnValue(0, "医生站事前服务" + errMsg, joRtn).ToString();
  1513. }
  1514. break;
  1515. }
  1516. default:
  1517. {
  1518. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对!").ToString();
  1519. return rtnResult;
  1520. }
  1521. }
  1522. return rtnResult;
  1523. }
  1524. catch (Exception ex)
  1525. {
  1526. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
  1527. return rtnResult;
  1528. }
  1529. finally
  1530. {
  1531. Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
  1532. }
  1533. }
  1534. public string Download(string InParam)
  1535. {
  1536. Global.writeLog("Download 入参:" + JsonHelper.Compress(InParam));
  1537. //设置返回值,错误信息
  1538. int errCode;
  1539. string errMsg, rtnResult = "", outParam;
  1540. try
  1541. {
  1542. //解析入参
  1543. if (parseInparam(InParam, out errMsg) != 0)
  1544. {
  1545. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1546. return rtnResult;
  1547. }
  1548. //BS架构调用方式问题,每次调用都需要重新初始化
  1549. if (init(InParam, out outParam) != 0)
  1550. {
  1551. rtnResult = outParam;
  1552. return rtnResult;
  1553. }
  1554. dynamic joData = new JObject();
  1555. joData.data = joParam["data"];
  1556. //string code = (string)joInParam["code"];
  1557. string funNO = (string)joParam["funNO"];
  1558. switch (businessType)
  1559. {
  1560. case "DirectoryDownload":
  1561. {
  1562. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1563. rtnResult = hBus.DownloadDirectory(funNO, downloadParam).ToString();
  1564. break;
  1565. }
  1566. case "DictionayDownload":
  1567. {
  1568. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1569. rtnResult = hBus.downDictionary(downloadParam);
  1570. break;
  1571. }
  1572. }
  1573. return rtnResult;
  1574. }
  1575. catch (Exception ex)
  1576. {
  1577. rtnResult = JsonHelper.setExceptionJson(-100, "Download", ex.Message).ToString();
  1578. return rtnResult;
  1579. }
  1580. finally
  1581. {
  1582. Global.writeLog("Download 出参:" + rtnResult);
  1583. }
  1584. }
  1585. public string PlatformDirectConnect(string InParam)
  1586. {
  1587. //设置返回值,错误信息
  1588. int errCode;
  1589. string errMsg, rtnResult = "", outParam;
  1590. try
  1591. {
  1592. Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
  1593. //解析入参
  1594. if (parseInparam(InParam, out errMsg) != 0)
  1595. {
  1596. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1597. return rtnResult;
  1598. }
  1599. Global.businessType = businessType;
  1600. string funNO = JsonHelper.getDestValue(joInParam, "funNO");
  1601. //BS架构调用方式问题,每次调用都需要重新初始化
  1602. if (init(InParam, out outParam) != 0)
  1603. {
  1604. rtnResult = outParam;
  1605. return rtnResult;
  1606. }
  1607. if (funNO=="4101Y")
  1608. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joInParam, "insuplc_admdvs");
  1609. JObject joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joParam));
  1610. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1611. {
  1612. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
  1613. return rtnResult;
  1614. }
  1615. else
  1616. {
  1617. rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
  1618. return rtnResult;
  1619. }
  1620. }
  1621. catch (Exception ex)
  1622. {
  1623. rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
  1624. return rtnResult;
  1625. }
  1626. finally
  1627. {
  1628. Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
  1629. }
  1630. }
  1631. }
  1632. }