代码整理
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,213 +975,39 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
|
||||
|
||||
#region 获取下一个阅片任务
|
||||
#region 访视任务 - Dicom 阅片
|
||||
|
||||
/// <summary>
|
||||
/// 获取下一个阅片任务
|
||||
/// 修改Dicom阅片问题
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<GetReadingTaskDto> GetNextTask(GetNextTaskInDto inDto)
|
||||
public async Task<IResponseOutput> ChangeDicomReadingQuestionAnswer(ChangeDicomReadingQuestionAnswerInDto 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)
|
||||
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()
|
||||
{
|
||||
|
||||
#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,
|
||||
ReadingQuestionCriterionTrialId = inDto.ReadingQuestionCriterionTrialId,
|
||||
ReadingQuestionTrialId = x.ReadingQuestionTrialId,
|
||||
SubjectId = taskInfo.SubjectId,
|
||||
ReadingQuestionCriterionTrialId = criterionId,
|
||||
ReadingQuestionTrialId = x.Id,
|
||||
TrialId = taskInfo.TrialId,
|
||||
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);
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(needAddAnswer);
|
||||
await _readingTaskQuestionAnswerRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok(true);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 提交表格问题
|
||||
/// 提交表格问题答案 病灶
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
|
@ -1300,7 +1099,7 @@ namespace IRaCIS.Application.Services
|
|||
QuestionId = inDto.QuestionId,
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
RowIndex = inDto.RowIndex,
|
||||
RowId= rowInfo.Id,
|
||||
RowId = rowInfo.Id,
|
||||
VisitTaskId = inDto.VisitTaskId
|
||||
}).ToList();
|
||||
|
||||
|
@ -1349,7 +1148,7 @@ namespace IRaCIS.Application.Services
|
|||
.SelectMany(x => x.ReadingTableQuestionTrialList).Where(x => x.QuestionMark == QuestionMark.AutoId).Select(x => new
|
||||
{
|
||||
x.ReadingQuestionId,
|
||||
TableQuestionId=x.Id,
|
||||
TableQuestionId = x.Id,
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
|
@ -1357,31 +1156,32 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
var questionMarkList = await _readingQuestionTrialRepository.Where(x => questionIds.Contains(x.Id)).Select(x => new
|
||||
{
|
||||
QuestionId=x.Id,
|
||||
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 >();
|
||||
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();
|
||||
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))
|
||||
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,
|
||||
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,
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -1393,11 +1193,180 @@ namespace IRaCIS.Application.Services
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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,15 +1,9 @@
|
|||
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
|
||||
{
|
||||
|
@ -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