diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index c96da135b..cb327e48f 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -865,6 +865,11 @@ 阅片期名称 + + + 类型 + + 获取影像阅片预览的Dto diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs index b6b111a70..68289fc89 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingPeriodSetViewModel.cs @@ -82,7 +82,6 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public class PreviewTheReadingListInDto : PageInput { - /// /// 中心ID /// @@ -113,6 +112,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// public string ReadingPeriodName { get; set; } + /// + /// 类型 + /// + public ReadingSetType ReadingSetType { get; set; } + } @@ -171,6 +175,9 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public string SubjectVisitName { get; set; } + public DateTime? EffectOfTime { get; set; } + + } public class ReadingPeriodSetView @@ -221,6 +228,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// public DateTime CreateTime { get; set; } + /// + /// 生效时间 + /// + public DateTime? EffectOfTime { get; set; } + /// /// 创建人 /// diff --git a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs index 2f3f85681..f7601135f 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs @@ -420,6 +420,7 @@ namespace IRaCIS.Application.Services ModuleName = dto.Name, SubjectVisitId = visit.Id, ReadingSetType= dto.ReadingSetType, + TrialId= dto.TrialId, Status = ReadingCommon.GetVisitSubmitStateEnum(visit), }); diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs index 6c8866b23..21b920786 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs @@ -49,6 +49,14 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task AddOrUpdateReadingPeriodSet(ReadingPeriodSetAddOrEdit addOrEditReadingPeriodSet) { + if (await _readingPeriodSetRepository.AnyAsync(x => x.Id != addOrEditReadingPeriodSet.Id && x.ReadingPeriodName == addOrEditReadingPeriodSet.ReadingPeriodName)) + { + return ResponseOutput.NotOk("阅片期名称重复,操作失败"); + } + if (addOrEditReadingPeriodSet.ReadingPeriodName == "Global") + { + return ResponseOutput.NotOk("阅片期名称不能为"); + } if (addOrEditReadingPeriodSet.Id == null) { var entity = _mapper.Map(addOrEditReadingPeriodSet); @@ -113,9 +121,18 @@ namespace IRaCIS.Application.Services { visitQuery = visitQuery.Where(x => inDto.SiteIds.Contains(x.SiteId)); + } - visitQuery = visitQuery.WhereIf(inDto.ExpirationDate != null, x => x.LatestScanDate <= inDto.ExpirationDate.Value) + + //var + var existsBubjectVisits = await _readModuleRepository.Where(y => y.ReadingSetType == inDto.ReadingSetType && y.TrialId == inDto.TrialId).Select(x => x.SubjectVisitId).ToListAsync(); + visitQuery = visitQuery.Where(x => existsBubjectVisits.Where(y =>x.Id == y).Count() == 0) + .WhereIf(inDto.ExpirationDate != null, x => x.LatestScanDate <= inDto.ExpirationDate.Value) .WhereIf(inDto.ExpirationVisitNum != null, x => x.VisitNum == inDto.ExpirationVisitNum); + + + + var subjectIdlist = await visitQuery.OrderBy(x => x.SubjectId).Select(x => x.SubjectId).Distinct().Skip((inDto.PageIndex - 1) * inDto.PageSize).Take(inDto.PageSize).ToListAsync(); var totalCount = visitQuery.Select(x => x.SubjectId).Distinct().Count(); var visitlist= await visitQuery.Include(x=>x.Subject).Include(x=>x.TrialSite).Where(x => subjectIdlist.Contains(x.SubjectId)).ToListAsync(); @@ -216,7 +233,8 @@ namespace IRaCIS.Application.Services SubjectCode = x.SubjectVisit.Subject.Code, SubjectId = x.SubjectVisit.SubjectId, SubjectVisitName = x.SubjectVisit.VisitName, - }); + EffectOfTime=x.ReadingPeriodSet.EffectOfTime, + }); return await plans.ToPagedListAsync(inDto.PageIndex, inDto.PageSize, inDto.SortField == null ? "SubjectId" : inDto.SortField, inDto.Asc); @@ -237,6 +255,11 @@ namespace IRaCIS.Application.Services .ProjectTo(_mapper.ConfigurationProvider); var pageList= await readQuery.ToPagedListAsync(query.PageIndex, query.PageSize, query.SortField == null ? "CreateTime" : query.SortField, query.Asc); + + pageList.CurrentPageData.ForEach(x => + { + x.SubjectVisitName = x.ReadingPeriodName == "Global" ? "末次访视" : x.SubjectVisitName; + }); return pageList; } @@ -266,10 +289,12 @@ namespace IRaCIS.Application.Services { if (indto.IsTakeEffect == ReadingPeriodStatus.TakeEffect) { + var readingPeriodSet =await _readingPeriodSetRepository.FirstOrDefaultAsync(x => x.Id == indto.Id); var plans = _readingPeriodPlanRepository.Where(x => x.ReadingPeriodSetId == indto.Id).Include(x=>x.SubjectVisit) .Include(x => x.ReadingPeriodSet).ToList(); var needAddVisitIds = plans.Select(x => x.SubjectVisitId).ToList(); - var repeatVisitNames = _readModuleRepository.Where(x => x.ReadingSetType == ReadingSetType.ImageReading && needAddVisitIds.Contains(x.SubjectVisitId)).Select(x => x.SubjectVisit.VisitName).ToList(); + var repeatVisitNames = _readModuleRepository.Where(x => x.ReadingSetType == ReadingSetType.ImageReading && needAddVisitIds.Contains(x.SubjectVisitId)).Select(x =>x.Subject.Code+"的"+ x.SubjectVisit.VisitName).ToList(); + if(repeatVisitNames.Count!=0) { return ResponseOutput.NotOk($"{string.Join(",", repeatVisitNames)}已经添加过阅片期,无法设置生效"); @@ -288,7 +313,8 @@ namespace IRaCIS.Application.Services SubjectVisitId = item.SubjectVisitId, ReadingSetType = item.ReadingPeriodSet.ReadingSetType, ReadingPeriodSetId= item.ReadingPeriodSet.Id, - Status = ReadingCommon.GetVisitSubmitStateEnum(item.SubjectVisit), + Status = ReadModuleEnum.TaskAllocation, + TrialId = readingPeriodSet.TrialId, }); }; @@ -300,7 +326,8 @@ namespace IRaCIS.Application.Services } var readQuery =await _readingPeriodSetRepository.UpdatePartialFromQueryAsync(indto.Id, x => new ReadingPeriodSet() { - IsTakeEffect = indto.IsTakeEffect + IsTakeEffect = indto.IsTakeEffect, + EffectOfTime= indto.IsTakeEffect== ReadingPeriodStatus.TakeEffect?DateTime.Now:null, }); var result = await _readingPeriodSetRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index e38553142..250590aa2 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -10,6 +10,7 @@ using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Application.Auth; using IRaCIS.Core.Domain.Share.Reading; using IRaCIS.Core.Infra.EFCore.Common; +using MassTransit; namespace IRaCIS.Core.Application.Services { @@ -18,14 +19,20 @@ namespace IRaCIS.Core.Application.Services { private readonly IRepository _subjectVisitRepository; private readonly IRepository _readModuleRepository; + private readonly IRepository _readingPeriodSetRepository; + private readonly IRepository _readingPeriodPlanRepository; private readonly IRepository _subjectRepository; public SubjectVisitService(IRepository subjectVisitRepository, IRepository readModuleRepository, + IRepository readingPeriodSetRepository, + IRepository readingPeriodPlanRepository, IRepository subjectRepository) { _subjectVisitRepository = subjectVisitRepository; this._readModuleRepository = readModuleRepository; + this._readingPeriodSetRepository = readingPeriodSetRepository; + this._readingPeriodPlanRepository = readingPeriodPlanRepository; _subjectRepository = subjectRepository; } @@ -103,6 +110,32 @@ namespace IRaCIS.Core.Application.Services // 末次访视添加全局阅片 if (dbBeforeEntity.IsFinalVisit == false && svCommand.IsFinalVisit == true) { + + ReadingPeriodSet? readingPeriodSet =await _readingPeriodSetRepository.FirstOrDefaultNoTrackingAsync(x => x.TrialId == dbBeforeEntity.TrialId && x.ReadingPeriodName == "Global"); + + if (readingPeriodSet == null) + { + readingPeriodSet = new ReadingPeriodSet() + { + Id = NewId.NextGuid(), + ReadingScope = ReadingScopeEnum.All, + ReadingSetType = ReadingSetType.ImageReading, + IsTakeEffect = ReadingPeriodStatus.TakeEffect, + ReadingPeriodName = "Global", + TrialId = dbBeforeEntity.TrialId, + }; + + + 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)) { @@ -110,9 +143,9 @@ namespace IRaCIS.Core.Application.Services { IsUrgent = dbBeforeEntity.IsUrgent, SubjectVisitId = svCommand.Id.Value, - Status = ReadingCommon.GetVisitSubmitStateEnum(dbBeforeEntity), + Status = ReadModuleEnum.TaskAllocation, SubjectId = dbBeforeEntity.SubjectId, - ModuleName="G",// 全局阅片 + ModuleName= "Global",// 全局阅片 ReadingSetType= ReadingSetType.ImageReading, ModuleType=ModuleTypeEnum.Global, }); diff --git a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs index 255a7bd3c..7244a023c 100644 --- a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs +++ b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs @@ -113,19 +113,24 @@ namespace IRaCIS.Core.Domain.Share.Reading ImageQuality = 1, /// - /// 一致性核查及分配 + /// 一致性核查 /// ConsistencyCheck = 2, + /// + /// 任务分配 + /// + TaskAllocation = 3, + /// /// 影像阅片 /// - ImageRead = 3, + ImageRead = 4, /// /// 阅片完成 /// - ReadComplete = 4, + ReadComplete = 5, } diff --git a/IRaCIS.Core.Domain/Reading/ReadModule.cs b/IRaCIS.Core.Domain/Reading/ReadModule.cs index 4f2949d2c..971ec63d2 100644 --- a/IRaCIS.Core.Domain/Reading/ReadModule.cs +++ b/IRaCIS.Core.Domain/Reading/ReadModule.cs @@ -70,6 +70,11 @@ namespace IRaCIS.Core.Domain.Models /// public Guid? ReadModuleId { get; set; } + /// + /// 项目ID + /// + public Guid TrialId { get; set; } + /// /// 对应 /// diff --git a/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs b/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs index 0e6e45a84..3fea312fc 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingPeriodSet.cs @@ -52,10 +52,15 @@ namespace IRaCIS.Core.Domain.Models [ForeignKey("VisitStageId")] public VisitStage? VisitStage { get; set; } - /// - /// 是否生效 - /// - public ReadingPeriodStatus IsTakeEffect { get; set; } + /// + /// 是否生效 + /// + public ReadingPeriodStatus IsTakeEffect { get; set; } + + /// + /// 生效时间 + /// + public DateTime? EffectOfTime { get; set; } /// /// 创建时间