一致性分析任务失效

Uat_Study
hang 2022-07-29 17:54:48 +08:00
parent 30f4dae15b
commit e7d788722c
2 changed files with 126 additions and 160 deletions

View File

@ -65,6 +65,13 @@
一致性分析配置表
</summary>
</member>
<member name="M:IRaCIS.Core.Application.Service.TaskConsistentRuleService.SetAnalysisTaskInvalid(System.Collections.Generic.List{System.Guid})">
<summary>
设置一致性分析任务失效
</summary>
<param name="taskIdList"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.TaskConsistentRuleService.GetAnalysisTaskList(IRaCIS.Core.Application.ViewModel.VisitTaskQuery)">
<summary>
一致性分析列表 (自身 组内 最后勾选 产生的任务)
@ -210,11 +217,11 @@
<param name="subjectId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.Allocation.VisitTaskService.CancelSubjectAssignedDoctor(System.Collections.Generic.List{IRaCIS.Core.Application.ViewModel.CancelSubjectAssignedDoctorCommand})">
<member name="M:IRaCIS.Core.Application.Service.Allocation.VisitTaskService.CancelSubjectAssignedDoctor(IRaCIS.Core.Application.ViewModel.CancelSubjectDoctorCommand)">
<summary>
取消Subject 分配的医生
</summary>
<param name="commandList"></param>
<param name="cancelCommand"></param>
<returns></returns>
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
</member>

View File

@ -42,6 +42,24 @@ namespace IRaCIS.Core.Application.Service
_enrollRepository = enrollRepository;
}
/// <summary>
/// 设置一致性分析任务失效
/// </summary>
/// <param name="taskIdList"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> SetAnalysisTaskInvalid(List<Guid> taskIdList)
{
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => taskIdList.Contains(t.Id), u => new VisitTask() { TaskState = TaskState.NotEffect });
await _visitTaskRepository.SaveChangesAsync();
return ResponseOutput.Ok();
}
/// <summary>
/// 一致性分析列表 (自身 组内 最后勾选 产生的任务)
@ -49,7 +67,7 @@ namespace IRaCIS.Core.Application.Service
/// <param name="queryVisitTask"></param>
/// <returns></returns>
[HttpPost]
public async Task<(PageOutput<AnalysisTaskView>,object?)> GetAnalysisTaskList(VisitTaskQuery queryVisitTask)
public async Task<(PageOutput<AnalysisTaskView>, 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<IQueryable<DoctorGroupConsistentSubjectView>> GetGroupConsistentQueryAsync(TaskConsistentRule filterObj, List<Guid>? subejctIdList = null)
{
var trialId = filterObj.TrialId;
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.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject);
if (subejctIdList != null && subejctIdList?.Count > 0)
{
comonTaskFilter = comonTaskFilter.And(t => subejctIdList.Contains(t.SubjectId));
}
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;
//单重阅片没有组件一致性
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;
}
/// <summary>
/// 组间一致性分析 选择Subejct 列表
/// </summary>
@ -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<IQueryable<DoctorGroupConsistentSubjectView>> GetGroupConsistentQueryAsync(TaskConsistentRule filterObj, List<Guid>? subejctIdList = null)
{
var trialId = filterObj.TrialId;
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.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject);
if (subejctIdList != null && subejctIdList?.Count > 0)
{
comonTaskFilter = comonTaskFilter.And(t => subejctIdList.Contains(t.SubjectId));
}
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;
//单重阅片没有组件一致性
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<TaskConsistentRuleBasic?> GetConsistentRule(TaskConsistentRuleQuery inQuery)
{
@ -612,68 +633,6 @@ namespace IRaCIS.Core.Application.Service
//public async Task<IResponseOutput> BatchAddOrUpdateTaskConsistentRule(TaskConsistentRuleBatchAddOrEdit addOrEdit)
//{
// var trialId = addOrEdit.TrialId;
// if (addOrEdit.IsBatchAdd)
// {
// var query = from enroll in _repository.Where<Enroll>(t => t.TrialId == trialId)
// join user in _repository.Where<User>() on enroll.DoctorId equals user.DoctorId
// join taskConsistentRule in _repository.Where<TaskConsistentRule>(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<TaskConsistentRule>()
// {
// 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<IResponseOutput> AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule)