代码整理
parent
7aa5f9355e
commit
ae88921049
|
@ -108,25 +108,6 @@ namespace IRaCIS.Application.Services
|
|||
#region 病灶的拆分与合并
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 阅片期 -全局和肿瘤学任务的生成
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 阅片页面 关联信息查询
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 拆分病灶
|
||||
/// </summary>
|
||||
|
@ -135,11 +116,11 @@ namespace IRaCIS.Application.Services
|
|||
public async Task SplitLesion(SplitLesionInDto inDto)
|
||||
{
|
||||
await this.VerifyIsBaseLineTask(inDto.VisitTaskId);
|
||||
var rowAnswer = await _readingTableAnswerRowInfoRepository.Where(x =>x.Id==inDto.RowId).AsNoTracking().FirstNotNullAsync();
|
||||
var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == rowAnswer.RowIndex && x.QuestionId == inDto.QuestionId).Include(x=>x.ReadingTableQuestionTrial).ToListAsync();
|
||||
var maxRowIndex = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId&&x.RowIndex< Math.Floor(rowAnswer.RowIndex+1)).OrderByDescending(x => x.RowIndex).Select(x => x.RowIndex).FirstOrDefaultAsync();
|
||||
var rowAnswer = await _readingTableAnswerRowInfoRepository.Where(x => x.Id == inDto.RowId).AsNoTracking().FirstNotNullAsync();
|
||||
var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == rowAnswer.RowIndex && x.QuestionId == inDto.QuestionId).Include(x => x.ReadingTableQuestionTrial).ToListAsync();
|
||||
var maxRowIndex = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.RowIndex < Math.Floor(rowAnswer.RowIndex + 1)).OrderByDescending(x => x.RowIndex).Select(x => x.RowIndex).FirstOrDefaultAsync();
|
||||
var newRowIndex = maxRowIndex + (decimal)0.01;
|
||||
|
||||
|
||||
rowAnswer.RowIndex = newRowIndex;
|
||||
rowAnswer.MergeRowId = null;
|
||||
rowAnswer.SplitOrMergeType = SplitOrMergeType.Split;
|
||||
|
@ -180,7 +161,7 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
await this.VerifyIsBaseLineTask(inDto.VisitTaskId);
|
||||
|
||||
var rowsInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId &&(x.Id == inDto.MainRowId || x.Id == inDto.MergeRowId)).ToListAsync();
|
||||
var rowsInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && (x.Id == inDto.MainRowId || x.Id == inDto.MergeRowId)).ToListAsync();
|
||||
|
||||
if (rowsInfo.Count() != 2)
|
||||
{
|
||||
|
@ -197,13 +178,13 @@ namespace IRaCIS.Application.Services
|
|||
QuestionMark.ShortAxis,
|
||||
};
|
||||
|
||||
var mainAnswer = await _readingTableQuestionAnswerRepository.Where(x => x.RowId == minaid).Include(x=>x.ReadingTableQuestionTrial).ToListAsync();
|
||||
var mainAnswer = await _readingTableQuestionAnswerRepository.Where(x => x.RowId == minaid).Include(x => x.ReadingTableQuestionTrial).ToListAsync();
|
||||
|
||||
foreach (var item in mainAnswer)
|
||||
{
|
||||
await _readingTableQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x=>x.RowId== mergeid&&x.TableQuestionId==item.TableQuestionId, x => new ReadingTableQuestionAnswer()
|
||||
await _readingTableQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.RowId == mergeid && x.TableQuestionId == item.TableQuestionId, x => new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer= needRemoveMark.Contains(item.ReadingTableQuestionTrial.QuestionMark)?string.Empty:item.Answer,
|
||||
Answer = needRemoveMark.Contains(item.ReadingTableQuestionTrial.QuestionMark) ? string.Empty : item.Answer,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -227,6 +208,149 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 阅片期 -全局和肿瘤学任务的生成
|
||||
|
||||
/// <summary>
|
||||
/// 添加阅片期任务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task AddReadingTask(Guid visitTaskId)
|
||||
{
|
||||
// ****** 先生成阅片期 阅片期任务阅片完成之后生成肿瘤学的 如果没有阅片期 直接生成肿瘤学 *********////
|
||||
#region 建立关系
|
||||
// 访视阅完产生 全局
|
||||
Dictionary<ModuleTypeEnum, ReadingCategory> typeChangeDic = new Dictionary<ModuleTypeEnum, ReadingCategory>();
|
||||
typeChangeDic.Add(ModuleTypeEnum.InPlanSubjectVisit, ReadingCategory.Visit);
|
||||
typeChangeDic.Add(ModuleTypeEnum.OutPlanSubjectVisit, ReadingCategory.Visit);
|
||||
//typeChange.Add(ModuleTypeEnum.Read, ReadingCategory.ReadingPeriod);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Global, ReadingCategory.Global);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Referee, ReadingCategory.Judge);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Oncology, ReadingCategory.Oncology);
|
||||
#endregion
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
|
||||
List<ReadingGenerataTaskDTO> needReadList = new List<ReadingGenerataTaskDTO>();
|
||||
if (!taskInfo.IsAnalysisCreate)
|
||||
{
|
||||
// 任务类型
|
||||
switch (taskInfo.ReadingCategory)
|
||||
{
|
||||
case ReadingCategory.Visit:
|
||||
needReadList = await _readModuleRepository.Where(x => x.SubjectVisitId == taskInfo.SourceSubjectVisitId &&
|
||||
|
||||
x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId &&
|
||||
x.ReadingSetType == ReadingSetType.ImageReading)
|
||||
.Select(x => new ReadingGenerataTaskDTO
|
||||
{
|
||||
IsUrgent = x.IsUrgent ?? false,
|
||||
SubjectId = x.SubjectId,
|
||||
VisitNum = x.VisitNum,
|
||||
ReadingName = x.ModuleName,
|
||||
ReadModuleId = x.Id,
|
||||
ReadingCategory = typeChangeDic[x.ModuleType],
|
||||
}).ToListAsync();
|
||||
if (needReadList.Any(x => x.ReadingCategory == ReadingCategory.Global))
|
||||
{
|
||||
needReadList = needReadList.Where(x => x.ReadingCategory != ReadingCategory.Oncology).ToList();
|
||||
}
|
||||
//needReadList = needReadList.Where(x => _visitTaskRepository.Where(y => y.SouceReadModuleId == x.ReadModuleId).Count() == 0).ToList();
|
||||
await _visitTaskHelpeService.AddTaskAsync(new GenerateTaskCommand()
|
||||
{
|
||||
OriginalVisitId = visitTaskId,
|
||||
ReadingCategory = GenerateTaskCategory.Global,
|
||||
TrialId = taskInfo.TrialId,
|
||||
ReadingGenerataTaskList = needReadList
|
||||
});
|
||||
break;
|
||||
// 肿瘤学
|
||||
case ReadingCategory.Global:
|
||||
var subjectVisitId = await _readModuleRepository.Where(x => x.Id == taskInfo.SouceReadModuleId).Select(x => x.SubjectVisitId).FirstOrDefaultAsync();
|
||||
var oncologyReadId = await _readModuleRepository.Where(x => x.SubjectVisitId == subjectVisitId && x.ModuleType == ModuleTypeEnum.Oncology
|
||||
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
|
||||
|
||||
|
||||
).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
await AddOncologyTask(oncologyReadId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 阅片页面 关联信息查询 以及基本验证
|
||||
|
||||
/// <summary>
|
||||
/// 获取既往任务名称和编号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<GetReadingPastResultListOutDto>> GetReadingPastResultList(GetReadingPastResultListInDto inDto)
|
||||
{
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
|
||||
var readingPastResultList = await _visitTaskRepository.Where(x =>
|
||||
x.TrialId == taskInfo.TrialId &&
|
||||
x.SubjectId == taskInfo.SubjectId &&
|
||||
x.ArmEnum == taskInfo.ArmEnum &&
|
||||
x.Id != inDto.VisitTaskId &&
|
||||
x.DoctorUserId == taskInfo.DoctorUserId &&
|
||||
x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId &&
|
||||
x.ReadingTaskState == ReadingTaskState.HaveSigned &&
|
||||
x.TaskState == TaskState.Effect &&
|
||||
x.IsAnalysisCreate == taskInfo.IsAnalysisCreate)
|
||||
.WhereIf(taskInfo.ReadingCategory != ReadingCategory.Visit, x => x.ReadingCategory == taskInfo.ReadingCategory)
|
||||
|
||||
.ProjectTo<GetReadingPastResultListOutDto>(_mapper.ConfigurationProvider).OrderBy(x => x.VisitTaskNum).ToListAsync();
|
||||
return readingPastResultList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取阅片的受试者信息
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<GetReadingSubjectInfoOutDto> GetReadingSubjectInfo(GetReadingSubjectInfoInDto inDto)
|
||||
{
|
||||
var visitTask = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstOrDefaultAsync();
|
||||
var subjectCode = await _subjectRepository.Where(x => x.Id == visitTask.SubjectId).Select(x => x.Code).FirstOrDefaultAsync();
|
||||
|
||||
var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == visitTask.TrialReadingCriterionId).Select(x => new
|
||||
{
|
||||
x.IsReadingShowPreviousResults,
|
||||
x.IsReadingShowSubjectInfo
|
||||
}).FirstOrDefaultAsync();
|
||||
var trialInfo = await _trialRepository.Where(x => x.Id == visitTask.TrialId).Select(x => new
|
||||
{
|
||||
x.ClinicalInformationTransmissionEnum,
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
return new GetReadingSubjectInfoOutDto()
|
||||
{
|
||||
VisitTaskId = visitTask.Id,
|
||||
SubjectId = visitTask.SubjectId,
|
||||
SubjectCode = visitTask.BlindSubjectCode.IsNullOrEmpty() ? subjectCode : visitTask.BlindSubjectCode,
|
||||
ReadingCategory = visitTask.ReadingCategory,
|
||||
TaskBlindName = visitTask.TaskBlindName,
|
||||
IsReadingShowPreviousResults = criterionInfo.IsReadingShowPreviousResults,
|
||||
IsReadingShowSubjectInfo = criterionInfo.IsReadingShowSubjectInfo,
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 验证是否为基线访视任务
|
||||
/// </summary>
|
||||
|
@ -236,7 +360,7 @@ namespace IRaCIS.Application.Services
|
|||
private async Task VerifyIsBaseLineTask(Guid visitTaskId)
|
||||
{
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
|
||||
if (taskinfo.ReadingCategory!=ReadingCategory.Visit)
|
||||
if (taskinfo.ReadingCategory != ReadingCategory.Visit)
|
||||
{
|
||||
throw new BusinessValidationFailedException("当前任务不是访视任务");
|
||||
}
|
||||
|
@ -247,6 +371,10 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据任务ID获取ReadingTool
|
||||
/// </summary>
|
||||
|
@ -261,6 +389,11 @@ namespace IRaCIS.Application.Services
|
|||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
#region 表格问题相关
|
||||
|
||||
/// <summary>
|
||||
|
@ -853,9 +986,6 @@ namespace IRaCIS.Application.Services
|
|||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region 获取下一个阅片任务
|
||||
/// <summary>
|
||||
|
@ -1089,68 +1219,7 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取阅片的受试者信息
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<GetReadingSubjectInfoOutDto> GetReadingSubjectInfo(GetReadingSubjectInfoInDto inDto)
|
||||
{
|
||||
var visitTask = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstOrDefaultAsync();
|
||||
var subjectCode = await _subjectRepository.Where(x => x.Id == visitTask.SubjectId).Select(x => x.Code).FirstOrDefaultAsync();
|
||||
|
||||
var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == visitTask.TrialReadingCriterionId).Select(x => new
|
||||
{
|
||||
x.IsReadingShowPreviousResults,
|
||||
x.IsReadingShowSubjectInfo
|
||||
}).FirstOrDefaultAsync();
|
||||
var trialInfo = await _trialRepository.Where(x => x.Id == visitTask.TrialId).Select(x => new
|
||||
{
|
||||
x.ClinicalInformationTransmissionEnum,
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
return new GetReadingSubjectInfoOutDto()
|
||||
{
|
||||
VisitTaskId = visitTask.Id,
|
||||
SubjectId = visitTask.SubjectId,
|
||||
SubjectCode = visitTask.BlindSubjectCode.IsNullOrEmpty() ? subjectCode : visitTask.BlindSubjectCode,
|
||||
ReadingCategory = visitTask.ReadingCategory,
|
||||
TaskBlindName = visitTask.TaskBlindName,
|
||||
IsReadingShowPreviousResults = criterionInfo.IsReadingShowPreviousResults,
|
||||
IsReadingShowSubjectInfo = criterionInfo.IsReadingShowSubjectInfo,
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#region 获取既往结果
|
||||
/// <summary>
|
||||
/// 获取既往结果
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<GetReadingPastResultListOutDto>> GetReadingPastResultList(GetReadingPastResultListInDto inDto)
|
||||
{
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
|
||||
var readingPastResultList = await _visitTaskRepository.Where(x =>
|
||||
x.TrialId == taskInfo.TrialId &&
|
||||
x.SubjectId == taskInfo.SubjectId &&
|
||||
x.ArmEnum == taskInfo.ArmEnum &&
|
||||
x.Id != inDto.VisitTaskId &&
|
||||
x.DoctorUserId == taskInfo.DoctorUserId &&
|
||||
x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId &&
|
||||
x.ReadingTaskState == ReadingTaskState.HaveSigned &&
|
||||
x.TaskState == TaskState.Effect &&
|
||||
x.IsAnalysisCreate == taskInfo.IsAnalysisCreate)
|
||||
.WhereIf(taskInfo.ReadingCategory != ReadingCategory.Visit, x => x.ReadingCategory == taskInfo.ReadingCategory)
|
||||
|
||||
.ProjectTo<GetReadingPastResultListOutDto>(_mapper.ConfigurationProvider).OrderBy(x => x.VisitTaskNum).ToListAsync();
|
||||
return readingPastResultList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 找子问题
|
||||
/// <summary>
|
||||
|
@ -1227,7 +1296,10 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
#endregion
|
||||
|
||||
#region 保存访视任务阅片问题答案
|
||||
|
||||
|
||||
#region 阅片任务 提交填写表单
|
||||
|
||||
/// <summary>
|
||||
/// 保存任务问题
|
||||
/// </summary>
|
||||
|
@ -1258,10 +1330,6 @@ namespace IRaCIS.Application.Services
|
|||
var result = await _visitTaskRepository.SaveChangesAsync();
|
||||
return ResponseOutput.Ok(result);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 阅片任务 提交填写表单
|
||||
|
||||
/// <summary>
|
||||
/// 验证访视提交
|
||||
|
@ -1567,75 +1635,6 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加阅片期任务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task AddReadingTask(Guid visitTaskId)
|
||||
{
|
||||
// ****** 先生成阅片期 阅片期任务阅片完成之后生成肿瘤学的 如果没有阅片期 直接生成肿瘤学 *********////
|
||||
#region 建立关系
|
||||
// 访视阅完产生 全局
|
||||
Dictionary<ModuleTypeEnum, ReadingCategory> typeChangeDic = new Dictionary<ModuleTypeEnum, ReadingCategory>();
|
||||
typeChangeDic.Add(ModuleTypeEnum.InPlanSubjectVisit, ReadingCategory.Visit);
|
||||
typeChangeDic.Add(ModuleTypeEnum.OutPlanSubjectVisit, ReadingCategory.Visit);
|
||||
//typeChange.Add(ModuleTypeEnum.Read, ReadingCategory.ReadingPeriod);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Global, ReadingCategory.Global);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Referee, ReadingCategory.Judge);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Oncology, ReadingCategory.Oncology);
|
||||
#endregion
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
|
||||
List<ReadingGenerataTaskDTO> needReadList = new List<ReadingGenerataTaskDTO>();
|
||||
if (!taskInfo.IsAnalysisCreate)
|
||||
{
|
||||
// 任务类型
|
||||
switch (taskInfo.ReadingCategory)
|
||||
{
|
||||
case ReadingCategory.Visit:
|
||||
needReadList = await _readModuleRepository.Where(x => x.SubjectVisitId == taskInfo.SourceSubjectVisitId &&
|
||||
|
||||
x.TrialReadingCriterionId==taskInfo.TrialReadingCriterionId&&
|
||||
x.ReadingSetType == ReadingSetType.ImageReading)
|
||||
.Select(x => new ReadingGenerataTaskDTO
|
||||
{
|
||||
IsUrgent = x.IsUrgent ?? false,
|
||||
SubjectId = x.SubjectId,
|
||||
VisitNum = x.VisitNum,
|
||||
ReadingName = x.ModuleName,
|
||||
ReadModuleId = x.Id,
|
||||
ReadingCategory = typeChangeDic[x.ModuleType],
|
||||
}).ToListAsync();
|
||||
if (needReadList.Any(x => x.ReadingCategory == ReadingCategory.Global))
|
||||
{
|
||||
needReadList = needReadList.Where(x => x.ReadingCategory != ReadingCategory.Oncology).ToList();
|
||||
}
|
||||
//needReadList = needReadList.Where(x => _visitTaskRepository.Where(y => y.SouceReadModuleId == x.ReadModuleId).Count() == 0).ToList();
|
||||
await _visitTaskHelpeService.AddTaskAsync(new GenerateTaskCommand()
|
||||
{
|
||||
OriginalVisitId = visitTaskId,
|
||||
ReadingCategory = GenerateTaskCategory.Global,
|
||||
TrialId = taskInfo.TrialId,
|
||||
ReadingGenerataTaskList = needReadList
|
||||
});
|
||||
break;
|
||||
// 肿瘤学
|
||||
case ReadingCategory.Global:
|
||||
var subjectVisitId = await _readModuleRepository.Where(x => x.Id == taskInfo.SouceReadModuleId).Select(x => x.SubjectVisitId).FirstOrDefaultAsync();
|
||||
var oncologyReadId = await _readModuleRepository.Where(x => x.SubjectVisitId == subjectVisitId && x.ModuleType == ModuleTypeEnum.Oncology
|
||||
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
|
||||
|
||||
|
||||
).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
await AddOncologyTask(oncologyReadId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue