修改
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using MassTransit;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -141,6 +142,140 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||
return readingData;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加转化任务病灶信息
|
||||
/// </summary>
|
||||
/// <param name="visitTaskId"></param>
|
||||
/// <param name="beforeConvertedTaskId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task AddConvertedTaskFocus(Guid visitTaskId, Guid beforeConvertedTaskId)
|
||||
{
|
||||
var originalTask = await _visitTaskRepository.Where(x => x.Id == beforeConvertedTaskId).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
|
||||
|
||||
var taskAnswer = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == visitTaskId && x.ReadingQuestionTrial.Type != "calculation").IgnoreAutoIncludes().AsNoTracking().ToListAsync();
|
||||
|
||||
taskAnswer.ForEach(x => {
|
||||
|
||||
x.VisitTaskId = beforeConvertedTaskId;
|
||||
|
||||
x.Id = NewId.NextGuid();
|
||||
});
|
||||
|
||||
|
||||
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == visitTaskId).AsNoTracking().ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).IgnoreAutoIncludes().ToListAsync();
|
||||
|
||||
tableRowAnswers.ForEach(x =>
|
||||
{
|
||||
x.VisitTaskId = beforeConvertedTaskId;
|
||||
x.IsCurrentTaskAdd = false;
|
||||
x.FristAddTaskId = beforeConvertedTaskId;
|
||||
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();
|
||||
|
||||
});
|
||||
|
||||
var tableAnswer = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == visitTaskId).IgnoreAutoIncludes().AsNoTracking().ToListAsync();
|
||||
|
||||
tableAnswer.ForEach(x =>
|
||||
{
|
||||
x.Id = NewId.NextGuid();
|
||||
x.VisitTaskId = beforeConvertedTaskId;
|
||||
x.RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault();
|
||||
});
|
||||
var addrowInfo = _mapper.Map<List<ReadingTableAnswerRowInfo>>(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();
|
||||
|
||||
// 找到病灶状态
|
||||
var newstateQuestionId = newLesionTableQuestionList.Where(x => x.QuestionMark == QuestionMark.State).Select(x => x.Id).FirstOrDefault();
|
||||
|
||||
|
||||
var stateAnswers = new List<string>() {
|
||||
NewLesionState.Loss.GetEnumInt(),
|
||||
NewLesionState.Suspected.GetEnumInt(),
|
||||
NewLesionState.UnableEvaluate.GetEnumInt()
|
||||
};
|
||||
|
||||
var needRowIds = tableAnswer.Where(x => x.TableQuestionId == newstateQuestionId && stateAnswers.Contains(x.Answer)).Select(x => x.RowId).Distinct().ToList();
|
||||
|
||||
|
||||
|
||||
|
||||
addrowInfo.ForEach(x =>
|
||||
{
|
||||
if (needRowIds.Contains(x.Id))
|
||||
{
|
||||
x.QuestionId = otherLesionQuestion.Id;
|
||||
x.OrderMark = otherLesionQuestion.OrderMark;
|
||||
x.RowMark = otherLesionQuestion.OrderMark + x.RowIndex.GetLesionMark();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
tableAnswer.ForEach(x =>
|
||||
{
|
||||
if (needRowIds.Contains(x.RowId))
|
||||
{
|
||||
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);
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取阅片报告任务List
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user