diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitFinalVisitTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitFinalVisitTrigger.cs index 0715165cc..96208ed59 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitFinalVisitTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitFinalVisitTrigger.cs @@ -132,10 +132,10 @@ namespace IRaCIS.Core.Application.Triggers SubjectVisitId = subjectVisitId, ReadingPeriodSetId = readingPeriodSet.Id, }); - - // 当前访视没有阅片期才添加 - if (!await _readModuleRepository.AnyAsync(x => x.SubjectVisitId == subjectVisitId && x.ReadingSetType == ReadingSetType.ImageReading)) - { + + + await _readModuleRepository.DeleteFromQueryAsync(x => x.ReadingSetType == ReadingSetType.ImageReading && x.SubjectVisitId == subjectVisitId, true); + await _readModuleRepository.AddAsync(new ReadModule() { ReadingPeriodSetId = readingPeriodSet.Id, @@ -149,7 +149,7 @@ namespace IRaCIS.Core.Application.Triggers TrialId = subjectVisit.TrialId, VisitNum = subjectVisit.VisitNum, }); - } + await _readModuleRepository.SaveChangesAsync(); }