申请限制

Uat_Study
hang 2022-07-19 09:46:43 +08:00
parent 883f06372f
commit 0b880e20da
1 changed files with 68 additions and 40 deletions

View File

@ -393,7 +393,7 @@ namespace IRaCIS.Core.Application.Service
else
{
var taskQuery = _visitTaskRepository.Where(x => x.TrialId == iRUnReadSubjectQuery.TrialId && x.DoctorUserId == _userInfo.Id&&x.TaskState == TaskState.Effect)
var taskQuery = _visitTaskRepository.Where(x => x.TrialId == iRUnReadSubjectQuery.TrialId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect)
.Where(x => !x.Subject.IsDeleted);
IRUnReadOutDto iRUnReadOut = new IRUnReadOutDto()
@ -611,7 +611,7 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(subjectIdList.Count() > 0 && assignConfirmCommand.IsJudgeDoctor, t => subjectIdList.Contains(t.SubjectId) && t.Subject.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
//过滤掉 那些回退的subject
.Where(t => !t.Subject.SubjectVisitList.Any(t => t.IsPMBackOrReReading))
.ToList();
@ -913,7 +913,7 @@ namespace IRaCIS.Core.Application.Service
}
else if (visitTask.SouceReadModuleId != null)
{
if (await _visitTaskRepository.AnyAsync(t => t.SouceReadModuleId == visitTask.SouceReadModuleId && t.TaskAllocationState == TaskAllocationState.Allocated && t.DoctorUserId == assignSubjectTaskToDoctorCommand.DoctorUserId && t.Id != visitTask.Id))
if (await _visitTaskRepository.AnyAsync(t => t.SouceReadModuleId == visitTask.SouceReadModuleId && t.TaskAllocationState == TaskAllocationState.Allocated && t.DoctorUserId == assignSubjectTaskToDoctorCommand.DoctorUserId && t.Id != visitTask.Id))
{
return ResponseOutput.NotOk("其中一个任务已分配给该医生,不允许分配");
}
@ -988,15 +988,7 @@ namespace IRaCIS.Core.Application.Service
foreach (var task in taskList)
{
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && task.IsAnalysisCreate)
{
throw new BusinessValidationFailedException("PM 不允许对一致性分析任务进行申请重阅");
}
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && task.ReadingCategory != ReadingCategory.Visit)
{
throw new BusinessValidationFailedException("PM 仅仅允许对访视类型的任务申请重阅");
}
if (task.ReadingTaskState != ReadingTaskState.HaveSigned || task.TaskState != TaskState.Effect)
{
@ -1009,43 +1001,79 @@ namespace IRaCIS.Core.Application.Service
}
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer && !trialConfig.IsReadingTaskViewInOrder && (task.ReadingCategory != ReadingCategory.Visit && task.ReadingCategory != ReadingCategory.Global))
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager)
{
throw new BusinessValidationFailedException("无序阅片仅仅允许IR 申请 全局和访视类型类别的任务进行重阅");
if (task.IsAnalysisCreate)
{
throw new BusinessValidationFailedException("PM 不允许对一致性分析任务进行申请重阅");
}
if (task.ReadingCategory != ReadingCategory.Visit)
{
throw new BusinessValidationFailedException("PM 仅仅允许对访视类型的任务申请重阅");
}
// 有序
if (trialConfig.IsReadingTaskViewInOrder)
{
// 当前访视之前 已有任务申请
if (await _visitTaskRepository.AnyAsync(t => t.TrialId == task.TrialId && t.SubjectId == task.SubjectId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Visit
&& t.ReadingTaskState == ReadingTaskState.HaveSigned && t.VisitTaskNum <= task.VisitTaskNum && t.Id != task.Id && t.ReReadingApplyState == ReReadingApplyState.HaveApplyed))
{
return ResponseOutput.NotOk("当前为有序阅片,之前有访视,或其他IR的本次访视已申请重阅还未处理不允许申请");
}
}
else
{
}
}
if (task.ReadingCategory == ReadingCategory.Judge && task.TaskState == TaskState.HaveReturned)
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer)
{
throw new BusinessValidationFailedException("访视重阅导致裁判任务重置的,不能申请重阅");
}
Expression<Func<VisitTask, bool>> filterExpression = t => t.TrialId == task.TrialId && t.SubjectId == task.SubjectId && t.TaskState == TaskState.Effect
&& t.ReadingTaskState == ReadingTaskState.HaveSigned && t.DoctorUserId == task.DoctorUserId && t.IsAnalysisCreate == false && t.VisitTaskNum > task.VisitTaskNum;
// 有序
if (trialConfig.IsReadingTaskViewInOrder)
{
//当前访视之前 已有任务申请
if (trialConfig.IsReadingTaskViewInOrder && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager
&& await _visitTaskRepository.AnyAsync(t => t.TrialId == task.TrialId && t.SubjectId == task.SubjectId && t.TaskState == TaskState.Effect && t.ReadingCategory==ReadingCategory.Visit
&& t.ReadingTaskState == ReadingTaskState.HaveSigned && t.VisitTaskNum <= task.VisitTaskNum && t.Id!= task.Id && t.ReReadingApplyState == ReReadingApplyState.HaveApplyed ))
{
return ResponseOutput.NotOk("当前为有序阅片,之前有访视,或其他IR的本次访视已申请重阅还未处理不允许申请");
Expression<Func<VisitTask, bool>> filterExpression = t => t.TrialId == task.TrialId && t.SubjectId == task.SubjectId && t.TaskState == TaskState.Effect
&& t.ReadingTaskState == ReadingTaskState.HaveSigned && t.DoctorUserId == task.DoctorUserId && t.IsAnalysisCreate == false && t.VisitTaskNum > task.VisitTaskNum;
if (task.ReadingCategory == ReadingCategory.Judge && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Global)))
{
throw new BusinessValidationFailedException("只允许申请该受试者阅片人最后一次完成全局任务重阅");
}
if (task.ReadingCategory == ReadingCategory.Oncology && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Oncology)))
{
throw new BusinessValidationFailedException("只允许申请该受试者阅片人最后一次完成肿瘤学任务重阅");
}
if (task.ReadingCategory == ReadingCategory.Judge && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Judge)))
{
throw new BusinessValidationFailedException("只允许申请该受试者阅片人最后一次完成裁判的任务重阅");
}
}
else
{
if ((task.ReadingCategory != ReadingCategory.Visit && task.ReadingCategory != ReadingCategory.Global))
{
throw new BusinessValidationFailedException("无序阅片仅仅允许IR 申请 全局和访视类型类别的任务进行重阅");
}
}
}
if (task.ReadingCategory == ReadingCategory.Judge && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Global)))
{
throw new BusinessValidationFailedException("只允许申请该受试者阅片人最后一次完成全局任务重阅");
}
if (task.ReadingCategory == ReadingCategory.Oncology && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Oncology)))
{
throw new BusinessValidationFailedException("只允许申请该受试者阅片人最后一次完成肿瘤学任务重阅");
}
if (task.ReadingCategory == ReadingCategory.Judge && await _visitTaskRepository.AnyAsync(filterExpression.And(t => t.ReadingCategory == ReadingCategory.Judge)))
{
throw new BusinessValidationFailedException("只允许申请该受试者阅片人最后一次完成裁判的任务重阅");
}
task.ReReadingApplyState = ReReadingApplyState.HaveApplyed;
@ -1106,7 +1134,7 @@ namespace IRaCIS.Core.Application.Service
visitTaskReReadingAppply.RequestReReadingResultEnum = agreeReReadingCommand.RequestReReadingResultEnum;
visitTaskReReadingAppply.RequestReReadingRejectReason = agreeReReadingCommand.RequestReReadingRejectReason;
if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree)
{
@ -1920,7 +1948,7 @@ namespace IRaCIS.Core.Application.Service
}
var list = await _visitTaskRepository.Where(filterExpression).OrderBy(t=>t.VisitTaskNum).ProjectTo<VisitTaskSimpleView>(_mapper.ConfigurationProvider).ToListAsync();
var list = await _visitTaskRepository.Where(filterExpression).OrderBy(t => t.VisitTaskNum).ProjectTo<VisitTaskSimpleView>(_mapper.ConfigurationProvider).ToListAsync();
return list;