diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index aae2476a4..3a46248bd 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -196,8 +196,13 @@ namespace IRaCIS.Core.Application.Service #region 后续访视 未分配的进行再次分配,重置的或者失效的 需要重新生成新的任务 (PM 有序退回 或者PM 有序 申请重阅) + var followBackVisitTask = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.VisitTaskNum > subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit && t.SourceSubjectVisit.CheckState != CheckStateEnum.CVPassed).OrderBy(t => t.VisitTaskNum).FirstOrDefaultAsync(); + //存在退回访视1 又退回基线 这种情况 生成任务 考虑基线先一致性核查通过,但是访视1还未通过时 生成任务 - var followVisitTaskList = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.VisitTaskNum > subjectVisit.VisitNum && t.SourceSubjectVisit.CheckState==CheckStateEnum.CVPassed && t.ReadingCategory == ReadingCategory.Visit, true).ToListAsync(); + var followVisitTaskList = await _visitTaskRepository + .Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.VisitTaskNum > subjectVisit.VisitNum && t.SourceSubjectVisit.CheckState == CheckStateEnum.CVPassed && t.ReadingCategory == ReadingCategory.Visit, true) + .WhereIf(followBackVisitTask !=null ,t=> t.VisitTaskNum < followBackVisitTask.VisitTaskNum) + .ToListAsync(); var followVisitGroup = followVisitTaskList.GroupBy(t => t.VisitTaskNum); diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index b5b9af3d4..6719e6551 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -1731,117 +1731,129 @@ namespace IRaCIS.Core.Application.Service if (isReReading) { - - //IR 申请 PM 同意 仅仅影响自己 - //当前任务及其之后的所有访视任务、全局任务、裁判任务、肿瘤学阅片任务 - if (await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer) && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) { - //有序 - if (trialConfig.IsReadingTaskViewInOrder) + //IR 申请 PM 同意 仅仅影响自己 + //当前任务及其之后的所有访视任务、全局任务、裁判任务、肿瘤学阅片任务 + if (await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer)) { - - switch (filterObj.ReadingCategory) + //有序 + if (trialConfig.IsReadingTaskViewInOrder) { - case ReadingCategory.Visit: - //影响当前医生 以及当前医生之后的 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.Global: + switch (filterObj.ReadingCategory) + { + case ReadingCategory.Visit: + //影响当前医生 以及当前医生之后的 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; - // 1、后续任务如果是访视任务,均不处理; - //2、后续任务如果是全局、状态为阅片完成则标记为重阅重置,若阅片中或待阅片则不处理; - //3、当前任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效 - //4、后续任务为肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效; + case ReadingCategory.Global: - //全局不影响后续访视任务 - filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && - ( - t.ReadingCategory == ReadingCategory.Global || - t.ReadingCategory == ReadingCategory.Oncology || - t.ReadingCategory == ReadingCategory.Judge) - ); - break; + // 1、后续任务如果是访视任务,均不处理; + //2、后续任务如果是全局、状态为阅片完成则标记为重阅重置,若阅片中或待阅片则不处理; + //3、当前任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效 + //4、后续任务为肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效; - //1、后续任务如果是访视任务、全局任务或裁判任务,均不处理; - case ReadingCategory.Oncology: + //全局不影响后续访视任务 + filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && + ( + t.ReadingCategory == ReadingCategory.Global || + t.ReadingCategory == ReadingCategory.Oncology || + t.ReadingCategory == ReadingCategory.Judge) + ); + break; - //仅仅影响自己 - filterExpression = filterExpression.And(t => (t.Id == filterObj.Id)); - break; + //1、后续任务如果是访视任务、全局任务或裁判任务,均不处理; + case ReadingCategory.Oncology: - //(只允许申请该阅片人最后一次完成裁判的任务重阅)申请的时候做了限制 - case ReadingCategory.Judge: + //仅仅影响自己 + filterExpression = filterExpression.And(t => (t.Id == filterObj.Id)); + break; - // 1、后续任务如果是访视任务、全局任务,均不处理; - //2、后续若有肿瘤学阅片,若肿瘤学阅片任务状态为阅片完成,则标记为重阅重置;若为阅片中则标记为失效,如为待阅片,则取消分配 + //(只允许申请该阅片人最后一次完成裁判的任务重阅)申请的时候做了限制 + case ReadingCategory.Judge: - //裁判的影响自己 和后续肿瘤学阅片 - filterExpression = filterExpression.And(t => (t.Id == filterObj.Id) || (t.VisitTaskNum > filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && t.ReadingCategory == ReadingCategory.Oncology)); + // 1、后续任务如果是访视任务、全局任务,均不处理; + //2、后续若有肿瘤学阅片,若肿瘤学阅片任务状态为阅片完成,则标记为重阅重置;若为阅片中则标记为失效,如为待阅片,则取消分配 - break; + //裁判的影响自己 和后续肿瘤学阅片 + filterExpression = filterExpression.And(t => (t.Id == filterObj.Id) || (t.VisitTaskNum > filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && t.ReadingCategory == ReadingCategory.Oncology)); + + break; - default: - throw new BusinessValidationFailedException("不支持重阅的任务类型"); + default: + throw new BusinessValidationFailedException("不支持重阅的任务类型"); + } } + //无序 + else + { + //1.当前任务及裁判任务 + //2.影响当前阅片人的任务 + filterExpression = filterExpression.And(t => t.Id == filterObj.Id || t.Id == filterObj.JudgeVisitTaskId); + } + } - //无序 else { - //1.当前任务及裁判任务 - //2.影响当前阅片人的任务 - filterExpression = filterExpression.And(t => t.Id == filterObj.Id || t.Id == filterObj.JudgeVisitTaskId); + throw new BusinessValidationFailedException("仅允许PM 同意 IR 申请的任务"); } + } + else if(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) + { + //PM 影响所有阅片人 仅仅针对访视 SPM CPM 掉用 + if (await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.ProjectManager) && filterObj.IsAnalysisCreate == false && filterObj.ReadingCategory == ReadingCategory.Visit) + { + //有序 + if (trialConfig.IsReadingTaskViewInOrder) + { + switch (filterObj.ReadingCategory) + { + case ReadingCategory.Visit: + //访视影响当前以及当前之后的 两个阅片人的 + filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum); + + break; + + default: + throw new BusinessValidationFailedException("不支持重阅的任务类型"); + } + } + //无序 + else + { + // 1.当前任务及裁判任务 + // 2.影响所有阅片人的任务 + + var judegTaskNum = filterObj.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge]; + + filterExpression = filterExpression.And(t => t.VisitTaskNum == filterObj.VisitTaskNum || t.VisitTaskNum == judegTaskNum); + } + + } + else + { + throw new BusinessValidationFailedException("仅允许SPM CPM 同意 PM 申请的非 一致性分析的访视任务"); + } } else { - throw new BusinessValidationFailedException("仅允许PM 同意 IR 申请的任务"); + throw new BusinessValidationFailedException("该用户类型查看何种列表未定义"); } - //PM 影响所有阅片人 仅仅针对访视 SPM CPM 掉用 - if (await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.ProjectManager) && (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) && filterObj.IsAnalysisCreate == false && filterObj.ReadingCategory == ReadingCategory.Visit) - { - //有序 - if (trialConfig.IsReadingTaskViewInOrder) - { - switch (filterObj.ReadingCategory) - { - case ReadingCategory.Visit: - //访视影响当前以及当前之后的 两个阅片人的 - filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum); - break; - default: - throw new BusinessValidationFailedException("不支持重阅的任务类型"); - } - } - //无序 - else - { - // 1.当前任务及裁判任务 - // 2.影响所有阅片人的任务 - - var judegTaskNum = filterObj.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge]; - - filterExpression = filterExpression.And(t => t.VisitTaskNum == filterObj.VisitTaskNum || t.VisitTaskNum == judegTaskNum); - } - - } - else - { - throw new BusinessValidationFailedException("仅允许SPM CPM 同意 PM 申请的非 一致性分析的访视任务"); - } }