diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 898665590..124622011 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -578,7 +578,7 @@ namespace IRaCIS.Core.Application.Service.Allocation //给Subject分配医生的时候, 未确认绑定关系的 DoctorUserList = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).Select(t => new { t.DoctorUserId, t.ArmEnum }), //IsApplyed = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).SelectMany(t => t.SubjectArmVisitTaskList).Any(c => c.DoctorUserId != null) - IsApplyed=false + IsApplyed = false }).ToList(); //已产生任务的Subject数量(裁判情况下,就是产生裁判任务Subject 的数量) @@ -1106,7 +1106,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { var visitGroupQuery = _visitTaskRepository.Where(x => x.TrialId == trialId && x.DoctorUserId == _userInfo.Id) .Where(x => !x.Subject.IsDeleted) - .Where(t => (t.ReadingTaskState != ReadingTaskState.HaveSigned || t.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed||t.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed) && t.TaskState == TaskState.Effect) + .Where(t => (t.ReadingTaskState != ReadingTaskState.HaveSigned || t.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed || t.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed) && t.TaskState == TaskState.Effect) .GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode }); var visitTaskQuery = visitGroupQuery.Select(x => new IRUnReadSubjectView() @@ -1125,7 +1125,7 @@ namespace IRaCIS.Core.Application.Service.Allocation VisistId = u.SourceSubjectVisitId, SuggesteFinishedTime = u.SuggesteFinishedTime, ReadingCategory = u.ReadingCategory, - IsAnalysisCreate=u.IsAnalysisCreate, + IsAnalysisCreate = u.IsAnalysisCreate, }).ToList(), }).Where(x => x.UnReadTaskCount > 0).OrderBy(x => x.SubjectId); @@ -1403,9 +1403,6 @@ namespace IRaCIS.Core.Application.Service.Allocation return ResponseOutput.NotOk("当前为有序阅片,当前访视之后,也申请了重阅 必须从后向前处理"); } - - - } @@ -1434,8 +1431,8 @@ namespace IRaCIS.Core.Application.Service.Allocation #region PM 申请双重阅片 同一访视 其他已申请的任务也修改为同意 await _visitTaskReReadingRepository.BatchUpdateNoTrackingAsync(t => t.OriginalReReadingTask.SubjectId == origenalTask.SubjectId && - t.OriginalReReadingTask.ReReadingApplyState==ReReadingApplyState.TrialGroupHaveApplyed && - //t.RequestReReadingResultEnum==RequestReReadingResult.Default && + t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed && + //t.RequestReReadingResultEnum==RequestReReadingResult.Default && t.RequestReReadingType == RequestReReadingType.TrialGroupApply && t.OriginalReReadingTask.VisitTaskNum == origenalTask.VisitTaskNum && t.Id != item.Id, u => new VisitTaskReReading() @@ -1676,9 +1673,9 @@ namespace IRaCIS.Core.Application.Service.Allocation 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.DoctorUserId == origenalTask.DoctorUserId && ((t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState != ReadingTaskState.WaitReading) || t.ReadingCategory == ReadingCategory.Global)) || t.ReadingCategory == ReadingCategory.Judge || t.ReadingCategory == ReadingCategory.Oncology) ); @@ -1686,9 +1683,8 @@ namespace IRaCIS.Core.Application.Service.Allocation case ReadingCategory.Global: - //全局不影响后续访视任务 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))); + ((t.DoctorUserId == origenalTask.DoctorUserId && ((t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState != ReadingTaskState.WaitReading) || t.ReadingCategory == ReadingCategory.Global)) || (t.ReadingCategory == ReadingCategory.Oncology) || (t.ReadingCategory == ReadingCategory.Judge))); break; case ReadingCategory.Oncology: @@ -1729,13 +1725,6 @@ namespace IRaCIS.Core.Application.Service.Allocation { ReReadingTaskTrackingDeal(influenceTask, agreeReReadingCommand); - //influenceTaskList.ForEach(t => - //{ - // //记录实际影像的任务 - - // influenceTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = t.Id }); - //}); - await SetMedicalReviewInvalidAsync(influenceTaskList, false); @@ -1759,14 +1748,14 @@ namespace IRaCIS.Core.Application.Service.Allocation } - if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned && influenceTask.ReadingCategory == ReadingCategory.Visit) + if (/*influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned &&*/ influenceTask.ReadingCategory == ReadingCategory.Visit) { await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() { TrialId = trialId, ReadingCategory = GenerateTaskCategory.ReReading, - + 哦 ReReadingTask = influenceTask, //同步才可以 @@ -1781,36 +1770,34 @@ namespace IRaCIS.Core.Application.Service.Allocation newTask.AllocateTime = DateTime.Now; newTask.SuggesteFinishedTime = DateTime.Now.AddDays(7); - //拷贝表单 - if ( (visitTaskReReadingAppply.IsCopyOrigenalForms && origenalTask.VisitTaskNum==influenceTask.VisitTaskNum)|| (visitTaskReReadingAppply.IsCopyFollowForms && origenalTask.VisitTaskNum != influenceTask.VisitTaskNum)) - { - if (origenalTask.ReadingCategory == ReadingCategory.Visit) - { - var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + //拷贝后续表单 + //if (visitTaskReReadingAppply.IsCopyFollowForms && origenalTask.VisitTaskNum != influenceTask.VisitTaskNum) + //{ + // if (origenalTask.ReadingCategory == ReadingCategory.Visit) + // { + // var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); - foreach (var item in list) - { - item.Id = Guid.Empty; - item.VisitTaskId = newTask.Id; - } + // foreach (var item in list) + // { + // item.Id = Guid.Empty; + // item.VisitTaskId = newTask.Id; + // } - _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; - } - else if (origenalTask.ReadingCategory == ReadingCategory.Global) - { - var list = _repository.Where(t => t.GlobalTaskId == origenalTask.Id).ToList(); + // _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; + // } + // else if (origenalTask.ReadingCategory == ReadingCategory.Global) + // { + // var list = _repository.Where(t => t.GlobalTaskId == origenalTask.Id).ToList(); - foreach (var item in list) - { - item.Id = Guid.Empty; - item.GlobalTaskId = newTask.Id; - } + // foreach (var item in list) + // { + // item.Id = Guid.Empty; + // item.GlobalTaskId = newTask.Id; + // } - _ = _repository.AddRangeAsync(list).Result; - } - - - } + // _ = _repository.AddRangeAsync(list).Result; + // } + //} } }); @@ -2385,11 +2372,24 @@ namespace IRaCIS.Core.Application.Service.Allocation //影响当前医生 以及当前医生之后的 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.Judge || t.ReadingCategory == ReadingCategory.Oncology) + // ); + + 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.Judge || t.ReadingCategory == ReadingCategory.Oncology) + ( + (((t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState != ReadingTaskState.WaitReading) || t.ReadingCategory == ReadingCategory.Global) && t.DoctorUserId == filterObj.DoctorUserId) + // 裁判 肿瘤学是另外的医生做 + || t.ReadingCategory == ReadingCategory.Judge + || t.ReadingCategory == ReadingCategory.Oncology + ) ); + + + break; case ReadingCategory.Global: @@ -2399,9 +2399,17 @@ namespace IRaCIS.Core.Application.Service.Allocation //3、当前任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效 //4、后续任务为肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效; - //全局不影响后续访视任务 + //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))); + + 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))); + ( + (t.DoctorUserId == filterObj.DoctorUserId && ((t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState != ReadingTaskState.WaitReading) || t.ReadingCategory == ReadingCategory.Global)) + || (t.ReadingCategory == ReadingCategory.Oncology) + || (t.ReadingCategory == ReadingCategory.Judge) + )); + break; //1、后续任务如果是访视任务、全局任务或裁判任务,均不处理; @@ -2534,7 +2542,6 @@ namespace IRaCIS.Core.Application.Service.Allocation if (isReReading) { - if ((_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && applyId != null) || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer && applyId == null)) { //有序 @@ -2544,10 +2551,14 @@ namespace IRaCIS.Core.Application.Service.Allocation { influenceTask.OptType = ReReadingOrBackOptType.Return; } - else + else if (influenceTask.ReadingTaskState == ReadingTaskState.Reading) { influenceTask.OptType = ReReadingOrBackOptType.Abandon; } + else + { + throw new BusinessValidationFailedException("IR 申请重阅,不会影响到后续未读的任务"); + } } else {