Uat_Study
he 2022-09-09 18:14:26 +08:00
parent 3586e650f9
commit b137e42c7a
1 changed files with 177 additions and 166 deletions

View File

@ -27,7 +27,7 @@ namespace IRaCIS.Application.Services
[ApiExplorerSettings(GroupName = "Reading")]
public class ReadingImageTaskService : BaseService, IReadingImageTaskService
{
private readonly IRepository<NoneDicomStudy> _noneDicomStudyRepository;
private readonly IRepository<VisitTask> _visitTaskRepository;
private readonly IRepository<Trial> _trialRepository;
@ -149,7 +149,7 @@ namespace IRaCIS.Application.Services
await _readingTableAnswerRowInfoRepository.DeleteFromQueryAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == inDto.RowIndex && x.QuestionId == inDto.QuestionId);
await _readingTableAnswerRowInfoRepository.SaveChangesAsync();
var indexs =await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId).Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToListAsync();
var indexs = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId).Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToListAsync();
var index = 1;
foreach (var item in indexs)
@ -177,20 +177,20 @@ namespace IRaCIS.Application.Services
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<(List<DicomReadingQuestionAnswer>,object)> GetDicomReadingQuestionAnswer(GetDicomReadingQuestionAnswerInDto inDto)
public async Task<(List<DicomReadingQuestionAnswer>, object)> GetDicomReadingQuestionAnswer(GetDicomReadingQuestionAnswerInDto inDto)
{
var criterionId = await _readingQuestionCriterionTrialRepository.Where(x => x.IsConfirm && x.TrialId == inDto.TrialId).Select(x => x.Id).FirstOrDefaultAsync();
var questions = await _readingQuestionTrialRepository.Where(x => x.IsShowInDicom && x.ReadingQuestionCriterionTrialId == criterionId&&x.Type!=ReadingQestionType.Table)
var questions = await _readingQuestionTrialRepository.Where(x => x.IsShowInDicom && x.ReadingQuestionCriterionTrialId == criterionId && x.Type != ReadingQestionType.Table)
.ProjectTo<DicomReadingQuestionAnswer>(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync();
var answers = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync();
var groups = questions.Where(x => x.Type != ReadingQestionType.Group).Select(x => x.GroupName).ToList();
var result = questions.Where(x => x.Type == ReadingQestionType.Group&&groups.Contains(x.GroupName)).ToList();
var result = questions.Where(x => x.Type == ReadingQestionType.Group && groups.Contains(x.GroupName)).ToList();
foreach (var item in result)
foreach (var item in result)
{
GetDicomReadingAnswer(item, questions, answers);
}
@ -199,13 +199,13 @@ namespace IRaCIS.Application.Services
{
ReadingTaskState = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.ReadingTaskState).FirstOrDefaultAsync()
}) ;
});
}
private void GetDicomReadingAnswer(DicomReadingQuestionAnswer item,List<DicomReadingQuestionAnswer> questions,List<ReadingTaskQuestionAnswer> answers)
private void GetDicomReadingAnswer(DicomReadingQuestionAnswer item, List<DicomReadingQuestionAnswer> questions, List<ReadingTaskQuestionAnswer> answers)
{
item.Answer = answers.Where(x => x.ReadingQuestionTrialId == item.Id).Select(x => x.Answer).FirstIsNullReturnEmpty();
item.Childrens = questions.Where(x => x.ParentId == item.Id||((item.Type == ReadingQestionType.Group && x.Type != ReadingQestionType.Group && x.ParentId == null && x.GroupName == item.GroupName)) ).ToList();
item.Childrens = questions.Where(x => x.ParentId == item.Id || ((item.Type == ReadingQestionType.Group && x.Type != ReadingQestionType.Group && x.ParentId == null && x.GroupName == item.GroupName))).ToList();
if (item.Childrens != null && item.Childrens.Count > 0)
{
foreach (var question in item.Childrens)
@ -213,7 +213,7 @@ namespace IRaCIS.Application.Services
GetDicomReadingAnswer(question, questions, answers);
}
}
}
/// <summary>
@ -221,7 +221,7 @@ namespace IRaCIS.Application.Services
/// </summary>
/// <param name="visitTaskId"></param>
/// <returns></returns>
private async Task<bool> AddBaseLineAnswerToOtherTask(Guid visitTaskId)
{
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
@ -235,24 +235,24 @@ namespace IRaCIS.Application.Services
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
{
// 找到基线的任务Id
var baseLineTaskId = await _visitTaskRepository.Where(x => x.SourceSubjectVisitId == baseLineVisitId && x.TaskState == TaskState.Effect&&x.ArmEnum==taskinfo.ArmEnum).Select(x => x.Id).FirstOrDefaultAsync();
var baseLineTaskId = await _visitTaskRepository.Where(x => x.SourceSubjectVisitId == baseLineVisitId && x.TaskState == TaskState.Effect && x.ArmEnum == taskinfo.ArmEnum).Select(x => x.Id).FirstOrDefaultAsync();
var copyTableAnswers =await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == baseLineTaskId).Select(x=> new CopyTableAnswerDto() {
Answer=x.Answer,
QuestionId=x.QuestionId,
QuestionMark=x.ReadingTableQuestionTrial.QuestionMark,
TableQuestionId=x.TableQuestionId,
RowIndex=x.RowIndex,
TrialId=x.TrialId
var copyTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == baseLineTaskId).Select(x => new CopyTableAnswerDto() {
Answer = x.Answer,
QuestionId = x.QuestionId,
QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
TableQuestionId = x.TableQuestionId,
RowIndex = x.RowIndex,
TrialId = x.TrialId
}).ToListAsync();
var tableRowAnswers=await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == baseLineTaskId).Select(x=> new ReadingTableAnswerRowInfo() {
IsCurrentTaskAdd=false,
QuestionId=x.QuestionId,
RowIndex=x.RowIndex,
TrialId=x.TrialId,
VisitTaskId=visitTaskId,
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == baseLineTaskId).Select(x => new ReadingTableAnswerRowInfo() {
IsCurrentTaskAdd = false,
QuestionId = x.QuestionId,
RowIndex = x.RowIndex,
TrialId = x.TrialId,
VisitTaskId = visitTaskId,
}).ToListAsync();
tableRowAnswers.ForEach(x =>
@ -261,7 +261,7 @@ namespace IRaCIS.Application.Services
x.Id = NewId.NextGuid();
});
List<QuestionMark?> notNeedCopyMarks = new List<QuestionMark?>()
List<QuestionMark?> notNeedCopyMarks = new List<QuestionMark?>()
{
QuestionMark.MajorAxis,
QuestionMark.ShortAxis,
@ -304,14 +304,14 @@ namespace IRaCIS.Application.Services
var visitTaskInfo = await _visitTaskRepository.Where(x => x.Id == indto.VisitTaskId).FirstNotNullAsync();
result.ReadingTaskState = visitTaskInfo.ReadingTaskState;
var taskInfoList = await _visitTaskRepository.Where(x => (x.SubjectId == visitTaskInfo.SubjectId && x.TaskState == TaskState.Effect
&& x.ReadingCategory == ReadingCategory.Visit && !x.IsAnalysisCreate && x.ReadingTaskState == ReadingTaskState.HaveSigned)||x.Id== indto.VisitTaskId
&& x.ReadingCategory == ReadingCategory.Visit && !x.IsAnalysisCreate && x.ReadingTaskState == ReadingTaskState.HaveSigned) || x.Id == indto.VisitTaskId
).OrderBy(x => x.VisitTaskNum).Select(x => new VisitTaskInfo()
{
BlindName=x.SourceSubjectVisit.BlindName,
BlindName = x.SourceSubjectVisit.BlindName,
VisitTaskId = x.Id,
TaskName = x.TaskName,
VisitTaskNum = x.VisitTaskNum,
IsCurrentTask=x.Id==indto.VisitTaskId,
IsCurrentTask = x.Id == indto.VisitTaskId,
}).ToListAsync();
@ -321,7 +321,7 @@ namespace IRaCIS.Application.Services
var criterionId = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == indto.TrialId && x.IsConfirm).Select(x => x.Id).FirstOrDefaultAsync();
var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == criterionId).ToListAsync();
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == criterionId).OrderBy(x=>x.ShowOrder).ToListAsync();
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == criterionId).OrderBy(x => x.ShowOrder).ToListAsync();
var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync();
@ -335,9 +335,9 @@ namespace IRaCIS.Application.Services
{
QuestionId = x.Id,
GroupName = x.GroupName,
IsShowInDicom=x.IsShowInDicom,
Type=x.Type,
TypeValue=x.TypeValue,
IsShowInDicom = x.IsShowInDicom,
Type = x.Type,
TypeValue = x.TypeValue,
QuestionName = x.QuestionName,
ShowOrder = x.ShowOrder,
@ -346,24 +346,24 @@ namespace IRaCIS.Application.Services
// 分组
foreach (var item in questions)
{
item.Childrens = questionList.Where(x => x.GroupName == item.GroupName&&x.Type!= ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto()
item.Childrens = questionList.Where(x => x.GroupName == item.GroupName && x.Type != ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto()
{
GroupName = x.GroupName,
QuestionId = x.Id,
IsShowInDicom = x.IsShowInDicom,
QuestionName = x.QuestionName,
Type=x.Type,
TypeValue=x.TypeValue,
Type = x.Type,
TypeValue = x.TypeValue,
ShowOrder = x.ShowOrder,
OrderMark=x.OrderMark,
OrderMark = x.OrderMark,
}).ToList();
// 问题
foreach (var question in item.Childrens)
{
foreach (var task in taskInfoList)
{
@ -382,7 +382,7 @@ namespace IRaCIS.Application.Services
{
QuestionName = question.OrderMark + x.ToString().PadLeft(2, '0'),
RowIndex=x,
RowIndex = x,
}).ToList();
@ -390,14 +390,14 @@ namespace IRaCIS.Application.Services
foreach (var row in question.Childrens)
{
// tableQuestion
row.Childrens = tableQuestionList.Where(x=>x.ReadingQuestionId== question.QuestionId).Select(x => new ReadingReportDto()
row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto()
{
QuestionName = x.QuestionName,
QuestionId = x.ReadingQuestionId,
TableQuestionId = x.Id,
Type=x.Type,
QuestionMark=x.QuestionMark,
TypeValue =x.TypeValue,
Type = x.Type,
QuestionMark = x.QuestionMark,
TypeValue = x.TypeValue,
RowIndex = row.RowIndex,
ShowOrder = x.ShowOrder,
@ -411,17 +411,17 @@ namespace IRaCIS.Application.Services
tableQuestion.Answer.Add(new TaskQuestionAnswer()
{
Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId&&x.RowIndex==tableQuestion.RowIndex&&x.TableQuestionId== tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(),
Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(),
TaskName = task.TaskName,
VisitTaskId = task.VisitTaskId,
});
}
}
}
};
}
#endregion
@ -449,7 +449,7 @@ namespace IRaCIS.Application.Services
await this.AddBaseLineAnswerToOtherTask(inDto.VisitTaskId);
return await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId)
.WhereIf(inDto.QuestionId != null, x => x.QuestionId == inDto.QuestionId)
.ProjectTo<GetTableAnswerRowInfoOutDto>(_mapper.ConfigurationProvider).OrderBy(x=>x.ShowOrder).ThenBy(x=>x.RowIndex)
.ProjectTo<GetTableAnswerRowInfoOutDto>(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ThenBy(x => x.RowIndex)
.ToListAsync();
}
@ -459,7 +459,7 @@ namespace IRaCIS.Application.Services
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<(GetReadingQuestionAndAnswerOutDto,object)> GetReadingQuestionAndAnswer(GetReadingQuestionAndAnswerInDto inDto)
public async Task<(GetReadingQuestionAndAnswerOutDto, object)> GetReadingQuestionAndAnswer(GetReadingQuestionAndAnswerInDto inDto)
{
var result = new GetReadingQuestionAndAnswerOutDto();
@ -468,21 +468,21 @@ namespace IRaCIS.Application.Services
result.ReadingTaskState = taskinfo.ReadingTaskState;
var baseLineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskinfo.SubjectId && x.IsBaseLine).Select(x => x.Id).FirstOrDefaultAsync();
result.IsBaseLineTask= taskinfo.SourceSubjectVisitId == baseLineVisitId;
result.IsBaseLineTask = taskinfo.SourceSubjectVisitId == baseLineVisitId;
var readingTaskState = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.ReadingTaskState).FirstOrDefaultAsync();
var criterion = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == inDto.TrialId && x.IsConfirm).FirstNotNullAsync();
#region 获取问题及答案
var qusetionList = await _readingQuestionTrialRepository.Where(x=>x.ReadingQuestionCriterionTrialId== criterion.Id)
.ProjectTo<TrialReadQuestionData>(_mapper.ConfigurationProvider).Where(x=>x.IsShowInDicom && (x.Type == ReadingQestionType.Table||x.Type== ReadingQestionType.Group)).OrderBy(x => x.ShowOrder).ToListAsync();
var qusetionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == criterion.Id)
.ProjectTo<TrialReadQuestionData>(_mapper.ConfigurationProvider).Where(x => x.IsShowInDicom && (x.Type == ReadingQestionType.Table || x.Type == ReadingQestionType.Group)).OrderBy(x => x.ShowOrder).ToListAsync();
var usedGurops = qusetionList.Where(x => x.Type == ReadingQestionType.Table).Select(x => x.GroupName).ToList();
qusetionList = qusetionList.Where(x =>usedGurops.Contains(x.GroupName)).ToList();
qusetionList = qusetionList.Where(x => usedGurops.Contains(x.GroupName)).ToList();
var answers = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync();
qusetionList.ForEach(x =>
@ -570,12 +570,12 @@ namespace IRaCIS.Application.Services
/// <param name="item"></param>
/// <param name="questionlists"></param>
/// <param name="tableQuestionLists"></param>
private void FindChildQuestion(TrialReadQuestionData item, List<TrialReadQuestionData> questionlists, List<TableQuestionTrial> tableQuestionLists,List<ReadingTableQuestionAnswerInfo> tableAnswers,List<ReadingTableAnswerRowInfo> tableAnsweRowInfos)
private void FindChildQuestion(TrialReadQuestionData item, List<TrialReadQuestionData> questionlists, List<TableQuestionTrial> tableQuestionLists, List<ReadingTableQuestionAnswerInfo> tableAnswers, List<ReadingTableAnswerRowInfo> tableAnsweRowInfos)
{
item.Childrens = questionlists.Where(x => x.ParentId == item.Id || (item.Type == ReadingQestionType.Group && x.Type != ReadingQestionType.Group && x.ParentId == null && x.GroupName == item.GroupName)).ToList();
item.TableQuestions = new TrialReadTableQuestion();
item.TableQuestions.Questions = tableQuestionLists.Where(x => x.ReadingQuestionId == item.Id).OrderBy(x=>x.ShowOrder).ToList();
item.TableQuestions.Questions = tableQuestionLists.Where(x => x.ReadingQuestionId == item.Id).OrderBy(x => x.ShowOrder).ToList();
item.TableQuestions.Questions.ForEach(x =>
{
@ -604,7 +604,7 @@ namespace IRaCIS.Application.Services
}).ToList();
});
var thisAnswer = tableAnswers.Where(x => x.QuestionId == item.Id).ToList();
var thisAnswer = tableAnswers.Where(x => x.QuestionId == item.Id).ToList();
var orders = thisAnswer.Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToList();
item.TableQuestions.Answers = new List<Dictionary<string, string>>();
orders.ForEach(x =>
@ -618,7 +618,7 @@ namespace IRaCIS.Application.Services
var rowInfo = tableAnsweRowInfos.Where(y => y.RowIndex == x && y.QuestionId == item.Id).FirstOrDefault();
answers.Add("MeasureData", rowInfo==null?string.Empty:rowInfo.MeasureData);
answers.Add("MeasureData", rowInfo == null ? string.Empty : rowInfo.MeasureData);
answers.Add("RowIndex", x.ToString());
answers.Add("InstanceId", rowInfo == null ? string.Empty : rowInfo.InstanceId.ToString());
answers.Add("SeriesId", rowInfo == null ? string.Empty : rowInfo.SeriesId.ToString());
@ -644,7 +644,7 @@ namespace IRaCIS.Application.Services
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<(List<GetRelatedVisitTaskOutDto>,object)> GetRelatedVisitTask(GetRelatedVisitTaskInDto inDto)
public async Task<(List<GetRelatedVisitTaskOutDto>, object)> GetRelatedVisitTask(GetRelatedVisitTaskInDto inDto)
{
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
var result = await _visitTaskRepository.Where(x =>
@ -658,12 +658,12 @@ namespace IRaCIS.Application.Services
x.ReadingCategory == ReadingCategory.Visit) || x.Id == inDto.VisitTaskId)
.Select(x => new GetRelatedVisitTaskOutDto()
{
TaskBlindName=x.TaskBlindName,
TaskName=x.TaskName,
VisitId=x.SourceSubjectVisitId,
VisitTaskId=x.Id,
VisitTaskNum=x.VisitTaskNum,
IsCurrentTask=x.Id==inDto.VisitTaskId,
TaskBlindName = x.TaskBlindName,
TaskName = x.TaskName,
VisitId = x.SourceSubjectVisitId,
VisitTaskId = x.Id,
VisitTaskNum = x.VisitTaskNum,
IsCurrentTask = x.Id == inDto.VisitTaskId,
}).OrderBy(x => x.VisitTaskNum).ToListAsync();
@ -672,7 +672,7 @@ namespace IRaCIS.Application.Services
return (result, new
{
ReadingTaskState = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.ReadingTaskState).FirstOrDefaultAsync()
}) ;
});
}
#endregion
@ -702,21 +702,21 @@ namespace IRaCIS.Application.Services
}
GetOncologyReadingInfoOutDto result = new GetOncologyReadingInfoOutDto() {
TrialEvaluationResult= trialCriterion.EvaluationResult,
IsShowDetail= trialCriterion.IsShowDetail,
TrialEvaluationReason = trialCriterion.EvaluationReason.IsNullOrEmpty()? ReadingCommon.EvaluationReason : trialCriterion.EvaluationReason,
OncologyTaskId = inDto.VisitTaskId,
ReadingTaskState= taskInfo.ReadingTaskState,
TrialEvaluationResult = trialCriterion.EvaluationResult,
IsShowDetail = trialCriterion.IsShowDetail,
TrialEvaluationReason = trialCriterion.EvaluationReason.IsNullOrEmpty() ? ReadingCommon.EvaluationReason : trialCriterion.EvaluationReason,
OncologyTaskId = inDto.VisitTaskId,
ReadingTaskState = taskInfo.ReadingTaskState,
};
// 先找到是R1还是R2的阅片 先找到全局阅片
var globalTaskInfo= await _visitTaskRepository
.Where(x => x.SubjectId == taskInfo.SubjectId&&
x.TaskState== TaskState.Effect&&
x.ReadingCategory== ReadingCategory.Global&&
x.VisitTaskNum< taskInfo.VisitTaskNum
).OrderByDescending(x=>x.VisitTaskNum)
var globalTaskInfo = await _visitTaskRepository
.Where(x => x.SubjectId == taskInfo.SubjectId &&
x.TaskState == TaskState.Effect &&
x.ReadingCategory == ReadingCategory.Global &&
x.VisitTaskNum < taskInfo.VisitTaskNum
).OrderByDescending(x => x.VisitTaskNum)
.FirstNotNullAsync();
@ -736,7 +736,7 @@ namespace IRaCIS.Application.Services
{
throw new BusinessValidationFailedException("异常裁判结果为null");
}
visitTask = await _visitTaskRepository.Where(x=>x.Id== judgeResultTaskId).FirstOrDefaultAsync();
visitTask = await _visitTaskRepository.Where(x => x.Id == judgeResultTaskId).FirstOrDefaultAsync();
}
result.GlobalTaskId = visitTask.Id;
@ -758,13 +758,13 @@ namespace IRaCIS.Application.Services
{
VisitName = x.SourceSubjectVisit.VisitName,
VisitTaskId = x.Id,
// QuestionList = x.ReadingTaskQuestionAnswerList.Where(y => y.ReadingQuestionTrial.IsJudgeQuestion).OrderBy(y => y.ReadingQuestionTrial.ShowOrder)
//.Select(y => new OncologyQuestion()
//{
// QuestionId = y.ReadingQuestionTrialId,
// QuestionName = y.ReadingQuestionTrial.QuestionName,
// Answer = y.GlobalChangeAnswer
//}).ToList()
// QuestionList = x.ReadingTaskQuestionAnswerList.Where(y => y.ReadingQuestionTrial.IsJudgeQuestion).OrderBy(y => y.ReadingQuestionTrial.ShowOrder)
//.Select(y => new OncologyQuestion()
//{
// QuestionId = y.ReadingQuestionTrialId,
// QuestionName = y.ReadingQuestionTrial.QuestionName,
// Answer = y.GlobalChangeAnswer
//}).ToList()
}).ToListAsync();
var oncologyReadingQuestions = await _readingOncologyTaskInfoRepository.Where(x => x.OncologyTaskId == inDto.VisitTaskId).ToListAsync();
@ -837,9 +837,9 @@ namespace IRaCIS.Application.Services
public async Task<IResponseOutput> SaveGlobalReadingInfo(SaveGlobalReadingInfoInDto inDto)
{
var visitTaskId = inDto.QuestionList.Select(x => x.VisitTaskId).FirstOrDefault();
await _readingGlobalTaskInfoRepository.BatchDeleteNoTrackingAsync(x => x.GlobalTaskId == inDto.GlobalTaskId&&x.TaskId== visitTaskId);
await _readingGlobalTaskInfoRepository.BatchDeleteNoTrackingAsync(x => x.GlobalTaskId == inDto.GlobalTaskId && x.TaskId == visitTaskId);
foreach(var item in inDto.QuestionList)
foreach (var item in inDto.QuestionList)
{
await _readingTaskQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.VisitTaskId == item.VisitTaskId && x.ReadingQuestionTrialId == item.QuestionId, x => new ReadingTaskQuestionAnswer()
{
@ -879,31 +879,31 @@ namespace IRaCIS.Application.Services
GetGlobalReadingInfoOutDto result = new GetGlobalReadingInfoOutDto()
{
GlobalTaskId = inDto.VisitTaskId,
ReadingTaskState=taskInfo.ReadingTaskState,
ReadingTaskState = taskInfo.ReadingTaskState,
};
// 一致性分析按照doctorId 其他按照分组
result.TaskList = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
x.SubjectId == taskInfo.SubjectId &&x.IsAnalysisCreate== taskInfo.IsAnalysisCreate&&x.TaskState==TaskState.Effect && x.VisitTaskNum < taskInfo.VisitTaskNum)
x.SubjectId == taskInfo.SubjectId && x.IsAnalysisCreate == taskInfo.IsAnalysisCreate && x.TaskState == TaskState.Effect && x.VisitTaskNum < taskInfo.VisitTaskNum)
.Where(x => x.DoctorUserId == taskInfo.DoctorUserId)
.OrderBy(x => x.VisitTaskNum).Select(x => new GlobalVisitInfo()
{
VisitName = x.SourceSubjectVisit.VisitName,
VisitTaskId = x.Id,
ArmEnum= taskInfo.ArmEnum,
VisitNum =x.SourceSubjectVisit.VisitNum,
ArmEnum = taskInfo.ArmEnum,
VisitNum = x.SourceSubjectVisit.VisitNum,
VisitId = x.SourceSubjectVisitId.Value,
BeforeQuestionList = x.ReadingTaskQuestionAnswerList.Where(y => y.ReadingQuestionTrial.IsJudgeQuestion).OrderBy(y => y.ReadingQuestionTrial.ShowOrder)
.Select(y => new GlobalQuestionInfo()
{
QuestionId = y.ReadingQuestionTrialId,
QuestionName = y.ReadingQuestionTrial.QuestionName,
AnswerGroup=y.ReadingQuestionTrial.AnswerGroup,
AnswerCombination=y.ReadingQuestionTrial.AnswerCombination,
JudgeType=y.ReadingQuestionTrial.JudgeType,
AnswerGroup = y.ReadingQuestionTrial.AnswerGroup,
AnswerCombination = y.ReadingQuestionTrial.AnswerCombination,
JudgeType = y.ReadingQuestionTrial.JudgeType,
Type = y.ReadingQuestionTrial.Type,
TypeValue = y.ReadingQuestionTrial.TypeValue,
Answer = y.Answer
@ -922,17 +922,17 @@ namespace IRaCIS.Application.Services
, (l, r) => new { question = l, global = r })
.SelectMany(lr => lr.global.DefaultIfEmpty(), (lr, r) => new GlobalQuestionInfo
{
Answer = lr.global == null|| lr.global.Count()==0 ?
(inDto.UsingOriginalData?lr.question.Answer: string.Empty) :
(lr.global.Select(x => x.Answer).FirstOrDefault().IsNullOrEmpty()&& inDto.UsingOriginalData?
lr.question.Answer:lr.global.Select(x => x.Answer).FirstOrDefault()
Answer = lr.global == null || lr.global.Count() == 0 ?
(inDto.UsingOriginalData ? lr.question.Answer : string.Empty) :
(lr.global.Select(x => x.Answer).FirstOrDefault().IsNullOrEmpty() && inDto.UsingOriginalData ?
lr.question.Answer : lr.global.Select(x => x.Answer).FirstOrDefault()
),
IsHaveChange= lr.global==null? false: lr.global.Any(),
IsHaveChange = lr.global == null ? false : lr.global.Any(),
QuestionId = lr.question.QuestionId,
QuestionName = lr.question.QuestionName,
Type = lr.question.Type,
AnswerGroup = lr.question.AnswerGroup,
AnswerCombination = lr.question.AnswerCombination,
JudgeType = lr.question.JudgeType,
@ -945,7 +945,7 @@ namespace IRaCIS.Application.Services
Answer = globalReadingQuestion.Where(y => y.TaskId == x.VisitTaskId && y.QuestionId == null).Select(x => x.Answer).FirstOrDefault() ?? String.Empty,
QuestionName = "原因",
Type = "input",
};
@ -979,7 +979,7 @@ namespace IRaCIS.Application.Services
TaskBlindName = x.TaskBlindName,
SubjectId = x.SubjectId,
ReadingCategory = x.ReadingCategory,
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value :default(Guid) ,
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : default(Guid),
VisitNum = x.VisitTaskNum,
}).FirstOrDefaultAsync();
@ -1026,9 +1026,9 @@ namespace IRaCIS.Application.Services
index++;
});
var subjectIndex = subjectTaskList.Where(x => x.SubjectId == inDto.SubjectId&&x.SubjectCode==inDto.SubjectCode).Select(x => x.Index).FirstOrDefault();
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();
var currentSubject = subjectTaskList.Where(x => x.Index >= subjectIndex && !x.ExistReadingApply).OrderBy(x => x.Index).FirstOrDefault();
if (currentSubject == null)
{
@ -1045,7 +1045,7 @@ namespace IRaCIS.Application.Services
VisistId = x.VisistId ?? default(Guid),
VisitTaskId = x.Id
}).FirstOrDefault();
}
@ -1093,7 +1093,7 @@ namespace IRaCIS.Application.Services
task.IsReadingShowPreviousResults = trialInfo.IsReadingShowPreviousResults;
task.IsReadingShowSubjectInfo = trialInfo.IsReadingShowSubjectInfo;
return task;
}
@ -1156,7 +1156,7 @@ namespace IRaCIS.Application.Services
{
VisitTaskId = task.VisitTaskId,
SubjectId = task.SubjectId,
SubjectCode = taskInfo.BlindSubjectCode.IsNullOrEmpty()? task.SubjectCode: taskInfo.BlindSubjectCode,
SubjectCode = taskInfo.BlindSubjectCode.IsNullOrEmpty() ? task.SubjectCode : taskInfo.BlindSubjectCode,
ReadingCategory = task.ReadingCategory,
TaskBlindName = task.TaskBlindName,
IsReadingShowPreviousResults = trialInfo.IsReadingShowPreviousResults,
@ -1241,7 +1241,7 @@ namespace IRaCIS.Application.Services
}
#endregion
#region 获取项目的阅片问题
/// <summary>
@ -1261,9 +1261,9 @@ namespace IRaCIS.Application.Services
{
var result = new GetTrialReadingQuestionPageDto();
var readingTaskState = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.ReadingTaskState).FirstOrDefaultAsync();
var qusetionList = await GetReadingAnswerView(inDto.ReadingQuestionCriterionTrialId,inDto.VisitTaskId);
var qusetionList = await GetReadingAnswerView(inDto.ReadingQuestionCriterionTrialId, inDto.VisitTaskId);
var formType = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.ReadingQuestionCriterionTrialId).Select(x => x.FormType).FirstOrDefaultAsync();
var groupList = new List<GetTrialReadingQuestionOutDto>();
@ -1321,13 +1321,13 @@ namespace IRaCIS.Application.Services
}
return (result, new
{
readingTaskState = readingTaskState,
FormType = formType
});
});
}
/// <summary>
@ -1336,7 +1336,7 @@ namespace IRaCIS.Application.Services
/// <param name="readingQuestionCriterionTrialId"></param>
/// <param name="visitTaskId"></param>
/// <returns></returns>
private async Task<List<GetTrialReadingQuestionOutDto>> GetReadingAnswerView(Guid readingQuestionCriterionTrialId,Guid? visitTaskId)
private async Task<List<GetTrialReadingQuestionOutDto>> GetReadingAnswerView(Guid readingQuestionCriterionTrialId, Guid? visitTaskId)
{
var query = from data in _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == readingQuestionCriterionTrialId)
@ -1357,12 +1357,12 @@ namespace IRaCIS.Application.Services
QuestionName = data.QuestionName,
IsRequired = data.IsRequired,
ShowQuestion = data.ShowQuestion,
LesionType=data.LesionType,
LesionType = data.LesionType,
ShowOrder = data.ShowOrder,
RelevanceId = data.RelevanceId,
IsShowInDicom=data.IsShowInDicom,
MaxQuestionCount=data.MaxQuestionCount,
IsShowInDicom = data.IsShowInDicom,
MaxQuestionCount = data.MaxQuestionCount,
RelevanceValue = data.RelevanceValue,
ImageCount = data.ImageCount,
ParentId = data.ParentId,
@ -1391,12 +1391,12 @@ namespace IRaCIS.Application.Services
public async Task<GetSystemReadingQuestionPageDto> GetSystemReadingQuestion(GetSystemReadingQuestionInDto inDto)
{
var result = new GetSystemReadingQuestionPageDto();
var qusetionList =await _readingQuestionSystem.Where(x => x.ReadingQuestionCriterionSystemId == inDto.Id)
var qusetionList = await _readingQuestionSystem.Where(x => x.ReadingQuestionCriterionSystemId == inDto.Id)
.ProjectTo<GetSystemReadingQuestionOutDto>(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync();
var questionIds = qusetionList.Select(x => x.Id).ToList();
var tableQuestionList =await _readingTableQuestionSystemRepository.Where(x => questionIds.Contains(x.ReadingQuestionId))
var tableQuestionList = await _readingTableQuestionSystemRepository.Where(x => questionIds.Contains(x.ReadingQuestionId))
.ProjectTo<TableQuestionDataInfo>(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync();
var groupList = new List<GetSystemReadingQuestionOutDto>();
@ -1424,7 +1424,7 @@ namespace IRaCIS.Application.Services
/// <param name="item"></param>
/// <param name="questionlists"></param>
/// <param name="tableQuestions"></param>
public void FindSystemChildQuestion(GetSystemReadingQuestionOutDto item, List<GetSystemReadingQuestionOutDto> questionlists,List<TableQuestionDataInfo> tableQuestions)
public void FindSystemChildQuestion(GetSystemReadingQuestionOutDto item, List<GetSystemReadingQuestionOutDto> questionlists, List<TableQuestionDataInfo> tableQuestions)
{
item.Childrens = questionlists.Where(x => x.ParentId == item.Id || (item.Type == ReadingQestionType.Group && x.Type != ReadingQestionType.Group && x.ParentId == null && x.GroupName == item.GroupName)).ToList();
@ -1441,7 +1441,7 @@ namespace IRaCIS.Application.Services
QuestionMark = x.QuestionMark,
TypeValue = x.TypeValue,
RelevanceId = x.RelevanceId,
IsRequired=x.IsRequired,
IsRequired = x.IsRequired,
RelevanceValue = x.RelevanceValue,
ImageCount = 0,
ParentId = item.Id,
@ -1473,7 +1473,7 @@ namespace IRaCIS.Application.Services
}).ToList(),
Remark = x.Remark,
}));
}));
if (item.Childrens != null && item.Childrens.Count != 0)
{
@ -1491,7 +1491,7 @@ namespace IRaCIS.Application.Services
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<GetReadingSubjectInfoOutDto> GetReadingSubjectInfo(GetReadingSubjectInfoInDto inDto)
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();
@ -1544,7 +1544,7 @@ namespace IRaCIS.Application.Services
taskids.Add(judgeDataInfo.TaskIdOne);
taskids.Add(judgeDataInfo.TaskIdTwo);
var taskList = await _visitTaskRepository.Where(x => taskids.Contains(x.Id)).OrderBy(x=>x.ArmEnum).ToListAsync();
var taskList = await _visitTaskRepository.Where(x => taskids.Contains(x.Id)).OrderBy(x => x.ArmEnum).ToListAsync();
judgeInfo.VisitTaskArmList = taskList.Select(x => new VisitTaskArm()
{
ArmEnum = x.ArmEnum,
@ -1614,7 +1614,7 @@ namespace IRaCIS.Application.Services
{
ArmEnum = item.ArmEnum,
VisitTaskId = item.VisitTaskId,
GlobalVisitTaskId= taskList[0].Id,
GlobalVisitTaskId = taskList[0].Id,
JudgeQuestionList = item.AfterQuestionList.Where(x => x.QuestionId != null).Select(x => new JudgeQuestion()
{
@ -1627,15 +1627,15 @@ namespace IRaCIS.Application.Services
// 加全局是否更新 和访视点注释
judgeReadingQuestion.JudgeQuestionList.Add( new JudgeQuestion() {
Answer= item.AfterQuestionList.Any(x=>x.IsHaveChange),
QuestionType= JudgeReadingQuestionType.GlobalChange,
judgeReadingQuestion.JudgeQuestionList.Add(new JudgeQuestion() {
Answer = item.AfterQuestionList.Any(x => x.IsHaveChange),
QuestionType = JudgeReadingQuestionType.GlobalChange,
});
judgeReadingQuestion.JudgeQuestionList.Add(new JudgeQuestion()
{
Answer = item.AfterQuestionList.Where(x => x.QuestionId==null).Select(x=>x.Answer).FirstOrDefault(),
Answer = item.AfterQuestionList.Where(x => x.QuestionId == null).Select(x => x.Answer).FirstOrDefault(),
QuestionType = JudgeReadingQuestionType.VisitRemark,
});
@ -1643,12 +1643,12 @@ namespace IRaCIS.Application.Services
judgeReadingInfo.VisitTaskInfoList.Add(judgeReadingQuestion);
if (twoItem != null)
{
var rTwoJudge = new JudgeReadingQuestion()
var rTwoJudge = new JudgeReadingQuestion()
{
ArmEnum = twoItem.ArmEnum,
VisitTaskId = twoItem.VisitTaskId,
GlobalVisitTaskId = taskList[1].Id,
JudgeQuestionList = twoItem.AfterQuestionList.Where(x => x.QuestionId != null).Select(x => new JudgeQuestion()
GlobalVisitTaskId = taskList[1].Id,
JudgeQuestionList = twoItem.AfterQuestionList.Where(x => x.QuestionId != null).Select(x => new JudgeQuestion()
{
Answer = x.Answer,
@ -1684,7 +1684,7 @@ namespace IRaCIS.Application.Services
}
return judgeInfo;
}
#endregion
@ -1710,7 +1710,7 @@ namespace IRaCIS.Application.Services
#endregion
#region 获取既往结果
/// <summary>
@ -1721,18 +1721,18 @@ namespace IRaCIS.Application.Services
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 =>
var readingPastResultList = await _visitTaskRepository.Where(x =>
x.TrialId == taskInfo.TrialId &&
x.SubjectId == taskInfo.SubjectId &&
x.ArmEnum== taskInfo.ArmEnum &&
x.SubjectId == taskInfo.SubjectId &&
x.ArmEnum == taskInfo.ArmEnum &&
x.Id != inDto.VisitTaskId &&
x.DoctorUserId == taskInfo.DoctorUserId &&
x.ReadingTaskState == ReadingTaskState.HaveSigned&&
x.TaskState==TaskState.Effect&&
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();
.WhereIf(taskInfo.ReadingCategory != ReadingCategory.Visit, x => x.ReadingCategory == taskInfo.ReadingCategory)
.ProjectTo<GetReadingPastResultListOutDto>(_mapper.ConfigurationProvider).OrderBy(x => x.VisitTaskNum).ToListAsync();
return readingPastResultList;
}
@ -1746,7 +1746,7 @@ namespace IRaCIS.Application.Services
/// <param name="questionlists"></param>
/// <param name="tableQuestions"></param>
[NonDynamicMethod]
public void FindChildQuestion(GetTrialReadingQuestionOutDto item, List<GetTrialReadingQuestionOutDto> questionlists,List<TableQuestionDataInfo> tableQuestions)
public void FindChildQuestion(GetTrialReadingQuestionOutDto item, List<GetTrialReadingQuestionOutDto> questionlists, List<TableQuestionDataInfo> tableQuestions)
{
item.Childrens = questionlists.Where(x => x.ParentId == item.Id || (item.Type == ReadingQestionType.Group && x.Type != ReadingQestionType.Group && x.ParentId == null && x.GroupName == item.GroupName)).ToList();
@ -1765,7 +1765,7 @@ namespace IRaCIS.Application.Services
TypeValue = x.TypeValue,
RelevanceId = x.RelevanceId,
IsRequired = x.IsRequired,
RelevanceValue = x.RelevanceValue,
RelevanceValue = x.RelevanceValue,
ImageCount = 0,
ParentId = item.Id,
DataTableColumn = x.DataTableColumn,
@ -1851,21 +1851,21 @@ namespace IRaCIS.Application.Services
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> VerifyVisitTaskQuestions(VerifyVisitTaskQuestionsInDto inDto)
public async Task<IResponseOutput> VerifyVisitTaskQuestions(VerifyVisitTaskQuestionsInDto inDto)
{
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
{
new ReadingCalculateData (){
QuestionType=QuestionType.SOD,
},
};
await _readingCalculateService.VerifyVisitTaskQuestions(inDto);
return ResponseOutput.Ok(true);
return ResponseOutput.Ok(true);
}
/// <summary>
@ -1877,13 +1877,13 @@ namespace IRaCIS.Application.Services
public async Task<IResponseOutput> SubmitTableQuestion(SubmitTableQuestionInDto inDto)
{
var tableQuestionIds = inDto.AnswerList.Select(x => x.TableQuestionId).ToList();
var questions = await _readingTableQuestionTrialRepository.Where(x => tableQuestionIds.Contains(x.Id) && x.MaxRowCount != null&&x.MaxRowCount!=0).ToListAsync();
var questions = await _readingTableQuestionTrialRepository.Where(x => tableQuestionIds.Contains(x.Id) && x.MaxRowCount != null && x.MaxRowCount != 0).ToListAsync();
foreach (var item in questions)
{
var answer = inDto.AnswerList.Where(x => x.TableQuestionId == item.Id).Select(x => x.Answer).FirstOrDefault();
var rowCount = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.TableQuestionId == item.Id && x.Answer == answer&&x.RowIndex!=inDto.RowIndex).CountAsync();
var rowCount = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.TableQuestionId == item.Id && x.Answer == answer && x.RowIndex != inDto.RowIndex).CountAsync();
if (rowCount > item.MaxRowCount.Value - 1)
{
@ -1903,38 +1903,49 @@ namespace IRaCIS.Application.Services
await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex);
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,
Answer = x.Answer,
Id = NewId.NextGuid(),
TrialId = inDto.TrialId,
QuestionId = inDto.QuestionId,
TableQuestionId = x.TableQuestionId,
RowIndex = inDto.RowIndex,
VisitTaskId = inDto.VisitTaskId
}).ToList();
await _readingTableAnswerRowInfoRepository.AddAsync(new ReadingTableAnswerRowInfo()
{
Id = NewId.NextGuid(),
TrialId = inDto.TrialId,
QuestionId = inDto.QuestionId,
MeasureData = inDto.MeasureData,
IsCurrentTaskAdd= isCurrentTaskAdd,
IsCurrentTaskAdd = isCurrentTaskAdd,
RowIndex = inDto.RowIndex,
InstanceId=inDto.InstanceId,
SeriesId=inDto.SeriesId,
InstanceId = inDto.InstanceId,
SeriesId = inDto.SeriesId,
VisitTaskId = inDto.VisitTaskId,
});
await _readingTableQuestionAnswerRepository.AddRangeAsync(answerList);
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
await _visitTaskRepository.UpdatePartialFromQueryAsync(inDto.VisitTaskId, x => new VisitTask()
{
ReadingTaskState = ReadingTaskState.Reading,
});
await this._readingCalculateService.CalculateTask(new CalculateTaskInDto()
{
IsChangeOtherTask=false,
VisitTaskId=inDto.VisitTaskId,
IsChangeOtherTask = false,
VisitTaskId = inDto.VisitTaskId,
});
return ResponseOutput.Ok(true);
}