diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 776e24769..629ccd743 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -65,6 +65,13 @@ 一致性分析配置表 + + + 设置一致性分析任务失效 + + + + 一致性分析列表 (自身 组内 最后勾选 产生的任务) @@ -210,11 +217,11 @@ - + 取消Subject 分配的医生 - + diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs index dbc44e0de..a6e6862ff 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs @@ -42,6 +42,24 @@ namespace IRaCIS.Core.Application.Service _enrollRepository = enrollRepository; } + /// + /// 设置一致性分析任务失效 + /// + /// + /// + [HttpPost] + public async Task SetAnalysisTaskInvalid(List taskIdList) + { + + + await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => taskIdList.Contains(t.Id), u => new VisitTask() { TaskState = TaskState.NotEffect }); + + await _visitTaskRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(); + + } + /// /// 一致性分析列表 (自身 组内 最后勾选 产生的任务) @@ -49,7 +67,7 @@ namespace IRaCIS.Core.Application.Service /// /// [HttpPost] - public async Task<(PageOutput,object?)> GetAnalysisTaskList(VisitTaskQuery queryVisitTask) + public async Task<(PageOutput, object?)> GetAnalysisTaskList(VisitTaskQuery queryVisitTask) { var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == queryVisitTask.TrialId) .Where(t => t.IsAnalysisCreate) @@ -165,8 +183,8 @@ namespace IRaCIS.Core.Application.Service TrialId = lastTask.TrialId, ArmEnum = lastTask.ArmEnum, ReadingCategory = ReadingCategory.Global, - TaskName= lastTask.VisitTaskNum + "Global", - TaskBlindName= lastTask.VisitTaskNum + "Global" + TaskName = lastTask.VisitTaskNum + "Global", + TaskBlindName = lastTask.VisitTaskNum + "Global" }; } @@ -174,7 +192,7 @@ namespace IRaCIS.Core.Application.Service existGlobal.BlindSubjectCode = lastTask.BlindSubjectCode; existGlobal.BlindTrialSiteCode = lastTask.BlindTrialSiteCode; - + subject.VisitTaskList.Add(existGlobal); } @@ -202,93 +220,6 @@ namespace IRaCIS.Core.Application.Service } - - private async Task> GetGroupConsistentQueryAsync(TaskConsistentRule filterObj, List? subejctIdList = null) - { - - var trialId = filterObj.TrialId; - var trialConfig = (await _repository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.ReadingType, t.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException(); - - - - Expression> comonTaskFilter = u => u.TrialId == trialId && u.IsAnalysisCreate == false && u.TaskState == TaskState.Effect && u.ReadingTaskState == ReadingTaskState.HaveSigned - && (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject); - - - if (subejctIdList != null && subejctIdList?.Count > 0) - { - comonTaskFilter = comonTaskFilter.And(t => subejctIdList.Contains(t.SubjectId)); - } - - Expression> 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 subjectQuery = default; - - //单重阅片没有组件一致性 - - 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 - ) - .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)) - - ; - - - - var query = subjectQuery.Select(t => new DoctorGroupConsistentSubjectView() - { - TrialId = t.TrialId, - SiteId = t.SiteId, - SubjectCode = t.Code, - TrialSiteCode = t.TrialSite.TrialSiteCode, - SubjectId = t.Id, - - - IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.IsSelfAnalysis == false), - - - ValidVisitCount = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count(), - - VisitTaskList = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter) - .Select(c => new VisitTaskGroupSimpleDTO() - { - ReadingCategory = c.ReadingCategory, - ReadingTaskState = c.ReadingTaskState, - TaskBlindName = c.TaskBlindName, - TaskName = c.TaskName, - TaskState = c.TaskState, - SubjectId = c.SubjectId, - VisitTaskNum = c.VisitTaskNum, - TrialId = c.TrialId, - DoctorUserId = c.DoctorUserId, - - SourceSubjectVisitId = c.SourceSubjectVisitId, - SouceReadModuleId = c.SouceReadModuleId, - - }).ToList() - - // - }); - - query = query.OrderByDescending(t => t.IsHaveGeneratedTask); - - return query; - } - /// /// 组间一致性分析 选择Subejct 列表 /// @@ -379,7 +310,7 @@ namespace IRaCIS.Core.Application.Service DoctorUserId = needAddDoctorUserId, ArmEnum = Arm.GroupConsistentArm, SouceReadModuleId = task.SouceReadModuleId, - SourceSubjectVisitId=task.SourceSubjectVisitId, + SourceSubjectVisitId = task.SourceSubjectVisitId, }); } @@ -399,17 +330,17 @@ namespace IRaCIS.Core.Application.Service existGlobal = new VisitTaskSimpleDTO() { SubjectId = lastTask.SubjectId, - TrialId = lastTask.TrialId, + TrialId = lastTask.TrialId, ReadingCategory = ReadingCategory.Global, - TaskBlindName= lastTask.VisitTaskNum + "Global", - TaskName= lastTask.VisitTaskNum+ "Global" + TaskBlindName = lastTask.VisitTaskNum + "Global", + TaskName = lastTask.VisitTaskNum + "Global" }; } existGlobal.ArmEnum = Arm.GroupConsistentArm; existGlobal.DoctorUserId = needAddDoctorUserId; - + subjectAddTaskList.Add(existGlobal); } @@ -543,6 +474,96 @@ namespace IRaCIS.Core.Application.Service + + private async Task> GetGroupConsistentQueryAsync(TaskConsistentRule filterObj, List? subejctIdList = null) + { + + var trialId = filterObj.TrialId; + var trialConfig = (await _repository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.ReadingType, t.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException(); + + + + Expression> comonTaskFilter = u => u.TrialId == trialId && u.IsAnalysisCreate == false && u.TaskState == TaskState.Effect && u.ReadingTaskState == ReadingTaskState.HaveSigned + && (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject); + + + if (subejctIdList != null && subejctIdList?.Count > 0) + { + comonTaskFilter = comonTaskFilter.And(t => subejctIdList.Contains(t.SubjectId)); + } + + Expression> 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 subjectQuery = default; + + //单重阅片没有组件一致性 + + 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 + ) + .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)) + + ; + + + + var query = subjectQuery.Select(t => new DoctorGroupConsistentSubjectView() + { + TrialId = t.TrialId, + SiteId = t.SiteId, + SubjectCode = t.Code, + TrialSiteCode = t.TrialSite.TrialSiteCode, + SubjectId = t.Id, + + + IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.IsSelfAnalysis == false), + + + ValidVisitCount = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count(), + + VisitTaskList = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter) + .Select(c => new VisitTaskGroupSimpleDTO() + { + ReadingCategory = c.ReadingCategory, + ReadingTaskState = c.ReadingTaskState, + TaskBlindName = c.TaskBlindName, + TaskName = c.TaskName, + TaskState = c.TaskState, + SubjectId = c.SubjectId, + VisitTaskNum = c.VisitTaskNum, + TrialId = c.TrialId, + DoctorUserId = c.DoctorUserId, + + SourceSubjectVisitId = c.SourceSubjectVisitId, + SouceReadModuleId = c.SouceReadModuleId, + + }).ToList() + + // + }); + + query = query.OrderByDescending(t => t.IsHaveGeneratedTask); + + return query; + } + + + + [HttpPost] public async Task GetConsistentRule(TaskConsistentRuleQuery inQuery) { @@ -612,68 +633,6 @@ namespace IRaCIS.Core.Application.Service - //public async Task BatchAddOrUpdateTaskConsistentRule(TaskConsistentRuleBatchAddOrEdit addOrEdit) - //{ - // var trialId = addOrEdit.TrialId; - - - - // if (addOrEdit.IsBatchAdd) - // { - // var query = from enroll in _repository.Where(t => t.TrialId == trialId) - // join user in _repository.Where() on enroll.DoctorId equals user.DoctorId - // join taskConsistentRule in _repository.Where(t => t.TrialId == trialId) on user.Id equals taskConsistentRule.AnalysisDoctorUserId into c - // from taskConsistentRule in c.DefaultIfEmpty() - // select new - // { - // TrialId = enroll.TrialId, - - // DoctorUserId = user.Id, - // //FullName = user.FullName, - // //UserCode = user.UserCode, - // //UserName = user.UserName, - - // IsHaveConfig = taskConsistentRule != null - // }; - - // var doctorList = await query.ToListAsync(); - - - // foreach (var doctor in doctorList) - // { - // if (!doctor.IsHaveConfig) - // { - // var verifyExp1 = new EntityVerifyExp() - // { - // VerifyExp = t => t.AnalysisDoctorUserId == doctor.DoctorUserId && t.TrialId == trialId, - // VerifyMsg = "已有该医生配置,不允许继续增加" - // }; - - // addOrEdit.AnalysisDoctorUserId = doctor.DoctorUserId; - // addOrEdit.Id = Guid.Empty; - - // var entity = await _taskConsistentRuleRepository.InsertOrUpdateAsync(addOrEdit, true, verifyExp1); - // } - // } - // } - // else - // { - // await _taskConsistentRuleRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId, c => new TaskConsistentRule() - // { - // PlanSubjectCount = c.PlanSubjectCount, - // PlanVisitCount = c.PlanVisitCount, - // IntervalWeeks = c.IntervalWeeks, - // IsGenerateGlobalTask = c.IsGenerateGlobalTask, - // IsHaveReadingPeriod = c.IsHaveReadingPeriod - - // }, true); - // } - - // await _taskConsistentRuleRepository.SaveChangesAsync(); - - // return ResponseOutput.Ok(); - //} - public async Task AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule)