组件一致性分析筛选条件修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
4b15bcdc55
commit
67819fc85d
|
@ -570,7 +570,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
var subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId &&
|
var subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId &&
|
||||||
t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count() >= filterObj.PlanVisitCount)
|
t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count() >= filterObj.PlanVisitCount)
|
||||||
.WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter)
|
.WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter)
|
||||||
.Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).Any(t => t.ReadingCategory == ReadingCategory.Global))
|
.Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).Any(t => t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum>filterObj.PlanVisitCount-1))
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@ -654,13 +654,11 @@ namespace IRaCIS.Core.Application.Service
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<IQueryable<DoctorGroupConsistentSubjectView>> GetGroupConsistentQueryAsync(TaskConsistentRule filterObj, List<Guid>? subejctIdList = null)
|
private async Task<IQueryable<DoctorGroupConsistentSubjectView>> GetGroupConsistentQueryAsync(TaskConsistentRule filterObj, List<Guid>? subejctIdList = null)
|
||||||
{
|
{
|
||||||
|
//单重阅片没有组件一致性
|
||||||
|
|
||||||
var trialId = filterObj.TrialId;
|
var trialId = filterObj.TrialId;
|
||||||
var trialReadingCriterionId = filterObj.TrialReadingCriterionId;
|
var trialReadingCriterionId = filterObj.TrialReadingCriterionId;
|
||||||
|
|
||||||
//var trialConfig = (await _repository.Where<Trial>(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.ReadingType, t.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Expression<Func<VisitTask, bool>> comonTaskFilter = u => u.TrialId == trialId && u.IsAnalysisCreate == false && u.TaskState == TaskState.Effect && u.ReadingTaskState == ReadingTaskState.HaveSigned && u.TrialReadingCriterionId == trialReadingCriterionId
|
Expression<Func<VisitTask, bool>> comonTaskFilter = u => u.TrialId == trialId && u.IsAnalysisCreate == false && u.TaskState == TaskState.Effect && u.ReadingTaskState == ReadingTaskState.HaveSigned && u.TrialReadingCriterionId == trialReadingCriterionId
|
||||||
&& (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject);
|
&& (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject);
|
||||||
|
@ -674,28 +672,16 @@ namespace IRaCIS.Core.Application.Service
|
||||||
Expression<Func<VisitTask, bool>> visitTaskFilter = comonTaskFilter.And(t => t.ReadingCategory == ReadingCategory.Visit);
|
Expression<Func<VisitTask, bool>> visitTaskFilter = comonTaskFilter.And(t => t.ReadingCategory == ReadingCategory.Visit);
|
||||||
|
|
||||||
|
|
||||||
////所选访视数量 的访视 其中必有一个访视后有全局任务
|
|
||||||
//if (filterObj.IsHaveReadingPeriod == true)
|
|
||||||
//{
|
|
||||||
// //visitTaskFilter = visitTaskFilter.And(t => t.Subject.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Any(u => u.VisitTaskNum == t.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && u.ReadingCategory == ReadingCategory.Global));
|
|
||||||
|
|
||||||
// //这里的过滤条件 不能用 where(comonTaskFilter) 会报错,奇怪的问题 只能重新写一遍
|
|
||||||
// visitTaskFilter = visitTaskFilter.And(c => c.Subject.SubjectVisitTaskList.Any(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && t.ReadingCategory == ReadingCategory.Global && t.IsAnalysisCreate == false && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned &&
|
|
||||||
// t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now && (t.ReReadingApplyState == ReReadingApplyState.Default || t.ReReadingApplyState == ReReadingApplyState.Reject)));
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
IQueryable<Subject> subjectQuery = default;
|
IQueryable<Subject> subjectQuery = default;
|
||||||
|
|
||||||
//单重阅片没有组件一致性
|
|
||||||
|
|
||||||
|
//双重阅片,并且都阅片完成
|
||||||
subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId &&
|
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(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(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))
|
||||||
|
.WhereIf(filterObj.IsHaveReadingPeriod == true, u => u.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum> filterObj.PlanVisitCount - 1).Select(t => t.DoctorUserId).Distinct().Count() == 2)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@ -809,9 +795,10 @@ namespace IRaCIS.Core.Application.Service
|
||||||
.Where(visitTaskFilter).Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SignTime!.Value.AddDays(taskConsistentRule.IntervalWeeks * 7) < DateTime.Now && t.DoctorUserId == user.Id)
|
.Where(visitTaskFilter).Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SignTime!.Value.AddDays(taskConsistentRule.IntervalWeeks * 7) < DateTime.Now && t.DoctorUserId == user.Id)
|
||||||
.Count() >= taskConsistentRule.PlanVisitCount :
|
.Count() >= taskConsistentRule.PlanVisitCount :
|
||||||
|
|
||||||
|
//全局要>计划访视数量后面
|
||||||
t.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter)
|
t.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter)
|
||||||
.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SignTime!.Value.AddDays(taskConsistentRule.IntervalWeeks * 7) < DateTime.Now && t.DoctorUserId == user.Id)
|
.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SignTime!.Value.AddDays(taskConsistentRule.IntervalWeeks * 7) < DateTime.Now && t.DoctorUserId == user.Id)
|
||||||
.Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).Any(t => t.ReadingCategory == ReadingCategory.Global)
|
.Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).Any(t => t.ReadingCategory == ReadingCategory.Global && t.VisitTaskNum>taskConsistentRule.PlanVisitCount-1)
|
||||||
&&
|
&&
|
||||||
t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter)
|
t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter)
|
||||||
.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SignTime!.Value.AddDays(taskConsistentRule.IntervalWeeks * 7) < DateTime.Now && t.DoctorUserId == user.Id)
|
.Where(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId && t.SignTime!.Value.AddDays(taskConsistentRule.IntervalWeeks * 7) < DateTime.Now && t.DoctorUserId == user.Id)
|
||||||
|
@ -983,35 +970,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 随机算法,选择指定数量的 subject
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="matchSubjectIdList"></param>
|
|
||||||
/// <param name="countToSelect"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public List<Guid> GetRandomSubjectIdList(List<Guid> matchSubjectIdList, int countToSelect)
|
|
||||||
{
|
|
||||||
|
|
||||||
// 使用 Fisher-Yates 随机置换算法来选择指定数量的 GUID
|
|
||||||
Random random = new Random();
|
|
||||||
|
|
||||||
for (int i = 0; i < countToSelect; i++)
|
|
||||||
{
|
|
||||||
// 生成一个随机索引
|
|
||||||
int randomIndex = random.Next(i, matchSubjectIdList.Count);
|
|
||||||
|
|
||||||
// 将选中的元素与当前元素交换位置
|
|
||||||
Guid temp = matchSubjectIdList[randomIndex];
|
|
||||||
matchSubjectIdList[randomIndex] = matchSubjectIdList[i];
|
|
||||||
matchSubjectIdList[i] = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
return matchSubjectIdList.Take(countToSelect).ToList();
|
|
||||||
|
|
||||||
// 使用洗牌算法来随机选择指定数量的GUID
|
|
||||||
//Random random = new Random();
|
|
||||||
//return matchSubjectIdList.OrderBy(g => random.Next()).Take(countToSelect).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue