From 8de44fb7b39438c287f9a1bd3efcd7d80264cccf Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Wed, 3 Dec 2025 15:13:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=87=8D=E9=98=85=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reading/Dto/ReadingImageTaskViewModel.cs | 3 + .../ReadingImageTaskService.cs | 1 + .../General/GeneralCalculateService.cs | 175 +++++++++++++++++- .../Interface/IGeneralCalculateService.cs | 10 + 4 files changed, 188 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index 070e20a71..a3f0817c3 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -956,6 +956,9 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public class CopyTableAnswerRowInfo : ReadingTableAnswerRowInfoBase { + + public Guid? IdentityRowId { get; set; } + public Guid OriginalId { get; set; } public LesionType? LesionType { get; set; } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index 1c97dafa9..06daa91e6 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -3078,6 +3078,7 @@ namespace IRaCIS.Core.Application.Service //await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.RowId == (inDto.RowId ?? default(Guid))); //await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.Id == (inDto.RowId ?? default(Guid))); _mapper.Map(inDto, rowInfo); + rowInfo.IdentityRowId = rowInfo.IdentityRowId == null ? NewId.NextGuid() : rowInfo.IdentityRowId; rowInfo.Id = inDto.RowId == null ? NewId.NextGuid() : inDto.RowId.Value; result.RowId = rowInfo.Id; rowInfo.IsCurrentTaskAdd = isCurrentTaskAdd; diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs index 9502c567f..9b9b4bfda 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs @@ -1,4 +1,5 @@ -using IRaCIS.Core.Application.Helper; +using DocumentFormat.OpenXml.Drawing.Spreadsheet; +using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.Service.Reading.Dto; using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; @@ -16,6 +17,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate { public class GeneralCalculateService(IRepository _readingTableQuestionAnswerRepository, IRepository _visitTaskRepository, + IRepository _readingTaskQuestionMarkRepository, + IRepository _readingNoneDicomMarkRepository, + IRepository _readingNoneDicomMarkBindingRepository, IRepository _readingQuestionCriterionTrialRepository, ILogger _logger, IRepository _readingTableQuestionTrialRepository, @@ -208,6 +212,175 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate return questions; } + /// + /// 复制既往新病灶答案 + /// + /// + public async Task CopyHistoryAnswer(VisitTask taskinfo, List tableRowList,List tableAnswerList) + { + + if (taskinfo.IsCopyLesionAnswer) + { + var historyTaskId = await _visitTaskRepository.Where(x => + x.ReadingCategory == ReadingCategory.Visit && + x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId && + x.IsAnalysisCreate == taskinfo.IsAnalysisCreate && + x.DoctorUserId == taskinfo.DoctorUserId && + x.IsSelfAnalysis == taskinfo.IsSelfAnalysis && + x.SubjectId == taskinfo.SubjectId && + x.ReadingTaskState == ReadingTaskState.HaveSigned && + x.VisitTaskNum == taskinfo.VisitTaskNum && + x.TaskState != TaskState.Effect && + x.ArmEnum == taskinfo.ArmEnum) + .OrderByDescending(x => x.SignTime) + .Select(x => x.Id).FirstOrDefaultAsync(); + + // 1.标记信息复制有问题 2. 标记 + + if (historyTaskId != Guid.Empty) + { + var historyTableRowList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync(); + var historyTableAnswerList = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync(); + + + var answerList = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync(); + + + var questionMarkList=await _readingTaskQuestionMarkRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync(); + var noneDicomMarkList=await _readingNoneDicomMarkRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync(); + var noneDicomMarkBindingList=await _readingNoneDicomMarkBindingRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync(); + + foreach (var item in tableRowList) + { + var historyRow = historyTableRowList.Where(x => + x.QuestionId == item.QuestionId && + x.RowIndex == item.RowIndex && + x.IdentityRowId==item.IdentityRowId && + x.IdentityRowId !=null && + x.OrganInfoId==item.OrganInfoId + ).FirstOrDefault(); + + if (historyRow != null) + { + item.StudyId= historyRow.StudyId; + item.SeriesId= historyRow.SeriesId; + item.InstanceId= historyRow.InstanceId; + + item.OtherStudyId = historyRow.OtherStudyId; + item.OtherSeriesId = historyRow.OtherSeriesId; + item.OtherInstanceId= historyRow.OtherInstanceId; + + item.MeasureData= historyRow.MeasureData.Replace(historyTaskId.ToString(),taskinfo.Id.ToString()); + item.OtherMeasureData = historyRow.OtherMeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString()); + + + tableAnswerList.Where(x => x.RowId == item.Id).ForEach(x => + { + x.Answer = x.Answer.IsNotNullOrEmpty() ? + historyTableAnswerList.Where(y => y.RowId == historyRow.Id && y.TableQuestionId == x.TableQuestionId).Select(x => x.Answer).FirstOrDefault()??string.Empty : + x.Answer; + }); + + } + } + + // 复制外层问题 + answerList.ForEach(x => + { + x.Id = NewId.NextGuid(); + x.VisitTaskId = taskinfo.Id; + }); + + await _readingTaskQuestionAnswerRepository.AddRangeAsync(answerList); + + + // 处理标记 + Dictionary dicomKeys=new Dictionary (); + + foreach (var item in questionMarkList) + { + item.Id = NewId.NextGuid(); + item.VisitTaskId = taskinfo.Id; + item.FristAddTaskId = taskinfo.Id; + if (item.MarkId != null) + { + if (dicomKeys.ContainsKey(item.MarkId.Value)) + { + item.MarkId = dicomKeys[item.MarkId.Value]; + item.MeasureData = item.MeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString()).Replace(item.MarkId.Value.ToString(), dicomKeys[item.MarkId.Value].ToString()); + } + else + { + var newguid = NewId.NextGuid(); + + item.MeasureData = item.MeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString()).Replace(item.MarkId.Value.ToString(), newguid.ToString()); + dicomKeys.Add(item.MarkId.Value, newguid); + item.MarkId = dicomKeys[item.MarkId.Value]; + } + } + } + + await _readingTaskQuestionMarkRepository.AddRangeAsync(questionMarkList); + + + // 处理非Dicom标记 + Dictionary noneKeys = new Dictionary(); + foreach (var item in noneDicomMarkList) + { + var newid= NewId.NextGuid(); + + item.VisitTaskId = taskinfo.Id; + if (item.MarkId != null) + { + if (noneKeys.ContainsKey(item.MarkId.Value)) + { + item.MarkId = noneKeys[item.MarkId.Value]; + item.MeasureData = item.MeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString()).Replace(item.MarkId.Value.ToString(), noneKeys[item.MarkId.Value].ToString()); + } + else + { + var newguid = NewId.NextGuid(); + + item.MeasureData = item.MeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString()).Replace(item.MarkId.Value.ToString(), newguid.ToString()); + noneKeys.Add(item.MarkId.Value, newguid); + item.MarkId = noneKeys[item.MarkId.Value]; + } + } + + #region 处理非DICOM绑定 + // 处理非DICOM绑定 + foreach (var binding in noneDicomMarkBindingList.Where(z => z.MarkId == item.MarkId)) + { + binding.Id = NewId.NextGuid(); + binding.VisitTaskId = taskinfo.Id; + if (binding.MarkId != null) + { + binding.NoneDicomMarkId = newid; + + if (noneKeys.ContainsKey(binding.MarkId.Value)) + { + binding.MarkId = noneKeys[binding.MarkId.Value]; + } + } + + + } + #endregion + + item.Id = NewId.NextGuid(); + } + + await _readingNoneDicomMarkRepository.AddRangeAsync(noneDicomMarkList); + + + await _readingNoneDicomMarkBindingRepository.AddRangeAsync(noneDicomMarkBindingList); + + + + } + } + + } /// /// 从上传文件中获取Datatable diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/IGeneralCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/IGeneralCalculateService.cs index 693033710..a1cf755b6 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/IGeneralCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/IGeneralCalculateService.cs @@ -21,6 +21,16 @@ namespace IRaCIS.Core.Application.Service List needChangeType ); + /// + /// 复制历史答案到当前任务 + /// + /// + /// + /// + /// + + Task CopyHistoryAnswer(VisitTask taskinfo, List tableRowList, List tableAnswerList) + /// /// 获取ReadingCalculateDto ///