From 67d2067a28c29f5293d6e8a346e7c1711e0e8a91 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Mon, 5 Jun 2023 18:15:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRECIST1Point1CalculateService.cs | 85 ++++++++++++------- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs index 225b8ec65..dc3a51093 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs @@ -1373,11 +1373,21 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// public async Task GetComparedTriggeringSODChange(ReadingCalculateDto inDto) { - var compareTaskId = await this.GetCompareTaskId(inDto,QuestionType.TargetLesion); + var compareTaskId = await this.GetCompareTaskId(inDto, QuestionType.TargetLesion); if (compareTaskId == null) { return string.Empty; } + + var lastTaskId = await GetLastVisitTaskId(inDto); + // 靶病灶评估为IUPD或者ICPD + + var targetLesionIsIUorIC = await _readingTaskQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == lastTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.TargetLesion && (x.Answer==TargetAssessment.iUPD.GetEnumInt()|| x.Answer==TargetAssessment.iCPD.GetEnumInt())); + if (!targetLesionIsIUorIC) + { + return string.Empty; + } + var compareTaskSOD = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == compareTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.SOD).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); var value = await GetSODData(inDto); @@ -1458,6 +1468,16 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate return string.Empty; } + + var lastTaskId = await GetLastVisitTaskId(inDto); + + // 新靶病灶为IUPD或者ICPD + var newTargetLesionIsIUorIC = await _readingTaskQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == lastTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.NewTargetLesion && (x.Answer==NewTargetLesionAssessment.iUPD.GetEnumInt() || x.Answer==NewTargetLesionAssessment.iCPD.GetEnumInt())); + if (!newTargetLesionIsIUorIC) + { + return string.Empty; + } + var compareTaskiSOD = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == compareTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.ISOD).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); var value = await GetiSODData(inDto); @@ -1758,55 +1778,54 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate QuestionType = x.ReadingQuestionTrial.QuestionType.Value }).ToListAsync(); - compareTaskList.ForEach(x => + compareTaskList.ForEach(y => { - x.TargetAssessmentIsIUorIC = answers.Any(x => questionType == QuestionType.TargetLesion && (x.Answer == TargetAssessment.iUPD.GetEnumInt() || x.Answer == TargetAssessment.iCPD.GetEnumInt())); - x.NewTargetLesionAssessmentIsIUorIC = answers.Any(x => questionType == QuestionType.NewTargetLesion && (x.Answer == NewTargetLesionAssessment.iUPD.GetEnumInt() || x.Answer == NewTargetLesionAssessment.iCPD.GetEnumInt())); + y.TargetAssessmentIsIUorIC = answers.Any(x =>x.VisitTaskId==y.VisitTaskId && x.QuestionType == QuestionType.TargetLesion && (x.Answer == TargetAssessment.iUPD.GetEnumInt() || x.Answer == TargetAssessment.iCPD.GetEnumInt())); + y.NewTargetLesionAssessmentIsIUorIC = answers.Any(x => x.VisitTaskId == y.VisitTaskId && x.QuestionType == QuestionType.NewTargetLesion && (x.Answer == NewTargetLesionAssessment.iUPD.GetEnumInt() || x.Answer == NewTargetLesionAssessment.iCPD.GetEnumInt())); }); } - - - - - - Guid? compareTaskId = null; if(compareTaskList.Count()==0) { return compareTaskId; } - int index = 0; switch (questionType) { case QuestionType.TargetLesion: - index = compareTaskList.FindLastIndex(x => x.TargetAssessmentIsIUorIC); - if (index == -1) + + for (int i = compareTaskList.Count()-1; i>=0; i--) { - return compareTaskList[0].VisitTaskId; - } - else if (index > 0 && !compareTaskList[index-1].TargetAssessmentIsIUorIC) - { - return compareTaskList[index-1].VisitTaskId; - } - else - { - return compareTaskList[0].VisitTaskId; + if (i == 0) + { + return compareTaskList[0].VisitTaskId; + } + else + { + if (compareTaskList[i].TargetAssessmentIsIUorIC && !compareTaskList[i - 1].TargetAssessmentIsIUorIC) + { + return compareTaskList[i].VisitTaskId; + } + } } + break; case QuestionType.NewTargetLesion: - index = compareTaskList.FindLastIndex(x => x.NewTargetLesionAssessmentIsIUorIC); - if (index == -1) + + for (int i = compareTaskList.Count() - 1; i >= 0; i--) { - return compareTaskList[0].VisitTaskId; - } - else if (index > 0 && !compareTaskList[index - 1].NewTargetLesionAssessmentIsIUorIC) - { - return compareTaskList[index - 1].VisitTaskId; - } - else - { - return compareTaskList[0].VisitTaskId; + if (i == 0) + { + return compareTaskList[0].VisitTaskId; + } + else + { + if (compareTaskList[i].NewTargetLesionAssessmentIsIUorIC && !compareTaskList[i - 1].NewTargetLesionAssessmentIsIUorIC) + { + return compareTaskList[i].VisitTaskId; + } + } } + break; }