代码整理
parent
f967de6b13
commit
e907a3e89b
|
@ -455,33 +455,6 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
#region 表格问题相关
|
#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>
|
/// <summary>
|
||||||
|
@ -1002,213 +975,39 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 获取下一个阅片任务
|
#region 访视任务 - Dicom 阅片
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取下一个阅片任务
|
/// 修改Dicom阅片问题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inDto"></param>
|
/// <param name="inDto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<GetReadingTaskDto> GetNextTask(GetNextTaskInDto inDto)
|
public async Task<IResponseOutput> ChangeDicomReadingQuestionAnswer(ChangeDicomReadingQuestionAnswerInDto inDto)
|
||||||
{
|
{
|
||||||
GetReadingTaskDto? task = new GetReadingTaskDto();
|
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
|
||||||
|
var criterionId = taskInfo.TrialReadingCriterionId;
|
||||||
var trialReadingCriterionId = inDto.TrialReadingCriterionId;
|
var questionIds = inDto.Answers.Select(x => x.Id).ToList();
|
||||||
|
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && questionIds.Contains(x.ReadingQuestionTrialId));
|
||||||
if(trialReadingCriterionId==null && inDto.VisistTaskId == null)
|
var needAddAnswer = inDto.Answers.Select(x => new ReadingTaskQuestionAnswer()
|
||||||
{
|
|
||||||
throw new BusinessValidationFailedException("当没有任务Id的时候,标准Id必传");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inDto.VisistTaskId != null)
|
|
||||||
{
|
|
||||||
task = await _visitTaskRepository.Where(x => x.Id == inDto.VisistTaskId).Select(x => new GetReadingTaskDto()
|
|
||||||
{
|
|
||||||
VisitTaskId = x.Id,
|
|
||||||
TaskBlindName = x.TaskBlindName,
|
|
||||||
SubjectId = x.SubjectId,
|
|
||||||
ReadingCategory = x.ReadingCategory,
|
|
||||||
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : default(Guid),
|
|
||||||
VisitNum = x.VisitTaskNum,
|
|
||||||
TrialReadingCriterionId=x.TrialReadingCriterionId,
|
|
||||||
|
|
||||||
}).FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
trialReadingCriterionId = task.TrialReadingCriterionId;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (inDto.SubjectId != null)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
#region 之前的
|
|
||||||
//var subjectList = await _subjectRepository.Where(t => t.TrialId == inDto.TrialId)
|
|
||||||
|
|
||||||
//.Select(s => new SubjectTask()
|
|
||||||
//{
|
|
||||||
// SubjectId = s.Id,
|
|
||||||
// UnReadTaskCount = s.SubjectVisitTaskList.Count(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect),
|
|
||||||
//}).OrderBy(x => x.SubjectId).ToListAsync();
|
|
||||||
//subjectList = subjectList.Select((x, index) => new SubjectTask()
|
|
||||||
//{
|
|
||||||
// Index = index,
|
|
||||||
// SubjectId = x.SubjectId,
|
|
||||||
// UnReadTaskCount = x.UnReadTaskCount,
|
|
||||||
//}).ToList();
|
|
||||||
|
|
||||||
|
|
||||||
//var subjectIndex = subjectList.Where(x => x.SubjectId == inDto.SubjectId).Select(x => x.Index).FirstOrDefault();
|
|
||||||
//var newSubjectId = subjectList.Where(x => x.Index >= subjectIndex && x.UnReadTaskCount != 0).Select(x => x.SubjectId).FirstOrDefault();
|
|
||||||
|
|
||||||
//var taskquery = _visitTaskRepository.Where(x => x.TrialId == inDto.TrialId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.SubjectId == newSubjectId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect).Select(x => new GetReadingTaskDto()
|
|
||||||
//{
|
|
||||||
// VisitTaskId = x.Id,
|
|
||||||
// TaskBlindName = x.TaskBlindName,
|
|
||||||
// ReadingCategory = x.ReadingCategory,
|
|
||||||
// VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule == null ? default(Guid) : x.ReadModule.SubjectVisitId,
|
|
||||||
// VisitNum = x.VisitTaskNum,
|
|
||||||
//}).OrderBy(x => x.VisitNum).ThenBy(x => x.ReadingCategory);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
var subjectTaskList = await _visitTaskService.GetOrderReadingIQueryable(inDto.TrialId, trialReadingCriterionId).Item2.ToListAsync();
|
|
||||||
|
|
||||||
var index = 0;
|
|
||||||
subjectTaskList.ForEach(x =>
|
|
||||||
{
|
|
||||||
x.Index = index;
|
|
||||||
index++;
|
|
||||||
});
|
|
||||||
|
|
||||||
var subjectIndex = subjectTaskList.Where(x => x.SubjectId == inDto.SubjectId && x.SubjectCode == inDto.SubjectCode).Select(x => x.Index).FirstOrDefault();
|
|
||||||
|
|
||||||
var currentSubject = subjectTaskList.Where(x => x.Index >= subjectIndex && !x.ExistReadingApply).OrderBy(x => x.Index).FirstOrDefault();
|
|
||||||
|
|
||||||
if (currentSubject == null)
|
|
||||||
{
|
|
||||||
throw new BusinessValidationFailedException("任务都已经完成");
|
|
||||||
}
|
|
||||||
|
|
||||||
task = currentSubject.UnReadTaskList.Select(x => new GetReadingTaskDto()
|
|
||||||
{
|
|
||||||
ReadingCategory = x.ReadingCategory,
|
|
||||||
SubjectCode = currentSubject.SubjectCode,
|
|
||||||
SubjectId = currentSubject.SubjectId,
|
|
||||||
TaskBlindName = x.TaskBlindName,
|
|
||||||
VisitNum = x.VisitNum,
|
|
||||||
VisistId = x.VisistId ?? default(Guid),
|
|
||||||
VisitTaskId = x.Id,
|
|
||||||
TrialReadingCriterionId = x.TrialReadingCriterionId,
|
|
||||||
}).FirstOrDefault();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
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,
|
|
||||||
TaskBlindName = x.TaskBlindName,
|
|
||||||
ReadingCategory = x.ReadingCategory,
|
|
||||||
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule == null ? default(Guid) : x.ReadModule.SubjectVisitId,
|
|
||||||
VisitNum = x.VisitTaskNum,
|
|
||||||
SubjectId = x.SubjectId,
|
|
||||||
SubjectCode = x.Subject.Code,
|
|
||||||
TrialReadingCriterionId = x.TrialReadingCriterionId,
|
|
||||||
}).FirstOrDefaultAsync();
|
|
||||||
if (task == null)
|
|
||||||
{
|
|
||||||
throw new BusinessValidationFailedException("任务都已经完成");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (task.SubjectCode.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
task.SubjectCode = await _subjectRepository.Where(x => x.Id == task.SubjectId).Select(x => x.Code).FirstOrDefaultAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => x.Id == task.VisitTaskId && x.FirstReadingTime == null, x => new VisitTask()
|
|
||||||
{
|
|
||||||
FirstReadingTime = DateTime.Now,
|
|
||||||
});
|
|
||||||
await _visitTaskRepository.SaveChangesAsync();
|
|
||||||
|
|
||||||
var visitTaskInfo = await _visitTaskRepository.Where(x => x.Id == task.VisitTaskId).FirstNotNullAsync();
|
|
||||||
|
|
||||||
task.SubjectCode = visitTaskInfo.BlindSubjectCode.IsNullOrEmpty() ? task.SubjectCode : visitTaskInfo.BlindSubjectCode;
|
|
||||||
|
|
||||||
|
|
||||||
var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == visitTaskInfo.TrialReadingCriterionId).Select(x => new
|
|
||||||
{
|
|
||||||
x.IsReadingShowPreviousResults,
|
|
||||||
x.IsReadingShowSubjectInfo,
|
|
||||||
|
|
||||||
}).FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
task.IsReadingShowPreviousResults = criterionInfo.IsReadingShowPreviousResults;
|
|
||||||
task.IsReadingShowSubjectInfo = criterionInfo.IsReadingShowSubjectInfo;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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,
|
Answer = x.Answer,
|
||||||
ReadingQuestionCriterionTrialId = inDto.ReadingQuestionCriterionTrialId,
|
SubjectId = taskInfo.SubjectId,
|
||||||
ReadingQuestionTrialId = x.ReadingQuestionTrialId,
|
ReadingQuestionCriterionTrialId = criterionId,
|
||||||
|
ReadingQuestionTrialId = x.Id,
|
||||||
|
TrialId = taskInfo.TrialId,
|
||||||
VisitTaskId = inDto.VisitTaskId,
|
VisitTaskId = inDto.VisitTaskId,
|
||||||
TrialId = inDto.TrialId
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
await _readingTaskQuestionAnswerRepository.AddRangeAsync(needAddAnswer);
|
||||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(inDto.VisitTaskId, x => new VisitTask()
|
await _readingTaskQuestionAnswerRepository.SaveChangesAsync();
|
||||||
{
|
|
||||||
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);
|
return ResponseOutput.Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 提交表格问题
|
/// 提交表格问题答案 病灶
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inDto"></param>
|
/// <param name="inDto"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
@ -1373,7 +1172,8 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
foreach (var row in rowInfo.Where(x => x.QuestionId == item.ReadingQuestionId))
|
foreach (var row in rowInfo.Where(x => x.QuestionId == item.ReadingQuestionId))
|
||||||
{
|
{
|
||||||
questionAnswerList.Add(new ReadingTableQuestionAnswer() {
|
questionAnswerList.Add(new ReadingTableQuestionAnswer()
|
||||||
|
{
|
||||||
Answer = orderMark + row.RowIndex.GetLesionMark(),
|
Answer = orderMark + row.RowIndex.GetLesionMark(),
|
||||||
Id = NewId.NextGuid(),
|
Id = NewId.NextGuid(),
|
||||||
QuestionId = item.ReadingQuestionId,
|
QuestionId = item.ReadingQuestionId,
|
||||||
|
@ -1393,11 +1193,180 @@ namespace IRaCIS.Application.Services
|
||||||
return ResponseOutput.Ok(true);
|
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>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<GetReadingTaskDto> GetNextTask(GetNextTaskInDto inDto)
|
||||||
|
{
|
||||||
|
GetReadingTaskDto? task = new GetReadingTaskDto();
|
||||||
|
|
||||||
|
var trialReadingCriterionId = inDto.TrialReadingCriterionId;
|
||||||
|
|
||||||
|
if (trialReadingCriterionId == null && inDto.VisistTaskId == null)
|
||||||
|
{
|
||||||
|
throw new BusinessValidationFailedException("当没有任务Id的时候,标准Id必传");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inDto.VisistTaskId != null)
|
||||||
|
{
|
||||||
|
task = await _visitTaskRepository.Where(x => x.Id == inDto.VisistTaskId).Select(x => new GetReadingTaskDto()
|
||||||
|
{
|
||||||
|
VisitTaskId = x.Id,
|
||||||
|
TaskBlindName = x.TaskBlindName,
|
||||||
|
SubjectId = x.SubjectId,
|
||||||
|
ReadingCategory = x.ReadingCategory,
|
||||||
|
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : default(Guid),
|
||||||
|
VisitNum = x.VisitTaskNum,
|
||||||
|
TrialReadingCriterionId = x.TrialReadingCriterionId,
|
||||||
|
|
||||||
|
}).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
trialReadingCriterionId = task.TrialReadingCriterionId;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (inDto.SubjectId != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
#region 之前的
|
||||||
|
//var subjectList = await _subjectRepository.Where(t => t.TrialId == inDto.TrialId)
|
||||||
|
|
||||||
|
//.Select(s => new SubjectTask()
|
||||||
|
//{
|
||||||
|
// SubjectId = s.Id,
|
||||||
|
// UnReadTaskCount = s.SubjectVisitTaskList.Count(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect),
|
||||||
|
//}).OrderBy(x => x.SubjectId).ToListAsync();
|
||||||
|
//subjectList = subjectList.Select((x, index) => new SubjectTask()
|
||||||
|
//{
|
||||||
|
// Index = index,
|
||||||
|
// SubjectId = x.SubjectId,
|
||||||
|
// UnReadTaskCount = x.UnReadTaskCount,
|
||||||
|
//}).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
//var subjectIndex = subjectList.Where(x => x.SubjectId == inDto.SubjectId).Select(x => x.Index).FirstOrDefault();
|
||||||
|
//var newSubjectId = subjectList.Where(x => x.Index >= subjectIndex && x.UnReadTaskCount != 0).Select(x => x.SubjectId).FirstOrDefault();
|
||||||
|
|
||||||
|
//var taskquery = _visitTaskRepository.Where(x => x.TrialId == inDto.TrialId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.SubjectId == newSubjectId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect).Select(x => new GetReadingTaskDto()
|
||||||
|
//{
|
||||||
|
// VisitTaskId = x.Id,
|
||||||
|
// TaskBlindName = x.TaskBlindName,
|
||||||
|
// ReadingCategory = x.ReadingCategory,
|
||||||
|
// VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule == null ? default(Guid) : x.ReadModule.SubjectVisitId,
|
||||||
|
// VisitNum = x.VisitTaskNum,
|
||||||
|
//}).OrderBy(x => x.VisitNum).ThenBy(x => x.ReadingCategory);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
var subjectTaskList = await _visitTaskService.GetOrderReadingIQueryable(inDto.TrialId, trialReadingCriterionId).Item2.ToListAsync();
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
subjectTaskList.ForEach(x =>
|
||||||
|
{
|
||||||
|
x.Index = index;
|
||||||
|
index++;
|
||||||
|
});
|
||||||
|
|
||||||
|
var subjectIndex = subjectTaskList.Where(x => x.SubjectId == inDto.SubjectId && x.SubjectCode == inDto.SubjectCode).Select(x => x.Index).FirstOrDefault();
|
||||||
|
|
||||||
|
var currentSubject = subjectTaskList.Where(x => x.Index >= subjectIndex && !x.ExistReadingApply).OrderBy(x => x.Index).FirstOrDefault();
|
||||||
|
|
||||||
|
if (currentSubject == null)
|
||||||
|
{
|
||||||
|
throw new BusinessValidationFailedException("任务都已经完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
task = currentSubject.UnReadTaskList.Select(x => new GetReadingTaskDto()
|
||||||
|
{
|
||||||
|
ReadingCategory = x.ReadingCategory,
|
||||||
|
SubjectCode = currentSubject.SubjectCode,
|
||||||
|
SubjectId = currentSubject.SubjectId,
|
||||||
|
TaskBlindName = x.TaskBlindName,
|
||||||
|
VisitNum = x.VisitNum,
|
||||||
|
VisistId = x.VisistId ?? default(Guid),
|
||||||
|
VisitTaskId = x.Id,
|
||||||
|
TrialReadingCriterionId = x.TrialReadingCriterionId,
|
||||||
|
}).FirstOrDefault();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
TaskBlindName = x.TaskBlindName,
|
||||||
|
ReadingCategory = x.ReadingCategory,
|
||||||
|
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule == null ? default(Guid) : x.ReadModule.SubjectVisitId,
|
||||||
|
VisitNum = x.VisitTaskNum,
|
||||||
|
SubjectId = x.SubjectId,
|
||||||
|
SubjectCode = x.Subject.Code,
|
||||||
|
TrialReadingCriterionId = x.TrialReadingCriterionId,
|
||||||
|
}).FirstOrDefaultAsync();
|
||||||
|
if (task == null)
|
||||||
|
{
|
||||||
|
throw new BusinessValidationFailedException("任务都已经完成");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (task.SubjectCode.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
task.SubjectCode = await _subjectRepository.Where(x => x.Id == task.SubjectId).Select(x => x.Code).FirstOrDefaultAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => x.Id == task.VisitTaskId && x.FirstReadingTime == null, x => new VisitTask()
|
||||||
|
{
|
||||||
|
FirstReadingTime = DateTime.Now,
|
||||||
|
});
|
||||||
|
await _visitTaskRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
var visitTaskInfo = await _visitTaskRepository.Where(x => x.Id == task.VisitTaskId).FirstNotNullAsync();
|
||||||
|
|
||||||
|
task.SubjectCode = visitTaskInfo.BlindSubjectCode.IsNullOrEmpty() ? task.SubjectCode : visitTaskInfo.BlindSubjectCode;
|
||||||
|
|
||||||
|
|
||||||
|
var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == visitTaskInfo.TrialReadingCriterionId).Select(x => new
|
||||||
|
{
|
||||||
|
x.IsReadingShowPreviousResults,
|
||||||
|
x.IsReadingShowSubjectInfo,
|
||||||
|
|
||||||
|
}).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
task.IsReadingShowPreviousResults = criterionInfo.IsReadingShowPreviousResults;
|
||||||
|
task.IsReadingShowSubjectInfo = criterionInfo.IsReadingShowSubjectInfo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using MassTransit;
|
|
||||||
using IRaCIS.Core.Infra.EFCore.Common;
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
using Panda.DynamicWebApi.Attributes;
|
using Panda.DynamicWebApi.Attributes;
|
||||||
using AutoMapper;
|
|
||||||
using IRaCIS.Core.Application.Contracts;
|
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
|
namespace IRaCIS.Application.Services
|
||||||
{
|
{
|
||||||
|
@ -35,7 +29,38 @@ namespace IRaCIS.Application.Services
|
||||||
return ResponseOutput.Ok(true);
|
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>
|
/// <summary>
|
||||||
/// 获取阅片非Dicom文件
|
/// 获取阅片非Dicom文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -112,11 +137,9 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 找子问题
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 找子问题
|
/// 找子问题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -189,6 +212,5 @@ namespace IRaCIS.Application.Services
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue