diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index cb327e48f..3529b86ad 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -965,6 +965,11 @@ 创建时间 + + + 生效时间 + + 创建人 diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs index 68289fc89..1c628bff3 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs @@ -260,6 +260,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// public int PlanCount { get; set; } + public bool IsGlobal { get; set; } + } public class SetReadingPeriodSetEffect diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs index 21b920786..a9d4f3847 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs @@ -233,7 +233,7 @@ namespace IRaCIS.Application.Services SubjectCode = x.SubjectVisit.Subject.Code, SubjectId = x.SubjectVisit.SubjectId, SubjectVisitName = x.SubjectVisit.VisitName, - EffectOfTime=x.ReadingPeriodSet.EffectOfTime, + EffectOfTime=x.ReadingPeriodSet.EffectOfTime, }); return await plans.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, inDto.SortField == null ? "SubjectId" : inDto.SortField, diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index 250590aa2..5fb3a76cd 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -19,18 +19,21 @@ namespace IRaCIS.Core.Application.Services { private readonly IRepository _subjectVisitRepository; private readonly IRepository _readModuleRepository; + private readonly IRepository _trialRepository; private readonly IRepository _readingPeriodSetRepository; private readonly IRepository _readingPeriodPlanRepository; private readonly IRepository _subjectRepository; public SubjectVisitService(IRepository subjectVisitRepository, IRepository readModuleRepository, + IRepository trialRepository, IRepository readingPeriodSetRepository, IRepository readingPeriodPlanRepository, IRepository subjectRepository) { _subjectVisitRepository = subjectVisitRepository; this._readModuleRepository = readModuleRepository; + this._trialRepository = trialRepository; this._readingPeriodSetRepository = readingPeriodSetRepository; this._readingPeriodPlanRepository = readingPeriodPlanRepository; _subjectRepository = subjectRepository; @@ -107,48 +110,56 @@ namespace IRaCIS.Core.Application.Services } } - // 末次访视添加全局阅片 - if (dbBeforeEntity.IsFinalVisit == false && svCommand.IsFinalVisit == true) + // 是否全局阅片 + var isGlobalReading = await _trialRepository.Where(x => x.Id == dbBeforeEntity.TrialId).Select(x => x.IsGlobalReading).FirstOrDefaultAsync(); + if (isGlobalReading) { - - ReadingPeriodSet? readingPeriodSet =await _readingPeriodSetRepository.FirstOrDefaultNoTrackingAsync(x => x.TrialId == dbBeforeEntity.TrialId && x.ReadingPeriodName == "Global"); - - if (readingPeriodSet == null) + // 末次访视添加全局阅片 + if (dbBeforeEntity.IsFinalVisit == false && svCommand.IsFinalVisit == true) { - readingPeriodSet = new ReadingPeriodSet() + + ReadingPeriodSet? readingPeriodSet = await _readingPeriodSetRepository.FirstOrDefaultNoTrackingAsync(x => x.TrialId == dbBeforeEntity.TrialId && x.ReadingPeriodName == "Global"); + + if (readingPeriodSet == null) { - Id = NewId.NextGuid(), - ReadingScope = ReadingScopeEnum.All, - ReadingSetType = ReadingSetType.ImageReading, - IsTakeEffect = ReadingPeriodStatus.TakeEffect, - ReadingPeriodName = "Global", - TrialId = dbBeforeEntity.TrialId, - }; + readingPeriodSet = new ReadingPeriodSet() + { + Id = NewId.NextGuid(), + ReadingScope = ReadingScopeEnum.All, + ReadingSetType = ReadingSetType.ImageReading, + IsTakeEffect = ReadingPeriodStatus.TakeEffect, + ReadingPeriodName = "Global", + TrialId = dbBeforeEntity.TrialId, + EffectOfTime = DateTime.Now, + IsGlobal = true, + }; - await _readingPeriodSetRepository.AddAsync(readingPeriodSet); + await _readingPeriodSetRepository.AddAsync(readingPeriodSet); - } + } - await _readingPeriodPlanRepository.AddAsync(new ReadingPeriodPlan() - { - SubjectVisitId = dbBeforeEntity.Id, - ReadingPeriodSetId = readingPeriodSet.Id, - }); - - // 当前访视没有阅片期才添加 - if (!await _readModuleRepository.AnyAsync(x => x.SubjectVisitId == svCommand.Id && x.ReadingSetType == ReadingSetType.ImageReading)) - { - await _readModuleRepository.AddAsync(new ReadModule() + await _readingPeriodPlanRepository.AddAsync(new ReadingPeriodPlan() { - IsUrgent = dbBeforeEntity.IsUrgent, - SubjectVisitId = svCommand.Id.Value, - Status = ReadModuleEnum.TaskAllocation, - SubjectId = dbBeforeEntity.SubjectId, - ModuleName= "Global",// 全局阅片 - ReadingSetType= ReadingSetType.ImageReading, - ModuleType=ModuleTypeEnum.Global, + SubjectVisitId = dbBeforeEntity.Id, + ReadingPeriodSetId = readingPeriodSet.Id, }); + + // 当前访视没有阅片期才添加 + if (!await _readModuleRepository.AnyAsync(x => x.SubjectVisitId == svCommand.Id && x.ReadingSetType == ReadingSetType.ImageReading)) + { + await _readModuleRepository.AddAsync(new ReadModule() + { + ReadingPeriodSetId = readingPeriodSet.Id, + IsUrgent = dbBeforeEntity.IsUrgent, + SubjectVisitId = svCommand.Id.Value, + Status = ReadModuleEnum.TaskAllocation, + SubjectId = dbBeforeEntity.SubjectId, + ModuleName = "Global",// 全局阅片 + ReadingSetType = ReadingSetType.ImageReading, + ModuleType = ModuleTypeEnum.Global, + }); + } } } } diff --git a/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs b/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs index 3fea312fc..090198b6f 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs @@ -72,6 +72,11 @@ namespace IRaCIS.Core.Domain.Models /// public Guid CreateUserId { get; set; } + /// + /// 是否为全局阅片 + /// + public bool IsGlobal { get; set; } + /// /// 阅片配置的类型 ///