diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index b40870fa2..b2873e0a5 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -108,8 +108,7 @@ namespace IRaCIS.Core.Application.ViewModel //重阅原始编号 //public string ReReadingOriginalTaskCode { get; set; } - //原任务的申请状态 方便PM 找到待审核的 - public ReReadingApplyState ReReadingApplyState { get; set; } + public Guid Id { get; set; } @@ -333,8 +332,13 @@ namespace IRaCIS.Core.Application.ViewModel + public List DoctorUserList { get; set; } + public List PreviousDoctorUserList => DoctorUserList.Where(t => t.OrignalSubjectUserId == null).ToList(); + + public List NowDoctorUserList => DoctorUserList.Where(t => t.OrignalSubjectUserId != null).ToList(); + //public UserSimpleInfo SingelDoctorUser { get; set; } //public UserSimpleInfo DoubleDoctorUser1 { get; set; } //public UserSimpleInfo DoubleDoctorUser2 { get; set; } @@ -343,6 +347,23 @@ namespace IRaCIS.Core.Application.ViewModel } + public class SubjectUserView + { + public DateTime? AssignTime { get; set; } + + public Arm ArmEnum { get; set; } + + public bool IsConfirmed { get; set; } + + //该属性有值 说明该医生被替换了 分配的时候 要过滤掉 + public Guid? OrignalSubjectUserId { get; set; } + + public UserSimpleInfo DoctorUser { get; set; } + } + + + + public class SubjectAssignView { public Guid TrialId { get; set; } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 89aa84eef..e5a5a55e6 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -63,7 +63,7 @@ namespace IRaCIS.Core.Application.Service.Allocation /// public async Task> GetSubjectAssignAndTaskStatList(SubjectAssignStatQuery querySubjectAssign) { - var subjectQuery = _subjectRepository.Where(t => t.TrialId == querySubjectAssign.TrialId && t.SubjectVisitTaskList.Any()) + var subjectQuery = _subjectRepository.Where(t => t.TrialId == querySubjectAssign.TrialId && t.SubjectVisitTaskList.Any()) .WhereIf(querySubjectAssign.SiteId != null, t => t.SiteId == querySubjectAssign.SiteId) .WhereIf(querySubjectAssign.SubjectId != null, t => t.Id == querySubjectAssign.SubjectId) .WhereIf(!string.IsNullOrEmpty(querySubjectAssign.SubjectCode), t => t.Code.Contains(querySubjectAssign.SubjectCode)) @@ -774,7 +774,7 @@ namespace IRaCIS.Core.Application.Service.Allocation .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < queryVisitTask.EndAllocateDate.Value.AddDays(1)) .ProjectTo(_mapper.ConfigurationProvider); - var defalutSortArray = new string[] { nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc", nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectId) , nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) }; + var defalutSortArray = new string[] { nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc", nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectId), nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) }; var pageList = await visitTaskQueryable.ToPagedListAsync(queryVisitTask.PageIndex, queryVisitTask.PageSize, queryVisitTask.SortField, queryVisitTask.Asc, string.IsNullOrWhiteSpace(queryVisitTask.SortField), defalutSortArray); @@ -792,10 +792,10 @@ namespace IRaCIS.Core.Application.Service.Allocation { var visitTaskQueryable = _visitTaskReReadingRepository - .Where(t=>t.RequestReReadingType==RequestReReadingType.DocotorApply) + .Where(t => t.RequestReReadingType == RequestReReadingType.DocotorApply) .Where(t => t.OriginalReReadingTask.DoctorUserId == _userInfo.Id) .Where(t => t.OriginalReReadingTask.TrialId == queryVisitTask.TrialId) - + .WhereIf(queryVisitTask.RootReReadingTaskId != null, t => t.RootReReadingTaskId == queryVisitTask.RootReReadingTaskId || t.OriginalReReadingTaskId == queryVisitTask.RootReReadingTaskId) .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(queryVisitTask.TaskCode) || t.RootReReadingTask.TaskCode.Contains(queryVisitTask.TaskCode)) .WhereIf(queryVisitTask.TaskState != null, t => t.OriginalReReadingTask.TaskState == queryVisitTask.TaskState) @@ -1114,7 +1114,7 @@ namespace IRaCIS.Core.Application.Service.Allocation RequestReReadingTime = DateTime.Now, RequestReReadingUserId = _userInfo.Id, IsCopyOrigenalForms = applyReReadingCommand.IsCopyOrigenalForms, - IsCopyFollowForms=applyReReadingCommand.IsCopyFollowForms, + IsCopyFollowForms = applyReReadingCommand.IsCopyFollowForms, RequestReReadingReason = applyReReadingCommand.RequestReReadingReason, RequestReReadingType = applyReReadingCommand.RequestReReadingType, @@ -1128,6 +1128,16 @@ namespace IRaCIS.Core.Application.Service.Allocation } + /// + /// 重阅原任务跟踪处理 + /// + /// + private void ReReadingTaskTrackingDeal(VisitTask origenalTask, ConfirmReReadingCommand agreeReReadingCommand) + { + origenalTask.ReReadingApplyState = agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? ReReadingApplyState.Agree : ReReadingApplyState.Reject; + origenalTask.TaskState = agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? TaskState.HaveReturned : origenalTask.TaskState; + } + /// /// 确认重阅与否 1同意 2 拒绝 /// @@ -1145,13 +1155,19 @@ namespace IRaCIS.Core.Application.Service.Allocation foreach (var item in agreeReReadingCommand.ConfirmReReadingList) { - var origenalTask = (await _visitTaskRepository.Where(t => item.OriginalReReadingTaskId == t.Id, true).FirstOrDefaultAsync()).IfNullThrowException(); + //var origenalTask = (await _visitTaskRepository.Where(t => item.OriginalReReadingTaskId == t.Id, true).FirstOrDefaultAsync()).IfNullThrowException(); + + ////更新原始任务 当前任务处理 + //origenalTask.ReReadingApplyState = agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? ReReadingApplyState.Agree : ReReadingApplyState.Reject; + //origenalTask.TaskState = agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? TaskState.HaveReturned : origenalTask.TaskState; - //更新原始任务 当前任务处理 - origenalTask.ReReadingApplyState = agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? ReReadingApplyState.Agree : ReReadingApplyState.Reject; - origenalTask.TaskState = agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? TaskState.HaveReturned : origenalTask.TaskState; + var origenalTask = (await _visitTaskRepository.Where(t => item.OriginalReReadingTaskId == t.Id).FirstOrDefaultAsync()).IfNullThrowException(); + Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && t.TaskState == TaskState.Effect; + + //是否是一致性分析任务 + filterExpression = filterExpression.And(t => t.IsAnalysisCreate == origenalTask.IsAnalysisCreate); //更新申请信息 var visitTaskReReadingAppply = await _visitTaskReReadingRepository.FirstOrDefaultAsync(t => t.Id == item.Id); @@ -1301,46 +1317,38 @@ namespace IRaCIS.Core.Application.Service.Allocation #region 有序 IR 申请 重阅 影响的其他访视查询 - Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && t.TaskState == TaskState.Effect; - //是否是一致性分析任务 - filterExpression = filterExpression.And(t => t.IsAnalysisCreate == origenalTask.IsAnalysisCreate); switch (origenalTask.ReadingCategory) { case ReadingCategory.Visit: //影响后续访视已经读完的,未读的不做处理 以及其他类型任务 - filterExpression = filterExpression.And(t => t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && - (t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned || - t.ReadingCategory == ReadingCategory.Global || - t.ReadingCategory == ReadingCategory.Oncology || - t.ReadingCategory == ReadingCategory.Judge) - ) - ; + filterExpression = filterExpression.And(t => t.VisitTaskNum >= origenalTask.VisitTaskNum && + ((t.DoctorUserId == origenalTask.DoctorUserId && ((t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned) || t.ReadingCategory == ReadingCategory.Global || t.ReadingCategory == ReadingCategory.Oncology)) + || + (t.ReadingCategory == ReadingCategory.Judge)) + ) + ; break; case ReadingCategory.Global: //全局不影响后续访视任务 - filterExpression = filterExpression.And(t => t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && - ( - t.ReadingCategory == ReadingCategory.Global || - t.ReadingCategory == ReadingCategory.Oncology || - t.ReadingCategory == ReadingCategory.Judge) - ); + filterExpression = filterExpression.And(t => t.VisitTaskNum >= origenalTask.VisitTaskNum && + (t.DoctorUserId == origenalTask.DoctorUserId && (t.ReadingCategory == ReadingCategory.Global || t.ReadingCategory == ReadingCategory.Oncology) || (t.ReadingCategory == ReadingCategory.Judge))); break; case ReadingCategory.Oncology: //仅仅影响自己 后续任务如果是访视任务、全局任务或裁判任务,均不处理 - filterExpression = filterExpression.And(t => /*t.Id == origenalTask.Id*/ t.Id == Guid.Empty); + filterExpression = filterExpression.And(t => t.Id == origenalTask.Id ); break; case ReadingCategory.Judge: //裁判的影响自己 和后续肿瘤学阅片 - filterExpression = filterExpression.And(t => /*(t.Id == origenalTask.Id) ||*/ t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && t.ReadingCategory == ReadingCategory.Oncology); + filterExpression = filterExpression.And(t => (t.Id == origenalTask.Id) || t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && t.ReadingCategory == ReadingCategory.Oncology); break; @@ -1352,65 +1360,78 @@ namespace IRaCIS.Core.Application.Service.Allocation #endregion - #region 这里时影响其他的任务 不包括申请的任务 申请的任务,在上面会统一处理 + + + + #region 这里时影响其他的任务 /*不包括申请的任务 申请的任务,在上面会统一处理*/ var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync(); foreach (var influenceTask in influenceTaskList) { - - if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned) + //处理申请的任务 + if (influenceTask.Id == origenalTask.Id) { - influenceTask.TaskState = TaskState.HaveReturned; + ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand); } + //处理其他任务 else { - influenceTask.TaskState = TaskState.Adbandon; - } - - - if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned && influenceTask.ReadingCategory == ReadingCategory.Visit) - { - await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() + if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned) { - TrialId = trialId, + influenceTask.TaskState = TaskState.HaveReturned; + } + else + { + influenceTask.TaskState = TaskState.Adbandon; + } - ReadingCategory = GenerateTaskCategory.ReReading, - ReReadingTask = influenceTask, - - //同步才可以 - Action = (newTask) => + if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned && influenceTask.ReadingCategory == ReadingCategory.Visit) + { + await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() { - //申请表 设置新任务Id - visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; + TrialId = trialId, - //生成的任务分配给原始医生 - newTask.DoctorUserId = origenalTask.DoctorUserId; - newTask.TaskAllocationState = TaskAllocationState.Allocated; - newTask.AllocateTime = DateTime.Now; + ReadingCategory = GenerateTaskCategory.ReReading, - //拷贝表单 - if (visitTaskReReadingAppply.IsCopyFollowForms) + ReReadingTask = influenceTask, + + //同步才可以 + Action = (newTask) => { + //申请表 设置新任务Id + visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; - var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == influenceTask.Id).ToList(); + //生成的任务分配给原始医生 + newTask.DoctorUserId = origenalTask.DoctorUserId; + newTask.TaskAllocationState = TaskAllocationState.Allocated; + newTask.AllocateTime = DateTime.Now; - foreach (var item in list) + //拷贝表单 + if (visitTaskReReadingAppply.IsCopyFollowForms) { - item.Id = Guid.Empty; - item.VisitTaskId = newTask.Id; + + var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == influenceTask.Id).ToList(); + + foreach (var item in list) + { + item.Id = Guid.Empty; + item.VisitTaskId = newTask.Id; + } + + _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; + } - _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; - } + }); + } - } - }); } + } #endregion @@ -1422,26 +1443,56 @@ namespace IRaCIS.Core.Application.Service.Allocation //无序阅片 只会申请访视类型和裁判类型的任务 注意这里有一致性分析的申请同意 else { - //访视任务产生了裁判 - if (origenalTask.ReadingCategory == ReadingCategory.Visit && origenalTask.JudgeVisitTaskId != null) + //1.当前任务及裁判任务 + //2.影响当前阅片人的任务 + filterExpression = filterExpression.And(t => t.Id == origenalTask.Id || t.Id == origenalTask.JudgeVisitTaskId); + + + var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync(); + + foreach (var influenceTask in influenceTaskList) { - - //裁判任务是否已阅片完成 - var judgeTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == origenalTask.JudgeVisitTaskId); - - if (judgeTask.ReadingTaskState == ReadingTaskState.HaveSigned) + //申请原任务处理 + if (influenceTask.Id == origenalTask.Id) { - judgeTask.TaskState = TaskState.HaveReturned; + ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand); } - //裁判任务未完 else { - judgeTask.TaskState = TaskState.Adbandon; + if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + influenceTask.TaskState = TaskState.HaveReturned; + } + else + { + influenceTask.TaskState = TaskState.Adbandon; + } } + } + #region Old + ////访视任务产生了裁判 + //if (origenalTask.ReadingCategory == ReadingCategory.Visit && origenalTask.JudgeVisitTaskId != null) + //{ + + // //裁判任务是否已阅片完成 + // var judgeTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == origenalTask.JudgeVisitTaskId); + + // if (judgeTask.ReadingTaskState == ReadingTaskState.HaveSigned) + // { + // judgeTask.TaskState = TaskState.HaveReturned; + // } + // //裁判任务未完 + // else + // { + // judgeTask.TaskState = TaskState.Adbandon; + // } + //} + #endregion + + - // 不管是访视还是裁判 都会立马产生的新任务并分配出去 } @@ -1450,8 +1501,6 @@ namespace IRaCIS.Core.Application.Service.Allocation #region 申请任务 重新生成 拷贝表单 - - //申请的任务 重新生成 await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() { TrialId = trialId, @@ -1490,21 +1539,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { } - //else if (origenalTask.ReadingCategory == ReadingCategory.Judge) - //{ - // newTask.JudgeResultImagePath = origenalTask.JudgeResultImagePath; - // newTask.JudgeResultRemark = origenalTask.JudgeResultRemark; - // newTask.JudgeResultTaskId = origenalTask.JudgeResultTaskId; - // //引起裁判的两个任务的 裁判任务Id 需要更新 - - // _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.JudgeVisitTaskId == origenalTask.Id, u => new VisitTask() - // { - // JudgeVisitTaskId = newTask.Id, - // }).Wait(); - - - //} } @@ -1833,7 +1868,8 @@ namespace IRaCIS.Core.Application.Service.Allocation /// 影响提示列表 重阅仅仅针对已完成的任务申请 退回针对的是未完成的(退回仅仅针对是访视类型的) /// /// - /// + /// 重阅还是直接回退 + /// 申请记录的Id /// [HttpGet("{taskId:guid}/{isReReading:bool}")] public async Task> GetReReadingOrBackInfluenceTaskList(Guid taskId, bool isReReading, Guid? applyId) @@ -1854,131 +1890,121 @@ namespace IRaCIS.Core.Application.Service.Allocation if (isReReading) { - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + + //IR 申请 PM 同意 仅仅影响自己 + + if ((_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer)) + || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer && applyId == null)) { - //IR 申请 PM 同意 仅仅影响自己 //当前任务及其之后的所有访视任务、全局任务、裁判任务、肿瘤学阅片任务 - if (await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer)) + + //有序 + if (trialConfig.IsReadingTaskViewInOrder) { - //有序 - if (trialConfig.IsReadingTaskViewInOrder) + + switch (filterObj.ReadingCategory) { + case ReadingCategory.Visit: + //影响当前医生 以及当前医生之后的 1、访视任务 已经读完的 + //2、后续任务如果是全局、肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效; + //3、当前任务、后续访视任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效 + filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum && + ((t.DoctorUserId == filterObj.DoctorUserId && ((t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned) || t.ReadingCategory == ReadingCategory.Global || t.ReadingCategory == ReadingCategory.Oncology)) + || + (t.ReadingCategory == ReadingCategory.Judge)) + ) + ; + break; - switch (filterObj.ReadingCategory) - { - case ReadingCategory.Visit: - //影响当前医生 以及当前医生之后的 1、访视任务 已经读完的 - //2、后续任务如果是全局、肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效; - //3、当前任务、后续访视任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效 - filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && - (t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned || - t.ReadingCategory == ReadingCategory.Global || - t.ReadingCategory == ReadingCategory.Oncology || - t.ReadingCategory == ReadingCategory.Judge) - ) - ; - break; + case ReadingCategory.Global: - case ReadingCategory.Global: + // 1、后续任务如果是访视任务,均不处理; + //2、后续任务如果是全局、状态为阅片完成则标记为重阅重置,若阅片中或待阅片则不处理; + //3、当前任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效 + //4、后续任务为肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效; - // 1、后续任务如果是访视任务,均不处理; - //2、后续任务如果是全局、状态为阅片完成则标记为重阅重置,若阅片中或待阅片则不处理; - //3、当前任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效 - //4、后续任务为肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效; + //全局不影响后续访视任务 + 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.VisitTaskNum >= filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && - ( - t.ReadingCategory == ReadingCategory.Global || - t.ReadingCategory == ReadingCategory.Oncology || - t.ReadingCategory == ReadingCategory.Judge) - ); - break; + //1、后续任务如果是访视任务、全局任务或裁判任务,均不处理; + case ReadingCategory.Oncology: - //1、后续任务如果是访视任务、全局任务或裁判任务,均不处理; - case ReadingCategory.Oncology: + //仅仅影响自己 + filterExpression = filterExpression.And(t => t.Id == filterObj.Id); + break; - //仅仅影响自己 - filterExpression = filterExpression.And(t => t.Id == filterObj.Id); - break; + //(只允许申请该阅片人最后一次完成裁判的任务重阅)申请的时候做了限制 + case ReadingCategory.Judge: - //(只允许申请该阅片人最后一次完成裁判的任务重阅)申请的时候做了限制 - case ReadingCategory.Judge: + // 1、后续任务如果是访视任务、全局任务,均不处理; + //2、后续若有肿瘤学阅片,若肿瘤学阅片任务状态为阅片完成,则标记为重阅重置;若为阅片中则标记为失效,如为待阅片,则取消分配 - // 1、后续任务如果是访视任务、全局任务,均不处理; - //2、后续若有肿瘤学阅片,若肿瘤学阅片任务状态为阅片完成,则标记为重阅重置;若为阅片中则标记为失效,如为待阅片,则取消分配 + //裁判的影响自己 和后续肿瘤学阅片 + filterExpression = filterExpression.And(t => t.Id == filterObj.Id || t.VisitTaskNum > filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && t.ReadingCategory == ReadingCategory.Oncology); - //裁判的影响自己 和后续肿瘤学阅片 - filterExpression = filterExpression.And(t => t.Id == filterObj.Id || t.VisitTaskNum > filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && t.ReadingCategory == ReadingCategory.Oncology); - - break; + 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 { - throw new BusinessValidationFailedException("仅允许PM 同意 IR 申请的任务"); + //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 掉用 + + else if (((_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.ProjectManager) && filterObj.IsAnalysisCreate == false && filterObj.ReadingCategory == ReadingCategory.Visit) + || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && applyId == null)) { - //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) { - //有序 - if (trialConfig.IsReadingTaskViewInOrder) + switch (filterObj.ReadingCategory) { - switch (filterObj.ReadingCategory) - { - case ReadingCategory.Visit: + case ReadingCategory.Visit: - //访视影响当前以及当前之后的 两个阅片人的 - filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum); + //访视影响当前以及当前之后的 两个阅片人的 + filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum); - break; + break; - default: - throw new BusinessValidationFailedException("不支持重阅的任务类型"); - } + 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 申请的非 一致性分析的访视任务"); + // 1.当前任务及裁判任务 + // 2.影响所有阅片人的任务 + + var judegTaskNum = filterObj.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge]; + + filterExpression = filterExpression.And(t => t.VisitTaskNum == filterObj.VisitTaskNum || t.VisitTaskNum == judegTaskNum); } + + //throw new BusinessValidationFailedException("仅允许SPM CPM 同意 PM 申请的非 一致性分析的访视任务"); } else { - throw new BusinessValidationFailedException("该用户类型查看何种列表未定义"); + throw new BusinessValidationFailedException("当前用户查看列表未定义"); } - } @@ -2016,7 +2042,12 @@ namespace IRaCIS.Core.Application.Service.Allocation } - var list = await _visitTaskRepository.Where(filterExpression).OrderBy(t => t.VisitTaskNum).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + var list = await _visitTaskRepository.Where(filterExpression) + //IR 申请的时候,仅仅看到影响自己的 + .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer, t => t.DoctorUserId == _userInfo.Id) + .OrderBy(t => t.VisitTaskNum).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + + #region 影响后的操作 foreach (var influenceTask in list) { @@ -2025,7 +2056,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + if ((_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && applyId != null) || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer && applyId == null)) { //有序 if (trialConfig.IsReadingTaskViewInOrder) @@ -2051,7 +2082,7 @@ namespace IRaCIS.Core.Application.Service.Allocation } } } - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) + if (((_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) && applyId != null) || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && applyId == null)) { //有序 if (trialConfig.IsReadingTaskViewInOrder) @@ -2145,6 +2176,8 @@ namespace IRaCIS.Core.Application.Service.Allocation } + #endregion + return list; diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 71cc4ac0e..1c27761cf 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -72,9 +72,11 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.VisitTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t=>t.ReadingCategory==ReadingCategory.Visit).Select(t=>t.VisitTaskNum).Distinct().Count())) .ForMember(o => o.GlobalTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Global).Select(t => t.VisitTaskNum).Distinct().Count())) .ForMember(o => o.OncologyTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Oncology).Select(t => t.VisitTaskNum).Distinct().Count())) - .ForMember(o => o.JudgeTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Select(t => t.VisitTaskNum).Distinct().Count())); - + .ForMember(o => o.JudgeTaskTypeCount, t => t.MapFrom(u => u.SubjectVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Select(t => t.VisitTaskNum).Distinct().Count())) + .ForMember(o => o.DoctorUserList, t => t.MapFrom(u => u.SubjectDoctorList)); + CreateMap() + .ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.DoctorUser)); CreateMap();