代码整理
parent
f967de6b13
commit
e907a3e89b
|
@ -455,33 +455,6 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
#region 表格问题相关
|
||||
|
||||
/// <summary>
|
||||
/// 修改Dicom阅片问题
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> ChangeDicomReadingQuestionAnswer(ChangeDicomReadingQuestionAnswerInDto inDto)
|
||||
{
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
|
||||
var criterionId = taskInfo.TrialReadingCriterionId;
|
||||
var questionIds = inDto.Answers.Select(x => x.Id).ToList();
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && questionIds.Contains(x.ReadingQuestionTrialId));
|
||||
var needAddAnswer = inDto.Answers.Select(x => new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
|
||||
Answer = x.Answer,
|
||||
SubjectId = taskInfo.SubjectId,
|
||||
ReadingQuestionCriterionTrialId = criterionId,
|
||||
ReadingQuestionTrialId = x.Id,
|
||||
TrialId = taskInfo.TrialId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
|
||||
}).ToList();
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(needAddAnswer);
|
||||
await _readingTaskQuestionAnswerRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok(true);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -1002,7 +975,248 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
|
||||
|
||||
#region 获取下一个阅片任务
|
||||
#region 访视任务 - Dicom 阅片
|
||||
|
||||
/// <summary>
|
||||
/// 修改Dicom阅片问题
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> ChangeDicomReadingQuestionAnswer(ChangeDicomReadingQuestionAnswerInDto inDto)
|
||||
{
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
|
||||
var criterionId = taskInfo.TrialReadingCriterionId;
|
||||
var questionIds = inDto.Answers.Select(x => x.Id).ToList();
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && questionIds.Contains(x.ReadingQuestionTrialId));
|
||||
var needAddAnswer = inDto.Answers.Select(x => new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
|
||||
Answer = x.Answer,
|
||||
SubjectId = taskInfo.SubjectId,
|
||||
ReadingQuestionCriterionTrialId = criterionId,
|
||||
ReadingQuestionTrialId = x.Id,
|
||||
TrialId = taskInfo.TrialId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
|
||||
}).ToList();
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(needAddAnswer);
|
||||
await _readingTaskQuestionAnswerRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok(true);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 提交表格问题答案 病灶
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<SubmitTableQuestionOutDto> SubmitTableQuestion(SubmitTableQuestionInDto inDto)
|
||||
{
|
||||
SubmitTableQuestionOutDto result = new SubmitTableQuestionOutDto();
|
||||
await VerifyTaskIsSign(inDto.VisitTaskId);
|
||||
|
||||
var tableQuestionIds = inDto.AnswerList.Select(x => x.TableQuestionId).ToList();
|
||||
|
||||
var tableQuestionIdGroup = tableQuestionIds.GroupBy(x => new { TableQuestionId = x }).Select(x => new TableQuestionData
|
||||
{
|
||||
TableQuestionId = x.Key.TableQuestionId,
|
||||
Count = x.Count()
|
||||
}).ToList();
|
||||
|
||||
if (tableQuestionIdGroup.Any(x => x.Count > 1))
|
||||
{
|
||||
throw new BusinessValidationFailedException($"相同问题传入两次!");
|
||||
}
|
||||
|
||||
if (inDto.RowIndex % 1 == 0)
|
||||
{
|
||||
var questionInfo = await _readingQuestionTrialRepository.Where(x => x.Id == inDto.QuestionId).FirstNotNullAsync();
|
||||
if (questionInfo.MaxQuestionCount != null)
|
||||
{
|
||||
if (questionInfo.MaxQuestionCount <
|
||||
(
|
||||
(await _readingTableAnswerRowInfoRepository.Where(x => x.RowIndex != inDto.RowIndex && ((x.RowIndex % 1) == 0) && x.VisitTaskId == inDto.VisitTaskId
|
||||
&& x.QuestionId == inDto.QuestionId
|
||||
).CountAsync()) + 1))
|
||||
{
|
||||
throw new BusinessValidationFailedException($"当前提交问题最大问题数为{questionInfo.MaxQuestionCount}!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var tableQuestions = await _readingTableQuestionTrialRepository.Where(x => tableQuestionIds.Contains(x.Id) && x.MaxRowCount != null && x.MaxRowCount != 0).ToListAsync();
|
||||
|
||||
foreach (var item in tableQuestions)
|
||||
{
|
||||
var answer = inDto.AnswerList.Where(x => x.TableQuestionId == item.Id).Select(x => x.Answer).FirstOrDefault();
|
||||
if (!answer.IsNullOrEmpty())
|
||||
{
|
||||
var rowCount = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.TableQuestionId == item.Id && ((x.RowIndex % 1) == 0) && x.Answer == answer && x.RowIndex != inDto.RowIndex).CountAsync();
|
||||
|
||||
if (rowCount > item.MaxRowCount.Value - 1)
|
||||
{
|
||||
throw new BusinessValidationFailedException($"问题{item.QuestionName}最大相同问题数为{item.MaxRowCount.Value},当前已存在{rowCount}条!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
var isCurrentTaskAddList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex).Select(x => x.IsCurrentTaskAdd).ToListAsync();
|
||||
bool isCurrentTaskAdd = true;
|
||||
if (isCurrentTaskAddList.Count() > 0)
|
||||
{
|
||||
isCurrentTaskAdd = isCurrentTaskAddList[0];
|
||||
}
|
||||
|
||||
|
||||
ReadingTableAnswerRowInfo rowInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex).AsNoTracking().FirstOrDefaultAsync();
|
||||
|
||||
rowInfo = rowInfo == null ? new ReadingTableAnswerRowInfo() : rowInfo;
|
||||
|
||||
await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex);
|
||||
await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex);
|
||||
|
||||
rowInfo.Id = NewId.NextGuid();
|
||||
rowInfo.TrialId = inDto.TrialId;
|
||||
rowInfo.QuestionId = inDto.QuestionId;
|
||||
rowInfo.MeasureData = inDto.MeasureData;
|
||||
rowInfo.IsCurrentTaskAdd = isCurrentTaskAdd;
|
||||
rowInfo.RowIndex = inDto.RowIndex;
|
||||
rowInfo.InstanceId = inDto.InstanceId;
|
||||
rowInfo.SeriesId = inDto.SeriesId;
|
||||
rowInfo.VisitTaskId = inDto.VisitTaskId;
|
||||
rowInfo.StudyId = inDto.StudyId;
|
||||
rowInfo.IsCanEditPosition = inDto.IsCanEditPosition;
|
||||
result.RowId = rowInfo.Id;
|
||||
|
||||
List<ReadingTableQuestionAnswer> answerList = inDto.AnswerList.Select(x => new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = x.Answer,
|
||||
Id = NewId.NextGuid(),
|
||||
TrialId = inDto.TrialId,
|
||||
QuestionId = inDto.QuestionId,
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
RowIndex = inDto.RowIndex,
|
||||
RowId = rowInfo.Id,
|
||||
VisitTaskId = inDto.VisitTaskId
|
||||
}).ToList();
|
||||
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.AddAsync(rowInfo);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(answerList);
|
||||
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(inDto.VisitTaskId, x => new VisitTask()
|
||||
{
|
||||
ReadingTaskState = ReadingTaskState.Reading,
|
||||
|
||||
});
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
await this._readingCalculateService.CalculateTask(new CalculateTaskInDto()
|
||||
{
|
||||
IsChangeOtherTask = false,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 提交Dicom阅片信息
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[NonDynamicMethod]
|
||||
public async Task<IResponseOutput> SubmitDicomVisitTask(SubmitDicomVisitTaskInDto inDto)
|
||||
{
|
||||
|
||||
|
||||
await VerifyTaskIsSign(inDto.VisitTaskId);
|
||||
|
||||
// 修改编号
|
||||
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
|
||||
|
||||
// 获取标准表格外层问题
|
||||
var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskInfo.TrialReadingCriterionId && x.LesionType != null && x.ReadingTableQuestionTrialList.Any(x => x.QuestionMark == QuestionMark.AutoId))
|
||||
.SelectMany(x => x.ReadingTableQuestionTrialList).Where(x => x.QuestionMark == QuestionMark.AutoId).Select(x => new
|
||||
{
|
||||
x.ReadingQuestionId,
|
||||
TableQuestionId = x.Id,
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
var questionIds = questionList.Select(x => x.ReadingQuestionId).ToList();
|
||||
|
||||
var questionMarkList = await _readingQuestionTrialRepository.Where(x => questionIds.Contains(x.Id)).Select(x => new
|
||||
{
|
||||
QuestionId = x.Id,
|
||||
x.OrderMark,
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
var rowInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && questionIds.Contains(x.QuestionId)).ToListAsync();
|
||||
List<ReadingTableQuestionAnswer> questionAnswerList = new List<ReadingTableQuestionAnswer>();
|
||||
foreach (var item in questionList)
|
||||
{
|
||||
await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.QuestionId == item.ReadingQuestionId
|
||||
&& x.TableQuestionId == item.TableQuestionId && x.VisitTaskId == inDto.VisitTaskId);
|
||||
|
||||
var orderMark = questionMarkList.Where(x => x.QuestionId == item.ReadingQuestionId).Select(x => x.OrderMark).FirstOrDefault();
|
||||
|
||||
foreach (var row in rowInfo.Where(x => x.QuestionId == item.ReadingQuestionId))
|
||||
{
|
||||
questionAnswerList.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = orderMark + row.RowIndex.GetLesionMark(),
|
||||
Id = NewId.NextGuid(),
|
||||
QuestionId = item.ReadingQuestionId,
|
||||
RowId = row.Id,
|
||||
RowIndex = row.RowIndex,
|
||||
TableQuestionId = item.TableQuestionId,
|
||||
TrialId = taskInfo.TrialId,
|
||||
VisitTaskId = taskInfo.Id,
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(questionAnswerList);
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
|
||||
await this.SubmitTaskChangeState(inDto.VisitTaskId);
|
||||
return ResponseOutput.Ok(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Dicom 非dicom 公用
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 验证访视提交
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> VerifyVisitTaskQuestions(VerifyVisitTaskQuestionsInDto inDto)
|
||||
{
|
||||
|
||||
await _readingCalculateService.VerifyVisitTaskQuestions(inDto);
|
||||
|
||||
//await _readingCalculateService.VerifyVisitTaskQuestions(inDto);
|
||||
return ResponseOutput.Ok(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取下一个阅片任务
|
||||
/// </summary>
|
||||
|
@ -1015,7 +1229,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
var trialReadingCriterionId = inDto.TrialReadingCriterionId;
|
||||
|
||||
if(trialReadingCriterionId==null && inDto.VisistTaskId == null)
|
||||
if (trialReadingCriterionId == null && inDto.VisistTaskId == null)
|
||||
{
|
||||
throw new BusinessValidationFailedException("当没有任务Id的时候,标准Id必传");
|
||||
}
|
||||
|
@ -1030,7 +1244,7 @@ namespace IRaCIS.Application.Services
|
|||
ReadingCategory = x.ReadingCategory,
|
||||
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : default(Guid),
|
||||
VisitNum = x.VisitTaskNum,
|
||||
TrialReadingCriterionId=x.TrialReadingCriterionId,
|
||||
TrialReadingCriterionId = x.TrialReadingCriterionId,
|
||||
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
|
@ -1104,8 +1318,8 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
else
|
||||
{
|
||||
task = await _visitTaskRepository.Where(x => x.TrialId == inDto.TrialId && x.TrialReadingCriterionId==trialReadingCriterionId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.DoctorUserId == _userInfo.Id
|
||||
&& x.TrialReadingCriterionId == trialReadingCriterionId
|
||||
task = await _visitTaskRepository.Where(x => x.TrialId == inDto.TrialId && x.TrialReadingCriterionId == trialReadingCriterionId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.DoctorUserId == _userInfo.Id
|
||||
&& x.TrialReadingCriterionId == trialReadingCriterionId
|
||||
&& x.TaskState == TaskState.Effect).Select(x => new GetReadingTaskDto()
|
||||
{
|
||||
VisitTaskId = x.Id,
|
||||
|
@ -1143,7 +1357,7 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
x.IsReadingShowPreviousResults,
|
||||
x.IsReadingShowSubjectInfo,
|
||||
|
||||
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
task.IsReadingShowPreviousResults = criterionInfo.IsReadingShowPreviousResults;
|
||||
|
@ -1153,254 +1367,9 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
return task;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region 阅片任务 提交填写表单
|
||||
|
||||
/// <summary>
|
||||
/// 保存任务问题
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SaveVisitTaskQuestions(SubmitVisitTaskQuestionsInDto inDto)
|
||||
{
|
||||
var subjectId = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.SubjectId).FirstOrDefaultAsync();
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.ReadingQuestionCriterionTrialId == inDto.ReadingQuestionCriterionTrialId);
|
||||
List<ReadingTaskQuestionAnswer> readingTaskAnswerList = inDto.AnswerList.Select(x => new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
SubjectId = subjectId,
|
||||
Answer = x.Answer,
|
||||
ReadingQuestionCriterionTrialId = inDto.ReadingQuestionCriterionTrialId,
|
||||
ReadingQuestionTrialId = x.ReadingQuestionTrialId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
TrialId = inDto.TrialId
|
||||
}).ToList();
|
||||
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(inDto.VisitTaskId, x => new VisitTask()
|
||||
{
|
||||
ReadingTaskState = ReadingTaskState.Reading,
|
||||
|
||||
});
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(readingTaskAnswerList);
|
||||
var result = await _visitTaskRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证访视提交
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> VerifyVisitTaskQuestions(VerifyVisitTaskQuestionsInDto inDto)
|
||||
{
|
||||
|
||||
await _readingCalculateService.VerifyVisitTaskQuestions(inDto);
|
||||
|
||||
//await _readingCalculateService.VerifyVisitTaskQuestions(inDto);
|
||||
return ResponseOutput.Ok(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 提交表格问题
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<SubmitTableQuestionOutDto> SubmitTableQuestion(SubmitTableQuestionInDto inDto)
|
||||
{
|
||||
SubmitTableQuestionOutDto result = new SubmitTableQuestionOutDto();
|
||||
await VerifyTaskIsSign(inDto.VisitTaskId);
|
||||
|
||||
var tableQuestionIds = inDto.AnswerList.Select(x => x.TableQuestionId).ToList();
|
||||
|
||||
var tableQuestionIdGroup = tableQuestionIds.GroupBy(x => new { TableQuestionId = x }).Select(x => new TableQuestionData
|
||||
{
|
||||
TableQuestionId = x.Key.TableQuestionId,
|
||||
Count = x.Count()
|
||||
}).ToList();
|
||||
|
||||
if (tableQuestionIdGroup.Any(x => x.Count > 1))
|
||||
{
|
||||
throw new BusinessValidationFailedException($"相同问题传入两次!");
|
||||
}
|
||||
|
||||
if (inDto.RowIndex % 1 == 0)
|
||||
{
|
||||
var questionInfo = await _readingQuestionTrialRepository.Where(x => x.Id == inDto.QuestionId).FirstNotNullAsync();
|
||||
if (questionInfo.MaxQuestionCount != null)
|
||||
{
|
||||
if (questionInfo.MaxQuestionCount <
|
||||
(
|
||||
(await _readingTableAnswerRowInfoRepository.Where(x => x.RowIndex != inDto.RowIndex && ((x.RowIndex % 1) == 0) && x.VisitTaskId == inDto.VisitTaskId
|
||||
&& x.QuestionId == inDto.QuestionId
|
||||
).CountAsync()) + 1))
|
||||
{
|
||||
throw new BusinessValidationFailedException($"当前提交问题最大问题数为{questionInfo.MaxQuestionCount}!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var tableQuestions = await _readingTableQuestionTrialRepository.Where(x => tableQuestionIds.Contains(x.Id) && x.MaxRowCount != null && x.MaxRowCount != 0).ToListAsync();
|
||||
|
||||
foreach (var item in tableQuestions)
|
||||
{
|
||||
var answer = inDto.AnswerList.Where(x => x.TableQuestionId == item.Id).Select(x => x.Answer).FirstOrDefault();
|
||||
if (!answer.IsNullOrEmpty())
|
||||
{
|
||||
var rowCount = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.TableQuestionId == item.Id && ((x.RowIndex % 1) == 0) && x.Answer == answer && x.RowIndex != inDto.RowIndex).CountAsync();
|
||||
|
||||
if (rowCount > item.MaxRowCount.Value - 1)
|
||||
{
|
||||
throw new BusinessValidationFailedException($"问题{item.QuestionName}最大相同问题数为{item.MaxRowCount.Value},当前已存在{rowCount}条!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
var isCurrentTaskAddList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex).Select(x => x.IsCurrentTaskAdd).ToListAsync();
|
||||
bool isCurrentTaskAdd = true;
|
||||
if (isCurrentTaskAddList.Count() > 0)
|
||||
{
|
||||
isCurrentTaskAdd = isCurrentTaskAddList[0];
|
||||
}
|
||||
|
||||
|
||||
ReadingTableAnswerRowInfo rowInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex).AsNoTracking().FirstOrDefaultAsync();
|
||||
|
||||
rowInfo = rowInfo == null ? new ReadingTableAnswerRowInfo() : rowInfo;
|
||||
|
||||
await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex);
|
||||
await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex);
|
||||
|
||||
rowInfo.Id = NewId.NextGuid();
|
||||
rowInfo.TrialId = inDto.TrialId;
|
||||
rowInfo.QuestionId = inDto.QuestionId;
|
||||
rowInfo.MeasureData = inDto.MeasureData;
|
||||
rowInfo.IsCurrentTaskAdd = isCurrentTaskAdd;
|
||||
rowInfo.RowIndex = inDto.RowIndex;
|
||||
rowInfo.InstanceId = inDto.InstanceId;
|
||||
rowInfo.SeriesId = inDto.SeriesId;
|
||||
rowInfo.VisitTaskId = inDto.VisitTaskId;
|
||||
rowInfo.StudyId = inDto.StudyId;
|
||||
rowInfo.IsCanEditPosition = inDto.IsCanEditPosition;
|
||||
result.RowId = rowInfo.Id;
|
||||
|
||||
List<ReadingTableQuestionAnswer> answerList = inDto.AnswerList.Select(x => new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = x.Answer,
|
||||
Id = NewId.NextGuid(),
|
||||
TrialId = inDto.TrialId,
|
||||
QuestionId = inDto.QuestionId,
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
RowIndex = inDto.RowIndex,
|
||||
RowId= rowInfo.Id,
|
||||
VisitTaskId = inDto.VisitTaskId
|
||||
}).ToList();
|
||||
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.AddAsync(rowInfo);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(answerList);
|
||||
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(inDto.VisitTaskId, x => new VisitTask()
|
||||
{
|
||||
ReadingTaskState = ReadingTaskState.Reading,
|
||||
|
||||
});
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
await this._readingCalculateService.CalculateTask(new CalculateTaskInDto()
|
||||
{
|
||||
IsChangeOtherTask = false,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 提交Dicom阅片信息
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[NonDynamicMethod]
|
||||
public async Task<IResponseOutput> SubmitDicomVisitTask(SubmitDicomVisitTaskInDto inDto)
|
||||
{
|
||||
|
||||
|
||||
await VerifyTaskIsSign(inDto.VisitTaskId);
|
||||
|
||||
// 修改编号
|
||||
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
|
||||
|
||||
// 获取标准表格外层问题
|
||||
var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskInfo.TrialReadingCriterionId && x.LesionType != null && x.ReadingTableQuestionTrialList.Any(x => x.QuestionMark == QuestionMark.AutoId))
|
||||
.SelectMany(x => x.ReadingTableQuestionTrialList).Where(x => x.QuestionMark == QuestionMark.AutoId).Select(x => new
|
||||
{
|
||||
x.ReadingQuestionId,
|
||||
TableQuestionId=x.Id,
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
var questionIds = questionList.Select(x => x.ReadingQuestionId).ToList();
|
||||
|
||||
var questionMarkList = await _readingQuestionTrialRepository.Where(x => questionIds.Contains(x.Id)).Select(x => new
|
||||
{
|
||||
QuestionId=x.Id,
|
||||
x.OrderMark,
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
var rowInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && questionIds.Contains(x.QuestionId)).ToListAsync();
|
||||
List<ReadingTableQuestionAnswer> questionAnswerList = new List< ReadingTableQuestionAnswer >();
|
||||
foreach (var item in questionList)
|
||||
{
|
||||
await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.QuestionId == item.ReadingQuestionId
|
||||
&& x.TableQuestionId == item.TableQuestionId && x.VisitTaskId == inDto.VisitTaskId);
|
||||
|
||||
var orderMark= questionMarkList.Where(x=>x.QuestionId==item.ReadingQuestionId).Select(x=>x.OrderMark).FirstOrDefault();
|
||||
|
||||
foreach (var row in rowInfo.Where(x=>x.QuestionId== item.ReadingQuestionId))
|
||||
{
|
||||
questionAnswerList.Add(new ReadingTableQuestionAnswer() {
|
||||
Answer= orderMark+row.RowIndex.GetLesionMark(),
|
||||
Id=NewId.NextGuid(),
|
||||
QuestionId= item.ReadingQuestionId,
|
||||
RowId= row.Id,
|
||||
RowIndex=row.RowIndex,
|
||||
TableQuestionId=item.TableQuestionId,
|
||||
TrialId= taskInfo.TrialId,
|
||||
VisitTaskId= taskInfo.Id,
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(questionAnswerList);
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
|
||||
await this.SubmitTaskChangeState(inDto.VisitTaskId);
|
||||
return ResponseOutput.Ok(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 签名提交任务修改状态
|
||||
/// </summary>
|
||||
|
@ -1409,7 +1378,7 @@ namespace IRaCIS.Application.Services
|
|||
private async Task SubmitTaskChangeState(Guid visitTaskId)
|
||||
{
|
||||
await VerifyTaskIsSign(visitTaskId);
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync( visitTaskId, x => new VisitTask()
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(visitTaskId, x => new VisitTask()
|
||||
{
|
||||
ReadingTaskState = ReadingTaskState.HaveSigned,
|
||||
SignTime = DateTime.Now,
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
using IRaCIS.Core.Domain.Share;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using MassTransit;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using Panda.DynamicWebApi.Attributes;
|
||||
using AutoMapper;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Newtonsoft.Json;
|
||||
using IRaCIS.Core.Application.Service;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
|
||||
namespace IRaCIS.Application.Services
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 非Dicom
|
||||
/// </summary>
|
||||
|
@ -35,7 +29,38 @@ namespace IRaCIS.Application.Services
|
|||
return ResponseOutput.Ok(true);
|
||||
}
|
||||
|
||||
#region 获取阅片非Dicom文件
|
||||
|
||||
/// <summary>
|
||||
/// 保存任务问题
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SaveVisitTaskQuestions(SubmitVisitTaskQuestionsInDto inDto)
|
||||
{
|
||||
var subjectId = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.SubjectId).FirstOrDefaultAsync();
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.ReadingQuestionCriterionTrialId == inDto.ReadingQuestionCriterionTrialId);
|
||||
List<ReadingTaskQuestionAnswer> readingTaskAnswerList = inDto.AnswerList.Select(x => new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
SubjectId = subjectId,
|
||||
Answer = x.Answer,
|
||||
ReadingQuestionCriterionTrialId = inDto.ReadingQuestionCriterionTrialId,
|
||||
ReadingQuestionTrialId = x.ReadingQuestionTrialId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
TrialId = inDto.TrialId
|
||||
}).ToList();
|
||||
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(inDto.VisitTaskId, x => new VisitTask()
|
||||
{
|
||||
ReadingTaskState = ReadingTaskState.Reading,
|
||||
|
||||
});
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(readingTaskAnswerList);
|
||||
var result = await _visitTaskRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取阅片非Dicom文件
|
||||
/// </summary>
|
||||
|
@ -112,11 +137,9 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 找子问题
|
||||
/// <summary>
|
||||
/// 找子问题
|
||||
/// </summary>
|
||||
|
@ -189,6 +212,5 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue