diff --git a/src/Shentun.Peis.Application.Contracts/CustomerOrgGroups/CustomerOrgGroupForPatientRegisterDto.cs b/src/Shentun.Peis.Application.Contracts/CustomerOrgGroups/CustomerOrgGroupForPatientRegisterDto.cs new file mode 100644 index 0000000..6515f39 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/CustomerOrgGroups/CustomerOrgGroupForPatientRegisterDto.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.CustomerOrgGroups +{ + public class CustomerOrgGroupForPatientRegisterDto + { + public Guid Id { get; set; } + /// + /// 分组名称 + /// + public string DisplayName { get; set; } + + /// + /// 价格 + /// + public decimal Price { get; set; } + + + /// + /// 适用性别 + /// + public char ForSexId { get; set; } + + + /// + /// 适用婚姻状况 + /// + public char MaritalStatusId { get; set; } + + + /// + /// 适用年龄下限 + /// + public short AgeLowerLimit { get; set; } + + + /// + /// 适用年龄上限 + /// + public short AgeUpperLimit { get; set; } + + + /// + /// 适用职务 + /// + public string? JobPost { get; set; } + + + /// + /// 适用职称 + /// + public string? JobTitle { get; set; } + + + + + + /// + /// 显示顺序 + /// + public int DisplayOrder { get; set; } + + /// + /// 体检次数ID + /// + public Guid CustomerOrgRegisterId { get; set; } + } +} 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/SumSummaryReportDetailResultDto.cs b/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportDetailResultDto.cs index 495cdf5..be5df87 100644 --- a/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportDetailResultDto.cs +++ b/src/Shentun.Peis.Application.Contracts/SumSummaryReports/SumSummaryReportDetailResultDto.cs @@ -35,7 +35,7 @@ namespace Shentun.Peis.SumSummaryReports /// /// 组合项目名称 /// - public string AsbitemName { get; set; } + public string AsbitemNames { get; set; } /// /// 检查医生 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/CustomerOrgGroups/CustomerOrgGroupAppService.cs b/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs index 903fe47..fb6d973 100644 --- a/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs +++ b/src/Shentun.Peis.Application/CustomerOrgGroups/CustomerOrgGroupAppService.cs @@ -145,7 +145,50 @@ namespace Shentun.Peis.CustomerOrgGroups } + [HttpPost("api/app/CustomerOrgGroup/GetListForPatentRegisterByFilter")] + public async Task> GetListForPatentRegisterByFilterAsync(GetListDto input) + { + + var oldlist = (await Repository.GetQueryableAsync()). + Include(x => x.CustomerOrgRegister). + Include(x => x.CustomerOrgRegister.CustomerOrg).AsEnumerable(); + + if (!string.IsNullOrEmpty(input.Filter)) + oldlist = oldlist.Where(m => m.DisplayName.Contains(input.Filter)); + + if (input.CustomerOrgId != null && input.CustomerOrgId != Guid.Empty) + oldlist = oldlist.Where(m => m.CustomerOrgRegister.CustomerOrg.Id == input.CustomerOrgId); + + if (input.CustomerOrgRegisterId != null && input.CustomerOrgRegisterId != Guid.Empty) + oldlist = oldlist.Where(m => m.CustomerOrgRegisterId == input.CustomerOrgRegisterId); + + if (input.MedicalTimes != null) + oldlist = oldlist.Where(m => m.CustomerOrgRegister.MedicalTimes == input.MedicalTimes); + + var entdto = oldlist.OrderBy(o => o.CustomerOrgRegister.CustomerOrg.DisplayOrder) + .ThenBy(o => o.CustomerOrgRegister.MedicalTimes) + .ThenBy(o => o.DisplayOrder) + .Select(s => new CustomerOrgGroupForPatientRegisterDto + { + Id = s.Id, + DisplayName = s.DisplayName, + DisplayOrder = s.DisplayOrder, + Price = s.Price, + ForSexId = s.ForSexId, + MaritalStatusId = s.MaritalStatusId, + JobTitle = s.JobTitle, + JobPost = s.JobPost, + AgeUpperLimit = s.AgeUpperLimit, + AgeLowerLimit = s.AgeLowerLimit, + CustomerOrgRegisterId = s.CustomerOrgRegisterId + }).OrderBy(m => m.DisplayOrder).ToList(); + + + return entdto; + + + } /// /// 创建单位分组 diff --git a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs index 3528201..51fc822 100644 --- a/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/PatientRegisters/PatientRegisterAppService.cs @@ -220,8 +220,8 @@ namespace Shentun.Peis.PatientRegisters var entdto = new PatientRegisterOrNoDto(); if (ent != null) { - var userList = await _userRepository.GetListAsync(); - var customerOrgList = await _customerOrgRepository.GetListAsync(); + //var userList = await _userRepository.GetListAsync(); + //var customerOrgList = await _customerOrgRepository.GetListAsync(); entdto = new PatientRegisterOrNoDto { @@ -273,8 +273,8 @@ namespace Shentun.Peis.PatientRegisters SummaryDate = DataHelper.ConversionDateToString(ent.SummaryDate), SummaryDoctorId = ent.SummaryDoctorId, ThirdInfo = ent.ThirdInfo, - CreatorName = EntityHelper.GetSurnameNoSql(userList, ent.CreatorId), - LastModifierName = EntityHelper.GetSurnameNoSql(userList, ent.LastModifierId), + CreatorName = _cacheService.GetSurnameAsync(ent.CreatorId).Result, + LastModifierName = _cacheService.GetSurnameAsync(ent.LastModifierId).Result, Address = ent.Patient.Address, //档案表信息 BirthPlaceId = ent.Patient.BirthPlaceId, DisplayName = ent.Patient.DisplayName, @@ -286,9 +286,9 @@ namespace Shentun.Peis.PatientRegisters PatientPassword = ent.Patient.PatientPassword, PostalCode = ent.Patient.PostalCode, Telephone = ent.Patient.Telephone, - CustomerOrgName = EntityHelper.GetCustomerOrgNameNoSql(customerOrgList, ent.CustomerOrgId), - CustomerOrgParentId = EntityHelper.GetParentNoSql(customerOrgList, ent.CustomerOrgId), - CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgList, ent.CustomerOrgId) + CustomerOrgName = _cacheService.GetCustomerOrgNameAsync(ent.CustomerOrgId).Result, + CustomerOrgParentId = _cacheService.GetTopCustomerOrgAsync(ent.CustomerOrgId).Result.Id, + //CustomerOrgParentName = EntityHelper.GetCustomerOrgParentNameNoSql(customerOrgList, ent.CustomerOrgId) }; } return entdto; diff --git a/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs b/src/Shentun.Peis.Application/SumSummaryReports/SumSummaryReportAppService.cs index d6f8040..1609a55 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, @@ -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 }) - .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); + + + } + sumSummaryReportHorizontalComparisonDtos = sumSummaryReportHorizontalComparisonDtos.OrderByDescending(o=>o.CheckDate).ToList(); + 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(); + } + } } }