InsuBusiness.cs 128 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535
  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 HuBeiMI.Forms;
  17. using System.Collections;
  18. using System.Data.SqlTypes;
  19. //using PTMedicalInsurance.Forms.ElectronicSettlementCertificates;
  20. using System.Threading;
  21. using FastReport.Editor;
  22. using PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler;
  23. using PTMedicalInsurance.Business.Core.Forms.DischargeAudit;
  24. namespace PTMedicalInsurance
  25. {
  26. public class InsuBusiness : IInsuBusiness
  27. {
  28. //定义相关的变量
  29. private Patients patient;
  30. private Fees fee;
  31. private Settlements settlement;
  32. //json对象属性
  33. private JObject joInParam;
  34. private JArray jaSession ;
  35. private JArray jaParams;
  36. private JObject joParam;
  37. private JObject joInterface;
  38. private JObject joInsuAdmObj;
  39. private JObject joParamA;//临时进销存使用
  40. JObject joParam992001;//临时进销存使用
  41. JObject joParam992002;//临时进销存使用
  42. JObject joParam992004;//临时进销存使用
  43. //设置业务实例
  44. CenterBusiness cBus = new CenterBusiness();
  45. HisMainBusiness hBus = new HisMainBusiness();
  46. HisIrisServices hIS = new HisIrisServices();
  47. MIIrisServices mIS= new MIIrisServices();
  48. InvokeHelper invoker = new InvokeHelper();
  49. //
  50. private string businessType;
  51. private string operationType;
  52. public InsuBusiness()
  53. {
  54. Global.curEvt.path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
  55. ComputerInfo comp = new ComputerInfo();
  56. Global.curEvt.mac = comp.GetMAC();
  57. Global.curEvt.ip = comp.GetIP(); //"10.1.4.100";
  58. Global.pat.insuplc_admdvs = ""; //如果是NULL中心会报错
  59. }
  60. private int parseInparam(string inParam,out string errMsg)
  61. {
  62. errMsg = "";
  63. try
  64. {
  65. joInParam = JObject.Parse(inParam);
  66. jaSession = JArray.Parse(JsonHelper.getDestValue(joInParam, "session"));
  67. Global.curEvt.jaSession = jaSession;
  68. jaParams = JArray.Parse(JsonHelper.getDestValue(joInParam, "params"));
  69. joParam = JObject.FromObject(jaParams[0]);
  70. if (JsonHelper.getDestValue(joInParam, "insuAdmObj") != "")
  71. joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInParam, "insuAdmObj"));
  72. joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
  73. Global.pat.insuplc_admdvs= JsonHelper.getDestValue(joInParam, "insuplc_admdvs");
  74. businessType = JsonHelper.getDestValue(joInParam, "businessType");
  75. return 0;
  76. }
  77. catch (Exception ex)
  78. {
  79. errMsg = "parseInparam 解析入参异常:" + errMsg;
  80. return -1;
  81. }
  82. }
  83. /// <summary>
  84. /// 签到
  85. /// </summary>
  86. /// <param name="InParam"></param>
  87. /// <returns></returns>
  88. public string Init(string InParam)
  89. {
  90. string errMsg, rtnResult ="";
  91. JObject joRtn = new JObject();
  92. try
  93. {
  94. if (hBus.initEnvironment(InParam, out errMsg) != 0)
  95. {
  96. return JsonHelper.setExceptionJson(-100, "initEnvironment 失败", errMsg).ToString();
  97. }
  98. else
  99. {
  100. //if (businessType != "BasicData") //医保对照不需要调用签到交易
  101. if ((businessType != "BasicData") && (businessType != "M6") && (businessType != "M6C") && (businessType != "M6Confirm") && (businessType != "M6CallBack"))
  102. {
  103. if (mIS.isSigned(ref Global.curEvt.signno) != true)
  104. {
  105. //签到
  106. if (cBus.signIn(out joRtn) != 0)
  107. {
  108. rtnResult = JsonHelper.setExceptionJson(-1, "签到异常", (string)joRtn["err_msg"]).ToString();
  109. return rtnResult;
  110. }
  111. else
  112. {
  113. Global.curEvt.signno = JsonHelper.getDestValue(joRtn, "output.signinoutb.sign_no");
  114. //插入签到表
  115. if (mIS.saveSignRecord(Global.curEvt.signno, out errMsg) != 0)
  116. {
  117. rtnResult = JsonHelper.setIrisReturnValue(0, "中心签到成功但插入签到表失败:" + errMsg, null).ToString();
  118. }
  119. else
  120. {
  121. rtnResult = JsonHelper.setIrisReturnValue(0, "签到成功", joRtn).ToString();
  122. }
  123. }
  124. }
  125. else
  126. {
  127. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
  128. }
  129. }
  130. else
  131. {
  132. Global.curEvt.signno = "abc123";
  133. rtnResult = JsonHelper.setIrisReturnValue(0, "初始化成功!", null).ToString();
  134. }
  135. return rtnResult;
  136. }
  137. }
  138. catch (Exception ex)
  139. {
  140. rtnResult = JsonHelper.setExceptionJson(-100, "Init 异常", ex.Message).ToString();
  141. return rtnResult;
  142. }
  143. finally
  144. {
  145. Global.writeLog("初始化结果:" + rtnResult);
  146. }
  147. }
  148. /// <summary>
  149. /// 初始化
  150. /// </summary>
  151. /// <param name="inParam"></param>
  152. /// <param name="outParam"></param>
  153. /// <returns></returns>
  154. private int init(string inParam, out string outParam)
  155. {
  156. string errMsg;
  157. outParam = "";
  158. try
  159. {
  160. //BS架构调用方式问题,每次调用都需要重新初始化
  161. JObject joInitRtn = JObject.Parse(Init(inParam));
  162. if (JsonHelper.parseIrisRtnValue(joInitRtn, out errMsg) != 0)
  163. {
  164. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)", errMsg).ToString();
  165. return -1;
  166. }
  167. else
  168. {
  169. return 0;
  170. }
  171. }
  172. catch (Exception ex)
  173. {
  174. outParam = JsonHelper.setExceptionJson(-100, "init(HIS医保环境初始化)异常", ex.Message).ToString();
  175. return -1;
  176. }
  177. }
  178. /// <summary>
  179. /// 获取患者信息
  180. /// </summary>
  181. /// <param name="InParam"></param>
  182. /// <returns></returns>
  183. public string GetPatientInfo(string InParam)
  184. {
  185. Global.writeLog("GetPatientInfo入参:" + JsonHelper.Compress(InParam));
  186. //设置返回值,错误信息
  187. int errCode;
  188. string errMsg, rtnResult = "",outParam;
  189. //BS架构调用方式问题,每次调用都需要重新初始化
  190. if (init(InParam,out outParam)!= 0)
  191. {
  192. rtnResult = outParam;
  193. return rtnResult;
  194. }
  195. JObject joInParam = JObject.Parse(InParam);
  196. string businessType = JsonHelper.getDestValue(joInParam,"businessType");
  197. try
  198. {
  199. switch (businessType)
  200. {
  201. case "M1"://门诊读卡
  202. {
  203. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  204. if (hBus.readCard(out outParam) != 0)
  205. {
  206. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  207. }
  208. else
  209. {
  210. //展示患者信息界面
  211. if (hBus.showPatInfo(outParam, out outParam) != 0)
  212. {
  213. rtnResult = outParam;
  214. }
  215. else
  216. {
  217. rtnResult = JsonHelper.setIrisReturnValue(0, "", JObject.Parse(outParam)).ToString();
  218. }
  219. }
  220. break;
  221. }
  222. case "Z1"://住院读卡
  223. {
  224. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  225. if (hBus.readCard(out outParam) != 0)
  226. {
  227. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  228. }
  229. else
  230. {
  231. //住院提示特殊人员标识:JsonHelper.getDestValue(JObject.Parse(outParam), "output.exp_content.ectoken");
  232. string patInfo = outParam;
  233. //展示患者信息界面
  234. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  235. {
  236. string idtype = JsonHelper.getDestValue(JObject.Parse(outParam), "output.selectedIdInfo.psn_idet_type");
  237. if (idtype != null)
  238. {
  239. string[] s1 = new string[8] { "9937", "230705", "211112", "236022", "230508", "236018", "2304", "2303" };//武汉乡村振兴人员身份类别
  240. if (s1.Contains(idtype))
  241. {
  242. MessageBox.Show("该人员存在特殊人员身份为" + idtype);
  243. }
  244. }
  245. rtnResult = outParam;
  246. }
  247. else
  248. {
  249. rtnResult = JsonHelper.setIrisReturnValue(0,"",JObject.Parse(outParam)).ToString();
  250. }
  251. }
  252. break;
  253. }
  254. }
  255. return rtnResult;
  256. }
  257. catch (Exception ex)
  258. {
  259. rtnResult = JsonHelper.setIrisReturnValue(-1 , "GetPatientInfo发生异常;" + ex.Message,null).ToString();
  260. return rtnResult;
  261. }
  262. finally
  263. {
  264. Global.writeLog("GetPatientInfo出参:" + JsonHelper.Compress(rtnResult));
  265. }
  266. }
  267. /// <summary>
  268. /// 登记
  269. /// </summary>
  270. /// <param name="InParam"></param>
  271. /// <returns></returns>
  272. public string Register(string InParam)
  273. {
  274. Global.writeLog("Register 入参:" + JsonHelper.Compress(InParam));
  275. //设置返回值,错误信息
  276. string errMsg, rtnResult = "", outParam;
  277. try
  278. {
  279. //解析入参
  280. if (parseInparam(InParam, out errMsg) != 0)
  281. {
  282. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  283. return rtnResult;
  284. }
  285. //BS架构调用方式问题,每次调用都需要重新初始化
  286. if (init(InParam, out outParam) != 0)
  287. {
  288. rtnResult = outParam;
  289. return rtnResult;
  290. }
  291. //获取pat
  292. hBus.GetRegPatInfo(businessType, joInParam, out Global.pat);
  293. switch (businessType)
  294. {
  295. case "M2"://门诊登记
  296. {
  297. break;
  298. }
  299. case "M2C"://门诊登记撤销
  300. {
  301. break;
  302. }
  303. case "Z0"://住院修改
  304. {
  305. break;
  306. }
  307. case "Z2"://入院登记
  308. {
  309. Global.writeLog(Global.pat.insuType);
  310. string regInParam = "";
  311. //校验HIS姓名与医保姓名是否一致
  312. if (hBus.checkName(Global.pat.name, out errMsg) != 0)
  313. {
  314. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  315. return rtnResult;
  316. }
  317. //显示登记面板
  318. if (hBus.showInPatRegisterForm( out regInParam) == 0)
  319. {
  320. Global.writeLog(regInParam);
  321. JObject joRegIn_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2401", regInParam));
  322. JObject joRegIn = JObject.Parse(JsonHelper.setCenterInpar("2401", regInParam));
  323. //上传给中心
  324. JObject joRegOut = invoker.invokeCenterService("2401", joRegIn);
  325. //将中心返回的结果返回HIS,调用HIS服务进行保存
  326. if (JsonHelper.parseCenterRtnValue(joRegOut,out errMsg) == 0)
  327. {
  328. joRegOut.Add("validflag",1);
  329. joRegOut.Add("regstate", 1);
  330. joRegOut.Add("type", 1);
  331. Global.pat.mdtrtID = JsonHelper.getDestValue(joRegOut, "output.result.mdtrt_id");
  332. //插入患者本次就诊用的参保信息
  333. if (hBus.insertPatCurInsuInfo(JsonHelper.getDestValue(joParam, "patientInfo"), out outParam) != 0)
  334. {
  335. if (DialogResult.Yes == MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  336. {
  337. }
  338. else
  339. {
  340. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!", outParam).ToString();
  341. return rtnResult;
  342. }
  343. }
  344. //插入医保平台
  345. if (mIS.saveInpatRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  346. {
  347. rtnResult = JsonHelper.setExceptionJson(-1, "云平台保存登记信息", outParam).ToString();
  348. return rtnResult;
  349. }
  350. //返回登记信息,插入HIS
  351. if (hIS.returnRegisterInfo(joRegIn_plain, joRegOut, out outParam) != 0)
  352. {
  353. rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
  354. return rtnResult;
  355. }
  356. else
  357. {
  358. rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
  359. return rtnResult;
  360. }
  361. }
  362. else
  363. {
  364. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", errMsg).ToString();
  365. return rtnResult;
  366. }
  367. }
  368. else
  369. {
  370. rtnResult = JsonHelper.setExceptionJson(-1, "展示登记界面", regInParam).ToString();
  371. return rtnResult;
  372. }
  373. }
  374. case "Z2C"://入院登记取消
  375. {
  376. //if (DialogResult.Yes == MessageBox.Show("即将进行取消中心医保登记,确定继续吗?", " 询问? ", MessageBoxButtons.YesNo))
  377. //{
  378. //}
  379. //else
  380. //{
  381. // rtnResult = JsonHelper.setExceptionJson(-1, "收费员撤销取消登记操作!", outParam).ToString();
  382. // return rtnResult;
  383. //}
  384. //取消中心登记
  385. if (cBus.cancleRegister("2404", out outParam) != 0)
  386. {
  387. //如果医保中心没有HIS所传的医保登记信息则默认撤销HIS登记信息
  388. int i = outParam.IndexOf("不存在有效的就诊登记信息");
  389. if (i != 0)
  390. {
  391. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam+ ",是否强制撤销HIS医保登记信息?", "提示", MessageBoxButtons.YesNo))
  392. {
  393. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  394. return rtnResult;
  395. } else
  396. {
  397. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  398. return rtnResult;
  399. }
  400. }
  401. }
  402. //取消医保平台登记
  403. if (mIS.cancleRegister(1, out outParam) != 0)
  404. {
  405. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  406. return rtnResult;
  407. }
  408. //取消HIS 登记
  409. if (hIS.cancleRegister( out outParam) != 0)
  410. {
  411. rtnResult = JsonHelper.setExceptionJson(-1, "中心和云医保平台取消登记成功,但HIS取消失败,", outParam).ToString();
  412. return rtnResult;
  413. }
  414. else
  415. {
  416. //CM 20230602 删除医保平台医保费用明细上传表数据
  417. mIS.deleteFee(out errMsg);
  418. rtnResult = JsonHelper.setIrisReturnValue(0, "取消医保登记成功", null).ToString();
  419. return rtnResult;
  420. }
  421. }
  422. case "Z6"://出院登记
  423. {
  424. break;
  425. }
  426. case "Z6C"://出院登记取消
  427. {
  428. if (cBus.cancleRegister("2405", out errMsg) != 0)
  429. {
  430. rtnResult = JsonHelper.setExceptionJson(-1, "取消出院登记", errMsg).ToString();
  431. return rtnResult;
  432. }
  433. else
  434. {
  435. rtnResult = JsonHelper.setIrisReturnValue(0, "取消出院登记成功", null).ToString();
  436. return rtnResult;
  437. }
  438. break;
  439. }
  440. default:
  441. {
  442. rtnResult = JsonHelper.setExceptionJson(-1, "Register 交易", "传入的业务编码不对!").ToString();
  443. return rtnResult;
  444. }
  445. }
  446. }
  447. catch (Exception ex)
  448. {
  449. rtnResult = JsonHelper.setIrisReturnValue(-1, "Register 发生异常;" + ex.Message, null).ToString();
  450. return rtnResult;
  451. }
  452. finally
  453. {
  454. Global.writeLog("Register 出参:" + JsonHelper.Compress(rtnResult));
  455. }
  456. return "";
  457. }
  458. /// <summary>
  459. /// 费用上传
  460. /// </summary>
  461. /// <param name="InParam"></param>
  462. /// <returns></returns>
  463. public string FeeUpload(string InParam)
  464. {
  465. Global.writeLog("FeeUpload 入参:" + JsonHelper.Compress(InParam));
  466. //设置返回值,错误信息
  467. int errCode;
  468. string errMsg, rtnResult = "", outParam;
  469. try
  470. {
  471. //解析入参
  472. if (parseInparam(InParam, out errMsg) != 0)
  473. {
  474. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  475. return rtnResult;
  476. }
  477. //BS架构调用方式问题,每次调用都需要重新初始化
  478. if (init(InParam, out outParam) != 0)
  479. {
  480. rtnResult = outParam;
  481. return rtnResult;
  482. }
  483. //获取pat
  484. hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  485. switch (businessType)
  486. {
  487. case "M3"://门诊费用上传
  488. {
  489. break;
  490. }
  491. case "M3C"://门诊费用撤销
  492. {
  493. break;
  494. }
  495. case "Z3"://入院费用上传
  496. {
  497. ////事前分析
  498. if (Global.curEvt.ext.isOpenAnalysis)
  499. {
  500. if (hBus.PreAnalysis("4", "", out errMsg) != 0)
  501. {
  502. //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  503. //return rtnResult;
  504. DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  505. if (dr != DialogResult.OK)
  506. {
  507. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  508. return rtnResult;
  509. }
  510. }
  511. }
  512. //从医保平台获取患者详细的医保登记信息
  513. if (mIS.queryRegisterInfo(1, out outParam) != 0)
  514. {
  515. rtnResult = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  516. return rtnResult;
  517. }
  518. JObject joReg = JObject.Parse(outParam);
  519. Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
  520. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  521. //先取消中心费用传送
  522. cBus.cancleFeeUpload("2302", out errMsg);
  523. //再删除医保传送表的数据
  524. mIS.deleteFee( out errMsg);
  525. #region【住院费用上传前调用3101事前服务】
  526. //1.获取3101入参报文
  527. /* 20221207 CM 朱鹏飞要求屏蔽调用事前事中服务交易
  528. if (hIS.GetInsuPatInfo("5", Global.pat, out outParam) != 0)
  529. {
  530. rtnResult = JsonHelper.setExceptionJson(-1, "获取3101医保明细审核事前分析服务入参失败:", outParam).ToString();
  531. return rtnResult;
  532. }
  533. else
  534. {
  535. //2.调用医保3101明细审核事前分析服务
  536. JObject joInput = new JObject();
  537. joInput = JObject.Parse(outParam);
  538. JObject jo3101Rtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", joInput.ToString().Replace("\r\n", "")));
  539. if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
  540. {
  541. DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  542. if (dr != DialogResult.OK)
  543. {
  544. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  545. return rtnResult;
  546. }
  547. }
  548. }
  549. */
  550. #endregion
  551. //开始进行费用传送
  552. //调用HIS费用查询信息
  553. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  554. {
  555. rtnResult = JsonHelper.setExceptionJson(-1, "获取HIS费用", outParam).ToString();
  556. return rtnResult;
  557. }
  558. //调用医保平台转换
  559. JObject joHisFee = JObject.Parse(outParam);
  560. if (mIS.convertHisFeeWithInsuCode(joHisFee,out outParam) != 0)
  561. {
  562. rtnResult = JsonHelper.setExceptionJson(-1, "转换HIS费用", outParam).ToString();
  563. return rtnResult;
  564. }
  565. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  566. //按指定条数分割后上传,保存,更新
  567. if (hBus.uploadFeeToCenter("2301",10, jaFeeDetail, out outParam) != 0)
  568. {
  569. rtnResult = JsonHelper.setExceptionJson(-1, "上传费用", outParam).ToString();
  570. return rtnResult;
  571. }
  572. else
  573. {
  574. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传成功", null).ToString();
  575. return rtnResult;
  576. }
  577. }
  578. case "Z3C"://住院费用上传取消
  579. {
  580. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  581. {
  582. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  583. return rtnResult;
  584. }
  585. if (mIS.deleteFee( out errMsg) != 0)
  586. {
  587. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  588. return rtnResult;
  589. }
  590. else
  591. {
  592. rtnResult = JsonHelper.setIrisReturnValue(0, "住院费用上传取消成功", null).ToString();
  593. return rtnResult;
  594. }
  595. }
  596. default:
  597. {
  598. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", "传入的业务编码不对!").ToString();
  599. return rtnResult;
  600. }
  601. }
  602. return rtnResult;
  603. }
  604. catch (Exception ex)
  605. {
  606. rtnResult = JsonHelper.setExceptionJson(-1, "FeeUpload 交易", ex.Message).ToString();
  607. return rtnResult;
  608. }
  609. finally
  610. {
  611. Global.writeLog("FeeUpload 出参:" + JsonHelper.Compress(rtnResult));
  612. }
  613. }
  614. /// <summary>
  615. /// 结算
  616. /// </summary>
  617. /// <param name="InParam"></param>
  618. /// <returns></returns>
  619. public string Settlement(string InParam)
  620. {
  621. Global.writeLog("Settlement 入参:" + JsonHelper.Compress(InParam));
  622. //设置返回值,错误信息
  623. string errMsg, rtnResult = "", outParam;
  624. try
  625. {
  626. //解析入参
  627. if (parseInparam(InParam, out errMsg) != 0)
  628. {
  629. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  630. return rtnResult;
  631. }
  632. //BS架构调用方式问题,每次调用都需要重新初始化
  633. if (init(InParam, out outParam) != 0)
  634. {
  635. rtnResult = outParam;
  636. return rtnResult;
  637. }
  638. //获取pat
  639. hBus.GetSettlementHisInfo(businessType, joInParam, out Global.pat);
  640. switch (businessType)
  641. {
  642. case "M4"://门诊预结算
  643. {
  644. OutpatientRegistration frmReg = new OutpatientRegistration();
  645. if (frmReg.ShowDialog() == DialogResult.OK)
  646. {
  647. rtnResult = "调用结束";
  648. }
  649. break;
  650. }
  651. case "M4C"://门诊预结算撤销
  652. {
  653. break;
  654. }
  655. case "M5"://门诊结算
  656. {
  657. Global.pat.admType = 1;
  658. string patInfo ="";
  659. //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
  660. if (hBus.readCard(out outParam) != 0)
  661. {
  662. rtnResult = JsonHelper.setExceptionJson(-100, "读卡失败!", outParam).ToString();
  663. return rtnResult;
  664. }
  665. else
  666. {
  667. patInfo = outParam;
  668. //展示患者信息界面
  669. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  670. {
  671. rtnResult = outParam;
  672. return rtnResult;
  673. }
  674. }
  675. //患者信息赋值给全局变量
  676. patInfo = outParam;
  677. if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
  678. {
  679. rtnResult = JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString();
  680. return rtnResult;
  681. }
  682. //校验HIS姓名与医保姓名是否一致
  683. if (hBus.checkName(Global.pat.name,out errMsg) != 0)
  684. {
  685. rtnResult = JsonHelper.setExceptionJson(-1, "校验HIS与医保姓名是否一致", errMsg).ToString();
  686. return rtnResult;
  687. }
  688. //弹窗提示患者是否正常参保
  689. hBus.InsuMessage(out string InsuMess);
  690. MessageBox.Show(InsuMess,"参保信息提示");
  691. ////事前分析
  692. if (Global.curEvt.ext.isOpenAnalysis)
  693. {
  694. if (hBus.PreAnalysis("2", "", out errMsg) != 0) //事前事中:门诊挂号1 门诊收费登记2 住院登记3 住院收费登记4 住院执行医嘱5 门诊结算6 门诊预结算7 住院结算8 住院预结算9 购药划卡10
  695. {
  696. //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  697. //return rtnResult;
  698. DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  699. if (dr != DialogResult.OK)
  700. {
  701. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  702. return rtnResult;
  703. }
  704. }
  705. }
  706. //显示登记面板
  707. if (hBus.showOutPatRegisterForm(out outParam) != 0)
  708. {
  709. rtnResult = JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString();
  710. return rtnResult;
  711. }
  712. JObject joReg = JObject.Parse(outParam);
  713. //医保挂号
  714. JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  715. JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
  716. jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
  717. jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2201", jo2201Inpar_plain));
  718. //此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
  719. JObject jo2203Inpar = new JObject();
  720. JObject jo2203Inpar_plain = new JObject();
  721. jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
  722. jo2203Inpar.Add("diseinfo",JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
  723. JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
  724. if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
  725. {
  726. rtnResult = JsonHelper.setExceptionJson(-1, "医保挂号", errMsg).ToString();
  727. return rtnResult;
  728. }
  729. else
  730. {
  731. Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
  732. //插入患者本次就诊用的参保信息
  733. if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
  734. {
  735. if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
  736. {
  737. rtnResult = JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam).ToString();
  738. return rtnResult;
  739. }
  740. }
  741. jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
  742. jo2203Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203", jo2203Inpar));
  743. jo2203Inpar = JObject.Parse(JsonHelper.setCenterInpar("2203", jo2203Inpar));
  744. //门诊登记信息,插入云医保平台
  745. jo2201Rtn.Add("validflag", 1);
  746. jo2201Rtn.Add("regstate", 1);
  747. jo2201Rtn.Add("type", 3);
  748. Global.writeLog(jo2201Inpar_plain.ToString());
  749. if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203Inpar_plain, out errMsg) != 0)
  750. {
  751. rtnResult = JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString();
  752. return rtnResult;
  753. }
  754. //返回登记信息,插入HIS
  755. /* if (hIS.returnRegisterInfo(jo2201Inpar_plain, jo2201Rtn, out outParam) != 0)
  756. {
  757. rtnResult = JsonHelper.setExceptionJson(-1, "HIS平台保存登记信息", outParam).ToString();
  758. return rtnResult;
  759. }
  760. else
  761. {
  762. rtnResult = JsonHelper.setIrisReturnValue(0, "登记成功", null).ToString();
  763. return rtnResult;
  764. }*/
  765. }
  766. //门诊就诊信息上传
  767. JObject jo2203Rtn = invoker.invokeCenterService("2203",jo2203Inpar );
  768. if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
  769. {
  770. rtnResult = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
  771. return rtnResult;
  772. }
  773. #region【门诊就诊信息上传成功后调用3101事前服务】
  774. //1.获取3101入参报文
  775. /*
  776. if (hIS.GetInsuPatInfo("1", Global.pat, out outParam) != 0)
  777. {
  778. rtnResult = JsonHelper.setExceptionJson(-1, "获取3101医保明细审核事前分析服务入参失败:", outParam).ToString();
  779. return rtnResult;
  780. }
  781. else
  782. {
  783. //2.调用医保3101明细审核事前分析服务
  784. JObject joInput = new JObject();
  785. //joInput.Add("data", JObject.Parse(outParam));
  786. joInput = JObject.Parse(outParam);
  787. JObject jo3101Rtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", joInput.ToString().Replace("\r\n", ""))); //.Replace(" ", "")
  788. if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
  789. {
  790. DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  791. if (dr != DialogResult.OK)
  792. {
  793. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  794. return rtnResult;
  795. }
  796. }
  797. }
  798. */
  799. #endregion
  800. //费用上传
  801. if (hBus.uploadFee("2204", 50, out outParam) != 0)
  802. {
  803. rtnResult = JsonHelper.setExceptionJson(-1, "费用上传", outParam).ToString();
  804. return rtnResult;
  805. }
  806. #region【门诊预结算2206前调用3102医保明细审核事中服务】
  807. //1.获取3102入参报文
  808. /*
  809. if (hIS.GetInsuPatInfo("2", Global.pat, out outParam) != 0)
  810. {
  811. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  812. return rtnResult;
  813. }
  814. else
  815. {
  816. //2.调用医保3102明细审核事前分析服务
  817. JObject joInput = new JObject();
  818. //joInput.Add("data", JObject.Parse(outParam));
  819. joInput = JObject.Parse(outParam);
  820. JObject jo3101Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  821. if (JsonHelper.parseCenterRtnValue(jo3101Rtn, out errMsg) != 0)
  822. {
  823. DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  824. if (dr != DialogResult.OK)
  825. {
  826. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  827. return rtnResult;
  828. }
  829. }
  830. }
  831. */
  832. #endregion
  833. ////事中分析
  834. if (Global.curEvt.ext.isOpenAnalysis)
  835. {
  836. if (hBus.PreAnalysis("7", "", out errMsg) != 0) //事前事中:门诊挂号1 门诊收费登记2 住院登记3 住院收费登记4 住院执行医嘱5 门诊结算6 门诊预结算7 住院结算8 住院预结算9 购药划卡10
  837. {
  838. //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  839. //return rtnResult;
  840. DialogResult dr = MessageBox.Show("【3102】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  841. if (dr != DialogResult.OK)
  842. {
  843. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  844. return rtnResult;
  845. }
  846. }
  847. }
  848. //调用IRIS获取医保各项金额
  849. if (mIS.getSumFee(out outParam) != 0)
  850. {
  851. rtnResult = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outParam).ToString();
  852. return rtnResult;
  853. }
  854. JObject joSumFee = JObject.Parse(outParam);
  855. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joReg, "settlement"));
  856. //修改joSettlement的就诊ID ,总金额等
  857. joSettlement["mdtrt_id"] = Global.pat.mdtrtID;
  858. joSettlement["medfee_sumamt"] = JsonHelper.getDestValue(joSumFee, "data.Sumamt");
  859. //预结算2206
  860. if (hBus.preSettlement_OutPat(joSettlement, out outParam) != 0)
  861. {
  862. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  863. return rtnResult;
  864. }
  865. //正式结算
  866. JObject joData = new JObject();
  867. joData.Add("data",joSettlement);
  868. JObject joRtn = invoker.invokeCenterService("2207", JsonHelper.setCenterInpar("2207A", joData));
  869. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  870. {
  871. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  872. return rtnResult;
  873. }
  874. else
  875. {
  876. //返回给云医保平台结算信息
  877. if (mIS.saveSettlement(joRtn, out errMsg) != 0)
  878. {
  879. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  880. return rtnResult;
  881. }
  882. //返回给云医保平台结算明细信息
  883. if (mIS.saveSettlementDetail(joRtn, out errMsg) != 0)
  884. {
  885. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  886. return rtnResult;
  887. }
  888. //返回给HIS
  889. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(joRtn, "output.setlinfo"));
  890. if (hIS.returnOutpatSettlementInfo(joSettlement, joSetlinfo, out outParam) != 0)
  891. {
  892. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  893. return rtnResult;
  894. }
  895. else
  896. {
  897. JObject joHisServieRtn = JObject.Parse(outParam);
  898. hBus.returnToFrontEndAfterSettlement(joRtn, joHisServieRtn, out outParam);
  899. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  900. return rtnResult;
  901. }
  902. }
  903. }
  904. case "M5C"://门诊结算撤销
  905. {
  906. //查询HIS医保结算记录表获取该病人的参保地
  907. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and ValidFlag = 1 ";
  908. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  909. sqlStr = sqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  910. JObject joSql = new JObject();
  911. joSql.Add("sqlStr", sqlStr);
  912. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  913. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  914. //{
  915. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  916. // return rtnResult;
  917. //}
  918. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  919. //退中心结算
  920. string newSettleID = "";
  921. string balc = "";
  922. string setl_time = "";
  923. if (cBus.cancleSettlement("2208", out outParam) != 0)
  924. {
  925. int i = outParam.IndexOf("获取到的就诊信息为无效状态,不能办理结算撤销业务");
  926. if (i != 0)
  927. {
  928. if (DialogResult.Yes != MessageBox.Show("医保中心提示:" + outParam + ",是否强制撤销HIS结算信息?", "提示", MessageBoxButtons.YesNo))
  929. {
  930. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消结算失败,", outParam).ToString();
  931. return rtnResult;
  932. }
  933. newSettleID = "YC";
  934. }
  935. else
  936. {
  937. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算", outParam).ToString();
  938. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  939. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  940. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  941. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  942. JObject joSqlStr = new JObject();
  943. joSqlStr.Add("sqlStr", SqlStr);
  944. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  945. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  946. if (jaCancleSettlInfo.Count == 1)
  947. {
  948. //询问收款员是否继续进行HIS退费
  949. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  950. {
  951. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  952. }
  953. }
  954. else
  955. {
  956. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  957. }
  958. return rtnResult;
  959. }
  960. }
  961. else
  962. {
  963. newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  964. balc = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.balc");
  965. setl_time = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_time");
  966. }
  967. //string newSettleID = "10290453";
  968. //Global.pat.mdtrtID = "202210281547480034293700000000";
  969. //Global.pat.psn_no = "YX423049577";
  970. //Global.pat.settlID = "10290445";
  971. //退云医保平台结算
  972. if (mIS.cancleSettlement(newSettleID, balc, setl_time ,out outParam) != 0)
  973. {
  974. rtnResult = JsonHelper.setExceptionJson(-1, "取消平台结算信息", outParam).ToString();
  975. //return rtnResult;
  976. }
  977. if (newSettleID != "YC")
  978. {
  979. //中心取消传送
  980. if (cBus.cancleFeeUpload("2205", out errMsg) != 0)
  981. {
  982. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  983. //return rtnResult;
  984. }
  985. //云平台取消传送
  986. if (mIS.deleteFee(out errMsg) != 0)
  987. {
  988. rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  989. return rtnResult;
  990. }
  991. //取消中心登记
  992. if (cBus.cancleRegister("2202", out outParam) != 0)
  993. {
  994. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记失败,", outParam).ToString();
  995. //return rtnResult;
  996. }
  997. //取消医保平台登记
  998. if (mIS.cancleRegister(3, out outParam) != 0)
  999. {
  1000. rtnResult = JsonHelper.setExceptionJson(-1, "中心取消登记成功,但云医保平台取消失败,", outParam).ToString();
  1001. return rtnResult;
  1002. }
  1003. }
  1004. //退HIS结算
  1005. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  1006. {
  1007. rtnResult = JsonHelper.setExceptionJson(-1, "取消HIS结算信息", outParam).ToString();
  1008. return rtnResult;
  1009. }
  1010. else
  1011. {
  1012. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  1013. return rtnResult;
  1014. }
  1015. }
  1016. case "M6"://门诊移动支付结算
  1017. {
  1018. MobilePay mp = new MobilePay(InParam, out errMsg);
  1019. if (errMsg != "")
  1020. {
  1021. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易1", errMsg).ToString();
  1022. return rtnResult;
  1023. }
  1024. if (mp.MobilePaySettlement(out outParam) != 0)
  1025. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易2", outParam).ToString();
  1026. else
  1027. rtnResult = outParam;
  1028. return rtnResult;
  1029. }
  1030. case "M6C"://门诊移动支付结算撤销
  1031. {
  1032. string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
  1033. MobilePay mp = new MobilePay(InParam, out errMsg);
  1034. if (errMsg != "")
  1035. {
  1036. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易3", errMsg).ToString();
  1037. return rtnResult;
  1038. }
  1039. if (String.IsNullOrEmpty(onlineYBFalg))
  1040. mp.MSettl.onlineYBFalg = "N";
  1041. else
  1042. mp.MSettl.onlineYBFalg = onlineYBFalg;
  1043. if (mp.MobilePayCancelSettlement(out outParam) != 0)
  1044. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易4", outParam).ToString();
  1045. else
  1046. rtnResult = JsonHelper.setExceptionJson(0, "Settlement 交易5", outParam).ToString();
  1047. return rtnResult;
  1048. }
  1049. case "M6Confirm"://门诊移动支付确认
  1050. {
  1051. MobilePay mp = new MobilePay(InParam, out errMsg);
  1052. if (errMsg != "")
  1053. {
  1054. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易6", errMsg).ToString();
  1055. return rtnResult;
  1056. }
  1057. if (mp.MobilePayConfirmSettlement(out outParam) != 0)
  1058. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易7", outParam).ToString();
  1059. else
  1060. rtnResult = outParam;
  1061. return rtnResult;
  1062. }
  1063. case "M6CallBack"://门诊移动支付回调
  1064. {
  1065. JObject jo = JObject.Parse(InParam);
  1066. joInsuAdmObj = new JObject();
  1067. joInsuAdmObj.Add("payOrdId", "");
  1068. jo.Add("insuAdmObj", joInsuAdmObj);
  1069. MobilePay mp = new MobilePay(jo.ToString(), out errMsg);
  1070. if (errMsg != "")
  1071. {
  1072. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易8", errMsg).ToString();
  1073. return rtnResult;
  1074. }
  1075. if (mp.MobilePayCallbackSettlement(out outParam) != 0)
  1076. rtnResult = outParam;
  1077. else
  1078. rtnResult = outParam;
  1079. return rtnResult;
  1080. }
  1081. case "Z4"://住院预结算
  1082. {
  1083. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1084. //1.获取3102入参报文
  1085. /*
  1086. if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
  1087. {
  1088. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  1089. return rtnResult;
  1090. }
  1091. else
  1092. {
  1093. //2.调用医保3102明细审核事前分析服务
  1094. JObject joInput = new JObject();
  1095. joInput = JObject.Parse(outParam);
  1096. JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1097. if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1098. {
  1099. DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果2:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1100. if (dr != DialogResult.OK)
  1101. {
  1102. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1103. return rtnResult;
  1104. }
  1105. }
  1106. }
  1107. */
  1108. #endregion
  1109. Global.pat.RYorCY = "2";
  1110. Global.pat.admType = 2;
  1111. JObject joSettle = new JObject();
  1112. if (hBus.preSettlement("2303",out joSettle, out outParam) != 0)
  1113. {
  1114. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1115. return rtnResult;
  1116. }
  1117. else
  1118. {
  1119. rtnResult = JsonHelper.setIrisReturnValue(0, "预结算成功", null).ToString();
  1120. return rtnResult;
  1121. }
  1122. }
  1123. case "Z4C"://住院预结算撤销
  1124. {
  1125. rtnResult = JsonHelper.setExceptionJson(-100, "该接口不支持预结算取消!", null).ToString();
  1126. return rtnResult;
  1127. }
  1128. case "Z5"://住院结算
  1129. {
  1130. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1131. //1.获取3102入参报文
  1132. /*
  1133. if (hIS.GetInsuPatInfo("9", Global.pat, out outParam) != 0)
  1134. {
  1135. rtnResult = JsonHelper.setExceptionJson(-1, "获取3102医保明细审核事中分析服务入参失败:", outParam).ToString();
  1136. return rtnResult;
  1137. }
  1138. else
  1139. {
  1140. //2.调用医保3102明细审核事前分析服务
  1141. JObject joInput = new JObject();
  1142. joInput = JObject.Parse(outParam);
  1143. JObject jo3102Rtn = invoker.invokeCenterService("3102", JsonHelper.setCenterInpar("3102", joInput.ToString().Replace("\r\n", "")));
  1144. if (JsonHelper.parseCenterRtnValue(jo3102Rtn, out errMsg) != 0)
  1145. {
  1146. DialogResult dr = MessageBox.Show("【3102】医保明细审核事中分析服务医保中心返回结果1:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1147. if (dr != DialogResult.OK)
  1148. {
  1149. rtnResult = JsonHelper.setExceptionJson(-1, "【3102】医保明细审核事中分析服务调用失败:", errMsg).ToString();
  1150. return rtnResult;
  1151. }
  1152. }
  1153. }
  1154. */
  1155. #endregion
  1156. #region【住院预结算2303前调用3102医保明细审核事中服务】
  1157. ////事中分析
  1158. if (Global.curEvt.ext.isOpenAnalysis)
  1159. {
  1160. if (hBus.PreAnalysis("9", "", out errMsg) != 0) //事前事中:门诊挂号1 门诊收费登记2 住院登记3 住院收费登记4 住院执行医嘱5 门诊结算6 门诊预结算7 住院结算8 住院预结算9 购药划卡10
  1161. {
  1162. //rtnResult = JsonHelper.setExceptionJson(-1, "事前分析", errMsg).ToString();
  1163. //return rtnResult;
  1164. DialogResult dr = MessageBox.Show("【3101】医保明细审核事前分析服务医保中心返回结果:" + errMsg + "!是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1165. if (dr != DialogResult.OK)
  1166. {
  1167. rtnResult = JsonHelper.setExceptionJson(-1, "【3101】医保明细审核事前分析服务调用失败:", errMsg).ToString();
  1168. return rtnResult;
  1169. }
  1170. }
  1171. }
  1172. #endregion
  1173. Global.pat.admType = 2;
  1174. Global.pat.RYorCY = "2";
  1175. JObject joPreSetOutpar ;
  1176. if (hBus.preSettlement("2303",out joPreSetOutpar, out outParam) != 0)
  1177. {
  1178. rtnResult = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1179. return rtnResult;
  1180. }
  1181. else
  1182. {
  1183. JObject joSettlement = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "Settlement"));
  1184. ////出院登记
  1185. //JObject joDischargeRegister = JObject.Parse(JsonHelper.getDestValue(joPreSetOutpar, "DischargeRegister"));
  1186. //JObject jo2402Rtn = invoker.invokeCenterService("2402", JsonHelper.setCenterInpar("2402", joDischargeRegister));
  1187. //if (JsonHelper.parseCenterRtnValue(jo2402Rtn, out errMsg) != 0)
  1188. //{
  1189. // rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1190. // return rtnResult;
  1191. //}
  1192. //正式结算
  1193. joSettlement.Add("data", joSettlement);
  1194. JObject jo2304Rtn = invoker.invokeCenterService("2304",JsonHelper.setCenterInpar("2304",joSettlement));
  1195. if (JsonHelper.parseCenterRtnValue(jo2304Rtn, out errMsg) != 0)
  1196. {
  1197. rtnResult = JsonHelper.setExceptionJson(-1, "结算失败", errMsg).ToString();
  1198. cBus.cancleRegister("2405", out errMsg);
  1199. return rtnResult;
  1200. }
  1201. else
  1202. {
  1203. //返回给云医保平台结算信息
  1204. if (mIS.saveSettlement(jo2304Rtn, out errMsg) != 0)
  1205. {
  1206. rtnResult = JsonHelper.setExceptionJson(-1, "结算成功,但云医保平台保存失败", errMsg).ToString();
  1207. return rtnResult;
  1208. }
  1209. //返回给云医保平台结算明细信息
  1210. if (mIS.saveSettlementDetail(jo2304Rtn, out errMsg) != 0)
  1211. {
  1212. rtnResult = JsonHelper.setExceptionJson(-1, "云医保平台保存结算明细失败", errMsg).ToString();
  1213. Global.writeLog(rtnResult);
  1214. MessageBox.Show(errMsg);
  1215. }
  1216. //返回给HIS
  1217. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2304Rtn, "output.setlinfo"));
  1218. if (hIS.returnInpatSettlementInfo(joParam, joSetlinfo, out outParam) != 0)
  1219. {
  1220. rtnResult = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  1221. return rtnResult;
  1222. }
  1223. else
  1224. {
  1225. //返回给前端
  1226. JObject joHisServieRtn = JObject.Parse(outParam);
  1227. hBus.returnToFrontEndAfterSettlement(jo2304Rtn, joHisServieRtn, out outParam);
  1228. rtnResult = JsonHelper.setIrisReturnValue(0, "结算成功", JObject.Parse(outParam)).ToString();
  1229. return rtnResult;
  1230. }
  1231. }
  1232. }
  1233. }
  1234. case "Z5C"://住院结算撤销
  1235. {
  1236. //查询结算表
  1237. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 and Hospital_Dr=" + Global.inf.hospitalDr
  1238. + " and Adm_Dr='" + Global.pat.adm_Dr + "'"
  1239. + " and MdtrtID='" + Global.pat.mdtrtID + "'"
  1240. + " Order By ID DESC ";
  1241. JObject joSql = new JObject();
  1242. joSql.Add("sqlStr", sqlStr);
  1243. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  1244. //if (JsonHelper.parseIrisRtnValue(joSettlInfo, out errMsg) != 0)
  1245. //{
  1246. // rtnResult = JsonHelper.setExceptionJson(-1, "查询结算信息失败!", errMsg).ToString();
  1247. // return rtnResult;
  1248. //}
  1249. //MessageBox.Show(joSettlInfo.ToString());
  1250. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joSettlInfo, "result.data[0].insuplc_admdvs");
  1251. Global.pat.SettID_YBJSB = JsonHelper.getDestValue(joSettlInfo, "result.data[0].SettlementID");
  1252. if (Global.pat.settlID != Global.pat.SettID_YBJSB)
  1253. {
  1254. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "通过09010059服务获取到的SettlementID<" + Global.pat.settlID + ">与DLL通过SQL语句" +
  1255. joSql + ",获取到的SettlementID<" + Global.pat.SettID_YBJSB + ">不同,可能存在HIS单边账,请联系医保开发人员处理该笔结算记录!").ToString();
  1256. //return rtnResult;
  1257. }
  1258. Global.pat.settlID = Global.pat.SettID_YBJSB;
  1259. //取消中心结算信息
  1260. if (cBus.cancleSettlement("2305", out outParam) != 0)
  1261. {
  1262. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算信息失败!", outParam).ToString();
  1263. //查看是医保平台是否已经退费,如果是,则询问是否继续退费
  1264. string SqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE ValidFlag = 0 AND BillType = -1 ";
  1265. SqlStr = SqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  1266. SqlStr = SqlStr + " AND SettlementID ='" + Global.pat.settlID + "'";
  1267. JObject joSqlStr = new JObject();
  1268. joSqlStr.Add("sqlStr", SqlStr);
  1269. JObject joCancleSettlInfo = mIS.QuerySettlementInfo(joSqlStr);
  1270. JArray jaCancleSettlInfo = JArray.Parse(JsonHelper.getDestValue(joCancleSettlInfo, "result.data"));
  1271. if (jaCancleSettlInfo.Count == 1)
  1272. {
  1273. //询问收款员是否继续进行HIS退费
  1274. if (DialogResult.Yes == MessageBox.Show("中心提示:" + outParam, " 该费用在医保中心已成功退费但在HIS未成功退费,是否强制退HIS费用? ", MessageBoxButtons.YesNo))
  1275. {
  1276. rtnResult = JsonHelper.setExceptionJson(0, "该费用在医保中心已成功退费但在HIS未成功退费,收款员选择强制退HIS费用!", outParam).ToString();
  1277. }
  1278. }
  1279. else
  1280. {
  1281. rtnResult = JsonHelper.setExceptionJson(-1, "取消中心结算(云医保平台未退费或未查询到退费记录)", outParam).ToString();
  1282. }
  1283. return rtnResult;
  1284. }
  1285. else
  1286. {
  1287. //退结算会返一个新的ID
  1288. string newSettleID = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_id");
  1289. string balc = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.balc");
  1290. string setl_time = JsonHelper.getDestValue(JObject.Parse(outParam), "output.setlinfo.setl_time");
  1291. //取消平台结算信息
  1292. if (mIS.cancleSettlement(newSettleID, balc, setl_time, out outParam) != 0)
  1293. {
  1294. rtnResult = JsonHelper.setExceptionJson(-1, "中心结算取消成功,医保平台结算信息取消失败!", outParam).ToString();
  1295. return rtnResult;
  1296. }
  1297. //中心取消传送
  1298. if (cBus.cancleFeeUpload("2302", out errMsg) != 0)
  1299. {
  1300. //rtnResult = JsonHelper.setExceptionJson(-1, "取消中心费用", errMsg).ToString();
  1301. //return rtnResult;
  1302. }
  1303. //云平台取消传送
  1304. if (mIS.deleteFee(out errMsg) != 0)
  1305. {
  1306. //rtnResult = JsonHelper.setExceptionJson(-1, "删除医保平台费用", errMsg).ToString();
  1307. //return rtnResult;
  1308. }
  1309. //取消HIS医保结算信息
  1310. if (hIS.cancleSettlementInfo(joParam, out outParam) != 0)
  1311. {
  1312. rtnResult = JsonHelper.setExceptionJson(-1, "中心跟医保平台结算取消成功, 取消HIS结算信息失败!", outParam).ToString();
  1313. return rtnResult;
  1314. }
  1315. //取消出院登记
  1316. if (cBus.cancleRegister("2405", out outParam) != 0)
  1317. {
  1318. rtnResult = JsonHelper.setExceptionJson(0, "中心,医保平台及HIS结算信息取消成功,取消出院登记失败!请手工取消出院登记!", outParam).ToString();
  1319. return rtnResult;
  1320. }
  1321. rtnResult = JsonHelper.setIrisReturnValue(0, "取消结算成功", null).ToString();
  1322. return rtnResult;
  1323. }
  1324. }
  1325. default:
  1326. {
  1327. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", "传入的业务编码不对!").ToString();
  1328. return rtnResult;
  1329. }
  1330. }
  1331. return rtnResult;
  1332. }
  1333. catch (Exception ex)
  1334. {
  1335. rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", ex.Message).ToString();
  1336. return rtnResult;
  1337. }
  1338. finally
  1339. {
  1340. Global.writeLog("Settlement 出参:" + JsonHelper.Compress(rtnResult));
  1341. }
  1342. }
  1343. //[STAThread]
  1344. //public void print(JObject joInParam)
  1345. //{
  1346. // //显示打印界面
  1347. // SettlementChecklist frmSettlList;
  1348. // string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1349. // if (insuAdmObj == "")
  1350. // {
  1351. // frmSettlList = new SettlementChecklist();
  1352. // }
  1353. // else
  1354. // {
  1355. // JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1356. // frmSettlList = new SettlementChecklist(joInsuAdmObj);
  1357. // }
  1358. // if (frmSettlList.ShowDialog() == DialogResult.OK)
  1359. // {
  1360. // };
  1361. //}
  1362. //[STAThread]
  1363. /// <summary>
  1364. /// 辅助交易
  1365. /// </summary>
  1366. /// <param name="InParam"></param>
  1367. /// <returns></returns>
  1368. public string AgentFun(string InParam)
  1369. {
  1370. Global.writeLog("AgentFun 入参:" + JsonHelper.Compress(InParam));
  1371. //设置返回值,错误信息
  1372. int errCode;
  1373. string errMsg, rtnResult = "", outParam;
  1374. try
  1375. {
  1376. //解析入参
  1377. if (parseInparam(InParam, out errMsg) != 0)
  1378. {
  1379. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1380. return rtnResult;
  1381. }
  1382. //BS架构调用方式问题,每次调用都需要重新初始化
  1383. if (init(InParam, out outParam) != 0)
  1384. {
  1385. rtnResult = outParam;
  1386. return rtnResult;
  1387. }
  1388. //获取pat
  1389. //hBus.GetFeeHisInfo(businessType, joInParam, out Global.pat);
  1390. switch (businessType)
  1391. {
  1392. case "BasicData"://基础数据维护
  1393. {
  1394. BasicData bd = new BasicData();
  1395. if (bd.ShowDialog() != DialogResult.OK)
  1396. {
  1397. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出基础数据维护界面").ToString();
  1398. return rtnResult;
  1399. }
  1400. break;
  1401. }
  1402. case "Exception"://异常处理1
  1403. {
  1404. //显示异常处理界面
  1405. HandleException frmEX = new HandleException();
  1406. if (frmEX.ShowDialog() != DialogResult.OK)
  1407. {
  1408. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出异常处理界面").ToString();
  1409. return rtnResult;
  1410. }
  1411. break;
  1412. }
  1413. case "CheckAndClearing"://对账清算
  1414. {
  1415. Clearing frmEX = new Clearing();
  1416. if (frmEX.ShowDialog() != DialogResult.OK)
  1417. {
  1418. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出对账清算界面").ToString();
  1419. return rtnResult;
  1420. }
  1421. break;
  1422. }
  1423. case "Print"://打印
  1424. {
  1425. //显示打印界面
  1426. SettlementChecklist frmSettlList;
  1427. string insuAdmObj = JsonHelper.getDestValue(joInParam, "insuAdmObj");
  1428. if (insuAdmObj == "")
  1429. {
  1430. frmSettlList = new SettlementChecklist();
  1431. if (frmSettlList.ShowDialog() != DialogResult.OK)
  1432. {
  1433. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出打印界面").ToString();
  1434. return rtnResult;
  1435. }
  1436. }
  1437. else
  1438. {
  1439. JObject joInsuAdmObj = JObject.Parse(insuAdmObj);
  1440. frmSettlList = new SettlementChecklist(joInsuAdmObj);
  1441. string groupID = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "groupID");
  1442. string userName = JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "userName");
  1443. DataTable dt = (DataTable)frmSettlList.dgvSettlRecord.DataSource;
  1444. if (dt.Rows.Count != 1)
  1445. {
  1446. frmSettlList.ShowDialog();
  1447. }
  1448. else
  1449. {
  1450. frmSettlList.btnPrint_Click(null, null);
  1451. }
  1452. }
  1453. return JsonHelper.setIrisReturnValue(0, "", null).ToString();
  1454. break;
  1455. }
  1456. case "Log"://日志
  1457. {
  1458. MessageBox.Show(businessType);
  1459. break;
  1460. }
  1461. case "RecordUpload"://上传记录
  1462. {
  1463. MessageBox.Show(businessType);
  1464. break;
  1465. }
  1466. case "HospitalRegister"://备案
  1467. {
  1468. ToRecordChoose Referral = new ToRecordChoose();
  1469. Referral.ShowDialog();
  1470. break;
  1471. }
  1472. case "MedInsuQuery"://医保查询
  1473. {
  1474. MedInsuQuery MedQuery = new MedInsuQuery();
  1475. if (MedQuery.ShowDialog() != DialogResult.OK)
  1476. {
  1477. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保查询界面").ToString();
  1478. return rtnResult;
  1479. }
  1480. break;
  1481. }
  1482. case "Appeal"://医保申诉
  1483. {
  1484. HopitalAppeal appeal = new HopitalAppeal();
  1485. if (appeal.ShowDialog() != DialogResult.OK)
  1486. {
  1487. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保申诉界面").ToString();
  1488. return rtnResult;
  1489. }
  1490. break;
  1491. }
  1492. case "PreAndInProcessAnalysis"://事前分析 诊间只有住院的事前分析
  1493. {
  1494. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1495. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1496. Global.pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInParam, "params[0].admID"));
  1497. JObject joResult = new JObject();
  1498. joResult.Add("result", JObject.Parse(JsonHelper.getDestValue(joParam, "insuData")));
  1499. //事前分析
  1500. if (Global.curEvt.ext.isOpenAnalysis)
  1501. {
  1502. if (hBus.PreAnalysis("5", joResult.ToString(), out errMsg) != 0)
  1503. {
  1504. MessageBox.Show(errMsg);
  1505. break;
  1506. }
  1507. }
  1508. break;
  1509. }
  1510. case "PrescribeCirculation"://医保处方流转
  1511. {
  1512. ////显示医保处方流转界面
  1513. //PrescriptionCirculation PresCir = new PrescriptionCirculation("");
  1514. //if (PresCir.ShowDialog() != DialogResult.OK)
  1515. //{
  1516. // rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保电子处方流转界面").ToString();
  1517. // return rtnResult;
  1518. //}
  1519. STA sta = new STA();
  1520. Thread thread = new Thread(sta.PrescribeCirculation);
  1521. thread.SetApartmentState(ApartmentState.STA); //重点
  1522. thread.IsBackground = true;
  1523. thread.Start();
  1524. thread.Join();
  1525. break;
  1526. }
  1527. case "PrescriptionCirculation_Pharmacy"://医保处方流转
  1528. {
  1529. //显示医保处方流转界面
  1530. PrescriptionCirculation_Pharmacy PresCir = new PrescriptionCirculation_Pharmacy();
  1531. if (PresCir.ShowDialog() != DialogResult.OK)
  1532. {
  1533. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出医保电子处方流转-取药机构界面").ToString();
  1534. return rtnResult;
  1535. }
  1536. break;
  1537. }
  1538. case "Special"://就医特殊属性上传
  1539. {
  1540. SpecialPsn spec = new SpecialPsn();
  1541. if (spec.ShowDialog() != DialogResult.OK)
  1542. {
  1543. rtnResult = JsonHelper.setExceptionJson(-100, "", "已退出就医特殊属性上传界面").ToString();
  1544. return rtnResult;
  1545. }
  1546. break;
  1547. }
  1548. default:
  1549. {
  1550. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", "传入的业务编码不对!").ToString();
  1551. return rtnResult;
  1552. }
  1553. }
  1554. return rtnResult;
  1555. }
  1556. catch (Exception ex)
  1557. {
  1558. rtnResult = JsonHelper.setExceptionJson(-1, "AgentFun 交易", ex.Message).ToString();
  1559. return rtnResult;
  1560. }
  1561. finally
  1562. {
  1563. Global.writeLog("AgentFun 出参:" + JsonHelper.Compress(rtnResult));
  1564. }
  1565. }
  1566. public string Download(string InParam)
  1567. {
  1568. Global.writeLog("Download 入参:" + JsonHelper.Compress(InParam));
  1569. //设置返回值,错误信息
  1570. int errCode;
  1571. string errMsg, rtnResult = "", outParam;
  1572. try
  1573. {
  1574. //解析入参
  1575. if (parseInparam(InParam, out errMsg) != 0)
  1576. {
  1577. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1578. return rtnResult;
  1579. }
  1580. //BS架构调用方式问题,每次调用都需要重新初始化
  1581. if (init(InParam, out outParam) != 0)
  1582. {
  1583. rtnResult = outParam;
  1584. return rtnResult;
  1585. }
  1586. dynamic joData = new JObject();
  1587. joData.data = joParam["data"];
  1588. //string code = (string)joInParam["code"];
  1589. string funNO = (string)joParam["funNO"];
  1590. switch (businessType)
  1591. {
  1592. case "DirectoryDownload":
  1593. {
  1594. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1595. rtnResult = hBus.DownloadDirectory(funNO, downloadParam).ToString();
  1596. break;
  1597. }
  1598. case "DictionayDownload":
  1599. {
  1600. string downloadParam = JsonHelper.setCenterInpar(funNO, joData.ToString());
  1601. rtnResult = hBus.downDictionary(downloadParam);
  1602. break;
  1603. }
  1604. }
  1605. return rtnResult;
  1606. }
  1607. catch (Exception ex)
  1608. {
  1609. rtnResult = JsonHelper.setExceptionJson(-100, "Download", ex.Message).ToString();
  1610. return rtnResult;
  1611. }
  1612. finally
  1613. {
  1614. Global.writeLog("Download 出参:" + rtnResult);
  1615. }
  1616. }
  1617. public string PlatformDirectConnect(string InParam)
  1618. {
  1619. //设置返回值,错误信息
  1620. int errCode;
  1621. string errMsg, rtnResult = "", outParam;
  1622. try
  1623. {
  1624. Global.writeLog("PlatformDirectConnect 入参:" + JsonHelper.Compress(InParam));
  1625. //解析入参
  1626. if (parseInparam(InParam, out errMsg) != 0)
  1627. {
  1628. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1629. return rtnResult;
  1630. }
  1631. Global.businessType = businessType;
  1632. string funNO = JsonHelper.getDestValue(joInParam, "funNO");
  1633. //BS架构调用方式问题,每次调用都需要重新初始化
  1634. if (init(InParam, out outParam) != 0)
  1635. {
  1636. rtnResult = outParam;
  1637. return rtnResult;
  1638. }
  1639. JObject joRtn;
  1640. string[] strArr = { "3501", "3502", "3503", "3504", "3505", "3506", "3507" };//进销存交易
  1641. bool exists = ((IList)strArr).Contains(funNO);
  1642. if (exists)
  1643. {
  1644. //解析入参
  1645. if (parsejoParam(joParam, funNO, out errMsg) != 0)
  1646. {
  1647. rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1648. return rtnResult;
  1649. }
  1650. //if (funNO == "3505")
  1651. //{
  1652. // //解析入参
  1653. // if (parsejoParamSet(joParam, funNO, out errMsg) != 0)
  1654. // {
  1655. // rtnResult = JsonHelper.setExceptionJson(-1, "", errMsg).ToString();
  1656. // return rtnResult;
  1657. // }
  1658. // invoker.invokeCenterServiceJXC("992001", JObject.Parse(JsonHelper.setCenterInpar("992001", joParam992001)));//结算信息上传
  1659. // invoker.invokeCenterServiceJXC("992004", JObject.Parse(JsonHelper.setCenterInpar("992004", joParam992004)));//结算费用明细上传
  1660. //}
  1661. //if (funNO == "3506")
  1662. //{
  1663. // invoker.invokeCenterServiceJXC("992002", JObject.Parse(JsonHelper.setCenterInpar("992002", joParam992001)));//结算退费信息上传
  1664. // invoker.invokeCenterServiceJXC("992004", JObject.Parse(JsonHelper.setCenterInpar("992004", joParam992004)));//结算退费费用明细上传
  1665. //}
  1666. joRtn = invoker.invokeCenterServiceJXC(funNO, JObject.Parse(JsonHelper.setCenterInpar(funNO, joParam)));
  1667. //joRtn = invoker.invokeCenterServiceJXC2(funNO, JObject.Parse(JsonHelper.setCenterInpar(funNO, joParam)));】】
  1668. if (funNO == "3505" || funNO == "3506")
  1669. {
  1670. if (!string.IsNullOrEmpty(joParam["selinfo"]["setl_id"].ToString()))
  1671. {
  1672. if (joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4299" || joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4201")
  1673. {
  1674. joParam["selinfo"]["hi_feesetl_type"] = "1";
  1675. joRtn = invoker.invokeCenterService(funNO + 'A', JsonHelper.setCenterInpar(funNO + 'A', joParamA));
  1676. }
  1677. }
  1678. else
  1679. {
  1680. joRtn = invoker.invokeCenterService(funNO + 'A', JsonHelper.setCenterInpar(funNO + 'A', joParamA));
  1681. }
  1682. }
  1683. else
  1684. {
  1685. joRtn = invoker.invokeCenterService(funNO + 'A', JsonHelper.setCenterInpar(funNO + 'A', joParamA));
  1686. }
  1687. }
  1688. else //非进销存交易
  1689. {
  1690. if (funNO== "I2002")
  1691. {
  1692. joRtn = invoker.invokeCenterServiceFZJK("I2002", joParam);//追溯码辅助接口
  1693. }
  1694. else
  1695. {
  1696. joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joParam));//正常交易走医保COM组件
  1697. }
  1698. }
  1699. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1700. {
  1701. rtnResult = JsonHelper.setExceptionJson(-1, "平台直连错误", errMsg).ToString();
  1702. return rtnResult;
  1703. }
  1704. else
  1705. {
  1706. rtnResult = JsonHelper.setIrisReturnValue(0, "", joRtn).ToString();
  1707. return rtnResult;
  1708. }
  1709. }
  1710. catch (Exception ex)
  1711. {
  1712. rtnResult = JsonHelper.setExceptionJson(-1, "PlatformDirectConnect 交易", ex.Message).ToString();
  1713. return rtnResult;
  1714. }
  1715. finally
  1716. {
  1717. Global.writeLog("PlatformDirectConnect 出参:" + JsonHelper.Compress(rtnResult));
  1718. }
  1719. }
  1720. private int parsejoParam(JObject joParam,string funno,out string errMsg)
  1721. {
  1722. errMsg = "";
  1723. try
  1724. {
  1725. if (funno == "3505"|| funno == "3506")
  1726. {
  1727. if (!string.IsNullOrEmpty(joParam["selinfo"]["setl_id"].ToString()))
  1728. {
  1729. if (joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4299" || joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4201")
  1730. {
  1731. joParam["selinfo"]["hi_feesetl_type"] = "1";
  1732. }
  1733. else
  1734. {
  1735. joParam["selinfo"]["hi_feesetl_type"] = "2";
  1736. }
  1737. }
  1738. else
  1739. {
  1740. joParam["selinfo"]["hi_feesetl_type"] = "0";
  1741. }
  1742. if(funno == "3506")
  1743. {
  1744. joParam["selinfo"]["fixmedins_bchno"] = joParam["selinfo"]["fixmedins_bchno"].ToString()+"-1".ToString();
  1745. joParam["selinfo"]["rtal_docno"] = joParam["selinfo"]["init_rtal_docno"].ToString();
  1746. }
  1747. JObject joRtn = JObject.Parse(joParam["selinfo"].ToString());
  1748. //if (!string.IsNullOrEmpty(joParam["selinfo"]["drugtracinfo"].ToString()))
  1749. //{
  1750. // joRtn.Add("drug_trac_info", joParam["selinfo"]["drugtracinfo"]);
  1751. // joParam["selinfo"] = joRtn;
  1752. //}
  1753. //MessageBox.Show("111");
  1754. //MessageBox.Show(joParam.ToString());
  1755. JArray selDtl = new JArray();
  1756. selDtl.Add(JObject.Parse(joParam["selinfo"].ToString()));
  1757. //MessageBox.Show(selDtl.ToString());
  1758. joParamA = new JObject();
  1759. joParamA.Add("selinfoDetail", selDtl);
  1760. //MessageBox.Show(joParamA.ToString());
  1761. return 0;
  1762. }
  1763. else if (funno == "3501")
  1764. {
  1765. JObject joRtn = JObject.Parse(joParam["invinfo"].ToString());
  1766. //if (!string.IsNullOrEmpty(joParam["invinfo"]["drugtracinfo"].ToString()))
  1767. //{
  1768. // joRtn.Add("drug_trac_info", joParam["invinfo"]["drugtracinfo"]);
  1769. // joParam["invinfo"] = joRtn;
  1770. //}
  1771. JArray selDtl = new JArray();
  1772. selDtl.Add(JObject.Parse(joParam["invinfo"].ToString()));
  1773. //MessageBox.Show(selDtl.ToString());
  1774. joParamA = new JObject();
  1775. joParamA.Add("invinfoDetail", selDtl);
  1776. return 0;
  1777. }
  1778. else if (funno == "3502")
  1779. {
  1780. JObject joRtn = JObject.Parse(joParam["invinfo"].ToString());
  1781. //if (!string.IsNullOrEmpty(joParam["invinfo"]["drugtracinfo"].ToString()))
  1782. //{
  1783. // joRtn.Add("drug_trac_info", joParam["invinfo"]["drugtracinfo"]);
  1784. // joParam["invinfo"] = joRtn;
  1785. //}
  1786. JArray selDtl = new JArray();
  1787. selDtl.Add(JObject.Parse(joParam["invinfo"].ToString()));
  1788. //MessageBox.Show(selDtl.ToString());
  1789. joParamA = new JObject();
  1790. joParamA.Add("invinfoDetail", selDtl);
  1791. return 0;
  1792. }
  1793. else if (funno == "3503")
  1794. {
  1795. JObject joRtn = JObject.Parse(joParam["purcinfo"].ToString());
  1796. //if (!string.IsNullOrEmpty(joParam["purcinfo"]["drugtracinfo"].ToString()))
  1797. //{
  1798. // joRtn.Add("drug_trac_info", joParam["purcinfo"]["drugtracinfo"]);
  1799. // joParam["purcinfo"] = joRtn;
  1800. //}
  1801. JArray selDtl = new JArray();
  1802. selDtl.Add(JObject.Parse(joParam["purcinfo"].ToString()));
  1803. //MessageBox.Show(selDtl.ToString());
  1804. joParamA = new JObject();
  1805. joParamA.Add("purcinfoDetail", selDtl);
  1806. return 0;
  1807. }
  1808. else if ( funno == "3504")
  1809. {
  1810. JObject joRtn = JObject.Parse(joParam["purcinfo"].ToString());
  1811. //if (!string.IsNullOrEmpty(joParam["purcinfo"]["drugtracinfo"].ToString()))
  1812. //{
  1813. // joRtn.Add("drug_trac_info", joParam["purcinfo"]["drugtracinfo"]);
  1814. // joParam["purcinfo"] = joRtn;
  1815. //}
  1816. JArray selDtl = new JArray();
  1817. selDtl.Add(JObject.Parse(joParam["purcinfo"].ToString()));
  1818. //MessageBox.Show(selDtl.ToString());
  1819. joParamA = new JObject();
  1820. joParamA.Add("purcinfoDetail", selDtl);
  1821. return 0;
  1822. }
  1823. else if (funno == "3507")
  1824. {
  1825. JObject joRtn = JObject.Parse(joParam["data"].ToString());
  1826. //if (!string.IsNullOrEmpty(joParam["purcinfo"]["drugtracinfo"].ToString()))
  1827. //{
  1828. // joRtn.Add("drug_trac_info", joParam["purcinfo"]["drugtracinfo"]);
  1829. // joParam["purcinfo"] = joRtn;
  1830. //}
  1831. JArray selDtl = new JArray();
  1832. selDtl.Add(JObject.Parse(joParam["data"].ToString()));
  1833. //MessageBox.Show(selDtl.ToString());
  1834. joParamA = new JObject();
  1835. joParamA.Add("goodDetail", selDtl);
  1836. return 0;
  1837. }
  1838. else { return -1; }
  1839. }
  1840. catch (Exception ex)
  1841. {
  1842. errMsg = "parsejoParam 解析入参异常1:" + errMsg;
  1843. return -1;
  1844. }
  1845. }
  1846. private int parsejoParamSet(JObject joParam, string funno, out string errMsg)
  1847. {
  1848. errMsg = "";
  1849. try
  1850. {
  1851. if (funno == "3505")
  1852. {
  1853. string setl_id = joParam["selinfo"]["setl_id"].ToString();
  1854. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 ";
  1855. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  1856. sqlStr = sqlStr + " AND SettlementID ='" + setl_id + "'";
  1857. JObject joSql = new JObject();
  1858. joSql.Add("sqlStr", sqlStr);
  1859. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  1860. //查询结算信息
  1861. JObject Outpam = JObject.Parse(joSettlInfo["result"]["data"][0].ToString());
  1862. dynamic setlinfo = new JObject();//结算信息节点
  1863. setlinfo.setl_id = Outpam["SettlementID"];//结算ID
  1864. setlinfo.mdtrt_id = Outpam["MdtrtID"];//就诊ID
  1865. setlinfo.psn_no = Outpam["PersonnelNO"];//人员编号
  1866. setlinfo.psn_name = Outpam["PatientName"];//人员姓名
  1867. setlinfo.psn_cert_type = Outpam["MdtrtCertType"];//凭证类型
  1868. setlinfo.certno = Outpam["CertificateNO"];//证件号码
  1869. setlinfo.gend = Outpam["Gender"];//性别
  1870. setlinfo.naty = Outpam["Nation"];//民族
  1871. setlinfo.brdy = Outpam["BirthDay"];//出生日期
  1872. setlinfo.age = Outpam["Age"];//年龄
  1873. setlinfo.insutype = Outpam["InsuranceType"];//险种类型
  1874. setlinfo.psn_type = Outpam["PersonType"];//人员类别
  1875. setlinfo.cvlserv_flag = Outpam["CivilserviceFlag"];//公务员标志
  1876. setlinfo.setl_time = Outpam["SettlementTime"];//结算时间
  1877. setlinfo.mdtrt_cert_type = Outpam["MdtrtCertType"];//就诊凭证类型
  1878. setlinfo.med_type = Outpam["MedicalType"];//医疗类别
  1879. setlinfo.medfee_sumamt = Outpam["Sumamt"];//医疗费总额
  1880. setlinfo.fulamt_ownpay_amt = Outpam["OwnPayAmount"];//全自费金额
  1881. setlinfo.overlmt_selfpay = Outpam["OverLimitAmount"];//超限价自费费用
  1882. setlinfo.preselfpay_amt = Outpam["PreSelfPayAmount"];//先行自付金额
  1883. setlinfo.inscp_scp_amt = Outpam["InPolicyRangeAmount"];//符合政策范围金额
  1884. setlinfo.act_pay_dedc = Outpam["ActualPayDeductible"];//实际支付起付线
  1885. setlinfo.hifp_pay = Outpam["HealthInsurancePay"];//基本医疗保险统筹基金支出
  1886. setlinfo.pool_prop_selfpay = Outpam["HealthInsuranceRatio"];//基本医疗保险统筹基金支付比例
  1887. setlinfo.cvlserv_pay = Outpam["CivilserviceAllowancePay"];//公务员医疗补助资金支出
  1888. setlinfo.hifes_pay = Outpam["EnterpriseSupplementPay"];//企业补充医疗保险基金支出
  1889. setlinfo.hifmi_pay = Outpam["SeriousIllnessPay"];//居民大病保险资金支出
  1890. setlinfo.hifob_pay = Outpam["LargeExpensesSupplementPay"];//职工大额医疗费用补助基金支出
  1891. setlinfo.maf_pay = Outpam["MedicalAssistPay"];//医疗救助基金支出
  1892. setlinfo.oth_pay = Outpam["OtherPay"];//结算ID
  1893. setlinfo.fund_pay_sumamt = Outpam["FundPaySumamt"];//基金支付总额
  1894. setlinfo.psn_part_amt = Outpam["PersonPaySumamt"];//个人负担总金额
  1895. setlinfo.acct_pay = Outpam["AccountPaySumamt"];//个人账户支出
  1896. setlinfo.psn_cash_pay = Outpam["PersonCashPay"];//个人现金支出
  1897. setlinfo.balc = Outpam["Balance"];//余额
  1898. setlinfo.acct_mulaid_pay = Outpam["AccountMutualAidAmount"];//个人账户共济支付金额
  1899. setlinfo.medins_setl_id = Outpam["OrganSettlementID"];//医药机构结算结算ID
  1900. setlinfo.clr_optins = Outpam["ClearingOrgan"];//clr_optins
  1901. setlinfo.clr_way = Outpam["ClearingWay"];//clr_way
  1902. setlinfo.clr_type = Outpam["ClearingType"];//clr_type
  1903. setlinfo.exp_content = "";//exp_content
  1904. setlinfo.hosp_part_amt = Outpam["HospitalPartAmount"];//医院负担金额
  1905. setlinfo.hifdm_pay = 0;//伤残人员医疗保障基金支出
  1906. dynamic setlinfo1 = new JObject();//结算信息节点
  1907. setlinfo1.setl_id = Outpam["SettlementID"];//结算ID
  1908. string outParam = "";
  1909. string AdmID = Outpam["AdmID"].ToString();
  1910. string billID = Outpam["BillID"].ToString();
  1911. string recordID = Outpam["RecordID"].ToString();
  1912. Global.pat.adm_Dr = int.Parse(AdmID);
  1913. Global.pat.billID = billID;
  1914. Global.pat.recordID = recordID;
  1915. //获取IS费用
  1916. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  1917. {
  1918. MessageBox.Show("获取HIS费用失败");
  1919. }
  1920. //调用医保平台转换HIS费用(转换医保编码等)
  1921. JObject joHisFee = JObject.Parse(outParam);
  1922. if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0)
  1923. {
  1924. MessageBox.Show("获取HIS费用医保对照关系失败");
  1925. }
  1926. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  1927. MessageBox.Show("11111");
  1928. JObject jaFeeOne = new JObject();
  1929. for (int i = 0; i < jaFeeDetail.Count; i++)
  1930. {
  1931. jaFeeOne.Add("feedetl_sn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
  1932. jaFeeOne.Add("rxno", "");//处方号
  1933. if (string.IsNullOrEmpty(jaFeeDetail[i]["rx_circ_flag"].ToString()))
  1934. {
  1935. jaFeeOne.Add("rx_circ_flag", "");//外购处方标志
  1936. }
  1937. else
  1938. {
  1939. jaFeeOne.Add("rx_circ_flag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
  1940. }
  1941. jaFeeOne.Add("fee_ocur_time", jaFeeDetail[i]["fee_ocur_time"]);
  1942. jaFeeOne.Add("med_list_codg", jaFeeDetail[i]["med_list_codg"]);
  1943. jaFeeOne.Add("medins_list_codg", jaFeeDetail[i]["medins_list_codg"]);
  1944. jaFeeOne.Add("medins_list_name", jaFeeDetail[i]["medins_list_desc"]);
  1945. jaFeeOne.Add("prodname", jaFeeDetail[i]["medins_list_desc"]);
  1946. if (string.IsNullOrEmpty(jaFeeDetail[i]["spec"].ToString()))
  1947. {
  1948. jaFeeOne.Add("spec", "");
  1949. }
  1950. else
  1951. {
  1952. jaFeeOne.Add("spec", jaFeeDetail[i]["spec"]);
  1953. }
  1954. if (string.IsNullOrEmpty(jaFeeDetail[i]["doseForm"].ToString()))
  1955. {
  1956. jaFeeOne.Add("dosform_name", "");
  1957. }
  1958. else
  1959. {
  1960. jaFeeOne.Add("dosform_name", jaFeeDetail[i]["doseForm"]);
  1961. }
  1962. jaFeeOne.Add(" det_item_fee_sumamt", jaFeeDetail[i]["det_item_fee_sumamt"]);
  1963. jaFeeOne.Add("cnt", jaFeeDetail[i]["cnt"]);
  1964. jaFeeOne.Add("pric", jaFeeDetail[i]["pric"]);
  1965. if (string.IsNullOrEmpty(jaFeeDetail[i]["sin_dos_dscr"].ToString()))
  1966. {
  1967. jaFeeOne.Add("sin_dos_dscr", "");
  1968. }
  1969. else
  1970. {
  1971. jaFeeOne.Add("sin_dos_dscr", jaFeeDetail[i]["sin_dos_dscr"]);
  1972. }
  1973. if (string.IsNullOrEmpty(jaFeeDetail[i]["used_frqu_dscr"].ToString()))
  1974. {
  1975. jaFeeOne.Add("used_frqu_dscr", "");
  1976. }
  1977. else
  1978. {
  1979. jaFeeOne.Add("used_frqu_dscr", jaFeeDetail[i]["used_frqu_dscr"]);
  1980. }
  1981. if (string.IsNullOrEmpty(jaFeeDetail[i]["prd_days"].ToString()))
  1982. {
  1983. jaFeeOne.Add("prd_days", "");
  1984. }
  1985. else
  1986. {
  1987. jaFeeOne.Add("prd_days", jaFeeDetail[i]["prd_days"]);
  1988. }
  1989. if (string.IsNullOrEmpty(jaFeeDetail[i]["medc_way_dscr"].ToString()))
  1990. {
  1991. jaFeeOne.Add("medc_way_dscr", "");
  1992. }
  1993. else
  1994. {
  1995. jaFeeOne.Add("medc_way_dscr", jaFeeDetail[i]["medc_way_dscr"]);
  1996. }
  1997. if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_codg"].ToString()))
  1998. {
  1999. jaFeeOne.Add("bilg_dr_codg", "");
  2000. }
  2001. else
  2002. {
  2003. jaFeeOne.Add("bilg_dr_codg", jaFeeDetail[i]["bilg_dr_codg"]);
  2004. }
  2005. if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_name"].ToString()))
  2006. {
  2007. jaFeeOne.Add("bilg_dr_name", "");
  2008. }
  2009. else
  2010. {
  2011. jaFeeOne.Add("bilg_dr_name", jaFeeDetail[i]["bilg_dr_name"]);
  2012. }
  2013. jaFeeOne.Add("phar_name", "");
  2014. jaFeeOne.Add("phar_prac_cert_no", "");
  2015. jaFeeOne.Add("tcmdrug_used_way", ""); //中药使用方式 1复方 2单方 必填
  2016. jaFeeOne.Add("trdn_flag", "1");//拆零标志 必填 0否 1是
  2017. jaFeeDetail.Add(jaFeeOne);
  2018. jaFeeOne = new JObject();
  2019. }
  2020. MessageBox.Show("22222");
  2021. joParam992001.Add("setlinfo", JObject.Parse(setlinfo));//结算信息节点
  2022. joParam992004.Add("setlinfo", JObject.Parse(setlinfo1));
  2023. joParam992004.Add("drugdetail", jaFeeDetail);//购药明细节点
  2024. //JObject OutJo = invoker.invokeCenterServiceJXC("992001", JObject.Parse(JsonHelper.setCenterInpar("992001", Jo992001)));
  2025. //MessageBox.Show("上传返回:" + OutJo.ToString());
  2026. }
  2027. if (funno == "3506")
  2028. {
  2029. string setl_id = joParam["selinfo"]["setl_id"].ToString();
  2030. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE billType = -1 ";
  2031. sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  2032. sqlStr = sqlStr + " AND SettlementID ='" + setl_id + "'";
  2033. JObject joSql = new JObject();
  2034. joSql.Add("sqlStr", sqlStr);
  2035. JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
  2036. //查询结算信息
  2037. JObject Outpam = JObject.Parse(joSettlInfo["result"]["data"][0].ToString());
  2038. string mdtrt_id = Outpam["MdtrtID"].ToString();//ADMID
  2039. string sqlStr1 = "SELECT * FROM BS_MedInsuSettlement WHERE billType = 1 ";
  2040. sqlStr1 = sqlStr1 + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
  2041. sqlStr1 = sqlStr1 + " AND MdtrtID ='" + mdtrt_id + "'";
  2042. JObject joSql1 = new JObject();
  2043. joSql1.Add("sqlStr1", sqlStr);
  2044. JObject joSettlInfo1 = mIS.QuerySettlementInfo(joSql1);
  2045. JObject Outpam1= JObject.Parse(joSettlInfo1["result"]["data"][0].ToString());
  2046. dynamic setlinfo = new JObject();//结算信息节点
  2047. setlinfo.setl_id = Outpam["SettlementID"];//结算ID
  2048. setlinfo.init_setl_id = Outpam1["SettlementID"]; ;//结算ID
  2049. setlinfo.setl_time = Outpam["SettlementTime"];//结算时间
  2050. setlinfo.mdtrt_id = Outpam["MdtrtID"];//就诊ID
  2051. setlinfo.psn_no = Outpam["PersonnelNO"];//人员编号
  2052. setlinfo.exp_content = "";//人员姓名
  2053. dynamic setlinfo1 = new JObject();//结算信息节点
  2054. setlinfo1.setl_id = Outpam["SettlementID"];//结算ID
  2055. joParam992002.Add("data", JObject.Parse(setlinfo));//结算信息节点
  2056. string AdmID = Outpam["AdmID"].ToString();
  2057. string billID = Outpam["BillID"].ToString();
  2058. string recordID = Outpam["RecordID"].ToString();
  2059. Global.pat.adm_Dr = int.Parse(AdmID);
  2060. Global.pat.billID = billID;
  2061. Global.pat.recordID = recordID;
  2062. string outParam = "";
  2063. //获取IS费用
  2064. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  2065. {
  2066. MessageBox.Show("获取HIS费用失败");
  2067. }
  2068. //调用医保平台转换HIS费用(转换医保编码等)
  2069. JObject joHisFee = JObject.Parse(outParam);
  2070. if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0)
  2071. {
  2072. MessageBox.Show("获取HIS费用医保对照关系失败");
  2073. }
  2074. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  2075. JObject jaFeeOne = new JObject();
  2076. for (int i = 0; i < jaFeeDetail.Count; i++)
  2077. {
  2078. jaFeeOne.Add("feedetl_sn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
  2079. jaFeeOne.Add("rxno", "");//处方号
  2080. if (string.IsNullOrEmpty(jaFeeDetail[i]["rx_circ_flag"].ToString()))
  2081. {
  2082. jaFeeOne.Add("rx_circ_flag", "");//外购处方标志
  2083. }else {
  2084. jaFeeOne.Add("rx_circ_flag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
  2085. }
  2086. jaFeeOne.Add("fee_ocur_time", jaFeeDetail[i]["fee_ocur_time"]);
  2087. jaFeeOne.Add("med_list_codg", jaFeeDetail[i]["med_list_codg"]);
  2088. jaFeeOne.Add("medins_list_codg", jaFeeDetail[i]["medins_list_codg"]);
  2089. jaFeeOne.Add("medins_list_name", jaFeeDetail[i]["medins_list_desc"]);
  2090. jaFeeOne.Add("prodname", jaFeeDetail[i]["medins_list_desc"]);
  2091. if (string.IsNullOrEmpty(jaFeeDetail[i]["spec"].ToString()))
  2092. {
  2093. jaFeeOne.Add("spec", "");
  2094. }
  2095. else
  2096. {
  2097. jaFeeOne.Add("spec", jaFeeDetail[i]["spec"]);
  2098. }
  2099. if (string.IsNullOrEmpty(jaFeeDetail[i]["doseForm"].ToString()))
  2100. {
  2101. jaFeeOne.Add("dosform_name", "");
  2102. }
  2103. else
  2104. {
  2105. jaFeeOne.Add("dosform_name", jaFeeDetail[i]["doseForm"]);
  2106. }
  2107. jaFeeOne.Add(" det_item_fee_sumamt", jaFeeDetail[i]["det_item_fee_sumamt"]);
  2108. jaFeeOne.Add("cnt", jaFeeDetail[i]["cnt"]);
  2109. jaFeeOne.Add("pric", jaFeeDetail[i]["pric"]);
  2110. if (string.IsNullOrEmpty(jaFeeDetail[i]["sin_dos_dscr"].ToString()))
  2111. {
  2112. jaFeeOne.Add("sin_dos_dscr", "");
  2113. }
  2114. else
  2115. {
  2116. jaFeeOne.Add("sin_dos_dscr", jaFeeDetail[i]["sin_dos_dscr"]);
  2117. }
  2118. if (string.IsNullOrEmpty(jaFeeDetail[i]["used_frqu_dscr"].ToString()))
  2119. {
  2120. jaFeeOne.Add("used_frqu_dscr", "");
  2121. }
  2122. else
  2123. {
  2124. jaFeeOne.Add("used_frqu_dscr", jaFeeDetail[i]["used_frqu_dscr"]);
  2125. }
  2126. if (string.IsNullOrEmpty(jaFeeDetail[i]["prd_days"].ToString()))
  2127. {
  2128. jaFeeOne.Add("prd_days", "");
  2129. }
  2130. else
  2131. {
  2132. jaFeeOne.Add("prd_days", jaFeeDetail[i]["prd_days"]);
  2133. }
  2134. if (string.IsNullOrEmpty(jaFeeDetail[i]["medc_way_dscr"].ToString()))
  2135. {
  2136. jaFeeOne.Add("medc_way_dscr", "");
  2137. }
  2138. else
  2139. {
  2140. jaFeeOne.Add("medc_way_dscr", jaFeeDetail[i]["medc_way_dscr"]);
  2141. }
  2142. if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_codg"].ToString()))
  2143. {
  2144. jaFeeOne.Add("bilg_dr_codg", "");
  2145. }
  2146. else
  2147. {
  2148. jaFeeOne.Add("bilg_dr_codg", jaFeeDetail[i]["bilg_dr_codg"]);
  2149. }
  2150. if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_name"].ToString()))
  2151. {
  2152. jaFeeOne.Add("bilg_dr_name", "");
  2153. }
  2154. else
  2155. {
  2156. jaFeeOne.Add("bilg_dr_name", jaFeeDetail[i]["bilg_dr_name"]);
  2157. }
  2158. jaFeeOne.Add("phar_name", "");
  2159. jaFeeOne.Add("phar_prac_cert_no", "");
  2160. jaFeeOne.Add("tcmdrug_used_way", ""); //中药使用方式 1复方 2单方 必填
  2161. jaFeeOne.Add("trdn_flag", "1");//拆零标志 必填 0否 1是
  2162. jaFeeDetail.Add(jaFeeOne);
  2163. jaFeeOne = new JObject();
  2164. }
  2165. joParam992004.Add("setlinfo", JObject.Parse(setlinfo1));
  2166. joParam992004.Add("drugdetail", jaFeeDetail);//购药明细节点
  2167. }
  2168. return 0;
  2169. }
  2170. catch (Exception ex)
  2171. {
  2172. errMsg = "parsejoParam 解析入参异常2:" + errMsg;
  2173. return -1;
  2174. }
  2175. }
  2176. /// <summary>
  2177. /// 自助机
  2178. /// </summary>
  2179. /// <param name="InParam"></param>
  2180. /// <returns></returns>
  2181. public string SelfServiceMachine(string InParam)
  2182. {
  2183. Global.writeLog("SelfServiceMachine 入参:" + JsonHelper.Compress(InParam));
  2184. //设置返回值,错误信息
  2185. string errMsg, rtnResult = "", outParam;
  2186. try
  2187. {
  2188. //解析入参
  2189. if (parseInparam(InParam, out errMsg) != 0)
  2190. {
  2191. rtnResult = JsonHelper.setExceptionJson(-1, "parseInparam", errMsg).ToString();
  2192. return rtnResult;
  2193. }
  2194. //获取pat
  2195. hBus.GetSelfServiceMachineInfo(businessType, joInParam, out Global.pat);
  2196. //BS架构调用方式问题,每次调用都需要重新初始化
  2197. if (init(InParam, out errMsg) != 0)
  2198. //if (hBus.InitA(InParam, out errMsg) != 0)
  2199. {
  2200. rtnResult = JsonHelper.setExceptionJson(-1, "InitA", errMsg).ToString(); ;
  2201. return rtnResult;
  2202. }
  2203. else
  2204. {
  2205. //joInParam.Add("patInfo", errMsg);
  2206. Global.writeLog($"InitA初始化成功!");
  2207. }
  2208. switch (businessType)
  2209. {
  2210. case "GetPatientInfo"://读取患者信息,该节点无需重定向
  2211. {
  2212. //重定向
  2213. Business.Core.SelfServiceMachine.PatientService patientService = new Business.Core.SelfServiceMachine.PatientService();
  2214. rtnResult = patientService.GetPatientInfo();
  2215. break;
  2216. }
  2217. case "OPReg"://门诊挂号
  2218. {
  2219. #region 链条式任务调度者
  2220. OPRegService service = new OPRegService();
  2221. rtnResult = service.Charge(operationType, joInParam);
  2222. break;
  2223. #endregion
  2224. }
  2225. case "OPSettl"://门诊结算
  2226. {
  2227. OPSettlementService service = new OPSettlementService();
  2228. rtnResult = service.Charge(operationType, joInParam);
  2229. break;
  2230. }
  2231. case "IPInReg"://入院登记
  2232. {
  2233. IPAdmRegService service = new IPAdmRegService();
  2234. rtnResult = service.Register(operationType, joInParam);
  2235. break;
  2236. }
  2237. case "IPInRegCancel"://取消入院登记
  2238. {
  2239. IPAdmRegService service = new IPAdmRegService();
  2240. rtnResult = service.CancelRegister(operationType, joInParam);
  2241. break;
  2242. }
  2243. case "IPOutReg"://出院登记
  2244. {
  2245. break;
  2246. }
  2247. case "IPUpoload"://住院费用上传
  2248. {
  2249. break;
  2250. }
  2251. case "IPPreSettl"://住院预计结算
  2252. {
  2253. break;
  2254. }
  2255. case "IPSettl"://住院结算
  2256. {
  2257. IPSettlementService service = new IPSettlementService();
  2258. rtnResult = service.Charge(joInParam);
  2259. return rtnResult;
  2260. }
  2261. case "DischargeAudit"://费用核查
  2262. {
  2263. DischargeAuditService service = new DischargeAuditService();
  2264. rtnResult = service.Audit(joInParam);
  2265. return rtnResult;
  2266. }
  2267. default:
  2268. {
  2269. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", "传入的业务编码不对!").ToString();
  2270. return rtnResult;
  2271. }
  2272. }
  2273. return rtnResult;
  2274. }
  2275. catch (Exception ex)
  2276. {
  2277. rtnResult = JsonHelper.setExceptionJson(-1, "SelfServiceMachine 交易", ex.Message).ToString();
  2278. return rtnResult;
  2279. }
  2280. finally
  2281. {
  2282. Global.writeLog("SelfServiceMachine 出参:" + JsonHelper.Compress(rtnResult));
  2283. }
  2284. }
  2285. }
  2286. }