修改预设与复制的冲突
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
0b28ef5461
commit
95e0239e42
|
|
@ -5,6 +5,7 @@ using IRaCIS.Core.Domain.Share;
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using NPOI.Util;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
{
|
{
|
||||||
|
|
@ -369,83 +370,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
|
|
||||||
List<ReadingTableAnswerRowInfo> addRowList = new List<ReadingTableAnswerRowInfo>();
|
List<ReadingTableAnswerRowInfo> addRowList = new List<ReadingTableAnswerRowInfo>();
|
||||||
List<ReadingTableQuestionAnswer> addTableQuestionAnswerList = new List<ReadingTableQuestionAnswer>();
|
List<ReadingTableQuestionAnswer> addTableQuestionAnswerList = new List<ReadingTableQuestionAnswer>();
|
||||||
// 判断当前任务是否是基线
|
|
||||||
if (taskinfo.SourceSubjectVisitId != baseLineVisitId && isReadingTaskViewInOrder == ReadingOrder.InOrder)
|
|
||||||
{
|
|
||||||
// 判断当前任务是是否有表格问题答案
|
|
||||||
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
|
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
|
||||||
{
|
{
|
||||||
|
|
||||||
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.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 && x.ReadingQuestionTrial.IsCopyLesions).Select(x => new CopyTableAnswerDto()
|
|
||||||
{
|
|
||||||
Answer = x.Answer,
|
|
||||||
QuestionId = x.QuestionId,
|
|
||||||
RowId = x.RowId,
|
|
||||||
QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
|
|
||||||
TableQuestionId = x.TableQuestionId,
|
|
||||||
RowIndex = x.RowIndex,
|
|
||||||
IsCopy = x.ReadingTableQuestionTrial.IsCopy,
|
|
||||||
TrialId = x.TrialId,
|
|
||||||
}).ToListAsync();
|
|
||||||
|
|
||||||
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == LastVisitTaskId && x.ReadingQuestionTrial.IsCopyLesions).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();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var tableAnswers = copyTableAnswers.Select(x => new ReadingTableQuestionAnswer
|
|
||||||
{
|
|
||||||
Id = NewId.NextGuid(),
|
|
||||||
Answer = x.IsCopy ? x.Answer : string.Empty,
|
|
||||||
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);
|
|
||||||
|
|
||||||
addRowList.AddRange(addList);
|
|
||||||
addTableQuestionAnswerList.AddRange(tableAnswers);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 添加 是否预设
|
// 添加 是否预设
|
||||||
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionTrial.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.IsPreinstall).Include(x => x.ReadingQuestionTrial).ToListAsync();
|
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionTrial.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.IsPreinstall).Include(x => x.ReadingQuestionTrial).ToListAsync();
|
||||||
|
// 是否有预设
|
||||||
if (tableQuestionList.Count() > 0)
|
if (tableQuestionList.Count() > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -492,6 +422,91 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (taskinfo.SourceSubjectVisitId != baseLineVisitId && isReadingTaskViewInOrder == ReadingOrder.InOrder)
|
||||||
|
{
|
||||||
|
|
||||||
|
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.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 && x.ReadingQuestionTrial.IsCopyLesions).Select(x => new CopyTableAnswerDto()
|
||||||
|
{
|
||||||
|
Answer = x.Answer,
|
||||||
|
QuestionId = x.QuestionId,
|
||||||
|
RowId = x.RowId,
|
||||||
|
QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
|
||||||
|
TableQuestionId = x.TableQuestionId,
|
||||||
|
RowIndex = x.RowIndex,
|
||||||
|
IsCopy = x.ReadingTableQuestionTrial.IsCopy,
|
||||||
|
TrialId = x.TrialId,
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == LastVisitTaskId && x.ReadingQuestionTrial.IsCopyLesions).ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
||||||
|
|
||||||
|
tableRowAnswers.ForEach(x =>
|
||||||
|
{
|
||||||
|
|
||||||
|
var rowinfo = addTableQuestionAnswerList.Where(y => y.QuestionId == x.QuestionId && y.RowIndex == x.RowIndex).FirstOrDefault();
|
||||||
|
|
||||||
|
x.VisitTaskId = visitTaskId;
|
||||||
|
x.IsCurrentTaskAdd = false;
|
||||||
|
x.Id = rowinfo == null ? NewId.NextGuid() : rowinfo.Id;
|
||||||
|
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 tableAnswers = copyTableAnswers.Select(x => new ReadingTableQuestionAnswer
|
||||||
|
{
|
||||||
|
Id = NewId.NextGuid(),
|
||||||
|
Answer = x.IsCopy ? x.Answer : string.Empty,
|
||||||
|
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);
|
||||||
|
|
||||||
|
addRowList.AddRange(addList);
|
||||||
|
addTableQuestionAnswerList.AddRange(tableAnswers);
|
||||||
|
|
||||||
|
addRowList = addRowList.GroupBy(x => new { x.Id }).Select(x => x.ToList().FirstOrDefault()).ToList();
|
||||||
|
addTableQuestionAnswerList = addTableQuestionAnswerList.GroupBy(x =>
|
||||||
|
new
|
||||||
|
{
|
||||||
|
x.RowId,
|
||||||
|
x.TableQuestionId,
|
||||||
|
x.Id
|
||||||
|
}).Select(x => new ReadingTableQuestionAnswer()
|
||||||
|
{
|
||||||
|
Id = NewId.NextGuid(),
|
||||||
|
Answer = x.Select(y => y.Answer).Max() ?? string.Empty,
|
||||||
|
QuestionId = x.Select(y => y.QuestionId).Max(),
|
||||||
|
RowIndex = x.Select(y => y.RowIndex).Max(),
|
||||||
|
RowId = x.Key.RowId,
|
||||||
|
TableQuestionId = x.Key.TableQuestionId,
|
||||||
|
TrialId = x.Select(y => y.TrialId).Max(),
|
||||||
|
VisitTaskId = visitTaskId,
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addRowList);
|
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addRowList);
|
||||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(addTableQuestionAnswerList);
|
await _readingTableQuestionAnswerRepository.AddRangeAsync(addTableQuestionAnswerList);
|
||||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue