diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs index be54204a5..71534ec38 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs @@ -98,7 +98,7 @@ namespace IRaCIS.Core.Application.Service if (toGenerateCount > 0) { - var toGenerateTaskList = item.ActualGlobalTaskList.Except(item.GeneratedGlobalTaskList).Take(toGenerateCount).ToList(); + var toGenerateTaskList = item.ActualGlobalTaskList.ExceptBy(item.GeneratedGlobalTaskList.Select(t => t.TaskId), t => t.TaskId).Take(toGenerateCount).ToList(); foreach (var toGenerateTask in toGenerateTaskList) { @@ -118,7 +118,7 @@ namespace IRaCIS.Core.Application.Service if (toGenerateCount > 0) { - var toGenerateTaskList = item.ActualJudgeTaskList.Except(item.GeneratedJudgeTaskList).Take(toGenerateCount).ToList(); + var toGenerateTaskList = item.ActualJudgeTaskList.ExceptBy(item.GeneratedJudgeTaskList.Select(t => t.TaskId), t => t.TaskId).Take(toGenerateCount).ToList(); foreach (var toGenerateTask in toGenerateTaskList) { @@ -137,7 +137,7 @@ namespace IRaCIS.Core.Application.Service if (toGenerateCount > 0) { - var toGenerateTaskList = item.ActualTumorTaskList.Except(item.GeneratedTumorTaskList).Take(toGenerateCount).ToList(); + var toGenerateTaskList = item.ActualTumorTaskList.ExceptBy(item.GeneratedTumorTaskList.Select(t => t.TaskId), t => t.TaskId).Take(toGenerateCount).ToList(); foreach (var toGenerateTask in toGenerateTaskList) { @@ -157,7 +157,7 @@ namespace IRaCIS.Core.Application.Service if (toGenerateCount > 0) { - var toGenerateTaskList = item.ActualVisitTaskList.Except(item.GeneratedVisitTaskList).Take(toGenerateCount).ToList(); + var toGenerateTaskList = item.ActualVisitTaskList.ExceptBy(item.GeneratedVisitTaskList.Select(t=>t.TaskId),t=>t.TaskId).Take(toGenerateCount).ToList(); foreach (var toGenerateTask in toGenerateTaskList) { diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 82ec696bd..3fec455af 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -1241,54 +1241,114 @@ namespace IRaCIS.Core.Application.Service //执行类似一致性核查回退流程 回退访视到影像上传流程 await VisitBackAsync(task.SourceSubjectVisitId); - //考虑该访视 另外一个阅片人的任务 var otherReviewerTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.SourceSubjectVisitId == task.SourceSubjectVisitId && t.Id != task.Id && t.TaskState == TaskState.Effect); + + #endregion + if (otherReviewerTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + //另外阅片人完成阅片了 就设置为重阅重置 + otherReviewerTask.TaskState = TaskState.HaveReturned; + } + else + { + otherReviewerTask.TaskState = TaskState.Adbandon; + } + //有序 if (trialConfig.IsReadingTaskViewInOrder) { - //本身自己 有序 PM 申请回退流程 - if (otherReviewerTask.ReadingTaskState == ReadingTaskState.HaveSigned) + Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == task.SubjectId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false; + + //自己的后续任务 取消分配 注意这里条件是> + //另一个阅片人的任务根据任务进度自动进入PM退回或PM申请重阅 + filterExpression = filterExpression.And(t => t.VisitTaskNum > task.VisitTaskNum); + + + var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync(); + + + foreach (var influenceTask in influenceTaskList) { - //另外阅片人完成阅片了 就设置为重阅重置 - otherReviewerTask.TaskState = TaskState.HaveReturned; + //申请任务的阅片人 后续任务肯定没做, 只有访视任务,没有其他任务 取消分配 + if (influenceTask.DoctorUserId == task.DoctorUserId) + { + + switch (influenceTask.ReadingCategory) + { + case ReadingCategory.Visit: + + influenceTask.DoctorUserId = null; + influenceTask.AllocateTime = null; + influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate; + break; + + case ReadingCategory.Global: + case ReadingCategory.Judge: + case ReadingCategory.Oncology: + + throw new BusinessValidationFailedException("不支持回退任务类型"); + } + } + //另外一个阅片人 + else + { + //另外一个阅片人 有序PM 申请重阅流程 + if (otherReviewerTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + switch (influenceTask.ReadingCategory) + { + case ReadingCategory.Visit: - //另外一个阅片人 有序PM 申请重阅流程 + break; + + case ReadingCategory.Global: + case ReadingCategory.Judge: + break; + case ReadingCategory.Oncology: + break; + default: + + throw new BusinessValidationFailedException("不支持回退任务类型"); + } + } + //另外一个阅片人 有序 PM 申请回退流程 + else + { + switch (influenceTask.ReadingCategory) + { + case ReadingCategory.Visit: + + influenceTask.DoctorUserId = null; + influenceTask.AllocateTime = null; + influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate; + break; + case ReadingCategory.Global: + case ReadingCategory.Judge: + case ReadingCategory.Oncology: + + throw new BusinessValidationFailedException("不支持回退任务类型"); + } + } + + } } - else - { - - otherReviewerTask.TaskState = TaskState.Adbandon; - - //另外一个阅片人 有序 PM 申请回退流程 - - } - } - //无序 无序阅片没有 全局 肿瘤学 + else { - if (otherReviewerTask.ReadingTaskState == ReadingTaskState.HaveSigned) - { - //另外阅片人完成阅片了 就设置为重阅重置 - otherReviewerTask.TaskState = TaskState.HaveReturned; - } - else - { + //无序 无序阅片没有 全局 肿瘤学 + //没有额外特殊的操作 - otherReviewerTask.TaskState = TaskState.Adbandon; - } } - - } else { @@ -1359,7 +1419,7 @@ namespace IRaCIS.Core.Application.Service var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.IsReadingTaskViewInOrder, t.ReadingType }).FirstOrDefaultAsync()).IfNullThrowException(); - Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == filterObj.SubjectId && t.TaskState == TaskState.Effect; + Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == filterObj.SubjectId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false; //重阅影响 if (isReReading) @@ -1367,68 +1427,57 @@ namespace IRaCIS.Core.Application.Service //有序 if (trialConfig.IsReadingTaskViewInOrder) { + //IR 仅仅影响自己 //当前任务及其之后的所有访视任务、全局任务、裁判任务、肿瘤学阅片任务 if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer) { switch (filterObj.ReadingCategory) { case ReadingCategory.Visit: - - //访视影响当前医生 以及当前医生之后的 - filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId); - - break; - case ReadingCategory.Global: - //全局的影响所有 不加额外过滤 + case ReadingCategory.Oncology: + + //影响当前医生 以及当前医生之后的 (1、访视任务 已经读完的,未读完的或者未读的 不处理) + //2、后续任务如果是全局、肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效; + //3、当前任务、后续访视任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效 + filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && + ((t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit) || + t.ReadingCategory == ReadingCategory.Global || + t.ReadingCategory == ReadingCategory.Oncology || + t.ReadingCategory == ReadingCategory.Judge) + ); + break; + case ReadingCategory.Judge: - //裁判的仅仅影响自己 - filterExpression = filterExpression.And(t => t.Id == filterObj.Id); + //裁判的影响自己 和后续肿瘤学阅片 + filterExpression = filterExpression.And(t => (t.Id == filterObj.Id) || (t.VisitTaskNum > filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && t.ReadingCategory == ReadingCategory.Oncology)); break; - case ReadingCategory.Oncology: - throw new BusinessValidationFailedException("不支持的任务类型"); - break; + default: - throw new BusinessValidationFailedException("不支持的任务类型"); - break; + throw new BusinessValidationFailedException("不支持重阅的任务类型"); } } - //影响所有阅片人 + //PM 影响所有阅片人 仅仅针对访视 if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { switch (filterObj.ReadingCategory) { case ReadingCategory.Visit: - //访视影响当前以及当前之后的 + //访视影响当前以及当前之后的 两个月月阅片人的 filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum); break; - case ReadingCategory.Global: - //全局的影响所有 不加额外过滤 - - break; - case ReadingCategory.Judge: - //裁判的仅仅影响自己 - filterExpression = filterExpression.And(t => t.Id == filterObj.Id); - - break; - case ReadingCategory.Oncology: - - throw new BusinessValidationFailedException("不支持的任务类型"); - break; - default: - throw new BusinessValidationFailedException("不支持的任务类型"); - break; + throw new BusinessValidationFailedException("不支持重阅的任务类型"); } } } @@ -1444,7 +1493,7 @@ namespace IRaCIS.Core.Application.Service // 1.当前任务及裁判任务 // 2.影响所有阅片人的任务 - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + if (filterObj.ReadingCategory == ReadingCategory.Visit && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { var judegTaskNum = filterObj.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge]; @@ -1456,17 +1505,22 @@ namespace IRaCIS.Core.Application.Service //退回影响 仅仅针对是访视类型的 else { + if (filterObj.ReadingCategory == ReadingCategory.Visit && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { //有序 if (trialConfig.IsReadingTaskViewInOrder) { + // 当前任务及其之后的所有访视任务 两个阅片人的 + //自己的后续任务 取消分配 + //另一个阅片人的任务根据任务进度自动进入PM退回或PM申请重阅() + filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum); } //无序 else { - //自己和另一个人的当前任务 + //自己和另一个人的当前任务 退回针对的是未完成的肯定不会有裁判 filterExpression = filterExpression.And(t => t.VisitTaskNum == filterObj.VisitTaskNum); } }