From 15108156c29cfe727f891e656d93783e1fb9806e Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Tue, 22 Apr 2025 11:33:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=B7=E8=B4=9D=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reading/Dto/ReadingImageTaskViewModel.cs | 2 + .../Service/Reading/_MapConfig.cs | 3 +- .../MRECISTHCCCalculateService.cs | 110 +++++++++++++++++- 3 files changed, 112 insertions(+), 3 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index a15c6200e..25a74f0d3 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -877,6 +877,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public class CopyTableAnswerRowInfo : ReadingTableAnswerRowInfoBase { public Guid OriginalId { get; set; } + + public LesionType? LesionType { get; set; } } public class CopyTableAnswerDto { diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index 2b582c3f2..30d18b8a0 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -166,7 +166,8 @@ namespace IRaCIS.Core.Application.Service CreateMap().ForMember(dest => dest.CreateUserRole, opt => opt.Ignore()); CreateMap() - .ForMember(d => d.OriginalId, u => u.MapFrom(s => s.Id)); + .ForMember(d => d.OriginalId, u => u.MapFrom(s => s.Id)) + .ForMember(d => d.LesionType, u => u.MapFrom(s => s.ReadingQuestionTrial.LesionType)); //.ForMember(dest => dest.Instance, opt => opt.Ignore()) //.ForMember(dest => dest.ReadingQuestionTrial, opt => opt.Ignore()); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/MRECISTHCCCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/MRECISTHCCCalculateService.cs index f2f207712..98d9abb9d 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/MRECISTHCCCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/MRECISTHCCCalculateService.cs @@ -1,4 +1,5 @@ -using IRaCIS.Core.Application.Service.Reading.Dto; +using DocumentFormat.OpenXml.Office.SpreadSheetML.Y2023.MsForms; +using IRaCIS.Core.Application.Service.Reading.Dto; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infra.EFCore.Common; @@ -757,7 +758,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate QuestionMark.MajorAxis, QuestionMark.ShortAxis, QuestionMark.State, - + }; var tableAnswers = copyTableAnswers.Select(x => new ReadingTableQuestionAnswer @@ -789,6 +790,111 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate await _readingTableQuestionAnswerRepository.SaveChangesAsync(); } + } + else + { + // 如果是基线 要把res1.1的病灶复制过来 + var recistTask = await _visitTaskRepository.Where(x => + x.TrialId == taskinfo.TrialId && + x.TaskState == TaskState.Effect && + x.ReadingTaskState == ReadingTaskState.HaveSigned && + x.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Point1 && + x.SubjectId == taskinfo.SubjectId && + x.SourceSubjectVisitId == taskinfo.SourceSubjectVisitId && + x.DoctorUserId==taskinfo.DoctorUserId).FirstOrDefaultAsync(); + if (recistTask != null) + { + + + var trialReadingCriterion=await _readingQuestionCriterionTrialRepository.Where(x => x.Id == recistTask.TrialReadingCriterionId).FirstOrDefaultAsync(); + + var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == recistTask.Id).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + + var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == taskinfo.TrialReadingCriterionId).ToListAsync(); + foreach (var rowInfo in tableRowAnswers) + { + var question= await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == x.LesionType).FirstOrDefaultAsync(); + var organ = await _organInfoRepository.Where(x => x.Id == rowInfo.OrganInfoId).FirstOrDefaultAsync(); + + var newOrgan = await _organInfoRepository.Where(x => x.SystemCriterionId == trialReadingCriterion.ReadingQuestionCriterionSystemId && + x.Classification == organ.TULOC && + x.Part == organ.Part && + x.TULOC == organ.TULOC && + x.TULAT == organ.TULAT && + x.IsLymphNodes == organ.IsLymphNodes + ).FirstOrDefaultAsync(); + + if (newOrgan != null) + { + rowInfo.OrganInfoId = newOrgan.Id; + } + rowInfo.VisitTaskId = visitTaskId; + rowInfo.IsCurrentTaskAdd = true; + rowInfo.Id = NewId.NextGuid(); + rowInfo.SeriesId = null; + rowInfo.InstanceId = null; + rowInfo.MeasureData = string.Empty; + rowInfo.PicturePath = string.Empty; + rowInfo.QuestionId = question == null ? default(Guid) : question.Id; + rowInfo.RowMark = question?.OrderMark + rowInfo.RowIndex.GetLesionMark(); + } + + + + var recistTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == recistTask.Id).Select(x => new CopyTableAnswerDto() + { + Answer = x.Answer, + QuestionId = x.QuestionId, + RowId = x.RowId, + QuestionMark = x.ReadingTableQuestionTrial.QuestionMark, + TableQuestionId = x.TableQuestionId, + RowIndex = x.RowIndex, + TrialId = x.TrialId, + }).ToListAsync(); + + foreach (var item in recistTableAnswers) + { + item.QuestionId = tableRowAnswers.Where(y => y.OriginalId == item.RowId).Select(x => x.QuestionId).FirstOrDefault(); + item.TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == item.QuestionId && x.QuestionMark == item.QuestionMark).Select(x => x.Id).FirstOrDefault(); + } + + + + List notNeedCopyMarks = new List() + { + QuestionMark.MajorAxis, + QuestionMark.ShortAxis, + QuestionMark.State, + }; + var tableAnswers = recistTableAnswers.Select(x => new ReadingTableQuestionAnswer + { + Id = NewId.NextGuid(), + Answer = notNeedCopyMarks.Contains(x.QuestionMark) ? string.Empty : x.Answer, + QuestionId = x.QuestionId, + RowIndex = x.RowIndex, + RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault(), + TableQuestionId = x.TableQuestionId, + TrialId = x.TrialId, + VisitTaskId = visitTaskId, + }); + + + var addList = _mapper.Map>(tableRowAnswers); + + await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList); + await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers); + + addList.ForEach(x => + { + x.MergeRow = null; + x.SplitRow = null; + + }); + await _readingTableQuestionAnswerRepository.SaveChangesAsync(); + } + + + } return new AddTaskLesionAnswerFromLastTaskOutDto()