InsuBusiness.cs 110 KB

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