IRC_NewDev
parent
2f41c21f75
commit
136a9e54ca
|
@ -585,6 +585,10 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<decimal?> GetEEM(ReadingCalculateDto inDto)
|
public async Task<decimal?> GetEEM(ReadingCalculateDto inDto)
|
||||||
{
|
{
|
||||||
|
if (inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).Count() == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||||
.Where(x => x.QuestionMark == QuestionMark.ElasticArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum();
|
.Where(x => x.QuestionMark == QuestionMark.ElasticArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum();
|
||||||
|
|
||||||
|
@ -597,6 +601,10 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<decimal?> GetEEMLumenSum(ReadingCalculateDto inDto)
|
public async Task<decimal?> GetEEMLumenSum(ReadingCalculateDto inDto)
|
||||||
{
|
{
|
||||||
|
if (inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).Count() == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
|
||||||
.Where(x => x.QuestionMark == QuestionMark.ElasticAreaDiffValue).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum();
|
.Where(x => x.QuestionMark == QuestionMark.ElasticAreaDiffValue).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum();
|
||||||
|
|
||||||
|
@ -675,97 +683,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
{
|
{
|
||||||
var visitTaskId = inDto.VisitTaskId;
|
var visitTaskId = inDto.VisitTaskId;
|
||||||
|
|
||||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).ProjectTo<VisitTaskDto>(_mapper.ConfigurationProvider).FirstNotNullAsync();
|
|
||||||
|
|
||||||
var baseLineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskinfo.SubjectId && x.IsBaseLine).Select(x => x.Id).FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
// 判断当前任务是否是基线
|
|
||||||
if (taskinfo.SourceSubjectVisitId != baseLineVisitId)
|
|
||||||
{
|
|
||||||
|
|
||||||
// 判断当前任务是是否有表格问题答案
|
|
||||||
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
|
|
||||||
{
|
|
||||||
if (taskinfo.BeforeConvertedTaskId != null)
|
|
||||||
{
|
|
||||||
await _generalCalculateService.AddConvertedTaskFocus(taskinfo.Id, taskinfo.BeforeConvertedTaskId.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
|
|
||||||
x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
|
|
||||||
x.IsAnalysisCreate == taskinfo.IsAnalysisCreate &&
|
|
||||||
x.DoctorUserId == taskinfo.DoctorUserId &&
|
|
||||||
x.IsSelfAnalysis == taskinfo.IsSelfAnalysis &&
|
|
||||||
x.SubjectId == taskinfo.SubjectId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ArmEnum == taskinfo.ArmEnum
|
|
||||||
&& x.VisitTaskNum < taskinfo.VisitTaskNum && x.TaskState == TaskState.Effect
|
|
||||||
).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,
|
|
||||||
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();
|
|
||||||
|
|
||||||
|
|
||||||
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,
|
|
||||||
QuestionMark.State,
|
|
||||||
};
|
|
||||||
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);
|
|
||||||
|
|
||||||
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList);
|
|
||||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
|
||||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new AddTaskLesionAnswerFromLastTaskOutDto()
|
return new AddTaskLesionAnswerFromLastTaskOutDto()
|
||||||
{
|
{
|
||||||
|
|
|
@ -660,94 +660,6 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
|
|
||||||
var baseLineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskinfo.SubjectId && x.IsBaseLine).Select(x => x.Id).FirstOrDefaultAsync();
|
var baseLineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskinfo.SubjectId && x.IsBaseLine).Select(x => x.Id).FirstOrDefaultAsync();
|
||||||
|
|
||||||
// 判断当前任务是否是基线
|
|
||||||
if (taskinfo.SourceSubjectVisitId != baseLineVisitId)
|
|
||||||
{
|
|
||||||
|
|
||||||
// 判断当前任务是是否有表格问题答案
|
|
||||||
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
|
|
||||||
{
|
|
||||||
if (taskinfo.BeforeConvertedTaskId != null)
|
|
||||||
{
|
|
||||||
await _generalCalculateService.AddConvertedTaskFocus(taskinfo.Id, taskinfo.BeforeConvertedTaskId.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
|
|
||||||
x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
|
|
||||||
x.IsAnalysisCreate == taskinfo.IsAnalysisCreate &&
|
|
||||||
x.DoctorUserId == taskinfo.DoctorUserId &&
|
|
||||||
x.IsSelfAnalysis == taskinfo.IsSelfAnalysis &&
|
|
||||||
x.SubjectId == taskinfo.SubjectId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ArmEnum == taskinfo.ArmEnum
|
|
||||||
&& x.VisitTaskNum < taskinfo.VisitTaskNum && x.TaskState == TaskState.Effect
|
|
||||||
).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,
|
|
||||||
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();
|
|
||||||
|
|
||||||
|
|
||||||
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,
|
|
||||||
QuestionMark.State,
|
|
||||||
};
|
|
||||||
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);
|
|
||||||
|
|
||||||
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList);
|
|
||||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
|
||||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new AddTaskLesionAnswerFromLastTaskOutDto()
|
return new AddTaskLesionAnswerFromLastTaskOutDto()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue