From 83297cab3254f2c0ebe86f35a4032cb23800c837 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 30 Sep 2022 10:26:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTO/TaskConsistentRuleViewModel.cs | 2 ++ .../Allocation/TaskConsistentRuleService.cs | 27 +++++++++++++------ .../Allocation/VisitTaskHelpeService.cs | 7 ++++- .../WorkLoad/DTO/DoctorWorkLoadViewModel.cs | 5 ++-- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs index 77cd6cdb1..84c7e00c3 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs @@ -128,6 +128,8 @@ namespace IRaCIS.Core.Application.ViewModel public Guid? SourceSubjectVisitId { get; set; } public Guid? SouceReadModuleId { get; set; } + public Guid TrialReadingCriterionId { get; set; } + } diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs index 010d41655..b21605826 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs @@ -129,6 +129,7 @@ namespace IRaCIS.Core.Application.Service { var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inCommand.TaskConsistentRuleId); var doctorUserId = inCommand.DoctorUserId; + var trialReadingCriterionId = filterObj.TrialReadingCriterionId; var list = await GetIQueryableDoctorSelfConsistentSubjectView(filterObj, doctorUserId, inCommand.SubejctIdList).ToListAsync(); @@ -146,14 +147,14 @@ namespace IRaCIS.Core.Application.Service var blindSubjectCode = string.Empty; - var subjectTask = _visitTaskRepository.Where(t => t.SubjectId == subject.SubjectId).OrderByDescending(t => t.BlindSubjectCode).FirstOrDefault().IfNullThrowException(); + var subjectTask = _visitTaskRepository.Where(t => t.SubjectId == subject.SubjectId && t.TrialReadingCriterionId==trialReadingCriterionId).OrderByDescending(t => t.BlindSubjectCode).FirstOrDefault().IfNullThrowException(); if (subjectTask.BlindSubjectCode != String.Empty) { blindSubjectCode = subjectTask.BlindSubjectCode; } else { - var maxCodeStr = _visitTaskRepository.Where(t => t.TrialId == subject.TrialId).OrderByDescending(t => t.BlindSubjectCode).Select(t => t.BlindSubjectCode).FirstOrDefault(); + var maxCodeStr = _visitTaskRepository.Where(t => t.TrialId == subject.TrialId && t.TrialReadingCriterionId == trialReadingCriterionId).OrderByDescending(t => t.BlindSubjectCode).Select(t => t.BlindSubjectCode).FirstOrDefault(); int.TryParse(maxCodeStr, out maxCodeInt); @@ -176,7 +177,7 @@ namespace IRaCIS.Core.Application.Service { var lastTask = (subject.VisitTaskList.Take(filterObj.PlanVisitCount).Last()).Clone(); - var existGlobal = _visitTaskRepository.Where(t => t.SubjectId == lastTask.SubjectId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum == lastTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); + var existGlobal = _visitTaskRepository.Where(t => t.SubjectId == lastTask.SubjectId &&t.TrialReadingCriterionId==trialReadingCriterionId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum == lastTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); if (existGlobal == null) @@ -188,7 +189,8 @@ namespace IRaCIS.Core.Application.Service ArmEnum = lastTask.ArmEnum, ReadingCategory = ReadingCategory.Global, TaskName = lastTask.VisitTaskNum + "Global", - TaskBlindName = lastTask.VisitTaskNum + "Global" + TaskBlindName = lastTask.VisitTaskNum + "Global", + TrialReadingCriterionId=trialReadingCriterionId, }; } @@ -266,12 +268,14 @@ namespace IRaCIS.Core.Application.Service var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.IsSelfAnalysis == false); + var trialReadingCriterionId = filterObj.TrialReadingCriterionId; + var query = await GetGroupConsistentQueryAsync(filterObj, inCommand.SubejctIdList); var subjectList = query.ToList(); - var doctorUserIdQuery = from enroll in _repository.Where(t => t.TrialId == trialId).Where(t => t.EnrollReadingCategoryList.Any(c => c.ReadingCategory == ReadingCategory.Global || c.ReadingCategory == ReadingCategory.Visit)) + var doctorUserIdQuery = from enroll in _repository.Where(t => t.TrialId == trialId).Where(t => t.EnrollReadingCategoryList.Where(t=>t.TrialReadingCriterionId==trialReadingCriterionId).Any(c => c.ReadingCategory == ReadingCategory.Global || c.ReadingCategory == ReadingCategory.Visit)) join user in _repository.Where() on enroll.DoctorId equals user.DoctorId select user.Id; @@ -316,6 +320,8 @@ namespace IRaCIS.Core.Application.Service ArmEnum = Arm.GroupConsistentArm, SouceReadModuleId = task.SouceReadModuleId, SourceSubjectVisitId = task.SourceSubjectVisitId, + + TrialReadingCriterionId=task.TrialReadingCriterionId, }); } @@ -327,7 +333,7 @@ namespace IRaCIS.Core.Application.Service var lastTask = (subjectAddTaskList.Take(filterObj.PlanVisitCount).Last()).Clone(); - var existGlobal = _visitTaskRepository.Where(t => t.SubjectId == lastTask.SubjectId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum == lastTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); + var existGlobal = _visitTaskRepository.Where(t => t.SubjectId == lastTask.SubjectId && t.TrialReadingCriterionId==trialReadingCriterionId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum == lastTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefault(); if (existGlobal == null) @@ -338,7 +344,9 @@ namespace IRaCIS.Core.Application.Service TrialId = lastTask.TrialId, ReadingCategory = ReadingCategory.Global, TaskBlindName = lastTask.VisitTaskNum + "Global", - TaskName = lastTask.VisitTaskNum + "Global" + TaskName = lastTask.VisitTaskNum + "Global", + + TrialReadingCriterionId=trialReadingCriterionId, }; } @@ -453,6 +461,8 @@ namespace IRaCIS.Core.Application.Service SourceSubjectVisitId = c.SourceSubjectVisitId, SouceReadModuleId = c.SouceReadModuleId, + TrialReadingCriterionId=c.TrialReadingCriterionId, + //自身一致性才有意义 //IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.ConsistentAnalysisOriginalTaskId == c.Id), @@ -541,7 +551,7 @@ namespace IRaCIS.Core.Application.Service SubjectId = t.Id, - IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.IsSelfAnalysis == false), + IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.IsSelfAnalysis == false && c.TrialReadingCriterionId==trialReadingCriterionId), ValidVisitCount = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count(), @@ -561,6 +571,7 @@ namespace IRaCIS.Core.Application.Service SourceSubjectVisitId = c.SourceSubjectVisitId, SouceReadModuleId = c.SouceReadModuleId, + TrialReadingCriterionId = c.TrialReadingCriterionId, }).ToList() diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index 2b618a4ae..dccbd7cd6 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -598,7 +598,9 @@ namespace IRaCIS.Core.Application.Service IsAnalysisCreate = reReadingVisitTask.IsAnalysisCreate, IsSelfAnalysis = reReadingVisitTask.IsSelfAnalysis, BlindSubjectCode = reReadingVisitTask.BlindSubjectCode, - BlindTrialSiteCode = reReadingVisitTask.BlindTrialSiteCode + BlindTrialSiteCode = reReadingVisitTask.BlindTrialSiteCode, + + // TaskAllocationState = reReadingVisitTask.TaskAllocationState, // AllocateTime = DateTime.Now, @@ -673,6 +675,7 @@ namespace IRaCIS.Core.Application.Service IsAnalysisCreate = true, IsSelfAnalysis = true, + TrialReadingCriterionId=task.TrialReadingCriterionId, }; await _visitTaskRepository.AddAsync(consistentTask); @@ -714,6 +717,8 @@ namespace IRaCIS.Core.Application.Service IsAnalysisCreate = true, IsSelfAnalysis = false, + TrialReadingCriterionId = task.TrialReadingCriterionId, + }; await _visitTaskRepository.AddAsync(consistentTask); diff --git a/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs b/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs index 6020168b1..8d744f907 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs @@ -264,7 +264,8 @@ namespace IRaCIS.Application.Contracts public List CriterionReadingCategoryList { get; set; } - public List CriterionCategoryList => CriterionReadingCategoryList + public List CriterionCategoryList => CriterionReadingCategoryList.Count==0? TrialReadingCriterionList.Select(t=>new CriterionReadingCategory() { EnrollId= EnrollId ,TrialReadingCriterionId=t.TrialReadingCriterionId}).ToList(): + CriterionReadingCategoryList .GroupBy(t => new { t.TrialReadingCriterionId, t.EnrollId }) .Select(g => new CriterionReadingCategory() { EnrollId = g.Key.EnrollId, TrialReadingCriterionId = g.Key.TrialReadingCriterionId, ReadingCategorys = g.Select(t => t.ReadingCategory).ToList() }).ToList(); @@ -291,7 +292,7 @@ namespace IRaCIS.Application.Contracts public Guid EnrollId { get; set; } public Guid TrialReadingCriterionId { get; set; } - public List ReadingCategorys { get; set; } + public List ReadingCategorys { get; set; } = new List(); }