diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 32a8dd92b..f575d78d0 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -896,6 +896,7 @@ namespace IRaCIS.Core.Application.Service.Allocation [HttpPost] public async Task<(PageOutput, object)> GetIRUnReadSubjectTaskList(IRUnReadSubjectQuery iRUnReadSubjectQuery) { + var trialId = iRUnReadSubjectQuery.TrialId; var trialReadingCriterionId = iRUnReadSubjectQuery.TrialReadingCriterionId; @@ -905,41 +906,40 @@ namespace IRaCIS.Core.Application.Service.Allocation var readingTool = criterionConfig.ReadingTool; var isReadingTaskViewInOrder = criterionConfig.IsReadingTaskViewInOrder; - var visitTaskListInfo = await GetOrderReadingIQueryable(new GetOrderReadingIQueryableInDto() - { - TrialId = trialId, - TrialReadingCriterionId = trialReadingCriterionId, - SubjectCode = iRUnReadSubjectQuery.SubjectCode, - Page = new PageInput() - { - PageIndex = iRUnReadSubjectQuery.PageIndex, - PageSize = iRUnReadSubjectQuery.PageSize, - Asc = iRUnReadSubjectQuery.Asc, - SortField = iRUnReadSubjectQuery.SortField, - - } - - }); - - - var totalCount = visitTaskListInfo.Item1; - var currentPageData = visitTaskListInfo.Item2; - - - - var result = new PageOutput() - { - PageSize = iRUnReadSubjectQuery.PageSize, - PageIndex = iRUnReadSubjectQuery.PageIndex, - TotalCount = totalCount, - CurrentPageData = currentPageData, - }; - - #region 按照Subject 维度 if (isReadingTaskViewInOrder) { + + var visitTaskListInfo = await GetOrderReadingIQueryable(new GetOrderReadingIQueryableInDto() + { + TrialId = trialId, + TrialReadingCriterionId = trialReadingCriterionId, + SubjectCode = iRUnReadSubjectQuery.SubjectCode, + Page = new PageInput() + { + PageIndex = iRUnReadSubjectQuery.PageIndex, + PageSize = iRUnReadSubjectQuery.PageSize, + Asc = iRUnReadSubjectQuery.Asc, + SortField = iRUnReadSubjectQuery.SortField, + + } + + }); + + + var totalCount = visitTaskListInfo.Item1; + var currentPageData = visitTaskListInfo.Item2; + + + + var result = new PageOutput() + { + PageSize = iRUnReadSubjectQuery.PageSize, + PageIndex = iRUnReadSubjectQuery.PageIndex, + TotalCount = totalCount, + CurrentPageData = currentPageData, + }; // 封装的方法有问题 //var result = await visitQuery.ToPagedListAsync(iRUnReadSubjectQuery.PageIndex, iRUnReadSubjectQuery.PageSize, String.IsNullOrEmpty(iRUnReadSubjectQuery.SortField) ? nameof(IRUnReadSubjectView.SubjectId) : iRUnReadSubjectQuery.SortField, iRUnReadSubjectQuery.Asc); @@ -957,10 +957,9 @@ namespace IRaCIS.Core.Application.Service.Allocation } else { - var taskQuery = _visitTaskRepository.Where(x => x.TrialId == iRUnReadSubjectQuery.TrialId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect && x.TrialReadingCriterionId == trialReadingCriterionId) // .Where(x=>x.Subject.ClinicalDataList.Any(c => c.IsSign && (c.ReadingId == x.SouceReadModuleId || c.ReadingId == x.SourceSubjectVisitId))) - .Where(x => !x.Subject.IsDeleted); + .Where(x => !x.Subject.IsDeleted).Where(x=>(x.IsNeedClinicalDataSign&&x.IsClinicalDataSign)||!x.IsNeedClinicalDataSign); IRUnReadOutDto iRUnReadOut = new IRUnReadOutDto() { @@ -973,8 +972,65 @@ namespace IRaCIS.Core.Application.Service.Allocation + var visitGroupQuery = taskQuery.GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode }); + + var visitTaskQuery = visitGroupQuery.Select(x => new IRUnReadSubjectView() + { + SubjectId = x.Key.SubjectId, + SubjectCode = x.Key.BlindSubjectCode == string.Empty ? x.Key.Code : x.Key.BlindSubjectCode, + + SuggesteFinishedTime = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Min(x => x.SuggesteFinishedTime), + + //未读任务量 + UnReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Count(), + + //未读 里可读任务量 + UnReadCanReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned && y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true) + //不能对包含聚合或子查询的表达式执行聚合函数 + //&& !x.Any(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.IsNeedClinicalDataSign == true && t.IsClinicalDataSign == false && t.VisitTaskNum y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState == ReadingTaskState.HaveSigned).Count(), + + ExistReadingApply = x.Any(y => y.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed || y.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed), + + //查出所有未读的 未读的可读的 在这个列表基础上 过滤下 y.IsFrontTaskNeedSignButNotSign==false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true) 这样容易排错 确认这三个字段是否维护有误 + UnReadTaskList = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).OrderBy(x => x.VisitTaskNum) + .Select(u => new IRUnreadTaskView() + { + Id = u.Id, + IsUrgent = u.IsUrgent, + VisitNum = u.VisitTaskNum, + TaskBlindName = u.TaskBlindName, + VisistId = u.SourceSubjectVisitId, + SuggesteFinishedTime = u.SuggesteFinishedTime, + ReadingCategory = u.ReadingCategory, + IsAnalysisCreate = u.IsAnalysisCreate, + ArmEnum = u.ArmEnum, + TrialReadingCriterionId = u.TrialReadingCriterionId, + IsNeedClinicalDataSign = u.IsNeedClinicalDataSign, + IsClinicalDataSign = u.IsClinicalDataSign, + IsFrontTaskNeedSignButNotSign = u.IsFrontTaskNeedSignButNotSign + }) + .ToList(), + }).Where(x => x.UnReadCanReadTaskCount > 0); + + + var totalCount = await visitGroupQuery.CountAsync(); + var currentPageData =await visitTaskQuery.ToListAsync(); + + var result = new PageOutput() + { + PageSize = iRUnReadSubjectQuery.PageSize, + PageIndex = iRUnReadSubjectQuery.PageIndex, + TotalCount = totalCount, + CurrentPageData = currentPageData, + }; + return (result, new { IsReadingTaskViewInOrder = isReadingTaskViewInOrder,