|
|
|
@ -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, |
|
|
|
@ -177,7 +183,7 @@ namespace Shentun.Peis.SumSummaryReports |
|
|
|
{ |
|
|
|
|
|
|
|
ItemTypeName = listItem.itemType.DisplayName, |
|
|
|
AsbitemName = string.Join(",", list.Where(o => o.registerCheck.Id == registerCheckId) |
|
|
|
AsbitemNames = 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()), |
|
|
|
ItemTypeDisplayOrder = listItem.itemType.DisplayOrder, |
|
|
|
@ -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 }) |
|
|
|
.OrderBy(o => o.registerCheckSummary.DisplayOrder) |
|
|
|
.GroupBy(o => o.registerCheckSummary.Summary) |
|
|
|
.Select(o => new SumSummaryReportDetailResultWithSummary() |
|
|
|
{ |
|
|
|
Summary = o.FirstOrDefault().registerCheckSummary.Summary |
|
|
|
}) |
|
|
|
.ToList<SumSummaryReportDetailResultWithSummary>(), |
|
|
|
|
|
|
|
}; |
|
|
|
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,53 +358,74 @@ namespace Shentun.Peis.SumSummaryReports |
|
|
|
/// <summary>
|
|
|
|
/// 获取横向对比 左侧组合项目
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="PatientId"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("api/app/sumsummaryreport/gethorizontalcomparisonasbitemlist")] |
|
|
|
public async Task<List<HorizontalComparisonAsbitemListDto>> GetHorizontalComparisonAsbitemListAsync(Guid PatientId) |
|
|
|
[HttpPost("api/app/SumSummaryReport/GetHorizontalComparisonAsbitems")] |
|
|
|
public async Task<List<HorizontalComparisonAsbitemListDto>> GetHorizontalComparisonAsbitemsAsync(PatientIdInputDto input) |
|
|
|
{ |
|
|
|
|
|
|
|
List<HorizontalComparisonAsbitemListDto> entdto = new List<HorizontalComparisonAsbitemListDto>(); |
|
|
|
|
|
|
|
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()) |
|
|
|
{ |
|
|
|
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) |
|
|
|
{ |
|
|
|
//var resultlist = new ItemTypeContrastListDto
|
|
|
|
//{
|
|
|
|
listItem.asbitem.DisplayOrder = listItem.itemType.DisplayOrder * 1000 + listItem.asbitem.DisplayOrder; |
|
|
|
listItem.itemType.DisplayName = parentItemType.DisplayName; |
|
|
|
listItem.itemType.DisplayOrder = parentItemType.DisplayOrder; |
|
|
|
|
|
|
|
// ItemTypeName = glist.FirstOrDefault().ItemTypeName,
|
|
|
|
// RegisterDate = glist.FirstOrDefault().RegisterDate,
|
|
|
|
// Summarys = string.Join("\n", glist.Select(s => s.Summarys).ToList())
|
|
|
|
//};
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var glist = g.ToList(); |
|
|
|
list = list.OrderBy(o => o.itemType.DisplayOrder) |
|
|
|
.OrderBy(o => o.asbitem.DisplayOrder).ToList(); |
|
|
|
|
|
|
|
foreach(var item in list) |
|
|
|
{ |
|
|
|
if (!entdto.Where(o => o.AsbitemId == item.asbitem.Id).Any()) |
|
|
|
{ |
|
|
|
var ent = new HorizontalComparisonAsbitemListDto |
|
|
|
{ |
|
|
|
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 |
|
|
|
}; |
|
|
|
|
|
|
|
AsbitemId = item.asbitem.Id, |
|
|
|
AsbitemName = item.asbitem.DisplayName |
|
|
|
|
|
|
|
}; |
|
|
|
entdto.Add(ent); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//var entdto = entlist.Select(s => new HorizontalComparisonAsbitemListDto
|
|
|
|
//{
|
|
|
|
// AsbitemId = s.AsbitemId,
|
|
|
|
// AsbitemName = s.Asbitem.DisplayName,
|
|
|
|
// CompleteFlag = s.RegisterChecks.FirstOrDefault(m => m.CreationTime)
|
|
|
|
//}).ToList();
|
|
|
|
} |
|
|
|
|
|
|
|
return entdto; |
|
|
|
} |
|
|
|
@ -405,18 +434,80 @@ namespace Shentun.Peis.SumSummaryReports |
|
|
|
/// <summary>
|
|
|
|
/// 获取横向对比数据
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="PatientId"></param>
|
|
|
|
/// <param name="AsbitemId"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("api/app/sumsummaryreport/gethorizontalcomparisonlist")] |
|
|
|
public async Task<List<HorizontalComparisonListDto>> GetHorizontalComparisonListAsync(Guid PatientId, Guid AsbitemId) |
|
|
|
[HttpPost("api/app/SumSummaryReport/GetHorizontalComparisons")] |
|
|
|
public async Task<List<SumSummaryReportHorizontalComparisonDto>> 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<HorizontalComparisonListEntity>, List<HorizontalComparisonListDto>>(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<SumSummaryReportHorizontalComparisonDto>(); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
sumSummaryReportHorizontalComparisonDtos = sumSummaryReportHorizontalComparisonDtos.OrderByDescending(o=>o.CheckDate).ToList(); |
|
|
|
return sumSummaryReportHorizontalComparisonDtos; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|