diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs index 2ea403ce3..64f158160 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs @@ -7,6 +7,7 @@ using System; using IRaCIS.Core.Domain.Share; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using IRaCIS.Application.Contracts; namespace IRaCIS.Core.Application.ViewModel { @@ -100,7 +101,14 @@ namespace IRaCIS.Core.Application.ViewModel public UserSimpleInfo DoctorUser { get; set; } - public List ReadingCategoryList { get; set; } + //public List ReadingCategoryList { get; set; } + + public List TrialReadingCriterionList { get; set; } + public List CriterionReadingCategoryList { get; set; } + + public List CriterionCategoryList => CriterionReadingCategoryList + .GroupBy(t => new { t.TrialReadingCriterionId, t.EnrollId }) + .Select(g => new CriterionReadingCategory() { EnrollId = g.Key.EnrollId, TrialReadingCriterionId = g.Key.TrialReadingCriterionId, ReadingCategorys = g.Select(t => t.ReadingCategory).ToList() }).ToList(); } diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 3de90f497..5fc47954e 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -67,7 +67,10 @@ namespace IRaCIS.Core.Application.Service CreateMap() .ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.Enroll.DoctorUser)) - .ForMember(o => o.ReadingCategoryList, t => t.MapFrom(u => u.Enroll.EnrollReadingCategoryList.OrderBy(t => t.ReadingCategory).Select(t => t.ReadingCategory).ToList())); + .ForMember(o => o.CriterionReadingCategoryList, t => t.MapFrom(u => u.Enroll.EnrollReadingCategoryList.Select(t => new TrialCriterionReadingCategory() { EnrollId = t.EnrollId, ReadingCategory = t.ReadingCategory, TrialReadingCriterionId = t.TrialReadingCriterionId }))) + .ForMember(o => o.TrialReadingCriterionList, t => t.MapFrom(u => u.Trial.ReadingQuestionCriterionTrialList.Where(t => t.IsConfirm).Select(t => new TrialReadingCriterionDto() { TrialReadingCriterionId = t.Id, TrialReadingCriterionName = t.CriterionName }))) + //.ForMember(o => o.ReadingCategoryList, t => t.MapFrom(u => u.Enroll.EnrollReadingCategoryList.OrderBy(t => t.ReadingCategory).Select(t => t.ReadingCategory).ToList())) + ; CreateMap().IncludeBase() .ForMember(o => o.AssignedSubjectCount, t => t.MapFrom(u => u.DoctorUser.VisitTaskList.Where(t => t.TrialId == u.TrialId).Select(t => t.SubjectId).Distinct().Count())) diff --git a/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs b/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs index 33619e865..35c137ff1 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/DTO/DoctorWorkLoadViewModel.cs @@ -145,9 +145,11 @@ namespace IRaCIS.Application.Contracts [NotDefault] public Guid EnrollId { get; set; } - public Guid TrialId { get; set; } + [NotDefault] + public Guid TrialReadingCriterionId { get; set; } + public List ReadingCategorys { get; set; } } @@ -252,12 +254,43 @@ namespace IRaCIS.Application.Contracts public string? AgreementFileName => AgreementPath?.Split('/').Last(); - public string AgreementFullPath => AgreementPath; + public string AgreementFullPath => AgreementPath; + //public List ReadingCategorys { get; set; } + + public List TrialReadingCriterionList { get; set; } + + public List CriterionReadingCategoryList { get; set; } + + + public List CriterionCategoryList => CriterionReadingCategoryList + .GroupBy(t => new { t.TrialReadingCriterionId, t.EnrollId }) + .Select(g => new CriterionReadingCategory() { EnrollId = g.Key.EnrollId, TrialReadingCriterionId = g.Key.TrialReadingCriterionId, ReadingCategorys = g.Select(t => t.ReadingCategory).ToList() }); + } + + public class TrialReadingCriterionDto + { + public Guid TrialReadingCriterionId { get; set; } + public string TrialReadingCriterionName { get; set; } + } + + public class TrialCriterionReadingCategory + { + public Guid EnrollId { get; set; } + public Guid TrialReadingCriterionId { get; set; } + public ReadingCategory ReadingCategory { get; set; } + } + + + + public class CriterionReadingCategory + { + public Guid EnrollId { get; set; } + public Guid TrialReadingCriterionId { get; set; } + public List ReadingCategorys { get; set; } } - } \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs index de32d24b5..84490f8cf 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/DoctorWorkloadService.cs @@ -110,10 +110,10 @@ namespace IRaCIS.Application.Services var enroll = await _enrollRepository.FirstAsync(t => t.Id == inDto.EnrollId); - if (_repository.Where(t => t.TrialId == enroll.TrialId && t.DoctorUserId == enroll.DoctorUserId && t.TaskAllocationState == TaskAllocationState.Allocated).Any()) + if (_repository.Where(t => t.TrialId == enroll.TrialId && t.DoctorUserId == enroll.DoctorUserId && t.TaskAllocationState == TaskAllocationState.Allocated && t.TrialReadingCriterionId==inDto.TrialReadingCriterionId).Any()) { - var readingCategoryList = await _enrollReadingCategoryRepository.Where(t => t.EnrollId == inDto.EnrollId).Select(t => t.ReadingCategory).ToListAsync(); + var readingCategoryList = await _enrollReadingCategoryRepository.Where(t => t.EnrollId == inDto.EnrollId && t.TrialReadingCriterionId == inDto.TrialReadingCriterionId).Select(t => t.ReadingCategory).ToListAsync(); if (readingCategoryList.Except(inDto.ReadingCategorys).Count() > 0) { @@ -133,7 +133,7 @@ namespace IRaCIS.Application.Services // await _enrollReadingCategoryRepository.DeleteFromQueryAsync(x => x.EnrollId == inDto.EnrollId); //} - await _enrollReadingCategoryRepository.DeleteFromQueryAsync(x => x.EnrollId == inDto.EnrollId); + await _enrollReadingCategoryRepository.DeleteFromQueryAsync(x => x.EnrollId == inDto.EnrollId && x.TrialReadingCriterionId == inDto.TrialReadingCriterionId); List enrollReadings = inDto.ReadingCategorys.Select(x => new EnrollReadingCategory() @@ -222,7 +222,10 @@ namespace IRaCIS.Application.Services EnrollId = intoGroup.Id, IsEnable = allocateRule.IsEnable, - ReadingCategorys = intoGroup.EnrollReadingCategoryList.Select(x => x.ReadingCategory).OrderBy(x => x).ToList(), + TrialReadingCriterionList = intoGroup.Trial.ReadingQuestionCriterionTrialList.Where(t=>t.IsConfirm).Select(t=>new TrialReadingCriterionDto() { TrialReadingCriterionId=t.Id,TrialReadingCriterionName=t.CriterionName}).ToList(), + + CriterionReadingCategoryList=intoGroup.EnrollReadingCategoryList.Select(t=>new TrialCriterionReadingCategory() { EnrollId=t.EnrollId,ReadingCategory=t.ReadingCategory, TrialReadingCriterionId = t.TrialReadingCriterionId }).ToList(), + DoctorId = doctor.Id, Code = doctor.ReviewerCode, FirstName = doctor.FirstName, diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs index e76d259b7..6818074ba 100644 --- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs +++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs @@ -78,6 +78,7 @@ namespace IRaCIS.Core.Domain.Models public Guid? DoctorUserId { get; set; } + public Guid TrialReadingCriterionId { get; set; } diff --git a/IRaCIS.Core.Domain/SQLFile/Sql脚本.sql b/IRaCIS.Core.Domain/SQLFile/Sql脚本.sql index 949e824d2..9c7cff7e5 100644 --- a/IRaCIS.Core.Domain/SQLFile/Sql脚本.sql +++ b/IRaCIS.Core.Domain/SQLFile/Sql脚本.sql @@ -42,3 +42,9 @@ update SystemDocConfirmedUser set CreateUserId=ConfirmUserId,CreateTime=getdat update TrialDocUserTypeConfirmedUser set IsDeleted=0 where IsDeleted is null update SystemDocConfirmedUser set IsDeleted=0 where IsDeleted is null + +update EnrollReadingCategory set TrialReadingCriterionId=(select top 1 Id from ReadingQuestionCriterionTrial where IsConfirm=1) +update VisitTask set TrialReadingCriterionId=(select top 1 Id from ReadingQuestionCriterionTrial where IsConfirm=1) +select * from EnrollReadingCategory where TrialReadingCriterionId is null +select * from VisitTask where TrialReadingCriterionId is null + diff --git a/IRaCIS.Core.Domain/Trial/EnrollReadingCategory.cs b/IRaCIS.Core.Domain/Trial/EnrollReadingCategory.cs index e0698b1a0..6cf112e7c 100644 --- a/IRaCIS.Core.Domain/Trial/EnrollReadingCategory.cs +++ b/IRaCIS.Core.Domain/Trial/EnrollReadingCategory.cs @@ -9,35 +9,38 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace IRaCIS.Core.Domain.Models { - /// - ///EnrollReadingCategory - /// - [Table("EnrollReadingCategory")] - public class EnrollReadingCategory : Entity, IAuditAdd - { - /// + /// + ///EnrollReadingCategory + /// + [Table("EnrollReadingCategory")] + public class EnrollReadingCategory : Entity, IAuditAdd + { + /// /// EnrollId /// - public Guid EnrollId { get; set; } - - /// + public Guid EnrollId { get; set; } + + /// /// ReadingCategory /// - public ReadingCategory ReadingCategory { get; set; } - - /// + public ReadingCategory ReadingCategory { get; set; } + + + public Guid TrialReadingCriterionId { get; set; } + + /// /// CreateUserId /// - public Guid CreateUserId { get; set; } - - /// + public Guid CreateUserId { get; set; } + + /// /// CreateTime /// - public DateTime CreateTime { get; set; } + public DateTime CreateTime { get; set; } [JsonIgnore] - [ForeignKey("EnrollId")] - public Enroll Enroll { get; set; } - } + [ForeignKey("EnrollId")] + public Enroll Enroll { get; set; } + } -} +}