InsuBusiness.cs 90 KB

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