From 9c575b2ffab7261dfdc0dc61839d6946a29a6eb8 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Tue, 29 Oct 2024 15:02:49 +0800 Subject: [PATCH] =?UTF-8?q?pacs+=E4=BA=BA=E5=AF=BF=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PacsBusiness/PacsBusinessAppService.cs | 64 +++++++++++++++++-- .../PatientRegisterAppService.cs | 21 +++++- .../ThirdBookingPushAppService.cs | 39 +++++++++-- .../PeisHttpApiHostModule.cs | 11 +++- 4 files changed, 118 insertions(+), 17 deletions(-) diff --git a/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs b/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs index ff7a5bf..6e5c8ef 100644 --- a/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs +++ b/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs @@ -1,6 +1,8 @@ -using Microsoft.AspNetCore.Mvc; +using log4net.Repository.Hierarchy; +using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; using NPOI.POIFS.Storage; using NPOI.Util; using NUglify.Helpers; @@ -14,10 +16,12 @@ using Shentun.Peis.RegisterChecks; using Shentun.Peis.RegisterCheckSuggestions; using Shentun.Peis.RegisterCheckSummarys; using Shentun.Peis.SumSummaryReports; +using Shentun.Peis.ThirdBookingPushs; using Shentun.Peis.ThirdPartyPublicInterfaces; using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Text; using System.Threading.Tasks; using Volo.Abp; @@ -25,6 +29,7 @@ using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; using Volo.Abp.Users; +using static Volo.Abp.Identity.Settings.IdentitySettingNames; namespace Shentun.Peis.PacsBusiness { @@ -52,6 +57,7 @@ namespace Shentun.Peis.PacsBusiness private readonly ICurrentUser _currentUser; private readonly IRepository _userItemTypeRepository; private readonly IRepository _dicomFileDetailRepository; + private readonly ILogger _logger; public PacsBusinessAppService( IConfiguration configuration, IRepository registerCheckRepository, @@ -69,7 +75,8 @@ namespace Shentun.Peis.PacsBusiness IRepository asbitemRepository, ICurrentUser currentUser, IRepository userItemTypeRepository, - IRepository dicomFileDetailRepository) + IRepository dicomFileDetailRepository, + ILogger logger) { _configuration = configuration; _registerCheckRepository = registerCheckRepository; @@ -88,6 +95,7 @@ namespace Shentun.Peis.PacsBusiness _currentUser = currentUser; _userItemTypeRepository = userItemTypeRepository; _dicomFileDetailRepository = dicomFileDetailRepository; + _logger = logger; } @@ -434,16 +442,16 @@ namespace Shentun.Peis.PacsBusiness if (registerCheckEnt == null) throw new UserFriendlyException("条码号不正确"); - if (!string.IsNullOrWhiteSpace(input.InstanceId)) + if (string.IsNullOrWhiteSpace(input.InstanceId)) throw new UserFriendlyException("InstanceId不正确"); - if (!string.IsNullOrWhiteSpace(input.ParentStudyId)) + if (string.IsNullOrWhiteSpace(input.ParentStudyId)) throw new UserFriendlyException("ParentStudyId不正确"); - if (!string.IsNullOrWhiteSpace(input.ParentPatientId)) + if (string.IsNullOrWhiteSpace(input.ParentPatientId)) throw new UserFriendlyException("ParentPatientId不正确"); - if (!string.IsNullOrWhiteSpace(input.ParentSeriesId)) + if (string.IsNullOrWhiteSpace(input.ParentSeriesId)) throw new UserFriendlyException("ParentSeriesId不正确"); if (string.IsNullOrWhiteSpace(input.Status)) @@ -526,6 +534,50 @@ namespace Shentun.Peis.PacsBusiness return entListDto; } + /// + /// 删除体检dicom服务数据,并清理dicom服务记录 + /// + /// + /// + [HttpPost("api/app/PacsBusiness/DeletePacsCheckDicomDataByRegisterCheckId")] + public async Task DeletePacsCheckDicomDataByRegisterCheckIdAsync(RegisterCheckIdInputDto input) + { + var dicomFileDetailList = await _dicomFileDetailRepository.GetListAsync(m => m.RegisterCheckId == input.RegisterCheckId); + if (dicomFileDetailList.Any()) + { + string authString = _configuration.GetValue("Pacs:AuthString"); + string baseApiUrl = _configuration.GetValue("Pacs:BaseApiUrl"); + if (string.IsNullOrWhiteSpace(authString) || string.IsNullOrWhiteSpace(baseApiUrl)) + { + throw new UserFriendlyException("请配置pacs相关信息"); + } + string parentPatientId = dicomFileDetailList.First().ParentPatientId; + + await CallPacsDicomServiceAsync($"{baseApiUrl}/patients/{parentPatientId}", authString, "delete"); + + await _dicomFileDetailRepository.DeleteManyAsync(dicomFileDetailList); + + } + } + + /// + /// 调用dicom服务api + /// + /// + /// + /// + /// + private async Task CallPacsDicomServiceAsync(string apiUrl, string authString, string mothod) + { + var enCodeAuthString = Convert.ToBase64String(Encoding.ASCII.GetBytes(authString)); + using var httpClient = new HttpClient(); + httpClient.DefaultRequestHeaders.Add("Authorization", $"Basic {enCodeAuthString}"); + if (mothod == "delete") + { + var response = await httpClient.DeleteAsync(apiUrl); + } + } + } } diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs index cb47522..1096399 100644 --- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs @@ -988,7 +988,14 @@ namespace Shentun.Peis.PatientRegisters if (!string.IsNullOrWhiteSpace(input.ThirdBookingId)) { - await _thirdBookingPushAppService.PushRegisterAsync(new PatientRegisterIdInputDto { PatientRegisterId = entity.Id }); + try + { + await _thirdBookingPushAppService.PushRegisterAsync(new PatientRegisterIdInputDto { PatientRegisterId = entity.Id }); + } + catch (Exception ex) + { + _logger.LogError($"推送人寿完成登记=》{ex.Message}"); + } } #endregion @@ -2208,8 +2215,18 @@ namespace Shentun.Peis.PatientRegisters if (!string.IsNullOrWhiteSpace(entity.ThirdBookingId) && input.IsAudit == 'Y') { - await _thirdBookingPushAppService.PushCompletePhysicalAsync(new PatientRegisterIdInputDto { PatientRegisterId = entity.Id }); + try + { + await _thirdBookingPushAppService.PushCompletePhysicalAsync(new PatientRegisterIdInputDto { PatientRegisterId = entity.Id }); + } + catch (Exception ex) + { + _logger.LogError($"推送人寿完成体检=》{ex.Message}"); + } + } + + #endregion return ObjectMapper.Map(newentity); } diff --git a/src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs b/src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs index 6f93cd8..b9a929d 100644 --- a/src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs +++ b/src/Shentun.Peis.Application/ThirdBookingPushs/ThirdBookingPushAppService.cs @@ -18,9 +18,11 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Net.Mime; using System.Security.Policy; +using System.ServiceModel.Channels; using System.Text; using System.Threading.Channels; using System.Threading.Tasks; +using Volo.Abp; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; @@ -128,11 +130,20 @@ namespace Shentun.Peis.ThirdBookingPushs thirdBookingEnt.MedicalStatus = '1'; await _thirdBookingRepository.UpdateAsync(thirdBookingEnt); } + else + { + throw new UserFriendlyException($"推送失败:Id为{input.PatientRegisterId},状态为:{decryptDataPara.STATUS},{decryptDataPara.MESSAGE}"); + } + } + else + { + throw new UserFriendlyException($"推送失败:Id为{input.PatientRegisterId},{resultPara.MESSAGE}"); } } } } + } } } @@ -223,6 +234,14 @@ namespace Shentun.Peis.ThirdBookingPushs thirdBookingEnt.MedicalStatus = '2'; await _thirdBookingRepository.UpdateAsync(thirdBookingEnt); } + else + { + throw new UserFriendlyException($"推送失败:Id为{input.PatientRegisterId},状态为:{decryptDataPara.STATUS},{decryptDataPara.MESSAGE}"); + } + } + else + { + throw new UserFriendlyException($"推送失败:Id为{input.PatientRegisterId},{resultPara.MESSAGE}"); } } } @@ -335,6 +354,14 @@ namespace Shentun.Peis.ThirdBookingPushs thirdBookingEnt.MedicalStatus = '3'; await _thirdBookingRepository.UpdateAsync(thirdBookingEnt); } + else + { + throw new UserFriendlyException($"推送失败:Id为{input.PatientRegisterId},{decryptDataPara.MESSAGE}"); + } + } + else + { + throw new UserFriendlyException($"推送失败:Id为{input.PatientRegisterId},{fileResultEncry.MESSAGE}"); } #endregion @@ -343,14 +370,14 @@ namespace Shentun.Peis.ThirdBookingPushs } + else + { + throw new UserFriendlyException($"推送失败:Id为{input.PatientRegisterId},{fileResultEncry.MESSAGE}"); + } #endregion - - - - } } } @@ -407,7 +434,7 @@ namespace Shentun.Peis.ThirdBookingPushs if (!response.IsSuccessStatusCode) { result = response.Content.ReadAsStringAsync().Result; - //throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); + throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); } result = await response.Content.ReadAsStringAsync(); @@ -463,7 +490,7 @@ namespace Shentun.Peis.ThirdBookingPushs if (!response.IsSuccessStatusCode) { result = response.Content.ReadAsStringAsync().Result; - //throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); + throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); } result = await response.Content.ReadAsStringAsync(); diff --git a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs index 2470ad4..21114bf 100644 --- a/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs +++ b/src/Shentun.Peis.HttpApi.Host/PeisHttpApiHostModule.cs @@ -571,7 +571,7 @@ public class PeisHttpApiHostModule : AbpModule RequestPath = "/UserSign" }); - + //虚拟目录 app.UseStaticFiles(new StaticFileOptions { @@ -632,8 +632,13 @@ public class PeisHttpApiHostModule : AbpModule app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); - //任务计划 - await StartScheduler(context); + var IsEnabledHangfire = configuration["Hangfire:IsEnabled"]; + if (!string.IsNullOrWhiteSpace(IsEnabledHangfire) && Convert.ToBoolean(IsEnabledHangfire) == true) + { + //任务计划 + await StartScheduler(context); + } + }