From 781484674423b31d1dbc8f3f1a63e51a9d168273 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Wed, 28 Aug 2024 11:06:33 +0800 Subject: [PATCH] 0828 --- ...terCheckPictureByCheckRequestNoInputDto.cs | 24 ++++ ...SumSummaryReportHorizontalComparisonDto.cs | 3 +- .../MenuInfos/MenuInfoAppService.cs | 2 +- .../PacsBusiness/PacsBusinessAppService.cs | 128 ++++++++++++++++++ .../RegisterCheckAsbitemAppService.cs | 22 ++- .../RegisterCheckPictureAppService.cs | 1 + .../SumSummaryReportAppService.cs | 93 ++++++++++++- 7 files changed, 266 insertions(+), 7 deletions(-) create mode 100644 src/Shentun.Peis.Application.Contracts/PacsBusiness/ImportRegisterCheckPictureByCheckRequestNoInputDto.cs create mode 100644 src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs diff --git a/src/Shentun.Peis.Application.Contracts/PacsBusiness/ImportRegisterCheckPictureByCheckRequestNoInputDto.cs b/src/Shentun.Peis.Application.Contracts/PacsBusiness/ImportRegisterCheckPictureByCheckRequestNoInputDto.cs new file mode 100644 index 0000000..0a586e8 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/PacsBusiness/ImportRegisterCheckPictureByCheckRequestNoInputDto.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.PacsBusiness +{ + public class ImportRegisterCheckPictureByCheckRequestNoInputDto + { + /// + /// 检查单号 + /// + public string CheckRequestNo { get; set; } + + /// + /// 文件名称 + /// + public string FileName { get; set; } + + /// + /// 图片base64 + /// + public string PictureBaseStr { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportHorizontalComparisonDto.cs b/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportHorizontalComparisonDto.cs index 195c43d..58679c8 100644 --- a/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportHorizontalComparisonDto.cs +++ b/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportHorizontalComparisonDto.cs @@ -7,7 +7,7 @@ namespace Shentun.Peis.SumSummaryReports public class SumSummaryReportHorizontalComparisonDto { public Guid RegsterCheckId { get; set; } - public DateTime CheckDate { get; set; } + public string CheckDate { get; set; } public List Summarys { get; set; } public List RegisterCheckItems { get; set; } } @@ -19,6 +19,7 @@ namespace Shentun.Peis.SumSummaryReports public class SumSummaryReportHorizontalComparisonWithCheckItemResultDto { + /// /// 项目名字 /// public string ItemName { get; set; } diff --git a/src/Shentun.Peis.Application/MenuInfos/MenuInfoAppService.cs b/src/Shentun.Peis.Application/MenuInfos/MenuInfoAppService.cs index 90f13b1..d5ea866 100644 --- a/src/Shentun.Peis.Application/MenuInfos/MenuInfoAppService.cs +++ b/src/Shentun.Peis.Application/MenuInfos/MenuInfoAppService.cs @@ -194,7 +194,7 @@ namespace Shentun.Peis.MenuInfos { var query = await _menuInfoRepository.GetQueryableAsync(); - + query = query.Where(m => m.IsActive == 'Y'); string AdminId = _configuration.GetValue("AdminId"); diff --git a/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs b/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs new file mode 100644 index 0000000..d94d64d --- /dev/null +++ b/src/Shentun.Peis.Application/PacsBusiness/PacsBusinessAppService.cs @@ -0,0 +1,128 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Shentun.Peis.Enums; +using Shentun.Peis.Models; +using Shentun.Peis.RegisterCheckPictures; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; + +namespace Shentun.Peis.PacsBusiness +{ + /// + /// pacs相关接口 + /// + [ApiExplorerSettings(GroupName = "Work")] + public class PacsBusinessAppService : ApplicationService + { + + private readonly IConfiguration _configuration; + private readonly IRepository _registerCheckRepository; + private readonly IRepository _patientRegisterRepository; + private readonly IRepository _registerCheckPictureRepository; + + public PacsBusinessAppService( + IConfiguration configuration, + IRepository registerCheckRepository, + IRepository patientRegisterRepository, + IRepository registerCheckPictureRepository) + { + _configuration = configuration; + _registerCheckRepository = registerCheckRepository; + _patientRegisterRepository = patientRegisterRepository; + _registerCheckPictureRepository = registerCheckPictureRepository; + } + + + /// + /// 导入心电图图片 根据检查单号 免登录 + /// + /// + /// + /// + [HttpPost("api/app/PacsBusiness/ImportRegisterCheckPictureByCheckRequestNo")] + public async Task ImportRegisterCheckPictureByCheckRequestNoAsync(ImportRegisterCheckPictureByCheckRequestNoInputDto input) + { + Random rd = new Random(); + + string AbsolutePath = _configuration.GetValue("PacsVirtualPath:RealPath"); + string AbsoluteName = _configuration.GetValue("PacsVirtualPath:Alias"); + + + + if (string.IsNullOrWhiteSpace(input.PictureBaseStr)) + { + throw new UserFriendlyException("图片数据不存在"); + } + + string PatientRegisterId = ""; + + var patientRegisterCompleteFlag = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId + where registerCheck.CheckRequestNo == input.CheckRequestNo + select new + { + registerCheckId = registerCheck.Id, + CompleteFlag = patientRegister.CompleteFlag + }).ToList(); + + if (patientRegisterCompleteFlag.Count == 0) + throw new UserFriendlyException("体检人员不存在"); + + if (patientRegisterCompleteFlag.FirstOrDefault().CompleteFlag == PatientRegisterCompleteFlag.PreRegistration) + throw new UserFriendlyException("预登记人员不能导入图片"); + if (patientRegisterCompleteFlag.FirstOrDefault().CompleteFlag == PatientRegisterCompleteFlag.SumCheck) + throw new UserFriendlyException("已总检人员不能导入图片"); + + + Guid registerCheckId = patientRegisterCompleteFlag.FirstOrDefault().registerCheckId; + + + + string PictureUrl = ImageHelper.Base64StrToImageInAbsolutePath(AbsolutePath, input.FileName, input.PictureBaseStr, + PatientRegisterId, + registerCheckId.ToString(), AbsoluteName); + + if (string.IsNullOrEmpty(PictureUrl)) + { + throw new UserFriendlyException("图片数据有误"); + } + + var ent = await _registerCheckPictureRepository.FirstOrDefaultAsync(m => m.RegisterCheckId == registerCheckId + && m.PictureFilename == PictureUrl); + + if (ent != null) + { + ent.PictureFilename = PictureUrl; + + await _registerCheckPictureRepository.UpdateAsync(ent); + } + else + { + var maxDisplayOrder = (await _registerCheckPictureRepository.GetQueryableAsync()) + .Where(m => m.RegisterCheckId == registerCheckId) + .OrderByDescending(o => o.DisplayOrder) + .Select(s => s.DisplayOrder) + .FirstOrDefault(); + + ent = new RegisterCheckPicture + { + DisplayOrder = maxDisplayOrder + 1, + IsPrint = 'Y', + PictureFilename = PictureUrl, + RegisterCheckId = registerCheckId, + PictureFileType = '0', + LocalPathName = "" + }; + + await _registerCheckPictureRepository.InsertAsync(ent); + } + + } + } +} diff --git a/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs b/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs index 55ada24..e168c2e 100644 --- a/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs +++ b/src/Shentun.Peis.Application/RegisterCheckAsbitems/RegisterCheckAsbitemAppService.cs @@ -364,6 +364,22 @@ namespace Shentun.Peis.RegisterAsbitems .OrderBy(o => o.Asbitem.DisplayOrder) .ToList(); + + var ggg = ( + from registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() + join chargeRequest in await _chargeRequestRepository.GetQueryableAsync() + on registerCheckAsbitem.ChargeRequestId equals chargeRequest.Id + where chargeRequest.PatientRegisterId == input.PatientRegisterId + && (chargeRequest.ChargeRequestFlag == ChargeRequestFlag.ChargeRequest + || chargeRequest.ChargeRequestFlag == ChargeRequestFlag.CancelChargeRequest + || chargeRequest.ChargeRequestFlag == ChargeRequestFlag.RefundRequest) + select new + { + + RegisterCheckAsbitem = registerCheckAsbitem, + ChargeRequest = chargeRequest, + }).ToQueryString(); + var chargeRequests = ( from registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() join chargeRequest in await _chargeRequestRepository.GetQueryableAsync() @@ -374,14 +390,14 @@ namespace Shentun.Peis.RegisterAsbitems || chargeRequest.ChargeRequestFlag == ChargeRequestFlag.RefundRequest) select new { - + RegisterCheckAsbitem = registerCheckAsbitem, ChargeRequest = chargeRequest, }) .ToList(); - entlist = entlist.Where(o=> !chargeRequests.Select(o=>o.ChargeRequest.Id).ToList() - .Contains((Guid)(o.RegisterCheckAsbitem.ChargeRequestId==null?Guid.Empty: o.RegisterCheckAsbitem.ChargeRequestId))).ToList(); + entlist = entlist.Where(o => !chargeRequests.Select(o => o.ChargeRequest.Id).ToList() + .Contains((Guid)(o.RegisterCheckAsbitem.ChargeRequestId == null ? Guid.Empty : o.RegisterCheckAsbitem.ChargeRequestId))).ToList(); var entdto = entlist.Select(s => new RegisterCheckAsbitemOrAsbitemDto { RegisterCheckAsbitemId = s.RegisterCheckAsbitem.Id, diff --git a/src/Shentun.Peis.Application/RegisterCheckPictures/RegisterCheckPictureAppService.cs b/src/Shentun.Peis.Application/RegisterCheckPictures/RegisterCheckPictureAppService.cs index d8567c4..5b2c3b5 100644 --- a/src/Shentun.Peis.Application/RegisterCheckPictures/RegisterCheckPictureAppService.cs +++ b/src/Shentun.Peis.Application/RegisterCheckPictures/RegisterCheckPictureAppService.cs @@ -236,6 +236,7 @@ namespace Shentun.Peis.RegisterCheckPictures /// /// /// + [RemoteService(false)] [HttpPost("api/app/registercheckpicture/uploadregistercheckpicturefilemany")] public async Task> UploadRegisterCheckPictureFileManyAsync([FromForm(Name = "file")] List files, Guid RegisterCheckId) { diff --git a/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs b/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs index 94a22ad..ea65d9f 100644 --- a/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs +++ b/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs @@ -9,6 +9,7 @@ using Shentun.Peis.Enums; using Shentun.Peis.Models; using Shentun.Peis.PatientRegisters; using Shentun.Peis.Patients; +using Shentun.Peis.PrintReports; using SqlSugar; using System; using System.Collections.Generic; @@ -382,7 +383,7 @@ namespace Shentun.Peis.SumSummaryReports join itemType in await _itemTypeRepository.GetQueryableAsync() on asbitem.ItemTypeId equals itemType.Id where patient.Id == input.PatientId - && patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck + && patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck && registerCheck.CompleteFlag == RegisterCheckCompleteFlag.Checked && asbitem.IsCheck == 'Y' select new @@ -486,7 +487,7 @@ namespace Shentun.Peis.SumSummaryReports var registerChecks = list.Where(o => o.registerCheck.Id == registerCheckId).ToList(); var sumSummaryReportHorizontalComparisonDto = new SumSummaryReportHorizontalComparisonDto() { - CheckDate = ((DateTime)registerChecks.First().registerCheck.CheckDate).Date, + CheckDate = DataHelper.ConversionDateShortToString(registerChecks.First().registerCheck.CheckDate), Summarys = registerChecks.OrderBy(o => o.registerCheckSummary.DisplayOrder) .GroupBy(o => o.registerCheckSummary.Summary) .Select(o => new SumSummaryReportHorizontalComparisonWithCheckSummaryDto() @@ -516,7 +517,95 @@ namespace Shentun.Peis.SumSummaryReports + /// + /// 获取上一次项目检查数据 + /// + /// + /// + [HttpPost("api/app/SumSummaryReport/GetLastTimeAsbitemResult")] + public async Task GetLastTimeAsbitemResultAsync(RegisterCheckIdInputDto input) + { + var paraQuery = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId + join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId + where registerCheck.Id == input.RegisterCheckId + select new + { + medicalTimes = patientRegister.MedicalTimes, + patientId = patientRegister.PatientId, + registerCheckId = registerCheck.Id, + asbitemId = registerCheckAsbitem.AsbitemId + }).ToList(); + + var asbitemIds = paraQuery.Select(s => s.asbitemId).ToList(); + var medicalTimes = paraQuery.FirstOrDefault().medicalTimes; + var patientId = paraQuery.FirstOrDefault().patientId; + + var list = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join registerCheck in await _registerCheckRepository.GetQueryableAsync() + on patientRegister.Id equals registerCheck.PatientRegisterId + join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() + on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId + join registerCheckSummary in await _registerCheckSummaryRepository.GetQueryableAsync() + on registerCheck.Id equals registerCheckSummary.RegisterCheckId + join asbitem in await _asbitemRepository.GetQueryableAsync() + on registerCheckAsbitem.AsbitemId equals asbitem.Id + join registerCheckItem in await _registerCheckItemRepository.GetQueryableAsync() + on registerCheck.Id equals registerCheckItem.RegisterCheckId + join item in await _itemRepository.GetQueryableAsync() + on registerCheckItem.ItemId equals item.Id + where patientRegister.PatientId == patientId + && patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck + && registerCheck.CompleteFlag == RegisterCheckCompleteFlag.Checked + && asbitem.IsCheck == 'Y' + && asbitemIds.Contains(asbitem.Id) + && patientRegister.MedicalTimes < medicalTimes + select new + { + patientRegister, + registerCheck, + registerCheckSummary, + registerCheckAsbitem, + asbitem, + registerCheckItem, + item + }).OrderByDescending(o => o.patientRegister.MedicalTimes).ToList(); + + + if (list.Count == 0) + return null; + + + var resultStatus = await _resultStatusRepository.GetListAsync(); + var registerCheckId = list.OrderBy(o => o.registerCheck.CheckDate).Select(o => o.registerCheck.Id).Distinct().FirstOrDefault(); + + var registerChecks = list.Where(o => o.registerCheck.Id == registerCheckId).ToList(); + var sumSummaryReportHorizontalComparisonDto = new SumSummaryReportHorizontalComparisonDto() + { + CheckDate = DataHelper.ConversionDateShortToString(registerChecks.First().registerCheck.CheckDate), + Summarys = registerChecks.OrderBy(o => o.registerCheckSummary.DisplayOrder) + .GroupBy(o => o.registerCheckSummary.Summary) + .Select(o => new SumSummaryReportHorizontalComparisonWithCheckSummaryDto() + { + Summary = o.FirstOrDefault().registerCheckSummary.Summary + }).ToList(), + RegisterCheckItems = registerChecks.OrderBy(o => o.item.DisplayOrder) + .GroupBy(o => o.registerCheckItem) + .Select(o => new SumSummaryReportHorizontalComparisonWithCheckItemResultDto() + { + ItemName = o.FirstOrDefault().item.DisplayName, + ResultValue = o.FirstOrDefault().registerCheckItem.Result, + ReferenceRangeValue = o.FirstOrDefault().registerCheckItem.ReferenceRangeValue, + UnitName = o.FirstOrDefault().registerCheckItem.Unit, + ReportFontColor = (resultStatus.Where(x => x.Id == o.FirstOrDefault().registerCheckItem.ResultStatusId).FirstOrDefault() == null) ? 0 : resultStatus.Where(x => x.Id == o.FirstOrDefault().registerCheckItem.ResultStatusId).FirstOrDefault().ReportFontColor + + }).ToList() + + }; + + return sumSummaryReportHorizontalComparisonDto; + }