|
|
|
@@ -60,13 +60,16 @@ namespace IRaCIS.Core.Application.Service
|
|
|
|
|
.WhereIf(queryVisitTask.ReadingCategory != null, t => t.ReadingCategory == queryVisitTask.ReadingCategory)
|
|
|
|
|
.WhereIf(queryVisitTask.ReadingTaskState != null, t => t.ReadingTaskState == queryVisitTask.ReadingTaskState)
|
|
|
|
|
.WhereIf(queryVisitTask.TaskAllocationState != null, t => t.TaskAllocationState == queryVisitTask.TaskAllocationState)
|
|
|
|
|
.WhereIf(queryVisitTask.IsSelfAnalysis != null, t => t.IsSelfAnalysis == queryVisitTask.IsSelfAnalysis)
|
|
|
|
|
.WhereIf(queryVisitTask.ArmEnum != null, t => t.ArmEnum == queryVisitTask.ArmEnum)
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(queryVisitTask.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(queryVisitTask.TrialSiteCode) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(queryVisitTask.TrialSiteCode) && t.IsAnalysisCreate == false))
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.TaskName.Contains(queryVisitTask.TaskName) || t.TaskBlindName.Contains(queryVisitTask.TaskName))
|
|
|
|
|
.WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.Subject.Code.Contains(queryVisitTask.SubjectCode))
|
|
|
|
|
.WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.AllocateTime > queryVisitTask.BeginAllocateDate)
|
|
|
|
|
.WhereIf(queryVisitTask.EndAllocateDate != null, t => t.AllocateTime < queryVisitTask.EndAllocateDate.Value.AddDays(1))
|
|
|
|
|
.ProjectTo<AnalysisTaskView>(_mapper.ConfigurationProvider);
|
|
|
|
|
|
|
|
|
|
var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId) , nameof(VisitTask.VisitTaskNum) };
|
|
|
|
|
var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId), nameof(VisitTask.VisitTaskNum) };
|
|
|
|
|
|
|
|
|
|
var pageList = await visitTaskQueryable.ToPagedListAsync(queryVisitTask.PageIndex, queryVisitTask.PageSize, queryVisitTask.SortField, queryVisitTask.Asc, string.IsNullOrWhiteSpace(queryVisitTask.SortField), defalutSortArray);
|
|
|
|
|
|
|
|
|
@@ -147,12 +150,30 @@ namespace IRaCIS.Core.Application.Service
|
|
|
|
|
//最后一个访视添加全局
|
|
|
|
|
if (filterObj.IsGenerateGlobalTask)
|
|
|
|
|
{
|
|
|
|
|
var globalTask = (subject.VisitTaskList.Take(filterObj.PlanVisitCount).Last()).Clone();
|
|
|
|
|
globalTask.TaskName = (int)globalTask.VisitTaskNum + "Global";
|
|
|
|
|
globalTask.TaskBlindName = (int)globalTask.VisitTaskNum + "Global";
|
|
|
|
|
globalTask.ReadingCategory = ReadingCategory.Global;
|
|
|
|
|
globalTask.VisitTaskNum += ReadingCommon.TaskNumDic[ReadingCategory.Global];
|
|
|
|
|
subject.VisitTaskList.Add(globalTask);
|
|
|
|
|
var lastTask = (subject.VisitTaskList.Take(filterObj.PlanVisitCount).Last()).Clone();
|
|
|
|
|
|
|
|
|
|
var existGlobal = _visitTaskRepository.Where(t => t.SubjectId == lastTask.SubjectId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum == lastTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).ProjectTo<VisitTaskSimpleDTO>(_mapper.ConfigurationProvider).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (existGlobal == null)
|
|
|
|
|
{
|
|
|
|
|
existGlobal = new VisitTaskSimpleDTO()
|
|
|
|
|
{
|
|
|
|
|
SubjectId = lastTask.SubjectId,
|
|
|
|
|
TrialId = lastTask.TrialId,
|
|
|
|
|
BlindSubjectCode = lastTask.BlindSubjectCode,
|
|
|
|
|
BlindTrialSiteCode = lastTask.BlindTrialSiteCode,
|
|
|
|
|
ArmEnum = lastTask.ArmEnum,
|
|
|
|
|
ReadingCategory = ReadingCategory.Global
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
existGlobal.TaskName = (int)existGlobal.VisitTaskNum + "Global";
|
|
|
|
|
existGlobal.TaskBlindName = (int)existGlobal.VisitTaskNum + "Global";
|
|
|
|
|
|
|
|
|
|
subject.VisitTaskList.Add(existGlobal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -217,10 +238,10 @@ namespace IRaCIS.Core.Application.Service
|
|
|
|
|
//单重阅片没有组件一致性
|
|
|
|
|
|
|
|
|
|
subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId &&
|
|
|
|
|
t.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).Select(t => t.DoctorUserId).Distinct().Count() == 2 &&
|
|
|
|
|
t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count() >= filterObj.PlanVisitCount
|
|
|
|
|
t.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).Select(t => t.DoctorUserId).Distinct().Count() == 2 &&
|
|
|
|
|
t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count() >= filterObj.PlanVisitCount
|
|
|
|
|
)
|
|
|
|
|
.WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).OrderBy(t => t.VisitTaskNum).Take(filterObj.PlanVisitCount*2 + 2).Any(t=>t.ReadingCategory == ReadingCategory.Global))
|
|
|
|
|
.WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).OrderBy(t => t.VisitTaskNum).Take(filterObj.PlanVisitCount * 2 + 2).Any(t => t.ReadingCategory == ReadingCategory.Global))
|
|
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
@@ -354,7 +375,9 @@ namespace IRaCIS.Core.Application.Service
|
|
|
|
|
VisitTaskNum = task.VisitTaskNum,
|
|
|
|
|
TrialId = task.TrialId,
|
|
|
|
|
DoctorUserId = needAddDoctorUserId,
|
|
|
|
|
ArmEnum = Arm.GroupConsistentArm
|
|
|
|
|
ArmEnum = Arm.GroupConsistentArm,
|
|
|
|
|
SouceReadModuleId = task.SouceReadModuleId,
|
|
|
|
|
SourceSubjectVisitId=task.SourceSubjectVisitId,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@@ -363,13 +386,28 @@ namespace IRaCIS.Core.Application.Service
|
|
|
|
|
|
|
|
|
|
if (filterObj.IsGenerateGlobalTask)
|
|
|
|
|
{
|
|
|
|
|
var globalTask = (subjectAddTaskList.Take(filterObj.PlanVisitCount).Last()).Clone();
|
|
|
|
|
globalTask.TaskName = (int)globalTask.VisitTaskNum + "Global";
|
|
|
|
|
globalTask.TaskBlindName = (int)globalTask.VisitTaskNum + "Global";
|
|
|
|
|
globalTask.ReadingCategory = ReadingCategory.Global;
|
|
|
|
|
globalTask.VisitTaskNum += ReadingCommon.TaskNumDic[ReadingCategory.Global];
|
|
|
|
|
globalTask.DoctorUserId =needAddDoctorUserId;
|
|
|
|
|
subjectAddTaskList.Add(globalTask);
|
|
|
|
|
var lastTask = (subjectAddTaskList.Take(filterObj.PlanVisitCount).Last()).Clone();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var existGlobal = _visitTaskRepository.Where(t => t.SubjectId == lastTask.SubjectId && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum == lastTask.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).ProjectTo<VisitTaskGroupSimpleDTO>(_mapper.ConfigurationProvider).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (existGlobal == null)
|
|
|
|
|
{
|
|
|
|
|
existGlobal = new VisitTaskSimpleDTO()
|
|
|
|
|
{
|
|
|
|
|
SubjectId = lastTask.SubjectId,
|
|
|
|
|
TrialId = lastTask.TrialId,
|
|
|
|
|
ArmEnum = lastTask.ArmEnum,
|
|
|
|
|
ReadingCategory = ReadingCategory.Global
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
existGlobal.TaskName = (int)existGlobal.VisitTaskNum + "Global";
|
|
|
|
|
existGlobal.TaskBlindName = (int)existGlobal.VisitTaskNum + "Global";
|
|
|
|
|
existGlobal.DoctorUserId = needAddDoctorUserId;
|
|
|
|
|
|
|
|
|
|
subjectAddTaskList.Add(existGlobal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@@ -412,7 +450,7 @@ namespace IRaCIS.Core.Application.Service
|
|
|
|
|
#region Subejct 维度
|
|
|
|
|
|
|
|
|
|
Expression<Func<VisitTask, bool>> comonTaskFilter = u => u.TrialId == trialId && u.IsAnalysisCreate == false && u.TaskState == TaskState.Effect && u.ReadingTaskState == ReadingTaskState.HaveSigned &&
|
|
|
|
|
u.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now && (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject) && u.DoctorUserId==doctorUserId;
|
|
|
|
|
u.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now && (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject) && u.DoctorUserId == doctorUserId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -435,9 +473,9 @@ namespace IRaCIS.Core.Application.Service
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId &&
|
|
|
|
|
t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count() >= filterObj.PlanVisitCount)
|
|
|
|
|
.WhereIf(filterObj.IsHaveReadingPeriod == true,u=>u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t=>t.ReadingCategory==ReadingCategory.Visit ||t.ReadingCategory==ReadingCategory.Global).OrderBy(t=>t.VisitTaskNum).Take(filterObj.PlanVisitCount+1).Any(t=>t.ReadingCategory==ReadingCategory.Global))
|
|
|
|
|
var subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId &&
|
|
|
|
|
t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count() >= filterObj.PlanVisitCount)
|
|
|
|
|
.WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).OrderBy(t => t.VisitTaskNum).Take(filterObj.PlanVisitCount + 1).Any(t => t.ReadingCategory == ReadingCategory.Global))
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -456,7 +494,7 @@ namespace IRaCIS.Core.Application.Service
|
|
|
|
|
|
|
|
|
|
ValidVisitCount = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count(),
|
|
|
|
|
|
|
|
|
|
VisitTaskList = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Select(c => new VisitTaskSimpleDTO()
|
|
|
|
|
VisitTaskList = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).OrderBy(t => t.VisitTaskNum).Select(c => new VisitTaskSimpleDTO()
|
|
|
|
|
{
|
|
|
|
|
Id = c.Id,
|
|
|
|
|
ReadingCategory = c.ReadingCategory,
|
|
|
|
@@ -469,8 +507,8 @@ namespace IRaCIS.Core.Application.Service
|
|
|
|
|
SubjectId = c.SubjectId,
|
|
|
|
|
VisitTaskNum = c.VisitTaskNum,
|
|
|
|
|
TrialId = c.TrialId,
|
|
|
|
|
SourceSubjectVisitId=c.SourceSubjectVisitId,
|
|
|
|
|
SouceReadModuleId=c.SouceReadModuleId,
|
|
|
|
|
SourceSubjectVisitId = c.SourceSubjectVisitId,
|
|
|
|
|
SouceReadModuleId = c.SouceReadModuleId,
|
|
|
|
|
|
|
|
|
|
//自身一致性才有意义
|
|
|
|
|
//IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.ConsistentAnalysisOriginalTaskId == c.Id),
|
|
|
|
@@ -492,7 +530,7 @@ namespace IRaCIS.Core.Application.Service
|
|
|
|
|
SouceReadModuleId = c.SouceReadModuleId,
|
|
|
|
|
}).ToList(),
|
|
|
|
|
|
|
|
|
|
}).OrderBy(t => t.VisitTaskNum).ToList()
|
|
|
|
|
}).ToList()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return query.OrderByDescending(t => t.IsHaveGeneratedTask);
|
|
|
|
|