diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 4083d5c21..6ea8aa5ab 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -17537,17 +17537,17 @@ - 质疑 + ���� - 一致性核查 + һ���Ժ˲� - 复制 + ���� diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs index 01f7dc0b0..831b93073 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs @@ -1,4 +1,5 @@ -using DocumentFormat.OpenXml.Drawing.Spreadsheet; +using Amazon.Runtime.Internal.Transform; +using DocumentFormat.OpenXml.Drawing.Spreadsheet; using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.Service.Reading.Dto; using IRaCIS.Core.Application.ViewModel; @@ -10,6 +11,7 @@ using MassTransit.Saga; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using MiniExcelLibs; +using System.Collections.Immutable; using System.Data; using System.IO; using System.Text; @@ -18,6 +20,10 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate { public class GeneralCalculateService(IRepository _readingTableQuestionAnswerRepository, IRepository _visitTaskRepository, + IRepository _segmentationRepository, + IRepository _segmentRepository, + IRepository _segmentBindingRepository, + IRepository _readingTaskQuestionMarkRepository, IRepository _readingNoneDicomMarkRepository, IRepository _readingNoneDicomMarkBindingRepository, @@ -225,6 +231,13 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate return; } + // 如果有表格问题或者外层问题答案就不复制了 + if ((await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == taskinfo.Id)) + || (await _readingTaskQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == taskinfo.Id))) + { + return; + } + if (taskinfo.IsCopyLesionAnswer) { var historyTaskId = await _visitTaskRepository.Where(x => @@ -255,7 +268,10 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate 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(); + Dictionary lesionRelationship = new Dictionary() { }; + // 这里后续还要添加病灶 比如现在是访视三 要把失效任务访视三的 在访视三的病灶添加过来 + // 同时自定义的 除了根据器官判断还需要根据 复制前值的答案相不相等 foreach (var item in tableRowList) { if (item.SplitOrMergeType == SplitOrMergeType.Merged) @@ -272,6 +288,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate if (historyRow != null) { + lesionRelationship.Add(historyRow.Id, item.Id); item.StudyId = historyRow.StudyId; item.SeriesId = historyRow.SeriesId; item.InstanceId = historyRow.InstanceId; @@ -380,6 +397,63 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate item.Id = NewId.NextGuid(); } + + #region 分割 + Dictionary segmentationRelationship = new Dictionary() { }; + var segmentationList = _segmentationRepository.Where(t => t.VisitTaskId == historyTaskId).ToList(); + + foreach (var item in segmentationList) + { + + var newSegmentationId = NewId.NextSequentialGuid(); + segmentationRelationship.Add(item.Id, newSegmentationId); + item.Id = newSegmentationId; + item.VisitTaskId = taskinfo.Id; + } + + + Dictionary segmentRelationship = new Dictionary() { }; + var segmentList = _segmentRepository.Where(t => t.VisitTaskId == historyTaskId).ToList(); + foreach (var item in segmentList) + { + var newSegmentationId = NewId.NextSequentialGuid(); + segmentRelationship.Add(item.Id, newSegmentationId); + if (segmentationRelationship.ContainsKey(item.SegmentationId)) + { + item.SegmentationId = segmentationRelationship[item.SegmentationId]; + } + item.Id = newSegmentationId; + item.VisitTaskId = taskinfo.Id; + } + + var segmentBindingList = _segmentBindingRepository.Where(x => x.VisitTaskId == historyTaskId).ToList(); + + foreach (var item in segmentBindingList) + { + if (segmentationRelationship.ContainsKey(item.SegmentationId)) + { + item.SegmentationId = segmentationRelationship[item.SegmentationId]; + } + if (segmentRelationship.ContainsKey(item.SegmentId)) + { + item.SegmentId = segmentRelationship[item.SegmentId]; + } + + if (item.RowId != null && lesionRelationship.ContainsKey(item.RowId.Value)) + { + item.RowId = lesionRelationship[item.RowId.Value]; + } + item.Id = NewId.NextSequentialGuid(); + item.VisitTaskId = taskinfo.Id; + } + + + _ = _segmentationRepository.AddRangeAsync(segmentationList).Result; + _ = _segmentRepository.AddRangeAsync(segmentList).Result; + _ = _segmentBindingRepository.AddRangeAsync(segmentBindingList).Result; + #endregion + + await _readingNoneDicomMarkRepository.AddRangeAsync(noneDicomMarkList); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs index c2b4a34f5..7aa60d1c6 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs @@ -296,11 +296,10 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate } } - if(trialReadingCriterion.IsOncologyReading) - { - await _generalCalculateService.CopyHistoryAnswer(taskinfo, addRowList, addTableQuestionAnswerList); - } - + + // 自定义的复制 + await _generalCalculateService.CopyHistoryAnswer(taskinfo, addRowList, addTableQuestionAnswerList); + await _readingTableAnswerRowInfoRepository.AddRangeAsync(addRowList); await _readingTableQuestionAnswerRepository.AddRangeAsync(addTableQuestionAnswerList); await _readingTableQuestionAnswerRepository.SaveChangesAsync();