From 78b3633dbb2396e41923bc3f81f7512b5f6a36a2 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 28 Jun 2022 16:47:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Allocation/DTO/VisitTaskViewModel.cs | 43 +++++++++++++++++-- .../Allocation/TaskAllocationRuleService.cs | 2 +- .../Service/Allocation/VisitTaskService.cs | 40 +++++++++++++++-- .../Allocation/AllocationRelation.cs | 10 ++--- .../Context/IRaCISDBContext.cs | 2 +- 5 files changed, 82 insertions(+), 15 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index dd718c068..12c1a30ca 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -17,26 +17,28 @@ namespace IRaCIS.Core.Application.ViewModel public Guid Id { get; set; } public Guid TrialId { get; set; } + public string TaskCode { get; set; } + public string TaskName { get; set; } public string TaskBlindName { get; set; } public ReadingCategory ReadingCategory { get; set; } public TaskAllocationState TaskAllocationState { get; set; } + public TaskState TaskState { get; set; } - public bool IsJudgeTaskReturn { get; set; } + + //public bool IsJudgeTaskReturn { get; set; } //public DateTime? CheckPassedTime { get; set; } public DateTime? AllocateTime { get; set; } public Guid SubjectId { get; set; } - public string TaskCode { get; set; } public bool IsUrgent { get; set; } public Arm ArmEnum { get; set; } public Guid? DoctorUserId { get; set; } - public TaskState TaskState { get; set; } public Guid CreateUserId { get; set; } public DateTime CreateTime { get; set; } @@ -209,12 +211,23 @@ namespace IRaCIS.Core.Application.ViewModel { 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 int? SubjectCount { get; set; } } @@ -226,6 +239,28 @@ namespace IRaCIS.Core.Application.ViewModel public Guid SubjectId { get; set; } public String TrialSiteCode { get; set; } = String.Empty; public string SubjectCode { get; set; } = String.Empty; + + public int? VisitValidTaskCount { get; set; } + + public int? VisitValidCount => VisitTaskList.Count(); + + public List VisitTaskList { get; set; } + } + + public class VisitTaskSimpleView + { + public Guid Id { get; set; } + public Guid TrialId { get; set; } + + public string TaskCode { get; set; } + + public string TaskName { get; set; } + public string TaskBlindName { get; set; } + + public ReadingCategory ReadingCategory { get; set; } + + public TaskAllocationState TaskAllocationState { get; set; } + public TaskState TaskState { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs index f4984860b..68725a224 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs @@ -77,7 +77,7 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{taskAllocationRuleId:guid}/{isJudgeDoctor:bool}")] - public async Task DeleteTaskAllocationRule(Guid taskAllocationRuleId, bool isJudgeDoctor ) + public async Task DeleteTaskAllocationRule( Guid taskAllocationRuleId, bool isJudgeDoctor ) { if(await _taskAllocationRuleRepository.Where(t => t.Id == taskAllocationRuleId ).AnyAsync(t => t.DoctorVisitTaskList.Where(t=>isJudgeDoctor?t.ArmEnum==Domain.Share.Arm.JudgeArm: t.ArmEnum != Domain.Share.Arm.JudgeArm).Count() > 0)) { diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index d133ec576..8a8ddb6e9 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -228,10 +228,42 @@ namespace IRaCIS.Core.Application.Service } - //public async Task> GetSelfConsistentList(SelfConsistentQuery inQuery) - //{ + public async Task> GetSelfConsistentList(SelfConsistentQuery inQuery) + { + var query = _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 => new { t.SubjectId, t.Subject.SiteId, t.Subject.Code, t.TrialId, t.Subject.TrialSite.TrialSiteCode }) + .Select(g => new SelfConsistentView() + { + SubjectId = g.Key.SubjectId, + TrialId = g.Key.TrialId, + SubjectCode = g.Key.Code, + TrialSiteCode = g.Key.TrialSiteCode, + SiteId = g.Key.SiteId, - //} + VisitTaskList = g.OrderBy(t=>t.SubjectVisit.VisitNum).Select(c=>new VisitTaskSimpleView() + { + Id=c.Id, + ReadingCategory=c.ReadingCategory, + TaskAllocationState=c.TaskAllocationState, + TaskBlindName=c.TaskBlindName, + TaskCode =c.TaskCode, + TaskName=c.TaskName, + TaskState=c.TaskState, + TrialId=c.TrialId + }).ToList(), + + VisitValidTaskCount = g.Count() + + }); + + return query.ToList(); + } @@ -616,7 +648,7 @@ namespace IRaCIS.Core.Application.Service } else { - throw new BusinessValidationFailedException("当前提交 Subject 以及医生所在Arm 与任务的Arm不一致,无法绑定,请核对数据"); + throw new BusinessValidationFailedException("在配置表中未找到配置的医生,无法应用绑定,请核对数据"); } } diff --git a/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs b/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs index bb9904e1c..0aea00e4a 100644 --- a/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs +++ b/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs @@ -50,7 +50,7 @@ namespace IRaCIS.Core.Domain.Share JudgeArm = 3, - TumorArm=4, + TumorArm = 4, } /// @@ -98,10 +98,10 @@ namespace IRaCIS.Core.Domain.Share public enum TaskState { //有效 - Effect=0, + Effect = 0, //未生效 - NotEffect=1, + NotEffect = 1, // 裁判任务,没做,或者做了没签名 废弃 Adbandon = 3, @@ -119,7 +119,7 @@ namespace IRaCIS.Core.Domain.Share HaveSigned = 2, - + } // @@ -149,7 +149,7 @@ namespace IRaCIS.Core.Domain.Share { Default = 0, - HaveApplyed=1, + HaveApplyed = 1, Agree = 2, diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index e0a124c12..0bb998ef4 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -88,7 +88,7 @@ namespace IRaCIS.Core.Infra.EFCore //modelBuilder.HasDbFunction(typeof(DbContext).GetMethod(nameof(GetTableList))); - modelBuilder.Entity().HasMany(t => t.DoctorVisitTaskList).WithOne(t => t.DoctorTaskAllocationRule).HasForeignKey(t=>t.DoctorUserId).HasPrincipalKey(u=>u.DoctorUserId); + modelBuilder.Entity().HasMany(t => t.DoctorVisitTaskList).WithOne(t => t.DoctorTaskAllocationRule).HasForeignKey(t=> new { t.DoctorUserId,t.TrialId } ).HasPrincipalKey(u=> new { u.DoctorUserId,u.TrialId }); modelBuilder.Entity().HasMany(t => t.SubjectArmVisitTaskList).WithOne(t=>t.SujectArm).HasForeignKey(t => new { t.SubjectId,t.ArmEnum}).HasPrincipalKey(u => new { u.SubjectId,u.ArmEnum }); modelBuilder.Entity().HasMany(t => t.JudgeVisitList).WithOne(t=>t.JudgeVisitTask);