diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 332daf2de..99f1b3dfe 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -14,7 +14,7 @@ using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Infra.EFCore.Common; using System.Linq.Expressions; -namespace IRaCIS.Core.Application.Service +namespace IRaCIS.Core.Application.Service.Allocation { /// /// 访视读片任务 @@ -52,7 +52,7 @@ namespace IRaCIS.Core.Application.Service _subjectUserRepository = subjectUserRepository; _readModuleRepository = readModuleRepository; _visitTaskReReadingRepository = visitTaskReReadingRepository; - this._taskMedicalReviewRepository = taskMedicalReviewRepository; + _taskMedicalReviewRepository = taskMedicalReviewRepository; _readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository; } @@ -478,10 +478,10 @@ namespace IRaCIS.Core.Application.Service if (assginSubjectDoctorCommand.IsReAssign) { - if (await _visitTaskRepository.AnyAsync(t => assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.DoctorUserId != null && t.ArmEnum == Arm.JudgeArm)) - { - throw new BusinessValidationFailedException("有Subject任务已应用,不允许重新分配"); - } + //if (await _visitTaskRepository.AnyAsync(t => assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.DoctorUserId != null && t.ArmEnum == Arm.JudgeArm)) + //{ + // throw new BusinessValidationFailedException("有Subject任务已应用,不允许重新分配"); + //} await _subjectUserRepository.BatchDeleteNoTrackingAsync(t => doctorUserIdList.Contains(t.DoctorUserId) && assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.ArmEnum == Arm.JudgeArm); @@ -494,10 +494,10 @@ namespace IRaCIS.Core.Application.Service if (assginSubjectDoctorCommand.IsReAssign) { - if (await _visitTaskRepository.AnyAsync(t => assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.DoctorUserId != null && t.ArmEnum != Arm.JudgeArm)) - { - throw new BusinessValidationFailedException("有Subject任务已应用,不允许重新分配"); - } + //if (await _visitTaskRepository.AnyAsync(t => assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.DoctorUserId != null && t.ArmEnum != Arm.JudgeArm)) + //{ + // throw new BusinessValidationFailedException("有Subject任务已应用,不允许重新分配"); + //} await _subjectUserRepository.BatchDeleteNoTrackingAsync(t => doctorUserIdList.Contains(t.DoctorUserId) && assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.ArmEnum != Arm.JudgeArm); @@ -722,7 +722,7 @@ namespace IRaCIS.Core.Application.Service //已分配的 医生的情况 - var haveAssignedSubjectDoctorList = subjectList.Clone().SelectMany(t => t.DoctorUserList.Select(c => new { t.SubjectId, DoctorUserId = c.DoctorUserId, c.ArmEnum })).ToList(); + var haveAssignedSubjectDoctorList = subjectList.Clone().SelectMany(t => t.DoctorUserList.Select(c => new { t.SubjectId, c.DoctorUserId, c.ArmEnum })).ToList(); //将目前已分配的情况 换到医生的维度 foreach (var waitAllocationDoctor in waitAllocationDoctorList) @@ -798,18 +798,18 @@ namespace IRaCIS.Core.Application.Service var doctor1Arm = Arm.DoubleReadingArm1; var doctor2Arm = Arm.DoubleReadingArm2; - if ((preferredDoctor1Arm == null && preferredDoctor2Arm == null) || - (preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm2) || - (preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == null) || - (preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == Arm.DoubleReadingArm2) + if (preferredDoctor1Arm == null && preferredDoctor2Arm == null || + preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm2 || + preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == null || + preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == Arm.DoubleReadingArm2 ) { doctor1Arm = Arm.DoubleReadingArm1; doctor2Arm = Arm.DoubleReadingArm2; } - else if ((preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm1) || - (preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == Arm.DoubleReadingArm1) || - (preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == null)) + else if (preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm1 || + preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == Arm.DoubleReadingArm1 || + preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == null) { doctor1Arm = Arm.DoubleReadingArm2; doctor2Arm = Arm.DoubleReadingArm1; @@ -1061,20 +1061,16 @@ namespace IRaCIS.Core.Application.Service } else { - if ((task.ReadingCategory != ReadingCategory.Visit && task.ReadingCategory != ReadingCategory.Global)) + if (task.ReadingCategory != ReadingCategory.Visit && task.ReadingCategory != ReadingCategory.Global) { throw new BusinessValidationFailedException("无序阅片,仅仅允许IR 申请 全局和访视类型类别的任务进行重阅"); } } - + } - - - - task.ReReadingApplyState = ReReadingApplyState.HaveApplyed; @@ -1123,8 +1119,8 @@ namespace IRaCIS.Core.Application.Service //更新原始任务 当前任务处理 - 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; @@ -1172,7 +1168,7 @@ namespace IRaCIS.Core.Application.Service filterExpression = filterExpression.And(t => t.IsAnalysisCreate == origenalTask.IsAnalysisCreate); //访视影响当前以及当前之后的 两个阅片人的 - filterExpression = filterExpression.And(t => (t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId) || (t.VisitTaskNum >= origenalTask.VisitTaskNum && t.DoctorUserId != origenalTask.DoctorUserId)); + filterExpression = filterExpression.And(t => t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId || t.VisitTaskNum >= origenalTask.VisitTaskNum && t.DoctorUserId != origenalTask.DoctorUserId); #region 影响的任务(排除申请的任务) @@ -1288,7 +1284,7 @@ namespace IRaCIS.Core.Application.Service //影响后续访视已经读完的,未读的不做处理 以及其他类型任务 filterExpression = filterExpression.And(t => t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && - ((t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit) || + (t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global || t.ReadingCategory == ReadingCategory.Oncology || t.ReadingCategory == ReadingCategory.Judge) @@ -1315,7 +1311,7 @@ namespace IRaCIS.Core.Application.Service 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; @@ -1804,7 +1800,7 @@ namespace IRaCIS.Core.Application.Service //2、后续任务如果是全局、肿瘤学阅片任务,状态为阅片完成标记为重阅重置;若在阅片中,则标记为失效;若为待阅片,则标记为失效; //3、当前任务、后续访视任务或者全局任务触发了裁判任务,若裁判任务状态为阅片完成,则标记为重阅重置;若在阅片中或待阅片,则标记为失效 filterExpression = filterExpression.And(t => t.VisitTaskNum >= filterObj.VisitTaskNum && t.DoctorUserId == filterObj.DoctorUserId && - ((t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit) || + (t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global || t.ReadingCategory == ReadingCategory.Oncology || t.ReadingCategory == ReadingCategory.Judge) @@ -1831,7 +1827,7 @@ namespace IRaCIS.Core.Application.Service case ReadingCategory.Oncology: //仅仅影响自己 - filterExpression = filterExpression.And(t => (t.Id == filterObj.Id)); + filterExpression = filterExpression.And(t => t.Id == filterObj.Id); break; //(只允许申请该阅片人最后一次完成裁判的任务重阅)申请的时候做了限制 @@ -1841,7 +1837,7 @@ namespace IRaCIS.Core.Application.Service //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;