修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
f082217e99
commit
712d87a4dd
|
|
@ -1193,57 +1193,57 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
var baseLineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskinfo.SubjectId && x.IsBaseLine).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
|
||||
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
|
||||
{
|
||||
|
||||
// 判断当前任务是否是基线
|
||||
if (taskinfo.SourceSubjectVisitId != baseLineVisitId)
|
||||
{
|
||||
// 判断当前任务是是否有表格问题答案
|
||||
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
|
||||
|
||||
// 判断当前任务是否是基线
|
||||
if (taskinfo.SourceSubjectVisitId != baseLineVisitId)
|
||||
{
|
||||
var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
|
||||
x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
|
||||
x.IsAnalysisCreate == taskinfo.IsAnalysisCreate &&
|
||||
x.ArmEnum == taskinfo.ArmEnum &&
|
||||
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.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
|
||||
var copyTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == LastVisitTaskId).Select(x => new CopyTableAnswerDto()
|
||||
// 判断当前任务是是否有表格问题答案
|
||||
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
|
||||
{
|
||||
Answer = x.Answer,
|
||||
QuestionId = x.QuestionId,
|
||||
RowId = x.RowId,
|
||||
QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
RowIndex = x.RowIndex,
|
||||
TrialId = x.TrialId
|
||||
}).ToListAsync();
|
||||
|
||||
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == LastVisitTaskId).ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
|
||||
x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
|
||||
x.IsAnalysisCreate == taskinfo.IsAnalysisCreate &&
|
||||
x.ArmEnum == taskinfo.ArmEnum &&
|
||||
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.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
tableRowAnswers.ForEach(x =>
|
||||
{
|
||||
x.VisitTaskId = visitTaskId;
|
||||
x.IsCurrentTaskAdd = false;
|
||||
x.Id = NewId.NextGuid();
|
||||
x.SeriesId = null;
|
||||
x.InstanceId = null;
|
||||
x.MeasureData = string.Empty;
|
||||
x.PicturePath = string.Empty;
|
||||
});
|
||||
|
||||
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 copyTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == LastVisitTaskId).Select(x => new CopyTableAnswerDto()
|
||||
{
|
||||
Answer = x.Answer,
|
||||
QuestionId = x.QuestionId,
|
||||
RowId = x.RowId,
|
||||
QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
RowIndex = x.RowIndex,
|
||||
TrialId = x.TrialId
|
||||
}).ToListAsync();
|
||||
|
||||
});
|
||||
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == LastVisitTaskId).ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
List<QuestionMark?> notNeedCopyMarks = new List<QuestionMark?>()
|
||||
|
||||
tableRowAnswers.ForEach(x =>
|
||||
{
|
||||
x.VisitTaskId = visitTaskId;
|
||||
x.IsCurrentTaskAdd = false;
|
||||
x.Id = NewId.NextGuid();
|
||||
x.SeriesId = null;
|
||||
x.InstanceId = null;
|
||||
x.MeasureData = string.Empty;
|
||||
x.PicturePath = string.Empty;
|
||||
});
|
||||
|
||||
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<QuestionMark?> notNeedCopyMarks = new List<QuestionMark?>()
|
||||
{
|
||||
QuestionMark.MajorAxis,
|
||||
QuestionMark.ShortAxis,
|
||||
|
|
@ -1251,169 +1251,169 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
|
||||
};
|
||||
|
||||
var tableAnswers = copyTableAnswers.Select(x => new ReadingTableQuestionAnswer
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
Answer = notNeedCopyMarks.Contains(x.QuestionMark) ? string.Empty : x.Answer,
|
||||
QuestionId = x.QuestionId,
|
||||
RowIndex = x.RowIndex,
|
||||
RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault(),
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
TrialId = x.TrialId,
|
||||
VisitTaskId = visitTaskId,
|
||||
});
|
||||
var tableAnswers = copyTableAnswers.Select(x => new ReadingTableQuestionAnswer
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
Answer = notNeedCopyMarks.Contains(x.QuestionMark) ? string.Empty : x.Answer,
|
||||
QuestionId = x.QuestionId,
|
||||
RowIndex = x.RowIndex,
|
||||
RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault(),
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
TrialId = x.TrialId,
|
||||
VisitTaskId = visitTaskId,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
var addList = _mapper.Map<List<ReadingTableAnswerRowInfo>>(tableRowAnswers);
|
||||
var addList = _mapper.Map<List<ReadingTableAnswerRowInfo>>(tableRowAnswers);
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||
|
||||
addList.ForEach(x =>
|
||||
{
|
||||
x.MergeRow = null;
|
||||
x.SplitRow = null;
|
||||
addList.ForEach(x =>
|
||||
{
|
||||
x.MergeRow = null;
|
||||
x.SplitRow = null;
|
||||
|
||||
});
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
});
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 基线任务
|
||||
// 如果是基线 要把res1.1的病灶复制过来
|
||||
var recistTask = await _visitTaskRepository.Where(x =>
|
||||
x.TrialId == taskinfo.TrialId &&
|
||||
x.TaskState == TaskState.Effect &&
|
||||
x.ReadingTaskState == ReadingTaskState.HaveSigned &&
|
||||
x.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Point1 &&
|
||||
x.SubjectId == taskinfo.SubjectId &&
|
||||
x.SourceSubjectVisitId == taskinfo.SourceSubjectVisitId
|
||||
).FirstOrDefaultAsync();
|
||||
if (recistTask != null)
|
||||
else
|
||||
{
|
||||
_userInfo.AuditIdentification = "HCC";
|
||||
|
||||
|
||||
var trialReadingCriterion=await _readingQuestionCriterionTrialRepository.Where(x => x.Id == taskinfo.TrialReadingCriterionId).FirstOrDefaultAsync();
|
||||
|
||||
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == recistTask.Id).ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == taskinfo.TrialReadingCriterionId).ToListAsync();
|
||||
foreach (var rowInfo in tableRowAnswers)
|
||||
// 基线任务
|
||||
// 如果是基线 要把res1.1的病灶复制过来
|
||||
var recistTask = await _visitTaskRepository.Where(x =>
|
||||
x.TrialId == taskinfo.TrialId &&
|
||||
x.TaskState == TaskState.Effect &&
|
||||
x.ReadingTaskState == ReadingTaskState.HaveSigned &&
|
||||
x.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Point1 &&
|
||||
x.SubjectId == taskinfo.SubjectId &&
|
||||
x.SourceSubjectVisitId == taskinfo.SourceSubjectVisitId
|
||||
).FirstOrDefaultAsync();
|
||||
if (recistTask != null)
|
||||
{
|
||||
var question = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == rowInfo.LesionType).FirstOrDefaultAsync();
|
||||
_userInfo.AuditIdentification = "HCC";
|
||||
|
||||
var organ = await _organInfoRepository.Where(x => x.Id == rowInfo.OrganInfoId).FirstOrDefaultAsync();
|
||||
if (organ != null)
|
||||
|
||||
var trialReadingCriterion = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == taskinfo.TrialReadingCriterionId).FirstOrDefaultAsync();
|
||||
|
||||
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == recistTask.Id).ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == taskinfo.TrialReadingCriterionId).ToListAsync();
|
||||
foreach (var rowInfo in tableRowAnswers)
|
||||
{
|
||||
var newOrgan = await _organInfoRepository.Where(x => x.SystemCriterionId == trialReadingCriterion.ReadingQuestionCriterionSystemId &&
|
||||
x.Classification == organ.Classification &&
|
||||
x.Part == organ.Part &&
|
||||
x.TULOC == organ.TULOC &&
|
||||
x.TULAT == organ.TULAT &&
|
||||
x.IsLymphNodes == organ.IsLymphNodes
|
||||
).FirstOrDefaultAsync();
|
||||
var question = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == rowInfo.LesionType).FirstOrDefaultAsync();
|
||||
|
||||
if (newOrgan != null)
|
||||
var organ = await _organInfoRepository.Where(x => x.Id == rowInfo.OrganInfoId).FirstOrDefaultAsync();
|
||||
if (organ != null)
|
||||
{
|
||||
rowInfo.OrganInfoId = newOrgan.Id;
|
||||
var newOrgan = await _organInfoRepository.Where(x => x.SystemCriterionId == trialReadingCriterion.ReadingQuestionCriterionSystemId &&
|
||||
x.Classification == organ.Classification &&
|
||||
x.Part == organ.Part &&
|
||||
x.TULOC == organ.TULOC &&
|
||||
x.TULAT == organ.TULAT &&
|
||||
x.IsLymphNodes == organ.IsLymphNodes
|
||||
).FirstOrDefaultAsync();
|
||||
|
||||
if (newOrgan != null)
|
||||
{
|
||||
rowInfo.OrganInfoId = newOrgan.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(rowInfo.MeasureData!=null)
|
||||
{
|
||||
rowInfo.MeasureData = rowInfo.MeasureData.Replace(recistTask.Id.ToString(), taskinfo.Id.ToString());
|
||||
}
|
||||
|
||||
rowInfo.VisitTaskId = visitTaskId;
|
||||
rowInfo.IsCurrentTaskAdd = true;
|
||||
rowInfo.Id = NewId.NextGuid();
|
||||
rowInfo.FristAddTaskId = visitTaskId;
|
||||
rowInfo.QuestionId = question == null ? default(Guid) : question.Id;
|
||||
rowInfo.RowMark = question?.OrderMark + rowInfo.RowIndex.GetLesionMark();
|
||||
}
|
||||
|
||||
|
||||
|
||||
var recistTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == recistTask.Id).Select(x => new CopyTableAnswerDto()
|
||||
{
|
||||
Answer = x.Answer,
|
||||
QuestionId = x.QuestionId,
|
||||
RowId = x.RowId,
|
||||
QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
RowIndex = x.RowIndex,
|
||||
TrialId = x.TrialId,
|
||||
}).ToListAsync();
|
||||
|
||||
foreach (var item in recistTableAnswers)
|
||||
{
|
||||
|
||||
item.QuestionId = tableRowAnswers.Where(y => y.OriginalId == item.RowId).Select(x => x.QuestionId).FirstOrDefault();
|
||||
|
||||
item.TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == item.QuestionId && x.QuestionMark == item.QuestionMark).Select(x => x.Id).FirstOrDefault();
|
||||
}
|
||||
|
||||
recistTableAnswers = recistTableAnswers.Where(x => x.TableQuestionId != default(Guid)).ToList();
|
||||
|
||||
List<QuestionMark?> notNeedCopyMarks = new List<QuestionMark?>()
|
||||
{
|
||||
|
||||
};
|
||||
var tableAnswers = recistTableAnswers.Select(x => new ReadingTableQuestionAnswer
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
Answer = notNeedCopyMarks.Contains(x.QuestionMark) ? string.Empty : x.Answer,
|
||||
QuestionId = x.QuestionId,
|
||||
RowIndex = x.RowIndex,
|
||||
RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault(),
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
TrialId = x.TrialId,
|
||||
VisitTaskId = visitTaskId,
|
||||
}).ToList();
|
||||
|
||||
// 添加 典型肝内病灶 默认值
|
||||
tableRowAnswers.ForEach(x =>
|
||||
{
|
||||
var tableQuestion = tableQuestionList.Where(y => y.ReadingQuestionId == x.QuestionId && y.QuestionMark == QuestionMark.TypicalIntrahepaticLesion).FirstOrDefault();
|
||||
if (tableQuestion != null)
|
||||
{
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
if (rowInfo.MeasureData != null)
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
Answer = ((int)(object)ReadingYesOrNo.No).ToString(),
|
||||
QuestionId = x.QuestionId,
|
||||
RowIndex = x.RowIndex,
|
||||
RowId = x.Id,
|
||||
TableQuestionId = tableQuestion.Id,
|
||||
TrialId = x.TrialId,
|
||||
VisitTaskId = visitTaskId,
|
||||
});
|
||||
rowInfo.MeasureData = rowInfo.MeasureData.Replace(recistTask.Id.ToString(), taskinfo.Id.ToString());
|
||||
}
|
||||
|
||||
rowInfo.VisitTaskId = visitTaskId;
|
||||
rowInfo.IsCurrentTaskAdd = true;
|
||||
rowInfo.Id = NewId.NextGuid();
|
||||
rowInfo.FristAddTaskId = visitTaskId;
|
||||
rowInfo.QuestionId = question == null ? default(Guid) : question.Id;
|
||||
rowInfo.RowMark = question?.OrderMark + rowInfo.RowIndex.GetLesionMark();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var addList = _mapper.Map<List<ReadingTableAnswerRowInfo>>(tableRowAnswers);
|
||||
var recistTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == recistTask.Id).Select(x => new CopyTableAnswerDto()
|
||||
{
|
||||
Answer = x.Answer,
|
||||
QuestionId = x.QuestionId,
|
||||
RowId = x.RowId,
|
||||
QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
RowIndex = x.RowIndex,
|
||||
TrialId = x.TrialId,
|
||||
}).ToListAsync();
|
||||
|
||||
foreach (var item in recistTableAnswers)
|
||||
{
|
||||
|
||||
item.QuestionId = tableRowAnswers.Where(y => y.OriginalId == item.RowId).Select(x => x.QuestionId).FirstOrDefault();
|
||||
|
||||
item.TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == item.QuestionId && x.QuestionMark == item.QuestionMark).Select(x => x.Id).FirstOrDefault();
|
||||
}
|
||||
|
||||
recistTableAnswers = recistTableAnswers.Where(x => x.TableQuestionId != default(Guid)).ToList();
|
||||
|
||||
List<QuestionMark?> notNeedCopyMarks = new List<QuestionMark?>()
|
||||
{
|
||||
|
||||
};
|
||||
var tableAnswers = recistTableAnswers.Select(x => new ReadingTableQuestionAnswer
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
Answer = notNeedCopyMarks.Contains(x.QuestionMark) ? string.Empty : x.Answer,
|
||||
QuestionId = x.QuestionId,
|
||||
RowIndex = x.RowIndex,
|
||||
RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault(),
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
TrialId = x.TrialId,
|
||||
VisitTaskId = visitTaskId,
|
||||
}).ToList();
|
||||
|
||||
// 添加 典型肝内病灶 默认值
|
||||
tableRowAnswers.ForEach(x =>
|
||||
{
|
||||
var tableQuestion = tableQuestionList.Where(y => y.ReadingQuestionId == x.QuestionId && y.QuestionMark == QuestionMark.TypicalIntrahepaticLesion).FirstOrDefault();
|
||||
if (tableQuestion != null)
|
||||
{
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
Answer = ((int)(object)ReadingYesOrNo.No).ToString(),
|
||||
QuestionId = x.QuestionId,
|
||||
RowIndex = x.RowIndex,
|
||||
RowId = x.Id,
|
||||
TableQuestionId = tableQuestion.Id,
|
||||
TrialId = x.TrialId,
|
||||
VisitTaskId = visitTaskId,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var addList = _mapper.Map<List<ReadingTableAnswerRowInfo>>(tableRowAnswers);
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||
|
||||
addList.ForEach(x =>
|
||||
{
|
||||
x.MergeRow = null;
|
||||
x.SplitRow = null;
|
||||
|
||||
});
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||
|
||||
addList.ForEach(x =>
|
||||
{
|
||||
x.MergeRow = null;
|
||||
x.SplitRow = null;
|
||||
|
||||
});
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return new AddTaskLesionAnswerFromLastTaskOutDto()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue