From ba898adbeed6268a5c6c6f7fae2646c9d7ed15ec Mon Sep 17 00:00:00 2001
From: "DESKTOP-G961P6V\\Zhh" <839860190@qq.com>
Date: Fri, 3 May 2024 00:11:40 +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
---
.../Patients/PatientIdInputDto.cs | 11 +
.../Patients/PatientWithAsbitemIdInputDto.cs | 12 ++
.../HorizontalComparisonAsbitemListDto.cs | 1 +
...SumSummaryReportHorizontalComparisonDto.cs | 46 ++++
.../SumSummaryReportAppService.cs | 197 +++++++++++++-----
.../SumSummaryReportAppServiceTest.cs | 52 +++++
6 files changed, 266 insertions(+), 53 deletions(-)
create mode 100644 src/Shentun.Peis.Application.Contracts/Patients/PatientIdInputDto.cs
create mode 100644 src/Shentun.Peis.Application.Contracts/Patients/PatientWithAsbitemIdInputDto.cs
create mode 100644 src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportHorizontalComparisonDto.cs
diff --git a/src/Shentun.Peis.Application.Contracts/Patients/PatientIdInputDto.cs b/src/Shentun.Peis.Application.Contracts/Patients/PatientIdInputDto.cs
new file mode 100644
index 0000000..4d9f4dc
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/Patients/PatientIdInputDto.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.Patients
+{
+ public class PatientIdInputDto
+ {
+ public Guid PatientId { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/Patients/PatientWithAsbitemIdInputDto.cs b/src/Shentun.Peis.Application.Contracts/Patients/PatientWithAsbitemIdInputDto.cs
new file mode 100644
index 0000000..ef1eb84
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/Patients/PatientWithAsbitemIdInputDto.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.Patients
+{
+ public class PatientWithAsbitemIdInputDto
+ {
+ public Guid PatientId { get; set; }
+ public Guid AsbitemId { get; set;}
+ }
+}
diff --git a/src/Shentun.Peis.Application.Contracts/SumSummaryReports/HorizontalComparisonAsbitemListDto.cs b/src/Shentun.Peis.Application.Contracts/SumSummaryReports/HorizontalComparisonAsbitemListDto.cs
index 246f713..ceadb8c 100644
--- a/src/Shentun.Peis.Application.Contracts/SumSummaryReports/HorizontalComparisonAsbitemListDto.cs
+++ b/src/Shentun.Peis.Application.Contracts/SumSummaryReports/HorizontalComparisonAsbitemListDto.cs
@@ -6,6 +6,7 @@ namespace Shentun.Peis.SumSummaryReports
{
public class HorizontalComparisonAsbitemListDto
{
+
///
/// 组合项目名称
diff --git a/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportHorizontalComparisonDto.cs b/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportHorizontalComparisonDto.cs
new file mode 100644
index 0000000..195c43d
--- /dev/null
+++ b/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportHorizontalComparisonDto.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shentun.Peis.SumSummaryReports
+{
+ public class SumSummaryReportHorizontalComparisonDto
+ {
+ public Guid RegsterCheckId { get; set; }
+ public DateTime CheckDate { get; set; }
+ public List Summarys { get; set; }
+ public List RegisterCheckItems { get; set; }
+ }
+
+ public class SumSummaryReportHorizontalComparisonWithCheckSummaryDto
+ {
+ public string Summary { get; set; }
+ }
+
+ public class SumSummaryReportHorizontalComparisonWithCheckItemResultDto
+ {
+ /// 项目名字
+ ///
+ public string ItemName { get; set; }
+
+ ///
+ /// 单位
+ ///
+ public string UnitName { get; set; }
+
+ ///
+ /// 参考范围
+ ///
+ public string ReferenceRangeValue { get; set; }
+
+ ///
+ /// 检查结果
+ ///
+ public string ResultValue { get; set; }
+ ///
+ /// 报告字体色
+ ///
+
+ public int ReportFontColor { get; set; }
+ }
+}
diff --git a/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs b/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs
index d6f8040..bab8fd2 100644
--- a/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs
+++ b/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs
@@ -7,6 +7,7 @@ using NPOI.OpenXmlFormats.Wordprocessing;
using Shentun.Peis.Enums;
using Shentun.Peis.Models;
using Shentun.Peis.PatientRegisters;
+using Shentun.Peis.Patients;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -18,6 +19,7 @@ using Volo.Abp.Account;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Identity;
+using Xceed.Document.NET;
namespace Shentun.Peis.SumSummaryReports
{
@@ -101,6 +103,8 @@ namespace Shentun.Peis.SumSummaryReports
join itemType in await _itemTypeRepository.GetQueryableAsync()
on asbitem.ItemTypeId equals itemType.Id
where patientRegister.Id == input.PatientRegisterId
+ && registerCheck.CompleteFlag == RegisterCheckCompleteFlag.Checked
+ && asbitem.IsCheck == 'Y'
select new
{
patient,
@@ -140,6 +144,8 @@ namespace Shentun.Peis.SumSummaryReports
where patient.Id == list.First().patient.Id
&& (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck || patientRegister.CompleteFlag == PatientRegisterCompleteFlag.Audit)
&& patientRegister.MedicalTimes < list.First().patientRegister.MedicalTimes
+ && registerCheck.CompleteFlag == RegisterCheckCompleteFlag.Checked
+ && asbitem.IsCheck == 'Y'
select new
{
patient,
@@ -200,30 +206,32 @@ namespace Shentun.Peis.SumSummaryReports
ReportBackgroundColor = (resultStatus.Where(x => x.Id == o.registerCheckItem.ResultStatusId).FirstOrDefault() == null) ? 16777215 : 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.Summary)
- .Select(o=> new SumSummaryReportDetailResultWithSummary(){
- Summary = o.FirstOrDefault().registerCheckSummary.Summary })
- .ToList(),
+ .OrderBy(o => o.registerCheckSummary.DisplayOrder)
+ .GroupBy(o => o.registerCheckSummary.Summary)
+ .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)
{
- var historyRegisterCheckItems = histroyList.GroupBy(o=>o.registerCheckItem)
- .Select(o => o.First().registerCheckItem )
+ var historyRegisterCheckItems = histroyList.GroupBy(o => o.registerCheckItem)
+ .Select(o => o.First().registerCheckItem)
.Where(o => o.ItemId == registerCheckItem.ItemId)
.Distinct().ToList();
for (var i = 0; i < historyRegisterCheckItems.Count; i++)
{
- if(i== 0)
+ if (i == 0)
{
registerCheckItem.PreviousItemResult = historyRegisterCheckItems[i].Result;
registerCheckItem.PreviousReportFontColor = (resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].ResultStatusId).FirstOrDefault() == null) ? 0 : resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].ResultStatusId).FirstOrDefault().ReportFontColor;
registerCheckItem.PreviousReportBackgroundColor = (resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].ResultStatusId).FirstOrDefault() == null) ? 16777215 : resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].ResultStatusId).FirstOrDefault().ReportBackgroundColor;
}
- else if(i== 1)
+ else if (i == 1)
{
registerCheckItem.PreviousTwoItemResult = historyRegisterCheckItems[i].Result;
registerCheckItem.PreviousTwoReportFontColor = (resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].ResultStatusId).FirstOrDefault() == null) ? 0 : resultStatus.Where(x => x.Id == historyRegisterCheckItems[i].ResultStatusId).FirstOrDefault().ReportFontColor;
@@ -237,13 +245,13 @@ namespace Shentun.Peis.SumSummaryReports
}
- var grouplist = detailedResultsList_Asbitems.OrderBy(o=>o.ItemTypeDisplayOrder)
- .OrderBy(o=>o.AsbitemDisplayOrder)
+ var grouplist = detailedResultsList_Asbitems.OrderBy(o => o.ItemTypeDisplayOrder)
+ .OrderBy(o => o.AsbitemDisplayOrder)
.GroupBy(g => g.ItemTypeName);
foreach (var g in grouplist)
{
- var glist = g.ToList();
+ var glist = g.OrderBy(o => o.ItemTypeDisplayOrder).OrderBy(o => o.AsbitemDisplayOrder).ToList();
var resultlist = new SumSummaryReportDetailResultDto
{
ItemTypeDisplayOrder = glist.FirstOrDefault().ItemTypeDisplayOrder,
@@ -350,54 +358,75 @@ namespace Shentun.Peis.SumSummaryReports
///
/// 获取横向对比 左侧组合项目
///
- ///
+ ///
///
- [HttpGet("api/app/sumsummaryreport/gethorizontalcomparisonasbitemlist")]
- public async Task> GetHorizontalComparisonAsbitemListAsync(Guid PatientId)
+ [HttpPost("api/app/SumSummaryReport/GetHorizontalComparisonAsbitems")]
+ public async Task> GetHorizontalComparisonAsbitemsAsync(PatientIdInputDto input)
{
List entdto = new List();
- var entlist = (await _registerCheckAsbitemRepository.GetDbSetAsync())
- .Include(x => x.Asbitem)
- .Include(x => x.RegisterCheck)
- .Include(x => x.PatientRegister)
- .Where(m => m.PatientRegister.PatientId == PatientId && m.PatientRegister.CompleteFlag != PatientRegisterCompleteFlag.PreRegistration)
- .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 asbitem in await _asbitemRepository.GetQueryableAsync()
+ on registerCheckAsbitem.AsbitemId equals asbitem.Id
+ join itemType in await _itemTypeRepository.GetQueryableAsync()
+ on asbitem.ItemTypeId equals itemType.Id
+ where patient.Id == input.PatientId
+ && (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck || patientRegister.CompleteFlag == PatientRegisterCompleteFlag.Audit)
+ && registerCheck.CompleteFlag == RegisterCheckCompleteFlag.Checked
+ && asbitem.IsCheck == 'Y'
+ select new
+ {
+ patient,
+ patientRegister,
+ registerCheck,
+ registerCheckAsbitem,
+ asbitem,
+ itemType
- var grouplist = entlist.GroupBy(o => o.AsbitemId);
+ }).AsNoTracking().Distinct().ToList();
- foreach (var g in grouplist)
+ if (!list.Any())
{
- //var resultlist = new ItemTypeContrastListDto
- //{
-
- // ItemTypeName = glist.FirstOrDefault().ItemTypeName,
- // RegisterDate = glist.FirstOrDefault().RegisterDate,
- // Summarys = string.Join("\n", glist.Select(s => s.Summarys).ToList())
- //};
-
- var glist = g.ToList();
-
- var ent = new HorizontalComparisonAsbitemListDto
+ return null;
+ }
+ //将子项目类别设置为父项目类别
+ var itemTypes = await _itemTypeRepository.GetListAsync();
+ foreach (var listItem in list)
+ {
+ var parentItemType = itemTypes.Where(o => o.Id == listItem.itemType.ParentId).FirstOrDefault();
+ if (parentItemType != null)
{
- AsbitemId = glist.Any() ? glist.FirstOrDefault().AsbitemId : Guid.Empty,
- AsbitemName = glist.Any() ? glist.FirstOrDefault().Asbitem.DisplayName : "",
- CompleteFlag = glist.Any() ? glist.OrderByDescending(m => m.CreationTime).FirstOrDefault().RegisterCheck.CompleteFlag : RegisterCheckCompleteFlag.UnChecked
- };
-
+ listItem.asbitem.DisplayOrder = listItem.itemType.DisplayOrder * 1000 + listItem.asbitem.DisplayOrder;
+ listItem.itemType.DisplayName = parentItemType.DisplayName;
+ listItem.itemType.DisplayOrder = parentItemType.DisplayOrder;
- entdto.Add(ent);
+ }
}
+ list = list.OrderBy(o => o.itemType.DisplayOrder)
+ .OrderBy(o => o.asbitem.DisplayOrder).ToList();
- //var entdto = entlist.Select(s => new HorizontalComparisonAsbitemListDto
- //{
- // AsbitemId = s.AsbitemId,
- // AsbitemName = s.Asbitem.DisplayName,
- // CompleteFlag = s.RegisterChecks.FirstOrDefault(m => m.CreationTime)
- //}).ToList();
+ foreach(var item in list)
+ {
+ if (!entdto.Where(o => o.AsbitemId == item.asbitem.Id).Any())
+ {
+ var ent = new HorizontalComparisonAsbitemListDto
+ {
+ AsbitemId = item.asbitem.Id,
+ AsbitemName = item.asbitem.DisplayName
+ };
+ entdto.Add(ent);
+ }
+ }
+
return entdto;
}
@@ -405,18 +434,80 @@ namespace Shentun.Peis.SumSummaryReports
///
/// 获取横向对比数据
///
- ///
- ///
+ ///
///
- [HttpGet("api/app/sumsummaryreport/gethorizontalcomparisonlist")]
- public async Task> GetHorizontalComparisonListAsync(Guid PatientId, Guid AsbitemId)
+ [HttpPost("api/app/SumSummaryReport/GetHorizontalComparisons")]
+ public async Task> GetHorizontalComparisonsAsync(PatientWithAsbitemIdInputDto input)
{
+ 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
+ where patient.Id == input.PatientId
+ && (patientRegister.CompleteFlag == PatientRegisterCompleteFlag.SumCheck || patientRegister.CompleteFlag == PatientRegisterCompleteFlag.Audit)
+ && registerCheck.CompleteFlag == RegisterCheckCompleteFlag.Checked
+ && asbitem.IsCheck == 'Y'
+ && asbitem.Id == input.AsbitemId
+ select new
+ {
+ patient,
+ patientRegister,
+ registerCheck,
+ registerCheckSummary,
+ registerCheckAsbitem,
+ asbitem,
+ registerCheckItem,
+ item
- var entlist = await _sumSummaryReportRepository.GetHorizontalComparisonListAsync(PatientId, AsbitemId);
- var entdto = ObjectMapper.Map, List>(entlist);
+ }).OrderByDescending(o => o.patientRegister.MedicalTimes).ToList();
- return entdto;
+ var resultStatus = await _resultStatusRepository.GetListAsync();
+ var registerCheckIds = list.OrderBy(o => o.registerCheck.CheckDate).Select(o => o.registerCheck.Id).Distinct().ToList();
+ var sumSummaryReportHorizontalComparisonDtos = new List();
+
+ foreach (var registerCheckId in registerCheckIds)
+ {
+ var registerChecks = list.Where(o => o.registerCheck.Id == registerCheckId).ToList();
+ var sumSummaryReportHorizontalComparisonDto = new SumSummaryReportHorizontalComparisonDto()
+ {
+ CheckDate = ((DateTime)registerChecks.First().registerCheck.CheckDate).Date,
+ 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()
+
+ };
+ sumSummaryReportHorizontalComparisonDtos.Add(sumSummaryReportHorizontalComparisonDto);
+
+
+ }
+
+ return sumSummaryReportHorizontalComparisonDtos;
}
diff --git a/test/Shentun.Peis.Application.Tests/SumSummaryReportAppServiceTest.cs b/test/Shentun.Peis.Application.Tests/SumSummaryReportAppServiceTest.cs
index e980d32..6a73412 100644
--- a/test/Shentun.Peis.Application.Tests/SumSummaryReportAppServiceTest.cs
+++ b/test/Shentun.Peis.Application.Tests/SumSummaryReportAppServiceTest.cs
@@ -1,6 +1,7 @@
using Shentun.Peis.ChargeRequests;
using Shentun.Peis.Models;
using Shentun.Peis.PatientRegisters;
+using Shentun.Peis.Patients;
using Shentun.Peis.SumSummaryReports;
using System;
using System.Collections.Generic;
@@ -44,5 +45,56 @@ namespace Shentun.Peis
await unitOfWork.CompleteAsync();
}
}
+
+ [Fact]
+ public async Task GetHorizontalComparisonAsbitemsAsync()
+ {
+ using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
+ {
+
+ var entity = new PatientIdInputDto()
+ {
+ PatientId = new Guid("3a12169c-6d0e-a9cb-1d46-6c8658d651da"),
+
+ };
+
+ var list = await _appService.GetHorizontalComparisonAsbitemsAsync(entity);
+ foreach(var item in list)
+ {
+ _output.WriteLine(item.AsbitemId.ToString() + item.AsbitemName);
+ }
+ await unitOfWork.CompleteAsync();
+ }
+ }
+
+ [Fact]
+ public async Task GetHorizontalComparisonsAsync()
+ {
+ using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
+ {
+
+ var entity = new PatientWithAsbitemIdInputDto()
+ {
+ PatientId = new Guid("3a12169c-6d0e-a9cb-1d46-6c8658d651da"),
+ AsbitemId = new Guid ("3a1206b3-42a2-7465-94e8-009c549c6edf")
+
+ };
+
+ var list = await _appService.GetHorizontalComparisonsAsync(entity);
+ foreach (var item in list)
+ {
+ _output.WriteLine(item.CheckDate.ToString());
+ foreach (var item2 in item.Summarys)
+ {
+ _output.WriteLine(item2.Summary);
+ }
+ foreach (var item2 in item.RegisterCheckItems)
+ {
+ _output.WriteLine(item2.ItemName + item2.ResultValue);
+ }
+ }
+ await unitOfWork.CompleteAsync();
+ }
+ }
}
}