From 5f32cebc8d5576c5806428a9a868909c71cd7e26 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Tue, 22 Nov 2022 10:35:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reading/Dto/ReadingImageTaskViewModel.cs | 9 +- .../ReadingImageTaskService.cs | 114 ++++++++++-------- 2 files changed, 71 insertions(+), 52 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index a59b0bc86..a7307b0fc 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -353,7 +353,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public Guid TrialId { get; set; } } - public class GetReadingQuestionAndAnswerOutDto + public class GetReadingQuestionAndAnswerOutDto: GetReadingTableQuestionOutDto { public bool IsBaseLineTask { get; set; } @@ -367,6 +367,12 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public ReadingTaskState ReadingTaskState { get; set; } + + } + + + public class GetReadingTableQuestionOutDto + { public List SinglePage { get; set; } public List MultiPage { get; set; } @@ -374,6 +380,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public List PublicPage { get; set; } } + public class TrialReadQuestionData : ReadingQuestionTrial { diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index 039cdfdd6..0a7bc3029 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -447,51 +447,13 @@ namespace IRaCIS.Application.Services var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == taskinfo.TrialReadingCriterionId).FirstNotNullAsync(); - //if (taskinfo.TaskState != TaskState.Effect) - //{ - // throw new BusinessValidationFailedException($"当前任务已失效!"); - //} 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; var visitTaskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync(); - var criterionId = taskinfo.TrialReadingCriterionId; - - - - - #region 获取问题及答案 - - var qusetionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == criterionId).ProjectTo(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync(); - - if (!criterionInfo.IseCRFShowInDicomReading) - { - qusetionList= qusetionList.Where(x => x.IsShowInDicom && (x.Type == ReadingQestionType.Table || x.Type == ReadingQestionType.Group)).OrderBy(x => x.ShowOrder).ToList(); - } - - - - var usedGurops = qusetionList.Where(x => x.Type == ReadingQestionType.Table).Select(x => 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 => - { - x.Answer = answers.Where(y => y.ReadingQuestionTrialId == x.Id).Select(x => x.Answer).FirstOrDefault() ?? string.Empty; - }); - - #endregion - - var formType = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == criterionId).Select(x => x.FormType).FirstOrDefaultAsync(); - var groupList = new List(); - - var qusetionIds = qusetionList.Select(x => x.Id).ToList(); - var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => qusetionIds.Contains(x.ReadingQuestionId)) - .ProjectTo(_mapper.ConfigurationProvider) - .OrderBy(x => x.ShowOrder).ToListAsync(); - + var tableAnswers = await _readingTableQuestionAnswerRepository .ProjectTo(_mapper.ConfigurationProvider) @@ -499,7 +461,66 @@ namespace IRaCIS.Application.Services var tableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - if (formType == FormType.MultiplePage) + var questionPage = await GetReadingTableQuestion(taskinfo.TrialReadingCriterionId, inDto.VisitTaskId, tableAnswers, tableAnsweRowInfos); + + result.SinglePage = questionPage.SinglePage; + result.MultiPage = questionPage.MultiPage; + result.PublicPage = questionPage.PublicPage; + result.BlindName = visitTaskInfo.TaskBlindName; + result.TaskNum = visitTaskInfo.VisitTaskNum; + + return (result, new + { + readingTaskState = visitTaskInfo.ReadingTaskState, + FormType = criterionInfo.FormType, + TaskNum = visitTaskInfo.VisitTaskNum, + + }); ; + } + + /// + /// 获取表格问题及答案 只返回表格问题 + /// + /// + /// + /// + /// + /// + [NonDynamicMethod] + public async Task GetReadingTableQuestion(Guid trialReadingCriterionId, Guid? taskId, List tableAnswers, List tableAnsweRowInfos) + { + var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == trialReadingCriterionId).FirstNotNullAsync(); + + var qusetionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == trialReadingCriterionId).ProjectTo(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync(); + + if (!criterionInfo.IseCRFShowInDicomReading) + { + qusetionList = qusetionList.Where(x => x.IsShowInDicom && (x.Type == ReadingQestionType.Table || x.Type == ReadingQestionType.Group)).OrderBy(x => x.ShowOrder).ToList(); + } + var usedGurops = qusetionList.Where(x => x.Type == ReadingQestionType.Table).Select(x => x.GroupName).ToList(); + qusetionList = qusetionList.Where(x => usedGurops.Contains(x.GroupName)).ToList(); + + if (taskId != null) + { + var answers = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == taskId).ToListAsync(); + qusetionList.ForEach(x => + { + x.Answer = answers.Where(y => y.ReadingQuestionTrialId == x.Id).Select(x => x.Answer).FirstOrDefault() ?? string.Empty; + }); + + } + + #endregion + + var groupList = new List(); + var qusetionIds = qusetionList.Select(x => x.Id).ToList(); + + var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => qusetionIds.Contains(x.ReadingQuestionId)) + .ProjectTo(_mapper.ConfigurationProvider) + .OrderBy(x => x.ShowOrder).ToListAsync(); + + var result = new GetReadingTableQuestionOutDto(); + if (criterionInfo.FormType == FormType.MultiplePage) { qusetionList = qusetionList.Where(x => x.ReadingCriterionPageId != null).ToList(); var readingCriterionPageIds = qusetionList.OrderBy(x => x.PageShowOrder).Select(x => x.ReadingCriterionPageId).Distinct().ToList(); @@ -544,16 +565,8 @@ namespace IRaCIS.Application.Services } - result.BlindName = visitTaskInfo.TaskBlindName; - result.TaskNum = visitTaskInfo.VisitTaskNum; - return (result, new - { - readingTaskState = visitTaskInfo.ReadingTaskState, - FormType = formType, - TaskNum = visitTaskInfo.VisitTaskNum, - - }); ; + return result; } /// @@ -641,8 +654,7 @@ namespace IRaCIS.Application.Services - #endregion - + #region 访视任务 - Dicom 阅片 表格问题 病灶的拆分与合并