From 9b2d431fa89cf74618a3660cc664f4587eff4828 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 4 Jul 2022 11:45:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E8=87=B4=E6=80=A7=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTO/TaskAllocationRuleViewModel.cs | 2 + .../DTO/TaskConsistentRuleViewModel.cs | 95 ++++++++- .../Allocation/DTO/VisitTaskViewModel.cs | 55 ------ .../Allocation/TaskConsistentRuleService.cs | 187 ++++++++++++++++++ .../TaskMedicalReviewRuleService.cs | 6 + .../Allocation/VisitTaskHelpeService.cs | 31 +++ .../Service/Allocation/VisitTaskService.cs | 91 +-------- .../Service/Allocation/_MapConfig.cs | 8 +- .../Allocation/AllocationRelation.cs | 4 + .../Allocation/TaskConsistentRule.cs | 12 +- 10 files changed, 339 insertions(+), 152 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs index b0a84a688..d5cbe4a65 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs @@ -152,6 +152,8 @@ namespace IRaCIS.Core.Application.ViewModel //public ReReadingApplyGenerateTaskCommand ReReadingApplyGenerateTaskCommand { get; set; } = new ReReadingApplyGenerateTaskCommand(); + public List GenerataConsistentTaskList { get; set; } + } //public class ReReadingApplyGenerateTaskCommand diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs index f0f0f8631..b7cf69fe4 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; namespace IRaCIS.Core.Application.ViewModel { /// TaskConsistentRuleView 列表视图模型 - public class TaskConsistentRuleView: TaskConsistentRuleAddOrEdit + public class TaskConsistentRuleView : TaskConsistentRuleAddOrEdit { public Guid CreateUserId { get; set; } public DateTime CreateTime { get; set; } @@ -20,6 +20,96 @@ namespace IRaCIS.Core.Application.ViewModel public UserSimpleInfo CompareDoctorUser { get; set; } + + public int? GeneratedSubjectCount { get; set; } + + public int? GeneratedVisitCount { get; set; } + + } + + public class ConsistentQuery : PageInput + { + + public Guid TaskConsistentRuleId { get; set; } + + //public int PlanSubjectCount { get; set; } + //public int PlanVisitCount { get; set; } + //public int IntervalWeeks { get; set; } + //public Guid? CompareDoctorUserId { get; set; } + //public bool IsHaveReadingPeriod { get; set; } + //public bool IsGenerateGlobalTask { get; set; } + //public Guid? AnalysisDoctorUserId { get; set; } + + } + + public class ConsistentConfirmGenerateCommand + { + public Guid TaskConsistentRuleId { get; set; } + + public List SubejctIdList { get; set; } + } + + + + public class DoctorConsistentRuleSubjectView + { + public Guid TrialId => VisitTaskList.Select(t => t.TrialId).First(); + public Guid SiteId => VisitTaskList.Select(t => t.SiteId).First(); + + public String TrialSiteCode => VisitTaskList.Select(t => t.TrialSiteCode).First(); + public string SubjectCode => VisitTaskList.Select(t => t.TrialSiteCode).First(); + + public Guid SubjectId { get; set; } + + public bool IsHaveCreatedTask { get; set; } + public int? ValidTaskCount { get; set; } + + public int? ValidVisitCount => VisitTaskList.Select(t => t.TaskName).Distinct().Count(); + + public List VisitTaskList { get; set; } + } + + public class VisitTaskSimpleView + { + public Guid Id { get; set; } + public Guid TrialId { get; set; } + public Guid SiteId { get; set; } + + public Guid SubjectId { get; set; } + + public Arm ArmEnum { get; set; } + public string TaskCode { get; set; } + + public string TaskName { get; set; } + public string TaskBlindName { get; set; } + + public decimal VisitTaskNum { get; set; } + + public ReadingCategory ReadingCategory { get; set; } + + public TaskState TaskState { get; set; } + + public String TrialSiteCode { get; set; } = String.Empty; + public string SubjectCode { get; set; } = String.Empty; + } + + + public class SelfConsistentView + { + public Guid TrialId { get; set; } + public Guid SiteId { get; set; } + + public String TrialSiteCode => VisitTaskList.Select(t => t.TrialSiteCode).First(); + public string SubjectCode => VisitTaskList.Select(t => t.TrialSiteCode).First(); + + public Guid SubjectId { get; set; } + + + public int? VisitValidTaskCount { get; set; } + + public int? VisitValidCount => VisitTaskList.Select(t => t.TaskName).Distinct().Count(); + + public List VisitTaskList { get; set; } } ///TaskConsistentRuleQuery 列表查询参数模型 @@ -35,7 +125,6 @@ namespace IRaCIS.Core.Application.ViewModel public class TaskConsistentRuleAddOrEdit { public Guid? Id { get; set; } - public Guid AnalysisDoctorUserId { get; set; } public bool IsEnable { get; set; } public string Note { get; set; } public Guid TrialId { get; set; } @@ -45,6 +134,8 @@ namespace IRaCIS.Core.Application.ViewModel public Guid? CompareDoctorUserId { get; set; } public bool IsHaveReadingPeriod { get; set; } public bool IsGenerateGlobalTask { get; set; } + public Guid AnalysisDoctorUserId { get; set; } + } diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index fba033359..b20704794 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -221,66 +221,11 @@ namespace IRaCIS.Core.Application.ViewModel } - public class SelfConsistentQuery - { - public Guid TrialId { get; set; } - - public Guid AnalysisDoctorUserId { get; set; } - - public Guid? CompareDoctorUserId { get; set; } - - public int IntervalWeeks { get; set; } - - public bool IsHaveReadingPeriod { get; set; } - - public Guid? SiteId { get; set; } - - public int? VisitCount { get; set; } - - public Guid? SubjectId { get; set; } - //public int? SubjectCount { get; set; } - } - public class SelfConsistentView - { - //public Guid TrialId { get; set; } - //public Guid SiteId { get; set; } - - public Guid SubjectId { get; set; } - public String TrialSiteCode => VisitTaskList.Select(t=>t.TrialSiteCode).First(); - public string SubjectCode => VisitTaskList.Select(t => t.TrialSiteCode).First(); - - public int? VisitValidTaskCount { get; set; } - - public int? VisitValidCount => VisitTaskList.Select(t=>t.TaskName).Distinct().Count(); - - public List VisitTaskList { get; set; } - } - - public class VisitTaskSimpleView - { - public Guid? Id { get; set; } - public Guid? TrialId { get; set; } - - public Guid? SubjectId { get; set; } - - public Arm? ArmEnum { get; set; } - public string? TaskCode { get; set; } - - public string? TaskName { get; set; } - public string? TaskBlindName { get; set; } - - public ReadingCategory? ReadingCategory { get; set; } - - public TaskState? TaskState { get; set; } - - public String? TrialSiteCode { get; set; } = String.Empty; - public string? SubjectCode { get; set; } = String.Empty; - } public class IRUnReadSubjectQuery : PageInput diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs index dac728c83..b565104f1 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Infrastructure; +using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.Application.Service { @@ -28,6 +29,186 @@ namespace IRaCIS.Core.Application.Service _visitTaskRepository = visitTaskRepository; } + + /// + /// 一致性分析列表 (自身 组内 最后勾选 产生的任务) + /// + /// + /// + [HttpPost] + public async Task> GetAnalysisTaskList(VisitTaskQuery queryVisitTask) + { + var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == queryVisitTask.TrialId) + .Where(t => t.IsAnalysisCreate) + + .WhereIf(queryVisitTask.SiteId != null, t => t.Subject.SiteId == queryVisitTask.SiteId) + .WhereIf(queryVisitTask.SubjectId != null, t => t.SubjectId == queryVisitTask.SubjectId) + .WhereIf(queryVisitTask.IsUrgent != null, t => t.IsUrgent == queryVisitTask.IsUrgent) + .WhereIf(queryVisitTask.DoctorUserId != null, t => t.DoctorUserId == queryVisitTask.DoctorUserId) + .WhereIf(queryVisitTask.ReadingCategory != null, t => t.ReadingCategory == queryVisitTask.ReadingCategory) + .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.ReadingTaskState == queryVisitTask.ReadingTaskState) + .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.TaskAllocationState == queryVisitTask.TaskAllocationState) + .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.TaskName.Contains(queryVisitTask.TaskName) || t.TaskBlindName.Contains(queryVisitTask.TaskName)) + .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.Subject.Code.Contains(queryVisitTask.SubjectCode)) + .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.AllocateTime > queryVisitTask.BeginAllocateDate) + .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.AllocateTime < queryVisitTask.EndAllocateDate.Value.AddDays(1)) + .ProjectTo(_mapper.ConfigurationProvider); + + var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId) }; + + var pageList = await visitTaskQueryable.ToPagedListAsync(queryVisitTask.PageIndex, queryVisitTask.PageSize, queryVisitTask.SortField, queryVisitTask.Asc, string.IsNullOrWhiteSpace(queryVisitTask.SortField), defalutSortArray); + + return (pageList); + } + + + /// + /// 为一致性分析医生,选择Subejct 列表 + /// + /// + /// + [HttpPost] + public async Task> GetDoctorConsistentRuleSubjectList(ConsistentQuery inQuery) + { + var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inQuery.TaskConsistentRuleId); + + var doctorUserId = filterObj.CompareDoctorUserId == null ? filterObj.AnalysisDoctorUserId : filterObj.CompareDoctorUserId; + + var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId) + .WhereIf(filterObj.CompareDoctorUserId == null, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId) + .WhereIf(filterObj.CompareDoctorUserId != null, t => t.DoctorUserId == filterObj.CompareDoctorUserId) + .Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect) + .Where(t => t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7 + 1) > DateTime.Now) + //重阅产生的访视任务 要把之前的访视任务去除 + .Where(t => t.ReReadingApplyState != ReReadingApplyState.Agree) + + .WhereIf(filterObj.IsHaveReadingPeriod == false, t => t.ReadingCategory == ReadingCategory.Visit) + .WhereIf(filterObj.IsHaveReadingPeriod == true, t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) + .GroupBy(t => t.SubjectId) + .Where(g => g.Count() > filterObj.PlanVisitCount); + + var query = group.Select(g => new DoctorConsistentRuleSubjectView() + { + SubjectId = g.Key, + + IsHaveCreatedTask = g.Any(t => t.IsAnalysisCreate && t.SubjectId == g.Key && t.DoctorUserId == doctorUserId), + + VisitTaskList = g.Where(t => t.IsAnalysisCreate == false).OrderBy(t => t.VisitTaskNum).Select(c => new VisitTaskSimpleView() + { + Id = c.Id, + ReadingCategory = c.ReadingCategory, + TaskBlindName = c.TaskBlindName, + TaskCode = c.TaskCode, + TaskName = c.TaskName, + TaskState = c.TaskState, + ArmEnum = c.ArmEnum, + SubjectId = c.SubjectId, + TrialId = c.TrialId, + SubjectCode = c.Subject.Code, + TrialSiteCode = c.Subject.TrialSite.TrialSiteCode, + }).ToList(), + + ValidTaskCount = g.Count() + + }); + + var count = group.Count(); + + query = query.OrderByDescending(t => t.IsHaveCreatedTask).Skip((inQuery.PageIndex - 1) * inQuery.PageSize); + var items = await query.Take(inQuery.PageSize).ToArrayAsync().ConfigureAwait(false); + + var pagedList = new PageOutput() + { + PageIndex = inQuery.PageIndex, + PageSize = inQuery.PageSize, + TotalCount = count, + CurrentPageData = items + }; + + + return pagedList; + } + + /// + /// 确认生成一致性分析任务 + /// + /// + /// + [HttpPost] + public async Task ConfirmGenerateConsistentTask(ConsistentConfirmGenerateCommand inCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService) + { + var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inCommand.TaskConsistentRuleId); + + var doctorUserId = filterObj.CompareDoctorUserId == null ? filterObj.AnalysisDoctorUserId : filterObj.CompareDoctorUserId; + + + + var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId && inCommand.SubejctIdList.Contains(t.SubjectId)) + .WhereIf(filterObj.CompareDoctorUserId == null, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId) + .WhereIf(filterObj.CompareDoctorUserId != null, t => t.DoctorUserId == filterObj.CompareDoctorUserId) + .Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect) + .Where(t => t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7 + 1) > DateTime.Now) + //重阅产生的访视任务 要把之前的访视任务去除 + .Where(t => t.ReReadingApplyState != ReReadingApplyState.Agree) + + .WhereIf(filterObj.IsHaveReadingPeriod == false, t => t.ReadingCategory == ReadingCategory.Visit) + .WhereIf(filterObj.IsHaveReadingPeriod == true, t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) + .GroupBy(t => t.SubjectId) + .Where(g => g.Count() > filterObj.PlanVisitCount); + + + var query = group.Select(g => new DoctorConsistentRuleSubjectView() + { + SubjectId = g.Key, + + IsHaveCreatedTask = g.Any(t => t.IsAnalysisCreate && t.SubjectId == g.Key && t.DoctorUserId == doctorUserId), + + VisitTaskList = g.Where(t => t.IsAnalysisCreate == false).OrderBy(t => t.VisitTaskNum).Select(c => new VisitTaskSimpleView() + { + Id = c.Id, + ReadingCategory = c.ReadingCategory, + TaskBlindName = c.TaskBlindName, + TaskCode = c.TaskCode, + TaskName = c.TaskName, + TaskState = c.TaskState, + ArmEnum = c.ArmEnum, + SubjectId = c.SubjectId, + TrialId = c.TrialId, + SubjectCode = c.Subject.Code, + TrialSiteCode = c.Subject.TrialSite.TrialSiteCode, + }).Take(filterObj.PlanVisitCount).ToList(), + + ValidTaskCount = g.Count() + + }); + + var list = query.ToList(); + + foreach (var subject in list) + { + + await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() + { + ReadingCategory = ReadingCategory.Consistent, + GenerataConsistentTaskList = subject.VisitTaskList + }); + + } + + + return ResponseOutput.Ok(); + + + } + + + + + /// + /// 一致性分配 配置+ 统计已经生成数量统计表 + /// + /// + /// [HttpPost] public async Task> GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery) { @@ -41,6 +222,9 @@ namespace IRaCIS.Core.Application.Service } + + + public async Task AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule) { @@ -85,5 +269,8 @@ namespace IRaCIS.Core.Application.Service } + + + } } diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewRuleService.cs index 8e5a9f9fd..0d8a83412 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewRuleService.cs @@ -57,6 +57,12 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{taskMedicalReviewRuleId:guid}")] public async Task DeleteTaskMedicalReviewRule(Guid taskMedicalReviewRuleId) { + + if(await _taskMedicalReviewRuleRepository.Where(t=>t.Id== taskMedicalReviewRuleId).AnyAsync(t => t.TaskMedicalReviewList.Any())) + { + return ResponseOutput.NotOk("已产生医学审核任务"); + } + var success = await _taskMedicalReviewRuleRepository.DeleteFromQueryAsync(t => t.Id == taskMedicalReviewRuleId,true); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index 34c98d907..3cd93c051 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -328,6 +328,7 @@ namespace IRaCIS.Core.Application.Service VisitTaskNum = reReadingVisitTask.VisitTaskNum, ReadingCategory = reReadingVisitTask.ReadingCategory, SourceSubjectVisitId = reReadingVisitTask.SourceSubjectVisitId, + SouceReadModuleId = reReadingVisitTask.SouceReadModuleId, IsReReadingCreate = true, TaskState = TaskState.Effect, @@ -354,6 +355,36 @@ namespace IRaCIS.Core.Application.Service //} break; + case ReadingCategory.Consistent: + + foreach (var task in generateTaskCommand.GenerataConsistentTaskList) + { + var consistentTask = new VisitTask() + { + TrialId = task.TrialId, + SubjectId = task.SubjectId, + ArmEnum = task.ArmEnum, + TaskName = task.TaskName, + TaskBlindName = task.TaskBlindName, + + VisitTaskNum = task.VisitTaskNum, + ReadingCategory = task.ReadingCategory, + + IsReReadingCreate = true, + TaskState = TaskState.Effect, + Code = currentMaxCodeInt + 1, + TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), + }; + + await _visitTaskRepository.AddAsync(consistentTask); + + currentMaxCodeInt = currentMaxCodeInt + 1; + + _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30)); + } + + break; + case ReadingCategory.Judge: var firstTask = await _visitTaskRepository.Where(x => generateTaskCommand.JudgeVisitTaskIdList.Contains(x.Id)).FirstOrDefaultAsync(); diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index fdad5bcc6..f443f9849 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -199,99 +199,10 @@ namespace IRaCIS.Core.Application.Service } - /// - /// 一致性分析列表 (自身 组内 最后勾选 产生的任务) - /// - /// - /// - [HttpPost] - public async Task> GetAnalysisTaskList(VisitTaskQuery queryVisitTask) - { - var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == queryVisitTask.TrialId) - .Where(t => t.IsAnalysisCreate) - - .WhereIf(queryVisitTask.SiteId != null, t => t.Subject.SiteId == queryVisitTask.SiteId) - .WhereIf(queryVisitTask.SubjectId != null, t => t.SubjectId == queryVisitTask.SubjectId) - .WhereIf(queryVisitTask.IsUrgent != null, t => t.IsUrgent == queryVisitTask.IsUrgent) - .WhereIf(queryVisitTask.DoctorUserId != null, t => t.DoctorUserId == queryVisitTask.DoctorUserId) - .WhereIf(queryVisitTask.ReadingCategory != null, t => t.ReadingCategory == queryVisitTask.ReadingCategory) - .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.ReadingTaskState == queryVisitTask.ReadingTaskState) - .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.TaskAllocationState == queryVisitTask.TaskAllocationState) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.TaskName.Contains(queryVisitTask.TaskName) || t.TaskBlindName.Contains(queryVisitTask.TaskName)) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.Subject.Code.Contains(queryVisitTask.SubjectCode)) - .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.AllocateTime > queryVisitTask.BeginAllocateDate) - .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.AllocateTime < queryVisitTask.EndAllocateDate.Value.AddDays(1)) - .ProjectTo(_mapper.ConfigurationProvider); - - var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId) }; - - var pageList = await visitTaskQueryable.ToPagedListAsync(queryVisitTask.PageIndex, queryVisitTask.PageSize, queryVisitTask.SortField, queryVisitTask.Asc, string.IsNullOrWhiteSpace(queryVisitTask.SortField), defalutSortArray); - - return (pageList); - } - - - //[HttpPost] - //public async Task> GetSelfConsistentList(SelfConsistentQuery inQuery) - //{ - // var group = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.DoctorUserId == inQuery.AnalysisDoctorUserId) - // .Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect) - // .Where(t => t.SignTime!.Value.AddDays(inQuery.IntervalWeeks * 7 + 1) > DateTime.Now) - // //重阅产生的访视任务 要把之前的访视任务去除 - // .Where(t => t.ReReadingApplyState != ReReadingApplyState.Agree) - // .WhereIf(inQuery.IsHaveReadingPeriod == false, t => t.ReadingCategory == ReadingCategory.Visit) - // .WhereIf(inQuery.IsHaveReadingPeriod == true, t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) - // .GroupBy(t => t.SubjectId) - // ; - - // var query= group.Select(g => new SelfConsistentView() - // { - // SubjectId = g.Key, - - // VisitTaskList = g.OrderBy(t => t.SubjectVisit.VisitNum).Select(c => new VisitTaskSimpleView() - // { - // Id = c.Id, - // ReadingCategory = c.ReadingCategory, - // TaskBlindName = c.TaskBlindName, - // TaskCode = c.TaskCode, - // TaskName = c.TaskName, - // TaskState = c.TaskState, - // ArmEnum = c.ArmEnum, - // SubjectId = c.SubjectId, - // TrialId = c.TrialId, - // SubjectCode = c.Subject.Code, - // TrialSiteCode = c.Subject.TrialSite.TrialSiteCode, - // }).Take(2).ToList(), - - // VisitValidTaskCount = g.Count() - - // }) + - // //source = source.Skip((pageNumber - 1) * pageSize); - // //var items = await source - // // .Take(pageSize) - // // .ToArrayAsync(cancellationToken) - // // .ConfigureAwait(false); - - // //var pagedList = new PageOutput() - // //{ - // // PageIndex = pageNumber, - // // PageSize = pageSize, - // // TotalCount = count, - // // CurrentPageData = items - // //}; - - - // //var count = group.Count(); - - // //var list= query.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList(); - - - - // return query.ToList(); - //} diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 4a93ef6e4..e461ffaec 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -191,7 +191,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.UserCode, t => t.MapFrom(u => u.UserCode)) .ForMember(o => o.UserName, t => t.MapFrom(u => u.UserName)) .ForMember(o => o.FullName, t => t.MapFrom(u => u.FullName)); - //.ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.UserTypeRole.UserTypeShortName)); + //.ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.UserTypeRole.UserTypeShortName)); @@ -207,14 +207,16 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.GeneratedGlobalTaskList, t => t.MapFrom(u => u.TaskMedicalReviewList.Where(t => t.VisitTask.ReadingCategory == ReadingCategory.Global && t.VisitTask.TaskState == TaskState.Effect && t.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.VisitTask.SignTime).Select(t => new TaskBasicIdView() { TaskId = t.VisitTaskId, TrialId = t.TrialId, DoctorUserId = t.DoctorUserId }))) .ForMember(o => o.GeneratedJudgeTaskList, t => t.MapFrom(u => u.TaskMedicalReviewList.Where(t => t.VisitTask.ReadingCategory == ReadingCategory.Judge && t.VisitTask.TaskState == TaskState.Effect && t.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.VisitTask.SignTime).Select(t => new TaskBasicIdView() { TaskId = t.VisitTaskId, TrialId = t.TrialId, DoctorUserId = t.DoctorUserId }))) - .ForMember(o => o.GeneratedTumorTaskList, t => t.MapFrom(u => u.TaskMedicalReviewList.Where(t => t.VisitTask.ReadingCategory == ReadingCategory.Oncology && t.VisitTask.TaskState == TaskState.Effect && t.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.VisitTask.SignTime).Select(t => new TaskBasicIdView() {TaskId = t.VisitTaskId,TrialId=t.TrialId,DoctorUserId=t.DoctorUserId }))) + .ForMember(o => o.GeneratedTumorTaskList, t => t.MapFrom(u => u.TaskMedicalReviewList.Where(t => t.VisitTask.ReadingCategory == ReadingCategory.Oncology && t.VisitTask.TaskState == TaskState.Effect && t.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.VisitTask.SignTime).Select(t => new TaskBasicIdView() { TaskId = t.VisitTaskId, TrialId = t.TrialId, DoctorUserId = t.DoctorUserId }))) .ForMember(o => o.GeneratedVisitTaskList, t => t.MapFrom(u => u.TaskMedicalReviewList.Where(t => t.VisitTask.ReadingCategory == ReadingCategory.Visit && t.VisitTask.TaskState == TaskState.Effect && t.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.VisitTask.SignTime).Select(t => new TaskBasicIdView() { TaskId = t.VisitTaskId, TrialId = t.TrialId, DoctorUserId = t.DoctorUserId }))); CreateMap(); - CreateMap(); + CreateMap() + .ForMember(o => o.GeneratedSubjectCount, t => t.MapFrom(u => u.DoctorConsistentTaskList.Select(t => t.SubjectId).Distinct().Count())) + .ForMember(o => o.GeneratedVisitCount, t => t.MapFrom(u => u.DoctorConsistentTaskList.Count())); CreateMap(); diff --git a/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs b/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs index 55cea8c3c..7f0998d76 100644 --- a/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs +++ b/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs @@ -23,7 +23,11 @@ namespace IRaCIS.Core.Domain.Share + //生成任务 额外增加的 前端那边不加 + ReReading = 6, + + Consistent = 7, } public enum TaskAllocationState diff --git a/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs b/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs index 63cd6f40b..329196993 100644 --- a/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs +++ b/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs @@ -4,9 +4,11 @@ // 生成时间 2022-07-01 15:32:56 // 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 using System; -using IRaCIS.Core.Domain.Share; -using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using System.Collections.Generic; +using EntityFrameworkCore.Projectables; +using System.Linq; + namespace IRaCIS.Core.Domain.Models { /// @@ -57,6 +59,12 @@ namespace IRaCIS.Core.Domain.Models public User CompareDoctorUser { get; set; } public User AnalysisDoctorUser { get; set; } + + public List DoctorVisitTaskList { get; set; } + + + [Projectable] + public List DoctorConsistentTaskList => DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == Id).ToList(); } }