From 39aa21b9cfbba8ae94d9d1323b70a41898e57142 Mon Sep 17 00:00:00 2001
From: wxd <123@qq.com>
Date: Thu, 7 Nov 2024 18:19:29 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8E=86=E6=AC=A1=E7=BB=93=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../GetItemTwoHistoricalResultsDto.cs | 25 ++++++++
.../GetItemTwoHistoricalResultsInputDto.cs | 20 +++++++
.../RegisterCheckItemAppService.cs | 57 +++++++++++++++++++
3 files changed, 102 insertions(+)
create mode 100644 src/Shentun.Peis.Application.Contracts/RegisterCheckItems/GetItemTwoHistoricalResultsDto.cs
create mode 100644 src/Shentun.Peis.Application.Contracts/RegisterCheckItems/GetItemTwoHistoricalResultsInputDto.cs
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;
+ }
}
}