修改任务分配验证
parent
1809869dbf
commit
e5a4eaa7b8
|
@ -108,10 +108,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
#region 分配
|
||||
if (isAssignSubjectToDoctor)
|
||||
{
|
||||
if (_taskAllocationRuleRepository.Where(t => t.TrialId == subjectVisit.TrialId && t.IsEnable).Count() < 2)
|
||||
{
|
||||
throw new BusinessValidationFailedException("能参与读片的医生数量必须大于2,自动分配任务中止");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (trialConfig.TaskAllocateObjEnum == TaskAllocateObj.Subject)
|
||||
|
@ -119,24 +116,23 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
if (trialConfig.IsFollowVisitAutoAssign)
|
||||
{
|
||||
var allocateSubjectArmList = _visitTaskRepository.Where(t => t.SubjectId == subjectVisit.SubjectId && t.TrialId == subjectVisit.TrialId && t.DoctorUserId != null).Select(t => new { t.DoctorUserId, t.ArmEnum }).Distinct().ToList();
|
||||
|
||||
|
||||
|
||||
var defaultState = trialConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskState.InitAllocated : TaskState.Allocated;
|
||||
|
||||
|
||||
task1.TaskState = defaultState;
|
||||
task2.TaskState = defaultState;
|
||||
|
||||
|
||||
#region 验证历史任务
|
||||
|
||||
var allocateSubjectArmList = _visitTaskRepository.Where(t => t.SubjectId == subjectVisit.SubjectId && t.TrialId == subjectVisit.TrialId && t.DoctorUserId != null).Select(t => new { t.DoctorUserId, t.ArmEnum }).Distinct().ToList();
|
||||
|
||||
|
||||
//不是初次分配 直接分配给Subject 之前的医生
|
||||
if (allocateSubjectArmList.Count != 0)
|
||||
{
|
||||
if (_taskAllocationRuleRepository.Where(t => t.TrialId == subjectVisit.TrialId && t.IsEnable).Count() < 2)
|
||||
{
|
||||
throw new BusinessValidationFailedException("能参与读片的医生数量必须大于2,自动分配任务中止");
|
||||
}
|
||||
|
||||
if (allocateSubjectArmList.GroupBy(t => t.DoctorUserId).Any(g => g.Count() == 2))
|
||||
{
|
||||
|
@ -149,14 +145,25 @@ namespace IRaCIS.Core.Application.Service
|
|||
throw new BusinessValidationFailedException("请确认是否改了配置,或者手动分配时,只分配了一个Arm ");
|
||||
}
|
||||
|
||||
//配置了医生
|
||||
if (assignConfigList.Count > 0)
|
||||
{
|
||||
var defaultState = trialConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskState.InitAllocated : TaskState.Allocated;
|
||||
|
||||
|
||||
task1.TaskState = defaultState;
|
||||
task2.TaskState = defaultState;
|
||||
|
||||
//分配给对应Arm的人
|
||||
task1.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 1).DoctorUserId;
|
||||
task2.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 2).DoctorUserId;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//分配给对应Arm的人
|
||||
task1.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 1).DoctorUserId;
|
||||
task2.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 2).DoctorUserId;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//找到配置规则表 进行分配
|
||||
|
@ -193,10 +200,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
else if (trialConfig.ReadingType == ReadingMethod.Single)
|
||||
{
|
||||
if (_taskAllocationRuleRepository.Where(t => t.TrialId == subjectVisit.TrialId && t.IsEnable).Count() < 2)
|
||||
{
|
||||
throw new BusinessValidationFailedException("能参与读片的医生数量必须大于2,自动分配任务中止");
|
||||
}
|
||||
|
||||
|
||||
var singleTask = await _visitTaskRepository.AddAsync(new VisitTask()
|
||||
{
|
||||
|
@ -229,10 +233,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
if (trialConfig.IsFollowVisitAutoAssign)
|
||||
{
|
||||
var defaultState = trialConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskState.InitAllocated : TaskState.Allocated;
|
||||
|
||||
|
||||
singleTask.TaskState = defaultState;
|
||||
|
||||
|
||||
//该Subject 之前是否有已分配的 如果改变配置 可能会出现 一个Subject 分配的同一个医生 有的在Arm1 有的在Arm2
|
||||
var allocateSubjectArmList = _visitTaskRepository.Where(t => t.SubjectId == subjectVisit.SubjectId && t.TrialId == subjectVisit.TrialId && t.DoctorUserId != null).Select(t => new { t.DoctorUserId, t.ArmEnum }).Distinct().ToList();
|
||||
|
@ -240,9 +241,23 @@ namespace IRaCIS.Core.Application.Service
|
|||
//不是初次分配
|
||||
if (allocateSubjectArmList.Count != 0)
|
||||
{
|
||||
singleTask.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 0).DoctorUserId;
|
||||
if (_taskAllocationRuleRepository.Where(t => t.TrialId == subjectVisit.TrialId && t.IsEnable).Count() < 2)
|
||||
{
|
||||
throw new BusinessValidationFailedException("能参与读片的医生数量必须大于2,自动分配任务中止");
|
||||
}
|
||||
|
||||
//配置了医生
|
||||
if (assignConfigList.Count > 0)
|
||||
{
|
||||
var defaultState = trialConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskState.InitAllocated : TaskState.Allocated;
|
||||
|
||||
singleTask.TaskState = defaultState;
|
||||
|
||||
singleTask.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 0).DoctorUserId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue