InsuBusiness.cs 94 KB

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