diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs index a77887387..e45e9c2bb 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs @@ -183,7 +183,8 @@ namespace IRaCIS.Core.Application.ViewModel public string TaskCode { get; set; } - + + [JsonIgnore] //可以不查询 public List GlobalVisitTaskList { get; set; } diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs index dbb8aa148..1a1a2bdbf 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs @@ -19,6 +19,7 @@ using Medallion.Threading; using IRaCIS.Core.Infrastructure.Extention; using System; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using NPOI.SS.Formula.Functions; namespace IRaCIS.Core.Application.Service { @@ -178,9 +179,7 @@ namespace IRaCIS.Core.Application.Service var list = await GetIQueryableDoctorSelfConsistentSubjectView(filterObj, doctorUserId, inCommand.SubejctIdList).ToListAsync(); - //var (group, query) = GetIQueryableDoctorSelfConsistentRuleSubjectView(filterObj, inCommand.SubejctIdList); - //var list = query.OrderByDescending(t => t.IsHaveGeneratedTask).ToList(); var @lock = _distributedLockProvider.CreateLock($"VisitTaskCode"); @@ -552,7 +551,8 @@ 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)) + .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)) ; @@ -596,29 +596,27 @@ namespace IRaCIS.Core.Application.Service IsClinicalDataSign = c.IsClinicalDataSign, IsNeedClinicalDataSign = c.IsNeedClinicalDataSign, - //自身一致性才有意义 - //IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.ConsistentAnalysisOriginalTaskId == c.Id), - GlobalVisitTaskList = c.Subject.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).Select(c => new VisitTaskSimpleDTO() - { - Id = c.Id, - ReadingCategory = c.ReadingCategory, - ReadingTaskState = c.ReadingTaskState, - TaskBlindName = c.TaskBlindName, - TaskCode = c.TaskCode, - TaskName = c.TaskName, - TaskState = c.TaskState, - ArmEnum = c.ArmEnum, - SubjectId = c.SubjectId, - VisitTaskNum = c.VisitTaskNum, - TrialId = c.TrialId, - SourceSubjectVisitId = c.SourceSubjectVisitId, - SouceReadModuleId = c.SouceReadModuleId, + //GlobalVisitTaskList = c.Subject.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).Select(c => new VisitTaskSimpleDTO() + //{ + // Id = c.Id, + // ReadingCategory = c.ReadingCategory, + // ReadingTaskState = c.ReadingTaskState, + // TaskBlindName = c.TaskBlindName, + // TaskCode = c.TaskCode, + // TaskName = c.TaskName, + // TaskState = c.TaskState, + // ArmEnum = c.ArmEnum, + // SubjectId = c.SubjectId, + // VisitTaskNum = c.VisitTaskNum, + // TrialId = c.TrialId, + // SourceSubjectVisitId = c.SourceSubjectVisitId, + // SouceReadModuleId = c.SouceReadModuleId, - TrialReadingCriterionId = c.TrialReadingCriterionId, - IsClinicalDataSign = c.IsClinicalDataSign, - IsNeedClinicalDataSign = c.IsNeedClinicalDataSign, - }).ToList(), + // TrialReadingCriterionId = c.TrialReadingCriterionId, + // IsClinicalDataSign = c.IsClinicalDataSign, + // IsNeedClinicalDataSign = c.IsNeedClinicalDataSign, + //}).ToList(), }).ToList() }); @@ -795,7 +793,14 @@ namespace IRaCIS.Core.Application.Service 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.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).OrderBy(t => t.VisitTaskNum).Take(taskConsistentRule.PlanVisitCount + 1).Any(t => t.ReadingCategory == ReadingCategory.Global)) + .Where(t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global).Any(t => t.ReadingCategory == ReadingCategory.Global) + && + t.SubjectVisitTaskList.AsQueryable().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(), diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index c67402eea..b7eff45b0 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -1374,7 +1374,7 @@ namespace IRaCIS.Core.Application.Service.Allocation - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + if (IsPMOrAPm()) { if (criterionConfig.IsAutoCreate == false) { @@ -1634,7 +1634,7 @@ namespace IRaCIS.Core.Application.Service.Allocation if (criterionConfig.CriterionType == CriterionType.RECIST1Point1 && criterionConfig.IsAdditionalAssessment) { // PM申请 SPM / CPM审批 - if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM)) + if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (IsSpmOrCPM())) { filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == origenalTask.TrialReadingCriterionId || t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB); } @@ -1643,7 +1643,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { // 1.1 基线任务影响BM任务 - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && _subjectVisitRepository.Any(t => t.Id == origenalTask.SourceSubjectVisitId && t.IsBaseLine == true)) + if ((IsPMOrAPm()) && _subjectVisitRepository.Any(t => t.Id == origenalTask.SourceSubjectVisitId && t.IsBaseLine == true)) { isIR1Point1AdditionalAssessmentBaseline = true; @@ -1666,7 +1666,7 @@ namespace IRaCIS.Core.Application.Service.Allocation if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree) { //PM申请 SPM / CPM审批 回退访视,因此这里不生成访视任务 影响多个标准的任务 - if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM)) + if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (IsSpmOrCPM())) { // 不管有序 无序 都会 回退访视 @@ -1786,7 +1786,7 @@ namespace IRaCIS.Core.Application.Service.Allocation } //IR申请 PM 审批 注意这里有一致性分析的申请同意 不会回退访视,在此要生成影响的访视任务 - else if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR)) + else if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && (IsPMOrAPm() || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR)) { @@ -2291,7 +2291,7 @@ namespace IRaCIS.Core.Application.Service.Allocation //PM 才允许操作 - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + if (IsPMOrAPm()) { #region 有序 无序公用流程 @@ -2556,6 +2556,16 @@ namespace IRaCIS.Core.Application.Service.Allocation } + private bool IsPMOrAPm() + { + return _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM; + } + + private bool IsSpmOrCPM() + { + return _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM; + } + /// /// 影响提示列表 重阅仅仅针对已完成的任务申请 退回针对的是未完成的(退回仅仅针对是访视类型的) /// @@ -2587,12 +2597,12 @@ namespace IRaCIS.Core.Application.Service.Allocation { // IR 申请 PM 同意 - if (((_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer)) + if ((( IsPMOrAPm() && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer)) || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer && applyId == null))) { // 1.1 基线任务影响BM任务 - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && _subjectVisitRepository.Any(t => t.Id == filterObj.SourceSubjectVisitId && t.IsBaseLine == true)) + if (IsPMOrAPm() && _subjectVisitRepository.Any(t => t.Id == filterObj.SourceSubjectVisitId && t.IsBaseLine == true)) { isIR1Point1AdditionalAssessmentBaseline = true; @@ -2630,7 +2640,7 @@ namespace IRaCIS.Core.Application.Service.Allocation //IR 申请 PM 同意 仅仅影响自己 - if ((_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer)) + if ((IsPMOrAPm() && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.IndependentReviewer)) || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer && applyId == null)) { @@ -2748,8 +2758,9 @@ namespace IRaCIS.Core.Application.Service.Allocation } //PM 影响所有阅片人 仅仅针对访视 SPM CPM 调用 - else if (((_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) && applyId != null && await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && t.CreateUser.UserTypeEnum == UserTypeEnum.ProjectManager) && filterObj.IsAnalysisCreate == false && filterObj.ReadingCategory == ReadingCategory.Visit) - || (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && applyId == null)) + else if (((IsSpmOrCPM()) && applyId != null && + await _visitTaskReReadingRepository.AnyAsync(t => t.Id == applyId && (t.CreateUser.UserTypeEnum == UserTypeEnum.ProjectManager || t.CreateUser.UserTypeEnum == UserTypeEnum.APM)) && filterObj.IsAnalysisCreate == false && filterObj.ReadingCategory == ReadingCategory.Visit) + || (IsPMOrAPm() && applyId == null)) { @@ -2812,7 +2823,7 @@ namespace IRaCIS.Core.Application.Service.Allocation throw new BusinessValidationFailedException(_localizer["VisitTask_NoConsistencyReturn"]); } - if (filterObj.ReadingCategory == ReadingCategory.Visit && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + if (filterObj.ReadingCategory == ReadingCategory.Visit && IsPMOrAPm()) { //有序 if (criterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder)