From 407205ec79c53b7d44e108b2aa61d6569402022e Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 4 Jul 2022 13:59:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E5=B1=9E=E6=80=A7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTO/TaskConsistentRuleViewModel.cs | 2 +- .../DTO/TaskMedicalReviewViewModel.cs | 8 +- .../Allocation/TaskConsistentRuleService.cs | 73 +++++++++++++------ .../Allocation/TaskMedicalReviewService.cs | 9 +-- .../Service/Allocation/_MapConfig.cs | 4 +- .../Allocation/TaskConsistentRule.cs | 4 +- 6 files changed, 61 insertions(+), 39 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs index b7cf69fe4..d07d20efa 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs @@ -61,7 +61,7 @@ namespace IRaCIS.Core.Application.ViewModel public Guid SubjectId { get; set; } - public bool IsHaveCreatedTask { get; set; } + public bool IsHaveGeneratedTask { get; set; } public int? ValidTaskCount { get; set; } public int? ValidVisitCount => VisitTaskList.Select(t => t.TaskName).Distinct().Count(); diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewViewModel.cs index 2a0d3d933..74a71511d 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewViewModel.cs @@ -12,12 +12,7 @@ namespace IRaCIS.Core.Application.ViewModel /// TaskMedicalReviewView 列表视图模型 public class TaskMedicalReviewView: VisitTaskViewBasic { - public Guid Id { get; set; } - public Guid CreateUserId { get; set; } - public DateTime CreateTime { get; set; } - public DateTime UpdateTime { get; set; } - public Guid UpdateUserId { get; set; } - public DateTime? AllocateTime { get; set; } + public int AuditState { get; set; } public DateTime? AuditSignTime { get; set; } public int DoctorUserIdeaEnum { get; set; } @@ -26,7 +21,6 @@ namespace IRaCIS.Core.Application.ViewModel - public UserSimpleInfo DoctorUser { get; set; } public UserSimpleInfo MedicalManagerUser { get; set; } diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs index b565104f1..e3e909665 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs @@ -10,6 +10,7 @@ using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Domain.Share; +using System.Linq.Expressions; namespace IRaCIS.Core.Application.Service { @@ -22,11 +23,13 @@ namespace IRaCIS.Core.Application.Service private readonly IRepository _taskConsistentRuleRepository; private readonly IRepository _visitTaskRepository; + private readonly IRepository _subjectUserRepository; - public TaskConsistentRuleService(IRepository visitTaskRepository, IRepository taskConsistentRuleRepository) + public TaskConsistentRuleService(IRepository visitTaskRepository, IRepository taskConsistentRuleRepository, IRepository subjectUserRepository) { _taskConsistentRuleRepository = taskConsistentRuleRepository; _visitTaskRepository = visitTaskRepository; + _subjectUserRepository = subjectUserRepository; } @@ -72,26 +75,41 @@ namespace IRaCIS.Core.Application.Service { var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inQuery.TaskConsistentRuleId); - var doctorUserId = filterObj.CompareDoctorUserId == null ? filterObj.AnalysisDoctorUserId : filterObj.CompareDoctorUserId; + + bool isSelfAnalysis = filterObj.CompareDoctorUserId == null; + + IQueryable subjectfilter = default; + + if (isSelfAnalysis == false) + { + //过滤不满足的Subject + + subjectfilter = _subjectUserRepository.Where(t => t.TrialId == filterObj.TrialId).GroupBy(t => t.SubjectId) + .Where(g => g.Any(t => t.DoctorUserId == filterObj.AnalysisDoctorUserId) && !g.Any(t => t.DoctorUserId == filterObj.CompareDoctorUserId)).Select(g => g.Key); + } + + var doctorUserId = isSelfAnalysis ? 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(isSelfAnalysis, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId) + // 组内一致性分析 + .WhereIf(isSelfAnalysis == false, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId && subjectfilter.Contains(t.SubjectId)) + .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); + .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), + IsHaveGeneratedTask = g.Any(t => t.IsAnalysisCreate && t.SubjectId == g.Key && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id), VisitTaskList = g.Where(t => t.IsAnalysisCreate == false).OrderBy(t => t.VisitTaskNum).Select(c => new VisitTaskSimpleView() { @@ -114,7 +132,7 @@ namespace IRaCIS.Core.Application.Service var count = group.Count(); - query = query.OrderByDescending(t => t.IsHaveCreatedTask).Skip((inQuery.PageIndex - 1) * inQuery.PageSize); + query = query.OrderByDescending(t => t.IsHaveGeneratedTask).Skip((inQuery.PageIndex - 1) * inQuery.PageSize); var items = await query.Take(inQuery.PageSize).ToArrayAsync().ConfigureAwait(false); var pagedList = new PageOutput() @@ -139,13 +157,27 @@ namespace IRaCIS.Core.Application.Service { var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inCommand.TaskConsistentRuleId); - var doctorUserId = filterObj.CompareDoctorUserId == null ? filterObj.AnalysisDoctorUserId : filterObj.CompareDoctorUserId; + bool isSelfAnalysis = filterObj.CompareDoctorUserId == null; + + IQueryable subjectfilter = default; + + if (isSelfAnalysis == false) + { + //过滤不满足的Subject + + subjectfilter = _subjectUserRepository.Where(t => t.TrialId == filterObj.TrialId).GroupBy(t => t.SubjectId) + .Where(g => g.Any(t => t.DoctorUserId == filterObj.AnalysisDoctorUserId) && !g.Any(t => t.DoctorUserId == filterObj.CompareDoctorUserId)).Select(g => g.Key); + } + + var doctorUserId = isSelfAnalysis ? 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) + // 自身一致性分析 + .WhereIf(isSelfAnalysis, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId) + // 组内一致性分析 + .WhereIf(isSelfAnalysis == false, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId && subjectfilter.Contains(t.SubjectId)) .Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect) .Where(t => t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7 + 1) > DateTime.Now) //重阅产生的访视任务 要把之前的访视任务去除 @@ -161,7 +193,7 @@ namespace IRaCIS.Core.Application.Service { SubjectId = g.Key, - IsHaveCreatedTask = g.Any(t => t.IsAnalysisCreate && t.SubjectId == g.Key && t.DoctorUserId == doctorUserId), + IsHaveGeneratedTask = 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() { @@ -187,6 +219,8 @@ namespace IRaCIS.Core.Application.Service foreach (var subject in list) { + + await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() { ReadingCategory = ReadingCategory.Consistent, @@ -222,9 +256,6 @@ namespace IRaCIS.Core.Application.Service } - - - public async Task AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule) { diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs index 19cd24d04..ab18cd687 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs @@ -68,14 +68,11 @@ namespace IRaCIS.Core.Application.Service { var trialId = generateCommand.TrialId; - var mimUserList = await _trialUserRepository.Where(t => t.User.UserTypeEnum == Domain.Share.UserTypeEnum.MIM && t.TrialId == trialId).Select(t => t.User).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + //var mimUserList = await _trialUserRepository.Where(t => t.User.UserTypeEnum == Domain.Share.UserTypeEnum.MIM && t.TrialId == trialId).Select(t => t.User).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - //if (mimUserList.Count == 0) - //{ - // return ResponseOutput.NotOk("没有MIM"); - //} - var defalutMIMUserId = mimUserList.FirstOrDefault()?.UserId; + + Guid? defalutMIMUserId = null /*mimUserList.FirstOrDefault()?.UserId*/; //获取当前医生数据 已经生成的,和配置的数量 var taskTaskMedicalReviewRuleList = await _taskMedicalReviewRuleRepository.Where(t => t.TrialId == trialId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index e461ffaec..7594ad55b 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -215,8 +215,8 @@ namespace IRaCIS.Core.Application.Service 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())); + .ForMember(o => o.GeneratedSubjectCount, t => t.MapFrom(u => u.DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == u.Id).Select(t => t.SubjectId).Distinct().Count())) + .ForMember(o => o.GeneratedVisitCount, t => t.MapFrom(u => u.DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == u.Id).Count())); CreateMap(); diff --git a/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs b/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs index 329196993..ec48332c5 100644 --- a/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs +++ b/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs @@ -63,8 +63,8 @@ namespace IRaCIS.Core.Domain.Models public List DoctorVisitTaskList { get; set; } - [Projectable] - public List DoctorConsistentTaskList => DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == Id).ToList(); + //[Projectable] + //public List DoctorConsistentTaskList => DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == Id).ToList(); } }