From 1c842e77c61d18372fb2ed837303cdeee5679280 Mon Sep 17 00:00:00 2001
From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com>
Date: Thu, 2 May 2024 17:00:17 +0800
Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E6=A3=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
....cs => SumSummaryReportDetailResultDto.cs} | 59 ++++-
.../SumSummaryReportAppService.cs | 207 ++++++++++++++----
.../ItemTypes/ItemTypeManager.cs | 5 +
.../SumSummaryReportAppServiceTest.cs | 48 ++++
4 files changed, 270 insertions(+), 49 deletions(-)
rename src/Shentun.Peis.Application.Contracts/SumSummaryReports/{DetailedResultsListDto.cs => SumSummaryReportDetailResultDto.cs} (52%)
create mode 100644 test/Shentun.Peis.Application.Tests/SumSummaryReportAppServiceTest.cs
diff --git a/src/Shentun.Peis.Application.Contracts/SumSummaryReports/DetailedResultsListDto.cs b/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportDetailResultDto.cs
similarity index 52%
rename from src/Shentun.Peis.Application.Contracts/SumSummaryReports/DetailedResultsListDto.cs
rename to src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportDetailResultDto.cs
index edb05af..b8c0dd0 100644
--- a/src/Shentun.Peis.Application.Contracts/SumSummaryReports/DetailedResultsListDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportDetailResultDto.cs
@@ -4,7 +4,7 @@ using System.Text;
namespace Shentun.Peis.SumSummaryReports
{
- public class DetailedResultsListDto
+ public class SumSummaryReportDetailResultDto
{
///
/// 项目类别名称
@@ -15,14 +15,14 @@ namespace Shentun.Peis.SumSummaryReports
///
/// 项目类别下的组合项目列表
///
- public List Asbitems { get; set; }
+ public List Asbitems { get; set; }
}
///
/// 项目类别下的组合项目
///
- public class DetailedResultsList_Asbitem
+ public class SumSummaryReportDetailResultWithAsbitem
{
///
@@ -44,24 +44,28 @@ namespace Shentun.Peis.SumSummaryReports
///
/// 检查日期
///
- public string CheckDate { get; set; }
+ public DateTime CheckDate { get; set; }
///
/// 检查项目列表
///
- public List Items { get; set; }
+ public List Items { get; set; }
///
/// 检查小结列表
///
- public List Summarys { get; set; }
+ public List Summarys { get; set; }
}
///
/// 检查项目
///
- public class DetailedResultsList_Asbitem_Item
+ public class SumSummaryReportDetailResultWithItem
{
+ ///
+ /// 项目ID
+ ///
+ public Guid ItemId { get; set; }
///
/// 项目名称
///
@@ -72,6 +76,16 @@ namespace Shentun.Peis.SumSummaryReports
///
public string ItemResult { get; set; }
+ ///
+ /// 上一次结果
+ ///
+ public string PreviousItemResult { get; set; }
+
+ ///
+ /// 上上次结果
+ ///
+ public string PreviousTwoItemResult { get; set; }
+
///
/// 参考范围
///
@@ -91,13 +105,42 @@ namespace Shentun.Peis.SumSummaryReports
/// 提示
///
public string ResultStatusName { get; set; }
+ //状态ID
+ public string ResultStatusId { get; set; }
+
+ ///
+ /// 上一次数据字体颜色
+ ///
+ public int PreviousReportFontColor { get; set; }
+ ///
+ /// 上一次数据背景颜色
+ ///
+ public int PreviousReportBackgroundColor { get; set; }
+
+ ///
+ /// 上两次数据字体颜色
+ ///
+ public int PreviousTwoReportFontColor { get; set; }
+ ///
+ /// 上两次数据背景颜色
+ ///
+ public int PreviousTwoReportBackgroundColor { get; set; }
+
+ ///
+ /// 数据字体颜色
+ ///
+ public int ReportFontColor { get; set; }
+ ///
+ /// 数据背景颜色
+ ///
+ public int ReportBackgroundColor { get; set; }
}
///
/// 检查小结
///
- public class DetailedResultsList_Asbitem_Summary
+ public class SumSummaryReportDetailResultWithSummary
{
///
/// 小结内容
diff --git a/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs b/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs
index 92bb064..871c22b 100644
--- a/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs
+++ b/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs
@@ -6,6 +6,8 @@ using Microsoft.VisualBasic;
using NPOI.OpenXmlFormats.Wordprocessing;
using Shentun.Peis.Enums;
using Shentun.Peis.Models;
+using Shentun.Peis.PatientRegisters;
+using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
@@ -26,93 +28,216 @@ namespace Shentun.Peis.SumSummaryReports
[Authorize]
public class SumSummaryReportAppService : ApplicationService
{
+ private readonly IRepository _patientRepository;
private readonly IRepository _registerCheckRepository;
private readonly IRepository _identityUserRepository;
private readonly IRepository _itemTypeRepository;
+ private readonly IRepository _registerCheckItemRepository;
+ private readonly IRepository- _itemRepository;
private readonly IRepository _patientRegisterRepository;
- private readonly IRepository _registerAsbitemRepository;
+ private readonly IRepository _registerCheckAsbitemRepository;
private readonly IRepository _resultStatusRepository;
private readonly ISumSummaryReportRepository _sumSummaryReportRepository;
private readonly CacheService _cacheService;
private readonly IRepository _registerCheckSummaryRepository;
private readonly IRepository _asbitemRepository;
public SumSummaryReportAppService(
+ IRepository patientRepository,
IRepository registerCheckRepository,
IRepository identityUserRepository,
IRepository itemTypeRepository,
IRepository patientRegisterRepository,
- IRepository registerAsbitemRepository,
+ IRepository registerCheckAsbitemRepository,
ISumSummaryReportRepository sumSummaryReportRepository,
IRepository resultStatusRepository,
CacheService cacheService,
IRepository registerCheckSummaryRepository,
- IRepository asbitemRepository)
+ IRepository asbitemRepository,
+ IRepository
- itemRepository,
+ IRepository registerCheckItemRepository)
{
this._registerCheckRepository = registerCheckRepository;
this._identityUserRepository = identityUserRepository;
this._itemTypeRepository = itemTypeRepository;
this._patientRegisterRepository = patientRegisterRepository;
- this._registerAsbitemRepository = registerAsbitemRepository;
+ this._registerCheckAsbitemRepository = registerCheckAsbitemRepository;
this._sumSummaryReportRepository = sumSummaryReportRepository;
_cacheService = cacheService;
_resultStatusRepository = resultStatusRepository;
_registerCheckSummaryRepository = registerCheckSummaryRepository;
_asbitemRepository = asbitemRepository;
+ _itemRepository = itemRepository;
+ _registerCheckItemRepository = registerCheckItemRepository;
+ _patientRepository = patientRepository;
}
///
/// 获取明细结果报告
///
- /// 人员登记ID
+ /// 人员登记ID
///
- [HttpGet("api/app/sumsummaryreport/getdetailedresultslist")]
- public async Task
> GetDetailedResultsListAsync(Guid PatientRegisterId)
+ [HttpGet("api/app/SumSummaryReport/GetDetailResults")]
+ public async Task> GetDetailResultsAsync(PatientRegisterIdInputDto input)
{
- List msg = new List();
+ List msg = new List();
var userlist = await _identityUserRepository.GetListAsync();
var resultStatus = await _resultStatusRepository.GetListAsync();
- var entlist = (await _registerCheckRepository.GetDbSetAsync())
- .Include(x => x.RegisterCheckAsbitems)
- .ThenInclude(x => x.Asbitem)
- .ThenInclude(x => x.ItemType)
- .ThenInclude(x => x.MedicalReportType)
- .Include(x => x.RegisterCheckSummaries)
- .Include(x => x.RegisterCheckItems)
- .ThenInclude(x => x.Item)
- .Where(m => m.RegisterCheckAsbitems.Select(s => s.PatientRegisterId).Contains(PatientRegisterId) &&
- m.CompleteFlag == RegisterCheckCompleteFlag.Checked)
- .ToList();
-
+ var list = (from patient in await _patientRepository.GetQueryableAsync()
+ join patientRegister in await _patientRegisterRepository.GetQueryableAsync()
+ on patient.Id equals patientRegister.PatientId
+ 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
+ join itemType in await _itemTypeRepository.GetQueryableAsync()
+ on asbitem.ItemTypeId equals itemType.Id
+ where patientRegister.Id == input.PatientRegisterId
+ select new
+ {
+ patient,
+ patientRegister,
+ registerCheck,
+ registerCheckSummary,
+ registerCheckAsbitem,
+ asbitem,
+ registerCheckItem,
+ item,
+ itemType
+
+ }).ToList();
+
+ if (!list.Any())
+ {
+ return null;
+ }
+ //获取历次结果
+ var histroyList = (from patient in await _patientRepository.GetQueryableAsync()
+ join patientRegister in await _patientRegisterRepository.GetQueryableAsync()
+ on patient.Id equals patientRegister.PatientId
+ 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
+ join itemType in await _itemTypeRepository.GetQueryableAsync()
+ on asbitem.ItemTypeId equals itemType.Id
+ where patient.Id == list.First().patient.Id
+ && (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck || patientRegister.CompleteFlag == PatientRegisterCompleteFlag.Audit)
+ && patientRegister.MedicalTimes < list.First().patientRegister.MedicalTimes
+ select new
+ {
+ patient,
+ patientRegister,
+ registerCheck,
+ registerCheckSummary,
+ registerCheckAsbitem,
+ asbitem,
+ registerCheckItem,
+ item,
+ itemType
+
+ }).OrderByDescending(o => o.patientRegister.MedicalTimes).ToList();
+ //将子项目类别设置为父项目类别
+ var itemTypes = await _itemTypeRepository.GetListAsync();
+ foreach (var listItem in list)
+ {
+ var parentItemType = itemTypes.Where(o => o.Id == listItem.itemType.ParentId).FirstOrDefault();
+ if (parentItemType != null)
+ {
+ listItem.asbitem.DisplayOrder = listItem.asbitem.ItemType.DisplayOrder * 1000 + listItem.asbitem.DisplayOrder;
+ listItem.itemType.DisplayName = parentItemType.DisplayName;
+ listItem.itemType.DisplayOrder = parentItemType.DisplayOrder;
- var asbitemList = entlist.Select(s => new DetailedResultsList_Asbitem
+ }
+ }
+ var detailedResultsList_Asbitems = new List();
+ var registerCheckIds = list.OrderBy(o => o.itemType.DisplayOrder)
+ .OrderBy(o => o.asbitem.DisplayOrder)
+ .Select(o => o.registerCheck.Id).Distinct().ToList();
+ foreach (var registerCheckId in registerCheckIds)
{
- AsbitemName = string.Join(",", s.RegisterCheckAsbitems.Select(rs => rs.Asbitem.DisplayName).ToList()),
- ItemTypeName = string.Join(",", s.RegisterCheckAsbitems.Select(rs => rs.Asbitem.ItemType.DisplayName).ToList()),
- CheckDate = DataHelper.ConversionDateToString(s.CheckDate),
- CheckDoctorName = EntityHelper.GetCheckDoctorName(s.CheckDoctorId, userlist),
- Items = s.RegisterCheckItems.Select(sa => new DetailedResultsList_Asbitem_Item
+ var listItem = list.Where(o => o.registerCheck.Id == registerCheckId).First();
+ var detailedResultsList_Asbitem = new SumSummaryReportDetailResultWithAsbitem()
{
- CriticalRangeValue = sa.CriticalRangeValue,
- ItemName = sa.Item.DisplayName,
- ItemResult = sa.Result,
- ReferenceRangeValue = sa.ReferenceRangeValue,
- ResultStatusName = (resultStatus.Where(o => o.Id == sa.ResultStatusId).FirstOrDefault() == null) ? "" : resultStatus.Where(o => o.Id == sa.ResultStatusId).FirstOrDefault().ReportPrompt,
- Unit = sa.Unit
- }).ToList(),
- Summarys = s.RegisterCheckSummaries.Count > 0 ? s.RegisterCheckSummaries.Select(sb => new DetailedResultsList_Asbitem_Summary
+ ItemTypeName = listItem.itemType.DisplayName,
+ AsbitemName = string.Join(",", list.Where(o => o.registerCheck.Id == registerCheckId)
+ .OrderBy(o => o.itemType.DisplayOrder).OrderBy(o => o.asbitem.DisplayOrder)
+ .Select(o => o.asbitem.DisplayName).Distinct().ToList()),
+ CheckDate = (DateTime)listItem.registerCheck.CheckDate,
+ CheckDoctorName = EntityHelper.GetCheckDoctorName(listItem.registerCheck.CheckDoctorId, userlist),
+ Items = list.Where(o => o.registerCheck.Id == registerCheckId)
+ .OrderBy(o => o.itemType.DisplayOrder).OrderBy(o => o.asbitem.DisplayOrder).OrderBy(o => o.item.DisplayOrder)
+ .Select(o => new SumSummaryReportDetailResultWithItem()
+ {
+ ItemId = o.registerCheckItem.ItemId,
+ ItemName = o.item.DisplayName,
+ ItemResult = o.registerCheckItem.Result,
+ ReferenceRangeValue = o.registerCheckItem.ReferenceRangeValue,
+ CriticalRangeValue = o.registerCheckItem.CriticalRangeValue,
+ Unit = o.registerCheckItem.Unit,
+ ResultStatusId = o.registerCheckItem.ResultStatusId,
+ ResultStatusName = (resultStatus.Where(x => x.Id == o.registerCheckItem.ResultStatusId).FirstOrDefault() == null) ? "" : resultStatus.Where(x => x.Id == o.registerCheckItem.ResultStatusId).FirstOrDefault().ReportPrompt,
+ ReportFontColor = (resultStatus.Where(x => x.Id == o.registerCheckItem.ResultStatusId).FirstOrDefault() == null) ? 0 : resultStatus.Where(x => x.Id == o.registerCheckItem.ResultStatusId).FirstOrDefault().ReportFontColor,
+ ReportBackgroundColor = (resultStatus.Where(x => x.Id == o.registerCheckItem.ResultStatusId).FirstOrDefault() == null) ? 16579836 : resultStatus.Where(x => x.Id == o.registerCheckItem.ResultStatusId).FirstOrDefault().ReportBackgroundColor,
+ }).Distinct().ToList(),
+ Summarys = list.Where(o => o.registerCheck.Id == registerCheckId)
+ .OrderBy(o=>o.registerCheckSummary.DisplayOrder)
+ .GroupBy(o=>o.registerCheckSummary)
+ .Select(o=> new SumSummaryReportDetailResultWithSummary(){
+ Summary = o.FirstOrDefault().registerCheckSummary.Summary })
+ .ToList(),
+
+ };
+ detailedResultsList_Asbitem.Summarys = detailedResultsList_Asbitem.Summarys.Distinct().ToList();
+ foreach (var registerCheckItem in detailedResultsList_Asbitem.Items)
{
- Summary = sb.Summary,
- }).ToList() : new List()
- }).ToList();
+ var historyRegisterCheckItems = histroyList.Select(o => new { o.registerCheckItem })
+ .Where(o => o.registerCheckItem.ItemId == registerCheckItem.ItemId).Distinct().ToList();
+
+ for (var i = 0; i < historyRegisterCheckItems.Count; i++)
+ {
+ if(i== 0)
+ {
+ registerCheckItem.PreviousItemResult = historyRegisterCheckItems[i].registerCheckItem.Result;
+ registerCheckItem.PreviousReportFontColor = (resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].registerCheckItem.ResultStatusId).FirstOrDefault() == null) ? 0 : resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].registerCheckItem.ResultStatusId).FirstOrDefault().ReportFontColor;
+ registerCheckItem.PreviousReportBackgroundColor = (resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].registerCheckItem.ResultStatusId).FirstOrDefault() == null) ? 0 : resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].registerCheckItem.ResultStatusId).FirstOrDefault().ReportBackgroundColor;
+ }
+ else if(i== 1)
+ {
+ registerCheckItem.PreviousTwoItemResult = historyRegisterCheckItems[i].registerCheckItem.Result;
+ registerCheckItem.PreviousTwoReportFontColor = (resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].registerCheckItem.ResultStatusId).FirstOrDefault() == null) ? 0 : resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].registerCheckItem.ResultStatusId).FirstOrDefault().ReportFontColor;
+ registerCheckItem.PreviousTwoReportBackgroundColor = (resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].registerCheckItem.ResultStatusId).FirstOrDefault() == null) ? 0 : resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].registerCheckItem.ResultStatusId).FirstOrDefault().ReportBackgroundColor;
+ }
+ }
+ }
- var grouplist = asbitemList.GroupBy(g => g.ItemTypeName);
+ detailedResultsList_Asbitems.Add(detailedResultsList_Asbitem);
+
+ }
+
+ var grouplist = detailedResultsList_Asbitems.GroupBy(g => g.ItemTypeName);
foreach (var g in grouplist)
{
var glist = g.ToList();
- var resultlist = new DetailedResultsListDto
+ var resultlist = new SumSummaryReportDetailResultDto
{
ItemTypeName = glist.FirstOrDefault().ItemTypeName,
Asbitems = glist
@@ -137,7 +262,7 @@ namespace Shentun.Peis.SumSummaryReports
var query = from a in await _patientRegisterRepository.GetQueryableAsync()
join b in await _registerCheckRepository.GetQueryableAsync() on a.Id equals b.PatientRegisterId
- join c in await _registerAsbitemRepository.GetQueryableAsync() on b.Id equals c.RegisterCheckId
+ join c in await _registerCheckAsbitemRepository.GetQueryableAsync() on b.Id equals c.RegisterCheckId
join d in await _asbitemRepository.GetQueryableAsync() on c.AsbitemId equals d.Id into dd
from ad in dd.DefaultIfEmpty()
join e in await _itemTypeRepository.GetQueryableAsync() on ad.ItemTypeId equals e.Id
@@ -225,7 +350,7 @@ namespace Shentun.Peis.SumSummaryReports
List entdto = new List();
- var entlist = (await _registerAsbitemRepository.GetDbSetAsync())
+ var entlist = (await _registerCheckAsbitemRepository.GetDbSetAsync())
.Include(x => x.Asbitem)
.Include(x => x.RegisterCheck)
.Include(x => x.PatientRegister)
diff --git a/src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs b/src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs
index 308d542..da0b982 100644
--- a/src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs
+++ b/src/Shentun.Peis.Domain/ItemTypes/ItemTypeManager.cs
@@ -42,6 +42,11 @@ namespace Shentun.Peis.ItemTypes
{
Verify(entity);
await EntityHelper.CheckSameName(_repository, entity.DisplayName);
+ var pathCode = await CreatePathCode(entity.ParentId);
+ if(pathCode.Length > 11 )
+ {
+ throw new UserFriendlyException("项目类别只允许最多两级");
+ }
return new ItemType(
GuidGenerator.Create()
)
diff --git a/test/Shentun.Peis.Application.Tests/SumSummaryReportAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/SumSummaryReportAppServiceTest.cs
new file mode 100644
index 0000000..a87ce7c
--- /dev/null
+++ b/test/Shentun.Peis.Application.Tests/SumSummaryReportAppServiceTest.cs
@@ -0,0 +1,48 @@
+using Shentun.Peis.ChargeRequests;
+using Shentun.Peis.Models;
+using Shentun.Peis.PatientRegisters;
+using Shentun.Peis.SumSummaryReports;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Uow;
+using Xunit;
+using Xunit.Abstractions;
+
+namespace Shentun.Peis
+{
+ public class SumSummaryReportAppServiceTest : PeisApplicationTestBase
+ {
+ private readonly IRepository _repository;
+ private readonly SumSummaryReportAppService _appService;
+ private readonly ITestOutputHelper _output;
+ private readonly IUnitOfWorkManager _unitOfWorkManager;
+ public SumSummaryReportAppServiceTest(ITestOutputHelper testOutputHelper)
+ {
+ _output = testOutputHelper;
+ _unitOfWorkManager = GetRequiredService();
+ _repository = GetRequiredService>();
+ _appService = GetRequiredService();
+ }
+
+ [Fact]
+ public async Task GetDetailResultsAsync()
+ {
+ using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
+ {
+
+ var entity = new PatientRegisterIdInputDto()
+ {
+ PatientRegisterId = new Guid("3a121795-7f84-9c04-844e-c2338a4241d1"),
+
+ };
+
+ var newEntity = await _appService.GetDetailResultsAsync(entity);
+ //await unitOfWork.CompleteAsync();
+ }
+ }
+ }
+}