修改退回重阅
parent
bd2aed9637
commit
50db94962e
|
@ -194,95 +194,102 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 重阅/退回的时候,需要将取消分配的访视类型的 任务重新分配
|
#region 后续访视 未分配的进行再次分配,重置的或者失效的 需要重新生成新的任务 (PM 有序退回 或者PM 有序 申请重阅)
|
||||||
|
|
||||||
|
//存在退回访视1 又退回基线 这种情况 生成任务 考虑基线先一致性核查通过,但是访视1还未通过时 生成任务
|
||||||
|
var followVisitTaskList = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.VisitTaskNum > subjectVisit.VisitNum && t.SourceSubjectVisit.CheckState==CheckStateEnum.CVPassed && t.ReadingCategory == ReadingCategory.Visit, true).ToListAsync();
|
||||||
|
|
||||||
|
var followVisitGroup = followVisitTaskList.GroupBy(t => t.VisitTaskNum);
|
||||||
|
|
||||||
|
//每个访视去判断 是分配还是生成
|
||||||
|
|
||||||
|
|
||||||
//后续未分配的访视 PM 有序退回 或者PM 有序 申请重阅
|
foreach (var visitGroup in followVisitGroup)
|
||||||
|
|
||||||
var notAllocateList = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.TaskState == TaskState.Effect && t.DoctorUserId == null
|
|
||||||
&& t.VisitTaskNum >= subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit, true).ToListAsync();
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var notAllocate in notAllocateList)
|
|
||||||
{
|
{
|
||||||
notAllocate.TaskAllocationState = TaskAllocationState.Allocated;
|
|
||||||
notAllocate.AllocateTime = DateTime.Now;
|
|
||||||
|
|
||||||
notAllocate.DoctorUserId = notAllocate.ArmEnum == Arm.DoubleReadingArm1 ? task1.DoctorUserId : task2.DoctorUserId;
|
var arm1 = visitGroup.FirstOrDefault(t => t.TaskState == TaskState.Effect && t.DoctorUserId == null && t.ArmEnum == Arm.DoubleReadingArm1);
|
||||||
}
|
if (arm1 != null)
|
||||||
|
|
||||||
//先回退访视1 再回退基线 这个时候 如果访视1都未做 这个时候是不需要生成任务的
|
|
||||||
|
|
||||||
//后续 废弃的任务 重阅重置,或者失效的 访视 需要重新生成
|
|
||||||
|
|
||||||
var needAddTaskList = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && (t.TaskState == TaskState.Adbandon || t.TaskState == TaskState.HaveReturned) && t.VisitTaskNum > subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit).ToListAsync();
|
|
||||||
|
|
||||||
//可能存在多次申请重阅 所以这里会有重复
|
|
||||||
|
|
||||||
foreach (var group in needAddTaskList.GroupBy(t => new { t.SubjectId, t.VisitTaskNum }))
|
|
||||||
{
|
|
||||||
var latestTask = group.OrderByDescending(t=>t.CreateTime).First();
|
|
||||||
|
|
||||||
var taskOne = await _visitTaskRepository.AddAsync(new VisitTask()
|
|
||||||
{
|
{
|
||||||
TrialId = trialId,
|
arm1.TaskAllocationState = TaskAllocationState.Allocated;
|
||||||
SubjectId = subjectVisit.SubjectId,
|
arm1.AllocateTime = DateTime.Now;
|
||||||
IsUrgent = subjectVisit.IsUrgent,
|
arm1.DoctorUserId = task1.DoctorUserId;
|
||||||
|
}
|
||||||
VisitTaskNum = subjectVisit.VisitNum,
|
else
|
||||||
ArmEnum = Arm.DoubleReadingArm1,//特殊
|
|
||||||
Code = currentMaxCodeInt + 1,
|
|
||||||
SourceSubjectVisitId = subjectVisit.Id,
|
|
||||||
TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)),
|
|
||||||
ReadingCategory = ReadingCategory.Visit,
|
|
||||||
|
|
||||||
TaskBlindName = latestTask.TaskBlindName,
|
|
||||||
TaskName = latestTask.TaskName,
|
|
||||||
|
|
||||||
BlindSubjectCode =latestTask.BlindSubjectCode,
|
|
||||||
BlindTrialSiteCode=latestTask.BlindTrialSiteCode,
|
|
||||||
IsAnalysisCreate= latestTask.IsAnalysisCreate,
|
|
||||||
IsSelfAnalysis= latestTask.IsSelfAnalysis,
|
|
||||||
TaskAllocationState=TaskAllocationState.Allocated,
|
|
||||||
AllocateTime=DateTime.Now,
|
|
||||||
DoctorUserId= task1.DoctorUserId
|
|
||||||
});
|
|
||||||
|
|
||||||
var taskTwo = await _visitTaskRepository.AddAsync(new VisitTask()
|
|
||||||
{
|
{
|
||||||
TrialId = trialId,
|
var latestTask = visitGroup.Where(t => t.ArmEnum == Arm.DoubleReadingArm1).OrderByDescending(t => t.CreateTime).First();
|
||||||
SubjectId = subjectVisit.SubjectId,
|
|
||||||
IsUrgent = subjectVisit.IsUrgent,
|
|
||||||
|
|
||||||
VisitTaskNum = subjectVisit.VisitNum,
|
|
||||||
//CheckPassedTime = subjectVisit.CheckPassedTime,
|
|
||||||
ArmEnum = Arm.DoubleReadingArm2,//特殊
|
|
||||||
Code = currentMaxCodeInt + 2,
|
|
||||||
SourceSubjectVisitId = subjectVisit.Id,
|
|
||||||
TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 2, nameof(VisitTask)),
|
|
||||||
ReadingCategory = ReadingCategory.Visit,
|
|
||||||
|
|
||||||
|
var taskOne = await _visitTaskRepository.AddAsync(new VisitTask()
|
||||||
|
{
|
||||||
|
TrialId = trialId,
|
||||||
|
SubjectId = subjectVisit.SubjectId,
|
||||||
|
IsUrgent = subjectVisit.IsUrgent,
|
||||||
|
ArmEnum = Arm.DoubleReadingArm1,//特殊
|
||||||
|
Code = currentMaxCodeInt + 1,
|
||||||
|
SourceSubjectVisitId = subjectVisit.Id,
|
||||||
|
TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)),
|
||||||
|
ReadingCategory = ReadingCategory.Visit,
|
||||||
|
|
||||||
TaskBlindName = latestTask.TaskBlindName,
|
VisitTaskNum = latestTask.VisitTaskNum,
|
||||||
TaskName = latestTask.TaskName,
|
TaskBlindName = latestTask.TaskBlindName,
|
||||||
|
TaskName = latestTask.TaskName,
|
||||||
|
|
||||||
BlindSubjectCode = latestTask.BlindSubjectCode,
|
BlindSubjectCode = latestTask.BlindSubjectCode,
|
||||||
BlindTrialSiteCode = latestTask.BlindTrialSiteCode,
|
BlindTrialSiteCode = latestTask.BlindTrialSiteCode,
|
||||||
IsAnalysisCreate = latestTask.IsAnalysisCreate,
|
IsAnalysisCreate = latestTask.IsAnalysisCreate,
|
||||||
IsSelfAnalysis = latestTask.IsSelfAnalysis,
|
IsSelfAnalysis = latestTask.IsSelfAnalysis,
|
||||||
TaskAllocationState = TaskAllocationState.Allocated,
|
TaskAllocationState = TaskAllocationState.Allocated,
|
||||||
AllocateTime = DateTime.Now,
|
AllocateTime = DateTime.Now,
|
||||||
DoctorUserId = task2.DoctorUserId
|
DoctorUserId = task1.DoctorUserId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
currentMaxCodeInt = currentMaxCodeInt + 1;
|
||||||
|
|
||||||
|
_provider.Set<int>($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30));
|
||||||
|
}
|
||||||
|
|
||||||
currentMaxCodeInt = currentMaxCodeInt + 2;
|
var arm2 = visitGroup.FirstOrDefault(t => t.TaskState == TaskState.Effect && t.DoctorUserId == null && t.ArmEnum == Arm.DoubleReadingArm2);
|
||||||
|
if (arm2 != null)
|
||||||
|
{
|
||||||
|
arm2.TaskAllocationState = TaskAllocationState.Allocated;
|
||||||
|
arm2.AllocateTime = DateTime.Now;
|
||||||
|
arm2.DoctorUserId = task2.DoctorUserId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var latestTask = visitGroup.Where(t => t.ArmEnum == Arm.DoubleReadingArm2).OrderByDescending(t => t.CreateTime).First();
|
||||||
|
|
||||||
_provider.Set<int>($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30));
|
var taskTwo = await _visitTaskRepository.AddAsync(new VisitTask()
|
||||||
|
{
|
||||||
|
TrialId = trialId,
|
||||||
|
SubjectId = subjectVisit.SubjectId,
|
||||||
|
IsUrgent = subjectVisit.IsUrgent,
|
||||||
|
|
||||||
|
//CheckPassedTime = subjectVisit.CheckPassedTime,
|
||||||
|
ArmEnum = Arm.DoubleReadingArm2,//特殊
|
||||||
|
Code = currentMaxCodeInt + 1,
|
||||||
|
SourceSubjectVisitId = subjectVisit.Id,
|
||||||
|
TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)),
|
||||||
|
ReadingCategory = ReadingCategory.Visit,
|
||||||
|
|
||||||
|
VisitTaskNum = latestTask.VisitTaskNum,
|
||||||
|
TaskBlindName = latestTask.TaskBlindName,
|
||||||
|
TaskName = latestTask.TaskName,
|
||||||
|
|
||||||
|
BlindSubjectCode = latestTask.BlindSubjectCode,
|
||||||
|
BlindTrialSiteCode = latestTask.BlindTrialSiteCode,
|
||||||
|
IsAnalysisCreate = latestTask.IsAnalysisCreate,
|
||||||
|
IsSelfAnalysis = latestTask.IsSelfAnalysis,
|
||||||
|
TaskAllocationState = TaskAllocationState.Allocated,
|
||||||
|
AllocateTime = DateTime.Now,
|
||||||
|
DoctorUserId = task2.DoctorUserId
|
||||||
|
});
|
||||||
|
|
||||||
|
currentMaxCodeInt = currentMaxCodeInt + 1;
|
||||||
|
|
||||||
|
_provider.Set<int>($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -389,7 +396,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
notAllocate.TaskAllocationState = TaskAllocationState.Allocated;
|
notAllocate.TaskAllocationState = TaskAllocationState.Allocated;
|
||||||
notAllocate.AllocateTime = DateTime.Now;
|
notAllocate.AllocateTime = DateTime.Now;
|
||||||
|
|
||||||
notAllocate.DoctorUserId = singleTask.DoctorUserId;
|
notAllocate.DoctorUserId = singleTask.DoctorUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
//后续 废弃的任务 重阅重置,或者失效的 访视 需要重新生成
|
//后续 废弃的任务 重阅重置,或者失效的 访视 需要重新生成
|
||||||
|
@ -426,7 +433,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
DoctorUserId = singleTask.DoctorUserId
|
DoctorUserId = singleTask.DoctorUserId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
currentMaxCodeInt = currentMaxCodeInt + 1;
|
currentMaxCodeInt = currentMaxCodeInt + 1;
|
||||||
|
|
||||||
_provider.Set<int>($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30));
|
_provider.Set<int>($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30));
|
||||||
|
@ -627,7 +634,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
TaskAllocationState = subjectUser == null ? TaskAllocationState.NotAllocate : TaskAllocationState.Allocated,
|
TaskAllocationState = subjectUser == null ? TaskAllocationState.NotAllocate : TaskAllocationState.Allocated,
|
||||||
AllocateTime = subjectUser == null ? null : DateTime.Now,
|
AllocateTime = subjectUser == null ? null : DateTime.Now,
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
await _visitTaskRepository.AddAsync(visitTask);
|
await _visitTaskRepository.AddAsync(visitTask);
|
||||||
currentMaxCodeInt = currentMaxCodeInt + 1;
|
currentMaxCodeInt = currentMaxCodeInt + 1;
|
||||||
|
|
Loading…
Reference in New Issue