diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs index d28b0355e..733df31c0 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs @@ -585,6 +585,10 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// public async Task 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) .Where(x => x.QuestionMark == QuestionMark.ElasticArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum(); @@ -597,6 +601,10 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// public async Task 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) .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 taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).ProjectTo(_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(_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 notNeedCopyMarks = new List() - { - 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>(tableRowAnswers); - - await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList); - await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers); - await _readingTableQuestionAnswerRepository.SaveChangesAsync(); - } - - - } - } return new AddTaskLesionAnswerFromLastTaskOutDto() { diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs index 680f529c3..e27fb4721 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs @@ -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(); - // 判断当前任务是否是基线 - 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(_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 notNeedCopyMarks = new List() - { - 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>(tableRowAnswers); - - await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList); - await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers); - await _readingTableQuestionAnswerRepository.SaveChangesAsync(); - } - - - } - } - return new AddTaskLesionAnswerFromLastTaskOutDto() {