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