InsuBusiness.cs 106 KB

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