From 3093d57960be66e6bf4ddc97f262e84cca670dd9 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 8 Jul 2022 09:21:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E8=87=B4=E6=80=A7=E6=A0=B8=E6=9F=A5?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 7 +- .../DTO/TaskAllocationRuleViewModel.cs | 2 +- .../DTO/TaskConsistentRuleViewModel.cs | 50 ++++++ .../Allocation/TaskConsistentRuleService.cs | 158 ++++++++++++++---- IRaCIS.Core.Application/TestService.cs | 1 - IRaCIS.Core.Domain/Allocation/VisitTask.cs | 2 +- .../Context/IRaCISDBContext.cs | 3 +- 7 files changed, 183 insertions(+), 40 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index c9f285961..446b4da20 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -109,7 +109,7 @@ - + 产生医学审核列表 @@ -1543,6 +1543,11 @@ 是否关闭对话 + + + 是否有问题 + + 对话内容 diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs index d5cbe4a65..42e338374 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs @@ -152,7 +152,7 @@ namespace IRaCIS.Core.Application.ViewModel //public ReReadingApplyGenerateTaskCommand ReReadingApplyGenerateTaskCommand { get; set; } = new ReReadingApplyGenerateTaskCommand(); - public List GenerataConsistentTaskList { get; set; } + public List GenerataConsistentTaskList { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs index 75e0a8756..c2c52dd10 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs @@ -51,6 +51,56 @@ namespace IRaCIS.Core.Application.ViewModel } + public class DoctorSelfConsistentSubjectView + { + public Guid TrialId { get; set; } + public Guid SiteId { get; set; } + + public String TrialSiteCode { get; set; } + public string SubjectCode { get; set; } + + public Guid SubjectId { get; set; } + + public bool IsHaveGeneratedTask { get; set; } + + + public int? ValidVisitCount { get; set; } + + public List VisitTaskList { get; set; } + } + + public class VisitTaskSimpleDTO + { + public Guid Id { get; set; } + public Guid TrialId { get; set; } + + public Guid SubjectId { get; set; } + + public Arm ArmEnum { get; set; } + public string TaskCode { get; set; } + + public string TaskName { get; set; } + public string TaskBlindName { get; set; } + + public decimal VisitTaskNum { get; set; } + + public ReadingCategory ReadingCategory { get; set; } + + //任务阅片状态 + public ReadingTaskState ReadingTaskState { get; set; } + + public TaskState TaskState { get; set; } + + [JsonIgnore] + public Guid? DoctorUserId { get; set; } + [JsonIgnore] + public Guid? TaskConsistentRuleId { get; set; } + + public bool IsHaveGeneratedTask { get; set; } + + public List GlobalVisitTaskList { get; set; } + } + public class DoctorConsistentRuleSubjectView { diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs index 7f261aa76..6232a7d0b 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs @@ -12,6 +12,7 @@ using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Domain.Share; using System.Linq.Expressions; using IRaCIS.Core.Infra.EFCore.Common; +using System.Linq; namespace IRaCIS.Core.Application.Service { @@ -74,25 +75,30 @@ namespace IRaCIS.Core.Application.Service /// /// [HttpPost] - public async Task> GetDoctorSelfConsistentRuleSubjectList(ConsistentQuery inQuery) + public async Task> GetDoctorSelfConsistentRuleSubjectList(ConsistentQuery inQuery) { var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inQuery.TaskConsistentRuleId); - var (group, query) = GetIQueryableDoctorSelfConsistentRuleSubjectView(filterObj); + var pagedList = await GetIQueryableDoctorSelfConsistentSubjectView(filterObj).ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(DoctorSelfConsistentSubjectView.SubjectCode) : inQuery.SortField, inQuery.Asc); - var count = group.Count(); - query = query.OrderByDescending(t => t.IsHaveGeneratedTask).Skip((inQuery.PageIndex - 1) * inQuery.PageSize); - var items = await query.Take(inQuery.PageSize).ToArrayAsync().ConfigureAwait(false); - var pagedList = new PageOutput() - { - PageIndex = inQuery.PageIndex, - PageSize = inQuery.PageSize, - TotalCount = count, - CurrentPageData = items - }; + //var (group, query) = GetIQueryableDoctorSelfConsistentRuleSubjectView(filterObj); + + //var count = group.Count(); + + //query = query.OrderByDescending(t => t.IsHaveGeneratedTask).Skip((inQuery.PageIndex - 1) * inQuery.PageSize); + + //var items = await query.Take(inQuery.PageSize).ToArrayAsync().ConfigureAwait(false); + + //var pagedList = new PageOutput() + //{ + // PageIndex = inQuery.PageIndex, + // PageSize = inQuery.PageSize, + // TotalCount = count, + // CurrentPageData = items + //}; return pagedList; @@ -109,9 +115,11 @@ namespace IRaCIS.Core.Application.Service var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inCommand.TaskConsistentRuleId); - var (group, query) = GetIQueryableDoctorSelfConsistentRuleSubjectView(filterObj, inCommand.SubejctIdList); + var list = await GetIQueryableDoctorSelfConsistentSubjectView(filterObj, inCommand.SubejctIdList).ToListAsync(); - var list = query.OrderByDescending(t => t.IsHaveGeneratedTask).ToList(); + //var (group, query) = GetIQueryableDoctorSelfConsistentRuleSubjectView(filterObj, inCommand.SubejctIdList); + + //var list = query.OrderByDescending(t => t.IsHaveGeneratedTask).ToList(); foreach (var subject in list) { @@ -136,26 +144,96 @@ namespace IRaCIS.Core.Application.Service } + private IQueryable GetIQueryableDoctorSelfConsistentSubjectView(TaskConsistentRule filterObj, List? subejctIdList = null) + { + var doctorUserId = filterObj.AnalysisDoctorUserId; + var trialId = filterObj.TrialId; + #region Subejct 维度 + + Expression> visitTaskFilter = t => t.IsAnalysisCreate == false && t.ReadingCategory == ReadingCategory.Visit && t.DoctorUserId == doctorUserId && + t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect && + t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now && + (t.ReReadingApplyState == ReReadingApplyState.Default || t.ReReadingApplyState == ReReadingApplyState.Reject); + + + if (subejctIdList != null && subejctIdList?.Count > 0) + { + visitTaskFilter.And( t => subejctIdList.Contains(t.SubjectId)); + } + + //所选访视数量 的访视 其中必有一个访视后有全局任务 + if (filterObj.IsHaveReadingPeriod == true) + { + visitTaskFilter = visitTaskFilter.And(t => t.Subject.SubjectVisitTaskList.Any(u => u.VisitTaskNum == t.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] + && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now)); + } + + //var globalWithVisitFilter = visitTaskFilter.And(t => t.VisitTaskNum <=) + + var subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId && t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count() >= filterObj.PlanVisitCount); + + + var query = subjectQuery.Select(t => new DoctorSelfConsistentSubjectView() + { + TrialId = t.TrialId, + SiteId = t.SiteId, + SubjectCode = t.Code, + TrialSiteCode = t.TrialSite.TrialSiteCode, + SubjectId = t.Id, + + IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.IsAnalysisCreate && c.DoctorUserId == doctorUserId), + + + ValidVisitCount = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count(), + + VisitTaskList = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Select(c => new VisitTaskSimpleDTO() + { + Id = c.Id, + ReadingCategory = c.ReadingCategory, + ReadingTaskState = c.ReadingTaskState, + TaskBlindName = c.TaskBlindName, + TaskCode = c.TaskCode, + TaskName = c.TaskName, + TaskState = c.TaskState, + ArmEnum = c.ArmEnum, + SubjectId = c.SubjectId, + VisitTaskNum = c.VisitTaskNum, + TrialId = c.TrialId, + + IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.ConsistentAnalysisOriginalTaskId == c.Id), + + GlobalVisitTaskList = c.Subject.SubjectVisitTaskList.Where(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now).Select(c => new VisitTaskSimpleDTO() + { + Id = c.Id, + ReadingCategory = c.ReadingCategory, + ReadingTaskState = c.ReadingTaskState, + TaskBlindName = c.TaskBlindName, + TaskCode = c.TaskCode, + TaskName = c.TaskName, + TaskState = c.TaskState, + ArmEnum = c.ArmEnum, + SubjectId = c.SubjectId, + VisitTaskNum = c.VisitTaskNum, + TrialId = c.TrialId, + + }).ToList(), + + }).ToList() + }); + + return query.OrderByDescending(t => t.IsHaveGeneratedTask); + + #endregion + } private (IQueryable>, IQueryable) GetIQueryableDoctorSelfConsistentRuleSubjectView(TaskConsistentRule filterObj, List? subejctIdList = null) { - - - //IQueryable subjectfilter = default; - - //if (isSelfAnalysis == false) - //{ - // //过滤不满足的Subject - - // subjectfilter = _subjectUserRepository.Where(t => t.TrialId == filterObj.TrialId).GroupBy(t => t.SubjectId) - // .Where(g => g.Any(t => t.DoctorUserId == filterObj.AnalysisDoctorUserId) && !g.Any(t => t.DoctorUserId == filterObj.CompareDoctorUserId)).Select(g => g.Key); - //} - var doctorUserId = filterObj.AnalysisDoctorUserId; + var trialId = filterObj.TrialId; - + #region 任务维度 var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId && t.IsAnalysisCreate == false && t.ReadingCategory == ReadingCategory.Visit && t.DoctorUserId == doctorUserId) @@ -170,7 +248,7 @@ namespace IRaCIS.Core.Application.Service //重阅产生的访视任务 要把之前的访视任务去除 .Where(t => t.ReReadingApplyState == ReReadingApplyState.Default || t.ReReadingApplyState == ReReadingApplyState.Reject) - .WhereIf(filterObj.IsHaveReadingPeriod == true, t => t.SameSubjectVisiTaskList.Any(u => u.VisitTaskNum == t.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] + .WhereIf(filterObj.IsHaveReadingPeriod == true, t => t.Subject.SubjectVisitTaskList.Any(u => u.VisitTaskNum == t.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now)) .GroupBy(t => t.SubjectId) .Where(g => g.Count() >= filterObj.PlanVisitCount); @@ -180,7 +258,7 @@ namespace IRaCIS.Core.Application.Service { SubjectId = g.Key, - IsHaveGeneratedTask = g.Any(c => c.SameSubjectVisiTaskList.Any(t => t.IsAnalysisCreate && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id)), + IsHaveGeneratedTask = g.Any(c => c.Subject.SubjectVisitTaskList.Any(t => t.IsAnalysisCreate && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id)), VisitTaskList = g.OrderBy(t => t.VisitTaskNum) @@ -200,7 +278,7 @@ namespace IRaCIS.Core.Application.Service SubjectCode = c.Subject.Code, TrialSiteCode = c.Subject.TrialSite.TrialSiteCode, - GlobalVisitTaskList = c.SameSubjectVisiTaskList.Where(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned).Select(t => new VisitTaskSimpleView() + GlobalVisitTaskList = c.Subject.SubjectVisitTaskList.Where(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned).Select(t => new VisitTaskSimpleView() { Id = t.Id, ReadingCategory = t.ReadingCategory, @@ -225,15 +303,25 @@ namespace IRaCIS.Core.Application.Service // UserName = c.DoctorUser.UserName //}).ToList(), - IsHaveGeneratedTask = c.SameSubjectVisiTaskList.Any(t => t.ConsistentAnalysisOriginalTaskId == c.Id), + IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.ConsistentAnalysisOriginalTaskId == c.Id), }).ToList(), ValidTaskCount = g.Count() - }); ; + }); return (group, query); + + #endregion + + + + + + + + } /// @@ -248,7 +336,7 @@ namespace IRaCIS.Core.Application.Service #region 是否有新的医生加入 自动加入配置 - if (await _taskConsistentRuleRepository.AnyAsync(t => t.TrialId == inQuery.TrialId)) + if (await _taskConsistentRuleRepository.AnyAsync(t => t.TrialId == inQuery.TrialId)) { var rule = await _taskConsistentRuleRepository.Where(t => t.TrialId == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstAsync(); @@ -275,7 +363,7 @@ namespace IRaCIS.Core.Application.Service { var query = from enroll in _repository.Where(t => t.TrialId == trialId) join user in _repository.Where() on enroll.DoctorId equals user.DoctorId - join taskConsistentRule in _repository.Where(t=>t.TrialId== trialId) on user.Id equals taskConsistentRule.AnalysisDoctorUserId into c + join taskConsistentRule in _repository.Where(t => t.TrialId == trialId) on user.Id equals taskConsistentRule.AnalysisDoctorUserId into c from taskConsistentRule in c.DefaultIfEmpty() select new { @@ -303,7 +391,7 @@ namespace IRaCIS.Core.Application.Service }; addOrEdit.AnalysisDoctorUserId = doctor.DoctorUserId; - addOrEdit.Id = Guid.Empty ; + addOrEdit.Id = Guid.Empty; var entity = await _taskConsistentRuleRepository.InsertOrUpdateAsync(addOrEdit, true, verifyExp1); } diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index c31415c2d..dd9a6cd2c 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -78,7 +78,6 @@ namespace IRaCIS.Application.Services //var list3 = _repository.Where(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SourceSubjectVisit.VisitTaskList).ToList(); var list2 = _repository.Where(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SubjectVisitTaskList).ToList(); - var list3 = _repository.Where(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SameSubjectVisiTaskList).ToList(); return _userInfo.LocalIp; } diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs index 71d423176..151d2157f 100644 --- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs +++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs @@ -84,7 +84,7 @@ namespace IRaCIS.Core.Domain.Models //排除一致性分析 因为souceVisitId 没值 //public List SameVisitTaskList { get; set; } - public List SameSubjectVisiTaskList { get; set; } + //public List SameSubjectVisiTaskList { get; set; } public TaskConsistentRule TaskConsistentRule { get; set; } diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 95f6e65ee..52348bb7a 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -103,7 +103,8 @@ namespace IRaCIS.Core.Infra.EFCore modelBuilder.Entity().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId); - modelBuilder.Entity().HasMany(t => t.SameSubjectVisiTaskList).WithOne().HasForeignKey(t => t.SubjectId).HasPrincipalKey(u=>u.SubjectId); + + modelBuilder.Entity().HasOne(t => t.Subject).WithMany(s=>s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId);