diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index 7bfb2b981..2ac38621e 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -261,6 +261,10 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public Guid TrialId { get; set; } } + public class CopyTableAnswerRowInfo : ReadingTableAnswerRowInfo + { + public Guid OriginalId { get; set; } + } public class CopyTableAnswerDto { public decimal RowIndex { get; set; } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs index 841507992..dd9a93b3a 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs @@ -823,7 +823,7 @@ namespace IRaCIS.Core.Application.Service var thisNum = await _subjectVisitRepository.Where(x => x.Id == inDto.SubjectVisitId).Select(x => x.VisitNum).FirstOrDefaultAsync(); // 先找到上一个访视 - var lastVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == inDto.SubjectId && x.VisitNum < thisNum).OrderByDescending(x => x.VisitNum).Select(x => x.Id).FirstOrDefaultAsync(); + var lastVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == inDto.SubjectId && !x.IsLostVisit && x.VisitNum < thisNum).OrderByDescending(x => x.VisitNum).Select(x => x.Id).FirstOrDefaultAsync(); // 找到访视任务Id diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs index 0f01da641..1fd4df7db 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs @@ -124,6 +124,7 @@ namespace IRaCIS.Application.Services rowAnswer.RowIndex = newRowIndex; rowAnswer.MergeRowId = null; + rowAnswer.SplitOrMergeType = SplitOrMergeType.Split; rowAnswer.SplitRowId = rowAnswer.Id; rowAnswer.Id = NewId.NextGuid(); tableAnswers.ForEach(x => @@ -146,11 +147,11 @@ namespace IRaCIS.Application.Services { await this.VerifyIsBaseLineTask(inDto.VisitTaskId); - var rowsInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId&&(x.RowIndex == inDto.MainRowIndex || x.RowIndex == inDto.MergeRowIndex)).ToListAsync(); + var rowsInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId &&(x.RowIndex == inDto.MainRowIndex || x.RowIndex == inDto.MergeRowIndex)).ToListAsync(); if (rowsInfo.Count() != 2) { - throw new BusinessValidationFailedException("合并的病灶并非同一个病灶类型"); + throw new BusinessValidationFailedException("合并的病灶并非同一个访视任务"); } @@ -161,6 +162,7 @@ namespace IRaCIS.Application.Services await _readingTableAnswerRowInfoRepository.UpdatePartialFromQueryAsync(mergeid, x => new ReadingTableAnswerRowInfo() { MergeRowId = minaid, + SplitOrMergeType = SplitOrMergeType.Merge, }); await _readingTableAnswerRowInfoRepository.SaveChangesAsync(); @@ -330,10 +332,17 @@ namespace IRaCIS.Application.Services // 判断当前任务是是否有表格问题答案 if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId))) { - // 找到基线的任务Id - var baseLineTaskId = await _visitTaskRepository.Where(x => x.SourceSubjectVisitId == baseLineVisitId && x.TaskState == TaskState.Effect && x.ArmEnum == taskinfo.ArmEnum).Select(x => x.Id).FirstOrDefaultAsync(); - var copyTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == baseLineTaskId).Select(x => new CopyTableAnswerDto() { + + + + + var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&x.VisitTaskNum< taskinfo.VisitTaskNum&&x.TaskState==TaskState.Effect&&x.ArmEnum==taskinfo.ArmEnum + ).OrderByDescending(x=>x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync(); + + + + var copyTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == LastVisitTaskId).Select(x => new CopyTableAnswerDto() { Answer = x.Answer, QuestionId = x.QuestionId, QuestionMark = x.ReadingTableQuestionTrial.QuestionMark, @@ -342,21 +351,21 @@ namespace IRaCIS.Application.Services TrialId = x.TrialId }).ToListAsync(); - var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == baseLineTaskId).Select(x => new ReadingTableAnswerRowInfo() { + var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == LastVisitTaskId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - IsCurrentTaskAdd = false, - QuestionId = x.QuestionId, - RowIndex = x.RowIndex, - TrialId = x.TrialId, - VisitTaskId = visitTaskId, - }).ToListAsync(); tableRowAnswers.ForEach(x => { - x.IsCurrentTaskAdd = false; + x.Id = NewId.NextGuid(); }); + tableRowAnswers.ForEach(x => + { + x.SplitRowId = tableRowAnswers.Where(y => y.OriginalId == x.SplitRowId).Select(y => y.Id).FirstOrDefault(); + x.MergeRowId = tableRowAnswers.Where(y => y.OriginalId == x.MergeRowId).Select(y => y.Id).FirstOrDefault(); + }); + List notNeedCopyMarks = new List() { QuestionMark.MajorAxis, diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index 4e8cdaa5a..ffbae29b3 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -52,6 +52,9 @@ namespace IRaCIS.Core.Application.Service CreateMap(); + CreateMap() + .ForMember(d => d.OriginalId, u => u.MapFrom(s => s.Id)); + #region 阅片问题 // 忽略列 diff --git a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs index 6b92ec5d7..c53d84cf0 100644 --- a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs +++ b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs @@ -16,6 +16,23 @@ namespace IRaCIS.Core.Domain.Share public static readonly string Group = "group"; } + /// + /// 病灶分裂或合并 + /// + public enum SplitOrMergeType + { + + /// + /// 分裂 + /// + Split = 0, + + /// + /// 合并 + /// + Merge = 1 + } + /// /// 是否存在或者NA /// diff --git a/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs b/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs index 47b2357f8..ee0037c3e 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs @@ -72,6 +72,9 @@ namespace IRaCIS.Core.Domain.Models /// public Guid? MergeRowId { get; set; } + + public SplitOrMergeType? SplitOrMergeType { get; set; } + /// /// CreateUserId ///