diff --git a/src/Shentun.Peis.Application.Contracts/RegisterCheckItems/GetItemTwoHistoricalResultsDto.cs b/src/Shentun.Peis.Application.Contracts/RegisterCheckItems/GetItemTwoHistoricalResultsDto.cs new file mode 100644 index 0000000..cd0abb1 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/RegisterCheckItems/GetItemTwoHistoricalResultsDto.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.RegisterCheckItems +{ + public class GetItemTwoHistoricalResultsDto + { + /// + /// 检查日期 + /// + public string CheckDate { get; set; } + + /// + /// 项目名称 + /// + public string ItemName { get; set; } + + + /// + /// 项目结果 + /// + public string ItemResult { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/RegisterCheckItems/GetItemTwoHistoricalResultsInputDto.cs b/src/Shentun.Peis.Application.Contracts/RegisterCheckItems/GetItemTwoHistoricalResultsInputDto.cs new file mode 100644 index 0000000..c90386b --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/RegisterCheckItems/GetItemTwoHistoricalResultsInputDto.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.RegisterCheckItems +{ + public class GetItemTwoHistoricalResultsInputDto + { + + /// + /// 检查ID + /// + public Guid RegisterCheckId { get; set; } + + /// + /// 项目ID + /// + public Guid ItemId { get; set; } + } +} diff --git a/src/Shentun.Peis.Application/RegisterCheckItems/RegisterCheckItemAppService.cs b/src/Shentun.Peis.Application/RegisterCheckItems/RegisterCheckItemAppService.cs index c22d2a3..b63f46f 100644 --- a/src/Shentun.Peis.Application/RegisterCheckItems/RegisterCheckItemAppService.cs +++ b/src/Shentun.Peis.Application/RegisterCheckItems/RegisterCheckItemAppService.cs @@ -518,5 +518,62 @@ namespace Shentun.Peis.RegisterCheckItems } + + /// + /// 获取前两次历史结果 + /// + /// + [HttpPost("api/app/RegisterCheckItem/GetItemTwoHistoricalResults")] + public async Task> GetItemTwoHistoricalResultsAsync(GetItemTwoHistoricalResultsInputDto input) + { + if (input.RegisterCheckId == Guid.Empty) + { + throw new UserFriendlyException("检查id不正确"); + } + + if (input.ItemId == Guid.Empty) + { + throw new UserFriendlyException("项目id不正确"); + } + + + var patientRegisterEnt = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId + join registerCheckItem in await _registerCheckItemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckItem.RegisterCheckId + where registerCheckItem.RegisterCheckId == input.RegisterCheckId && registerCheckItem.ItemId == input.ItemId + select new + { + patientId = patientRegister.PatientId, + patientRegisterId = patientRegister.Id + }).FirstOrDefault(); + if (patientRegisterEnt == null) + { + throw new UserFriendlyException("数据不正确"); + } + + var historicalItemResult = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId + 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 == patientRegisterEnt.patientId + && registerCheckItem.ItemId == input.ItemId + && patientRegister.Id != patientRegisterEnt.patientRegisterId + orderby registerCheckItem.CreationTime descending + select new + { + checkDate = registerCheckItem.CheckDate, + itemName = item.DisplayName, + itemResult = registerCheckItem.Result + }).Take(2); + + var entListDto = historicalItemResult.Select(s => new GetItemTwoHistoricalResultsDto + { + CheckDate = DataHelper.ConversionDateShortToString(s.checkDate), + ItemName = s.itemName, + ItemResult = s.itemResult + }).ToList(); + + return entListDto; + } } }