diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index e38083603..597215059 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -40,6 +40,8 @@ namespace IRaCIS.Core.Application.Service private readonly IRepository _readingTaskQuestionAnswerRepository; private readonly IRepository _readingTableAnswerRowInfoRepository; private readonly IRepository _readingTableQuestionAnswerRepository; + private readonly IRepository _readingTableQuestionTrialRepository; + private readonly IRepository _readingQuestionTrialRepository; private readonly IMapper _mapper; private readonly IUserInfo _userInfo; private readonly IRepository _visitTaskReReadingRepository; @@ -58,6 +60,8 @@ namespace IRaCIS.Core.Application.Service IRepository readingTaskQuestionAnswerRepository, IRepository readingTableAnswerRowInfoRepository, IRepository readingTableQuestionAnswerRepository, + IRepository readingTableQuestionTrialRepository, + IRepository readingQuestionTrialRepository, IRepository readingJudgeInfoRepository, IRepository taskAllocationRuleRepository, IMapper mapper, IUserInfo userInfo, IRepository visitTaskReReadingRepository, IRepository trialReadingCriterionRepository, IRepository trialClinicalDataSetRepository, IRepository readingClinicalDataRepository, @@ -72,6 +76,8 @@ namespace IRaCIS.Core.Application.Service this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository; this._readingTableAnswerRowInfoRepository = readingTableAnswerRowInfoRepository; this._readingTableQuestionAnswerRepository = readingTableQuestionAnswerRepository; + this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository; + this._readingQuestionTrialRepository = readingQuestionTrialRepository; _provider = provider; _subjectVisitRepository = subjectVisitRepository; this._readingJudgeInfoRepository = readingJudgeInfoRepository; @@ -108,6 +114,9 @@ namespace IRaCIS.Core.Application.Service /// public async Task AddConvertedTask(Guid taskId) { + + var originalTask = await _visitTaskRepository.Where(x => x.Id == taskId).Include(x => x.TrialReadingCriterion).FirstNotNullAsync(); + var taskInfo = await _visitTaskRepository.Where(x => x.Id == taskId).IgnoreAutoIncludes().AsNoTracking().FirstNotNullAsync(); taskInfo.ReadingTaskState = ReadingTaskState.Reading; taskInfo.IsConvertedTask = true; @@ -170,6 +179,71 @@ namespace IRaCIS.Core.Application.Service x.RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault(); }); var addrowInfo = _mapper.Map>(tableRowAnswers); + switch (originalTask.TrialReadingCriterion.CriterionType) + { + case CriterionType.IRECIST1Point1: + //非靶病灶全部数据复制,不可更改。支持如果状态为:显著增大需要自动改为: 显著增大(iUPD) + var stateQuestionId = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == originalTask.TrialReadingCriterionId + && x.ReadingQuestionTrial.LesionType == LesionType.NonTargetLesions && x.QuestionMark == QuestionMark.State).Select(x=>x.Id).FirstOrDefaultAsync(); + + tableAnswer.ForEach(x => + { + if (x.TableQuestionId == stateQuestionId && x.Answer.EqEnum(NoTargetState.Increase)) + { + x.Answer = NoTargetState.IUPD.GetEnumInt(); + } + }); + + // 新转换为其它既往新病灶: 状态为消失、疑似、无法评估的新病灶自动转换为:其它既往新病灶,且不可以编辑 + + // 找到新病灶问题 + var newLesionQuestion = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == originalTask.TrialReadingCriterionId && x.LesionType == LesionType.NewLesions).FirstOrDefaultAsync(); + + + // 找到其他既往新病灶 + var otherLesionQuestion = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == originalTask.TrialReadingCriterionId && x.LesionType == LesionType.OtherPreviousNewLesion).FirstOrDefaultAsync(); + + + + if (newLesionQuestion != null && otherLesionQuestion != null) + { + // 找到表格问题 + var newLesionTableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == newLesionQuestion.Id).ToListAsync(); + + // 找到表格问题 + var otherLesionTableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == otherLesionQuestion.Id).ToListAsync(); + + addrowInfo.ForEach(x => + { + + if (x.QuestionId == newLesionQuestion.Id) + { + x.QuestionId = otherLesionQuestion.Id; + x.OrderMark = otherLesionQuestion.OrderMark; + x.RowMark = otherLesionQuestion.OrderMark+x.RowIndex.GetLesionMark(); + } + }); + + tableAnswer.ForEach(x => + { + if (x.QuestionId == newLesionQuestion.Id) + { + x.QuestionId = otherLesionQuestion.Id; + + var newLesionTableQuestion = newLesionTableQuestionList.Where(y => y.Id == x.TableQuestionId).FirstOrDefault(); + if (newLesionTableQuestion != null) + { + x.TableQuestionId = otherLesionTableQuestionList.Where(y => y.QuestionMark == newLesionTableQuestion.QuestionMark).Select(x => x.Id).FirstOrDefault(); + + } + + } + + }); + } + + break; + } await _readingTaskQuestionAnswerRepository.AddRangeAsync(taskAnswer); await _readingTableAnswerRowInfoRepository.AddRangeAsync(addrowInfo); await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswer); diff --git a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs index 132cb1dac..ed3ed7236 100644 --- a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs +++ b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs @@ -648,7 +648,17 @@ namespace IRaCIS.Core.Domain.Share /// /// 消失 /// - Loss = 3 + Loss = 3, + + /// + /// 显著增大(iUPD) + /// + IUPD = 4, + + /// + /// 进一步增大(iCPD) + /// + ICPD = 5 } @@ -906,6 +916,26 @@ namespace IRaCIS.Core.Domain.Share /// BaselineLesions=4, + /// + /// 新靶病灶 + /// + NewTargetLesion = 5, + + /// + /// 新非靶病灶 + /// + NewNonTargetLesion = 6, + + /// + /// 其它既往新病灶 + /// + OtherPreviousNewLesion = 7, + + /// + /// 触发iRECSIT后的新病灶 + /// + TriggeringIRECSIT = 8 + }