diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 9b02ef678..3b5e60af4 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -3078,6 +3078,13 @@ + + + 获取选中的计划 + + + + 分页获取 diff --git a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs index 3be4b184a..837da754b 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs @@ -182,7 +182,7 @@ namespace IRaCIS.Application.Services /// public async Task> GetSubjectReadVisits(GetSubjectReadVisitsInDto inDto) { - var visitquery = _subjectVisitRepository.Where(x => x.SubjectId == inDto.SubjectId && x.LatestScanDate != null); + var visitquery = _subjectVisitRepository.Where(x => x.SubjectId == inDto.SubjectId && x.SubmitState != SubmitStateEnum.None); var finalVisitNum = await visitquery.Where(x => x.IsFinalVisit).Select(x => x.VisitNum).FirstOrDefaultAsync(); diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs index e88ae9c47..6ac11916a 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs @@ -84,8 +84,12 @@ namespace IRaCIS.Application.Services /// public async Task> GetPreviewTheReadingList(PreviewTheReadingListInDto inDto) { + if (await _readingPeriodPlanRepository.AnyAsync(x => x.ReadingPeriodSetId == inDto.ReadingPeriodSetId)) + { + return await GetPreviewTheReadingPlanList(inDto); + } var readset = (await _readingPeriodSetRepository.Where(x => x.Id == inDto.ReadingPeriodSetId).Include(x => x.ReadingPeriodSites).FirstOrDefaultAsync()).IfNullThrowConvertException(); - var visitquery = _subjectVisitRepository.Where(x => x.TrialId == readset.TrialId && x.LatestScanDate != null && x.InPlan); + var visitquery = _subjectVisitRepository.Where(x => x.TrialId == readset.TrialId && x.SubmitState != SubmitStateEnum.None && x.InPlan); if (readset.ReadingScope == ReadingScopeEnum.Site) { var siteids = readset.ReadingPeriodSites.Select(x => x.SiteId); @@ -180,7 +184,8 @@ namespace IRaCIS.Application.Services ReadingPeriodSetId = inDto.ReadingPeriodSetId }); }); - + await _readingPeriodPlanRepository.DeleteFromQueryAsync(x => x.ReadingPeriodSetId == inDto.ReadingPeriodSetId); + await _readingPeriodPlanRepository.SaveChangesAsync(); await _readingPeriodPlanRepository.AddRangeAsync(plans); var res = await _readingPeriodPlanRepository.SaveChangesAsync(); return ResponseOutput.Result(res); @@ -196,10 +201,10 @@ namespace IRaCIS.Application.Services var plans =await _readingPeriodPlanRepository.Where(x => x.ReadingPeriodSetId == inDto.ReadingPeriodSetId).Include(x => x.SubjectVisit).Include(x => x.SubjectVisit.TrialSite).Include(x => x.SubjectVisit.Subject) .Include(x => x.ReadingPeriodSet).ToListAsync(); - return plans.Select(x => new PreviewTheReadingListOutDto + return plans.Select(x => new PreviewTheReadingListOutDto { ExpirationDate = x.ReadingPeriodSet.ExpirationDate, - SubjectVisitId = x.Id, + SubjectVisitId = x.SubjectVisitId, TrialSiteCode = x.SubjectVisit.TrialSite.TrialSiteCode, LatestScanDate =x.SubjectVisit.LatestScanDate, ReadingPeriodName = x.ReadingPeriodSet.ReadingPeriodName, @@ -207,6 +212,7 @@ namespace IRaCIS.Application.Services SubjectCode = x.SubjectVisit.Subject.Code, SubjectId = x.SubjectVisit.SubjectId, SubjectVisitName = x.SubjectVisit.VisitName, + //Remark= readset.Remark }).ToList(); } @@ -258,6 +264,8 @@ namespace IRaCIS.Application.Services var plans = _readingPeriodPlanRepository.Where(x => x.ReadingPeriodSetId == indto.Id).Include(x=>x.SubjectVisit) .Include(x => x.ReadingPeriodSet).ToList(); + plans = plans.Where(x => _readModuleRepository.Where(y => x.SubjectVisitId == y.SubjectVisitId && x.ReadingPeriodSet.ReadingSetType == y.ReadingSetType).Count() == 0).ToList(); + List readModules = new List(); foreach (var item in plans) { diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index 0bca3bbdb..9a1d69528 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -8,6 +8,7 @@ using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Application.Auth; +using IRaCIS.Core.Domain.Share.Reading; namespace IRaCIS.Core.Application.Services { @@ -15,11 +16,15 @@ namespace IRaCIS.Core.Application.Services public class SubjectVisitService : BaseService, ISubjectVisitService { private readonly IRepository _subjectVisitRepository; + private readonly IRepository _readModuleRepository; private readonly IRepository _subjectRepository; - public SubjectVisitService(IRepository subjectVisitRepository, IRepository subjectRepository) + public SubjectVisitService(IRepository subjectVisitRepository, + IRepository readModuleRepository, + IRepository subjectRepository) { _subjectVisitRepository = subjectVisitRepository; + this._readModuleRepository = readModuleRepository; _subjectRepository = subjectRepository; } @@ -74,6 +79,7 @@ namespace IRaCIS.Core.Application.Services else { dbBeforeEntity = await _subjectVisitRepository.UpdateFromDTOAsync(svCommand, false, false, verifyExp1, verifyExp2, verifyExp3); + if (svCommand.PDState != dbBeforeEntity.PDState && dbBeforeEntity.SubmitState == SubmitStateEnum.Submitted) { @@ -92,6 +98,21 @@ namespace IRaCIS.Core.Application.Services throw new BusinessValidationFailedException("当前访视已经有有影像上传,不允许设置为失访。"); } } + + //// 末次访视添加全局阅片 + //if (dbBeforeEntity.IsFinalVisit == false && svCommand.IsFinalVisit == true) + //{ + // if (!await _readModuleRepository.AnyAsync(x => x.SubjectVisitId == svCommand.Id && x.ReadingSetType == ReadingSetType.ImageReading)) + // { + // _readModuleRepository.AddAsync(new ReadModule() + // { + // IsUrgent= dbBeforeEntity.IsUrgent, + // SubjectVisitId= svCommand.Id.Value, + // Status= + + // }); + // } + //} }