diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 1da83f575..1accf30d6 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -1771,6 +1771,13 @@ + + + 计算融合靶病灶的状态 + + + + 计算靶病灶状态 diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index f22e2b2fe..620042d14 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -1435,7 +1435,7 @@ namespace IRaCIS.Application.Services QuestionMark.MajorAxis, QuestionMark.ShortAxis, QuestionMark.State, - + QuestionMark.PPD, }; tableAnswers.ForEach(x => @@ -1468,6 +1468,7 @@ namespace IRaCIS.Application.Services { await VerifyTaskIsSign(inDto.VisitTaskId); await this.VerifyIsBaseLineTask(inDto.VisitTaskId); + var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.MergeMainRowId).Include(x => x.TrialReadingCriterion).FirstNotNullAsync(); var mergeRow = await _readingTableAnswerRowInfoRepository.Where(x => x.Id == inDto.MergeMainRowId).Include(x => x.ReadingQuestionTrial).FirstNotNullAsync(); var mark = mergeRow.ReadingQuestionTrial.OrderMark + mergeRow.RowIndex.GetLesionMark(); @@ -1496,6 +1497,19 @@ namespace IRaCIS.Application.Services VisitTaskId = inDto.VisitTaskId, ComputationTrigger = ComputationTrigger.Lesion, }); + + // 保存完了计算疾病进展 + switch (taskinfo.TrialReadingCriterion.CriterionType) + { + case CriterionType.Lugano2014: + await _luganoCalculateService.CalculateMergeTargetLesionStatus(new CalculateTargetLesionStatusInDto() + { + QuestionId = inDto.QuestionId, + VisitTaskId = inDto.VisitTaskId, + RowNumber = mergeRow.RowIndex, + }); + break; + } } /// @@ -1863,7 +1877,7 @@ namespace IRaCIS.Application.Services throw new BusinessValidationFailedException(_localizer["ReadingImage_Idnotcorrespond"]); } } - var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.TrialReadingCriterion).FirstNotNullAsync(); + var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.TrialReadingCriterion).Include(x => x.SourceSubjectVisit).FirstNotNullAsync(); inDto.BlindName = taskinfo.TaskBlindName; switch (taskinfo.TrialReadingCriterion.CriterionType) { @@ -1993,9 +2007,9 @@ namespace IRaCIS.Application.Services var targetlymphQuestion = targetTablequestionList.Where(x => x.QuestionMark == QuestionMark.IsLymph).FirstOrDefault(); - // 判断是否存在淋巴结问题 - if (targetlymphQuestion != null) - { + // 判断是否存在淋巴结问题 + if (targetlymphQuestion != null && taskinfo.SourceSubjectVisit.VisitNum == 0) + { // 判断是否为淋巴结 if (inDto.QuestionId == targetTablequestionList[0].ReadingQuestionId && inDto.AnswerList.Any(x => x.TableQuestionId == targetlymphQuestion.Id && x.Answer.EqEnum(ReadingYesOrNo.No))) { diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/ILuganoCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/ILuganoCalculateService.cs index 6ee6012e7..81624907a 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/ILuganoCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/ILuganoCalculateService.cs @@ -15,5 +15,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate.Interface /// /// Task CalculateTargetLesionStatus(CalculateTargetLesionStatusInDto inDto); + + /// + /// 计算靶病灶融合后状态 + /// + /// + /// + Task CalculateMergeTargetLesionStatus(CalculateTargetLesionStatusInDto inDto); } } diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs index 402bb334d..42c162eaa 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs @@ -869,11 +869,117 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate } /// - /// 计算靶病灶状态 + /// 计算融合靶病灶的状态 /// /// /// - public async Task CalculateTargetLesionStatus(CalculateTargetLesionStatusInDto inDto) + public async Task CalculateMergeTargetLesionStatus(CalculateTargetLesionStatusInDto inDto) + { + var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync(); + + // 找到靶病灶问题 + var targetQuestion = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskInfo.TrialReadingCriterionId && x.LesionType == LesionType.TargetLesion).FirstOrDefaultAsync(); + if (targetQuestion != null) + { + // 找到状态问题 + var stateQuestion = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == targetQuestion.Id && x.QuestionMark == QuestionMark.State).FirstOrDefaultAsync(); + if (stateQuestion != null) + { + + // 找到主病灶的状态 + var state = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == (int)Math.Floor(inDto.RowNumber) && x.TableQuestionId == stateQuestion.Id).Select(x => x.Answer).FirstOrDefaultAsync(); + + // 长径 + var majorAxis = (await _readingTableQuestionAnswerRepository.Where(x => + x.VisitTaskId == inDto.VisitTaskId && + x.RowIndex == (int)Math.Floor(inDto.RowNumber) && + x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.MajorAxis && + x.QuestionId == targetQuestion.Id + ).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); + + // 短径 + var shortAxis = (await _readingTableQuestionAnswerRepository.Where(x => + x.VisitTaskId == inDto.VisitTaskId && + x.RowIndex == (int)Math.Floor(inDto.RowNumber) && + x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.ShortAxis && + x.QuestionId == targetQuestion.Id + ).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); + + // 找到ppd问题 + var ppdQuestion = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == targetQuestion.Id && x.QuestionMark == QuestionMark.PPD).FirstOrDefaultAsync(); + + if (ppdQuestion != null) + { + var pPdAnswer = (await _readingTableQuestionAnswerRepository.Where(x => + x.VisitTaskId == inDto.VisitTaskId && + x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.PPD && + x.QuestionId == targetQuestion.Id && + x.RowIndex == inDto.RowNumber + ).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); + + + // 是否符合疾病进展 + var accord = false; + + var lowPPDInfo = await GetLowPPDInfo(new GetPPDInfoInDto() + { + RowIndex = (int)Math.Floor(inDto.RowNumber), + VisitTaskId = inDto.VisitTaskId, + QuestionId = inDto.QuestionId, + }); + + + if (lowPPDInfo.NadirPPD != 0) + { + //当前融合靶病灶LDi>15 mm && + //(当前融合靶病灶的ppd-最低点PPD)/最低点PPD ≥50 % + + if (majorAxis >= 15 && + (pPdAnswer - lowPPDInfo.NadirPPD) * 100 / lowPPDInfo.NadirPPD >= 50 + { + accord = true; + } + } + + // 符合疾病进展 + if (accord) + { + await _readingTableQuestionAnswerRepository.UpdatePartialFromQueryAsync(x => + x.VisitTaskId == inDto.VisitTaskId && + x.RowIndex == inDto.RowNumber && + x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && + x.QuestionId == targetQuestion.Id, x => new ReadingTableQuestionAnswer() + { + Answer = TargetState.DiseaseProgression.GetEnumInt() + } + ); + } + else if (state == TargetState.DiseaseProgression.GetEnumInt()) + { + await _readingTableQuestionAnswerRepository.UpdatePartialFromQueryAsync(x => + x.VisitTaskId == inDto.VisitTaskId && + x.RowIndex == inDto.RowNumber && + x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && + x.QuestionId == targetQuestion.Id, x => new ReadingTableQuestionAnswer() + { + Answer = TargetState.Exist.GetEnumInt() + } + ); + } + + + } + } + + } + } + + /// + /// 计算靶病灶状态 + /// + /// + /// + public async Task CalculateTargetLesionStatus(CalculateTargetLesionStatusInDto inDto) { if (inDto.RowNumber % 1 != 0) {