From bf54bcfd9b087cdf4de84dfcb787d7313c25da06 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Wed, 31 Jan 2024 10:18:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/CriterionCalculateDto.cs | 5 + .../LuganoCalculateService.cs | 116 +++++++++++++++++- 2 files changed, 118 insertions(+), 3 deletions(-) diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/Dto/CriterionCalculateDto.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/Dto/CriterionCalculateDto.cs index 181920845..adcca1fe9 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/Dto/CriterionCalculateDto.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/Dto/CriterionCalculateDto.cs @@ -22,6 +22,11 @@ namespace IRaCIS.Core.Application.ViewModel } + public class GetSplitPPdInDto + { + public Guid RowId { get; set; } + } + public class ReadingTaskQuestionAnswerDto : ReadingTaskQuestionAnswer { public QuestionType QuestionType { get; set; } diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs index 7e4d51382..8c0d89da3 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs @@ -13,6 +13,7 @@ using MassTransit; using System.Reflection.Metadata.Ecma335; using System.Linq; using NPOI.SS.Formula.Functions; +using DocumentFormat.OpenXml.Drawing.Charts; namespace IRaCIS.Core.Application.Service.ReadingCalculate { @@ -885,19 +886,106 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate 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 ppdAnswerList= await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.TableQuestionId == stateQuestion.Id) - .Where(x=> x.RowIndex >= (int)Math.Floor(inDto.RowNumber) && x.RowIndex< ((int)Math.Floor(inDto.RowNumber)+1)) - .Select(x => x.Answer).ToListAsync(); + var ppdAnswerList= await _readingTableQuestionAnswerRepository.Where(x => + x.VisitTaskId == inDto.VisitTaskId && + x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.PPD && + x.QuestionId == targetQuestion.Id && + x.RowIndex >= (int)Math.Floor(inDto.RowNumber) && x.RowIndex < ((int)Math.Floor(inDto.RowNumber) + 1) + ).Select(x => x.Answer).ToListAsync(); var allPPd = ppdAnswerList.Select(x => x.IsNullOrEmptyReturn0()).Sum(); + // 是否符合疾病进展 + 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) + { + //15mm < 当前靶病灶LDi≤20mm && + //&& 相比最低点PPD增加百分比 ≥50% && + //(相比PPD最低点LDi增加值 ≥5 mm + //or相比PPD最低点SDi增加值≥5 mm) + if (15 < majorAxis && majorAxis <= 20 && + (allPPd - lowPPDInfo.NadirPPD) * 100 / lowPPDInfo.NadirPPD >= 50 && + (majorAxis - lowPPDInfo.LowPPDLDi >= 5 || + shortAxis - lowPPDInfo.LowPPDSDi >= 5) + ) + { + accord = true; + } + + //当前靶病灶LDi>20 mm + //相比最低点PPD增加百分比 ≥50% + // (相比PPD最低点LDi增加值 ≥10 mm + // 或者相比PPD最低点SDi增加值Sdi ≥10 mm) + if ( majorAxis > 20 && + (allPPd - lowPPDInfo.NadirPPD) * 100 / lowPPDInfo.NadirPPD >= 50 && + (majorAxis - lowPPDInfo.LowPPDLDi >= 10 || + shortAxis - lowPPDInfo.LowPPDSDi >= 10) + ) + { + accord = true; + } + + } + + // 符合疾病进展 + if (accord) + { + await _readingTableQuestionAnswerRepository.UpdatePartialFromQueryAsync(x => + x.VisitTaskId == inDto.VisitTaskId && + x.RowIndex == (int)Math.Floor(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 == (int)Math.Floor(inDto.RowNumber) && + x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && + x.QuestionId == targetQuestion.Id, x => new ReadingTableQuestionAnswer() + { + Answer = TargetState.Exist.GetEnumInt() + } + ); + } } @@ -910,6 +998,28 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate } + /// + /// 获取分裂病灶的PPd之和 不包括当前的主病灶 + /// + /// + [HttpPost] + public async Task GetSplitPPdSum(GetSplitPPdInDto inDto) + { + var rowinfo = await _readingTableAnswerRowInfoRepository.Where(x => x.Id == inDto.RowId).FirstNotNullAsync(); + + + var ppdAnswerList = await _readingTableQuestionAnswerRepository.Where(x => + x.VisitTaskId == rowinfo.VisitTaskId && + x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.PPD && + x.QuestionId == rowinfo.QuestionId && + x.RowIndex > (int)Math.Floor(rowinfo.RowIndex) && x.RowIndex < ((int)Math.Floor(rowinfo.RowIndex) + 1) + ).Select(x => x.Answer).ToListAsync(); + + var allPPd = ppdAnswerList.Select(x => x.IsNullOrEmptyReturn0()).Sum(); + + return allPPd; + } + #region 将上一次的访视病灶添加到这一次 ///