InsuBusiness.cs 81 KB

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