From 149cca011aa3a80e1f5163cb908c9d6d71614ae6 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Mon, 15 Sep 2025 11:31:08 +0800 Subject: [PATCH] =?UTF-8?q?PWCG=20=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReadingCalculate/PCWG3CalculateService.cs | 92 +++++++------------ 1 file changed, 33 insertions(+), 59 deletions(-) diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs index 243c56325..50469b1a3 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs @@ -7,6 +7,7 @@ using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infra.EFCore.Common; using IRaCIS.Core.Infrastructure; using MassTransit; +using MassTransit.Initializers; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; @@ -1110,7 +1111,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate } /// - /// 修改上一次访视结果 + /// 修改上一次访视结果 并且计算是不是PD /// /// /// @@ -1125,75 +1126,48 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var isPDResult = false; + // 先判断有没有上一个任务 if (lastTask != null) { + // 查看历史有没有PD + var taskIdList = taskList.Select(x => x.VisitTaskId).ToList(); - #region 1、基线后第一个访视:新病灶计数≥ 2个;2、基线后第二个访视(应满足访视间隔6周以上,否则顺延)新病灶≥ 2个; - //1、基线后第一个访视:新病灶计数≥ 2个;2、基线后第二个访视(应满足访视间隔6周以上,否则顺延)新病灶≥ 2个; - - - var firstVisit = taskList.FirstOrDefault(); - if (baseLineTask != null && baseLineTask.StudyTime != null) + var pdTaskList = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId!=inDto.VisitTaskId&& taskIdList.Contains(x.VisitTaskId) && x.ReadingQuestionTrial.QuestionType == QuestionType.SiteVisitForTumorEvaluation && x.Answer == VisitTumorEvaluation.PD.GetEnumInt()).OrderByDescending(x=>x.VisitTask.VisitTaskNum).ToListAsync(); + + // 当前访视新病灶数量 + var thisNewLesionsCount = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.NewLesionsCount).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0(); + // 历史有PD + if (pdTaskList.Count() > 0&& thisNewLesionsCount >= 2) { - //基线后第二个访视(应满足访视间隔6周以上,否则顺延) - var secondVisit = taskList.Where(x => x.VisitTaskNum >= 2 && x.StudyTime >= baseLineTask.StudyTime.Value.AddDays(42)).FirstOrDefault(); - if (secondVisit != null) + // 满足以下所有条件:1、前序访视已经确定为PD;2、当前访视,新病灶≥2个; + isPDResult = true; + } + else + { + // 满足以下所有条件:1、前序访视没有评估为PD,2、前一个访视:新病灶计数≥2个;3、当前访视:新病灶2个:4.前后2个访视间隔6周以上。 + + var lastStudyDate = taskList.Where(x=>x.VisitTaskId==lastTask.VisitTaskId).Select(x=>x.StudyTime).FirstOrDefault(); + var thisStudyDate= taskList.Where(x => x.VisitTaskId == inDto.VisitTaskId).Select(x => x.StudyTime).FirstOrDefault(); + + var lastNewLesionsStr=await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == lastTask.VisitTaskId && x.ReadingQuestionTrialId == newLesionsCountQuestionId).Select(x => x.Answer).FirstOrDefaultAsync(); + + var lastNewLesionsCount = lastNewLesionsStr.IsNullOrEmptyReturn0(); + if (lastStudyDate != null && thisStudyDate != null) { - - var firstTaskNewLesionsCount = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == firstVisit!.VisitTaskId && x.ReadingQuestionTrialId == newLesionsCountQuestionId).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); - - // 第二访视数量 - var secondVisitLesionsCount = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == lastTask.VisitTaskId && x.ReadingQuestionTrialId == newLesionsCountQuestionId).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); - - // 判断是否是当前访视 当前访视还未入库 - if (secondVisit.VisitTaskId == inDto.VisitTaskId) - { - secondVisitLesionsCount = (inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.NewLesionsCount).Select(x => x.Answer).FirstOrDefault()).IsNullOrEmptyReturn0(); - } - - if (firstTaskNewLesionsCount >= 2 && secondVisitLesionsCount >= 2) - { - isPDResult = true; - } - } - - #endregion - - - - if (lastTask.VisitTaskNum >= 2m) - { - - var lastTasknewLesionsCount = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == lastTask.VisitTaskId && x.ReadingQuestionTrialId == newLesionsCountQuestionId).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); - var thisVisitTaskNewLesionsCount = (inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.NewLesionsCount).Select(x => x.Answer).FirstOrDefault()).IsNullOrEmptyReturn0(); - - var thisVisitTask = taskList.LastOrDefault(); - - if (thisVisitTask != null && thisVisitTask.StudyTime != null && lastTask.StudyTime != null && - - - lastTasknewLesionsCount >= 2 && thisVisitTaskNewLesionsCount >= 2 && lastTask.StudyTime.Value.AddDays(42) <= thisVisitTask.StudyTime) + if (lastNewLesionsCount >= 2 && thisNewLesionsCount >= 2 && thisStudyDate.Value > lastStudyDate.Value.AddDays(42)) { + var visitForTumorEvaluationQuestionId = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.SiteVisitForTumorEvaluation).Select(x => x.QuestionId).FirstOrDefault(); + await _readingTaskQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.VisitTaskId == lastTask.VisitTaskId && x.ReadingQuestionTrialId == visitForTumorEvaluationQuestionId, x => new ReadingTaskQuestionAnswer + { + Answer = VisitTumorEvaluation.PD.GetEnumInt(), + }); isPDResult = true; } } + } - + } - if (isPDResult) - { - var visitForTumorEvaluationQuestionId = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.SiteVisitForTumorEvaluation).Select(x => x.QuestionId).FirstOrDefault(); - - if (lastTask != null) - { - await _readingTaskQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.VisitTaskId == lastTask.VisitTaskId && x.ReadingQuestionTrialId == visitForTumorEvaluationQuestionId, x => new ReadingTaskQuestionAnswer - { - Answer = VisitTumorEvaluation.PD.GetEnumInt(), - }); - } - } - - return isPDResult; }