diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index 6743d9efd..5d4a851fc 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -1066,275 +1066,7 @@ namespace IRaCIS.Application.Services } #endregion - #region 获取项目已确认的标准 - /// - /// 获取项目已确认的标准 - /// - /// - /// - [HttpPost] - public async Task> GetTrialConfirmCriterionList(GetConfirmCriterionInDto inDto) - { - var result = await _visitTaskRepository.Where(x => x.TrialId == inDto.TrialId && x.TrialReadingCriterion.IsConfirm ) - .WhereIf(inDto.VisitTaskId !=null ,t=>t.Id==inDto.VisitTaskId) - .Select(x => new GetTrialConfirmCriterionListOutDto() - { - ReadingQuestionCriterionTrialId = x.TrialReadingCriterion.Id, - ReadingQuestionCriterionTrialName = x.TrialReadingCriterion.CriterionName - }).Distinct().ToListAsync(); - return result; - } - #endregion - - - - - - #region 获取项目的阅片问题 - /// - /// 获取项目的阅片问题ECRF预览 - /// - /// - /// SinglePage 单页 - /// - /// MultiPage 多页 - /// - /// PublicPage 公共 - /// - /// - /// - [HttpPost] - public async Task<(GetTrialReadingQuestionPageDto, object)> GetTrialReadingQuestion(GetTrialReadingQuestionInDto inDto) - { - 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 formType = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.ReadingQuestionCriterionTrialId).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(); - if (inDto.FormType != null) - { - formType = inDto.FormType.Value; - } - - if (formType == FormType.MultiplePage) - { - qusetionList = qusetionList.Where(x => x.ReadingCriterionPageId != null).ToList(); - var readingCriterionPageIds = qusetionList.OrderBy(x => x.PageShowOrder).Select(x => x.ReadingCriterionPageId).Distinct().ToList(); - foreach (var item in readingCriterionPageIds) - { - var newPageQusetionList = qusetionList.Where(x => x.ReadingCriterionPageId == item).ToList(); - var firstData = newPageQusetionList.FirstOrDefault(); - var page = new GetTrialReadingQuestionOutDto() - { - PageName = firstData.PageName, - IsPage = true, - IsPublicPage = firstData.IsPublicPage, - }; - - var pageGroupList = newPageQusetionList.Where(x => x.Type == ReadingQestionType.Group || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList(); - pageGroupList.ForEach(x => - { - this.FindChildQuestion(x, newPageQusetionList, tableQuestionList); - }); - - page.Childrens = pageGroupList.Where(x => !(x.Type == ReadingQestionType.Group && x.Childrens.Count() == 0)).ToList(); - groupList.Add(page); - } - - result.PublicPage = groupList.Where(x => x.IsPublicPage.Value).ToList(); - result.MultiPage = groupList.Where(x => !x.IsPublicPage.Value).ToList(); - } - else - { - qusetionList = qusetionList.Where(x => x.ReadingCriterionPageId == null).ToList(); - - groupList = qusetionList.Where(x => x.Type == ReadingQestionType.Group || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList(); - groupList.ForEach(x => - { - this.FindChildQuestion(x, qusetionList, tableQuestionList); - }); - - groupList = groupList.Where(x => !(x.Type == ReadingQestionType.Group && x.Childrens.Count() == 0)).ToList(); - - result.SinglePage = groupList; - - - } - - - return (result, new - { - readingTaskState = readingTaskState, - FormType = formType - - }); - } - - /// - /// 或者阅片答案预览 - /// - /// - /// - /// - private async Task> GetReadingAnswerView(Guid readingQuestionCriterionTrialId, Guid? visitTaskId) - { - var query = from data in _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == readingQuestionCriterionTrialId) - - join page in _readingCriterionPageRepository.AsQueryable() on data.ReadingCriterionPageId ?? default(Guid) equals page.Id into pageTemp - from leftpage in pageTemp.DefaultIfEmpty() - - join questionAnswer in _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == visitTaskId) on data.Id equals questionAnswer.ReadingQuestionTrialId into questionAnswerTemp - from leftquestionAnswer in questionAnswerTemp.DefaultIfEmpty() - select new GetTrialReadingQuestionOutDto() - { - - Id = data.Id, - ReadingQuestionCriterionTrialId = data.ReadingQuestionCriterionTrialId, - TrialId = data.TrialId, - Type = data.Type, - ParentTriggerValue = data.ParentTriggerValue, - GroupName = data.GroupName, - QuestionName = data.QuestionName, - IsRequired = data.IsRequired, - ShowQuestion = data.ShowQuestion, - LesionType = data.LesionType, - QuestionGenre=data.QuestionGenre, - DictionaryCode=data.DictionaryCode, - - ShowOrder = data.ShowOrder, - RelevanceId = data.RelevanceId, - IsShowInDicom = data.IsShowInDicom, - MaxQuestionCount = data.MaxQuestionCount, - RelevanceValue = data.RelevanceValue, - ImageCount = data.ImageCount, - ParentId = data.ParentId, - TypeValue = data.TypeValue, - Answer = leftquestionAnswer.Answer, - ReadingCriterionPageId = data.ReadingCriterionPageId, - PageName = leftpage.PageName, - PageShowOrder = leftpage.ShowOrder, - IsPublicPage = leftpage.IsPublicPage, - }; - - var qusetionList = await query.Where(x => x.ShowQuestion != ShowQuestion.Hide).OrderBy(x => x.ShowOrder).ToListAsync(); - - return qusetionList; - } - #endregion - - #region 获取系统的阅片问题 - - /// - /// 获取系统的阅片问题 - /// - /// - /// - [HttpPost] - public async Task GetSystemReadingQuestion(GetSystemReadingQuestionInDto inDto) - { - var result = new GetSystemReadingQuestionPageDto(); - var qusetionList = await _readingQuestionSystem.Where(x => x.ReadingQuestionCriterionSystemId == inDto.Id) - .ProjectTo(_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)) - .ProjectTo(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync(); - - var groupList = new List(); - - //qusetionList = qusetionList.Where(x => x.ParentId == null).ToList(); - - groupList = qusetionList.Where(x => x.Type == ReadingQestionType.Group || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList(); - groupList.ForEach(x => - { - this.FindSystemChildQuestion(x, qusetionList, tableQuestionList); - }); - - groupList = groupList.Where(x => !(x.Type == ReadingQestionType.Group && x.Childrens.Count() == 0)).ToList(); - - result.SinglePage = groupList; - - - return result; - } - - - /// - /// 获取系统 - /// - /// - /// - /// - public void FindSystemChildQuestion(GetSystemReadingQuestionOutDto item, List questionlists, List 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.AddRange(tableQuestions.Where(x => x.ReadingQuestionId == item.Id).Select(x => new GetSystemReadingQuestionOutDto - { - Childrens = new List(), - ShowOrder = x.ShowOrder, - GroupName = string.Empty, - Id = x.Id, - Type = x.Type, - DictionaryCode=x.DictionaryCode, - TableQuestionType = x.TableQuestionType, - DependParentId = x.DependParentId, - IsDepend = x.IsDepend, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RelevanceId = x.RelevanceId, - IsRequired = x.IsRequired, - RelevanceValue = x.RelevanceValue, - ImageCount = 0, - ParentId = item.Id, - DataTableColumn = x.DataTableColumn, - LesionType = item.LesionType, - QuestionName = x.QuestionName, - RelationQuestions = tableQuestions.Where(z => (z.DependParentId ?? default(Guid)) == x.Id).Select(x => new GetSystemReadingQuestionOutDto - { - Childrens = new List(), - ShowOrder = x.ShowOrder, - GroupName = string.Empty, - Id = x.Id, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - TableQuestionType = x.TableQuestionType, - DependParentId = x.DependParentId, - IsDepend = x.IsDepend, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RelevanceId = x.RelevanceId, - RelevanceValue = x.RelevanceValue, - ImageCount = 0, - ParentId = item.Id, - DataTableColumn = x.DataTableColumn, - LesionType = item.LesionType, - QuestionName = x.QuestionName, - RelationQuestions = new List(), - Remark = x.Remark, - - }).ToList(), - Remark = x.Remark, - - })); - - if (item.Childrens != null && item.Childrens.Count != 0) - { - item.Childrens.ForEach(x => - { - this.FindSystemChildQuestion(x, questionlists, tableQuestions); - }); - } - } - #endregion + /// /// 获取阅片的受试者信息 @@ -1370,13 +1102,6 @@ namespace IRaCIS.Application.Services }; } - - - - - - - #region 获取既往结果 /// /// 获取既往结果 diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingTaskQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingTaskQuestionService.cs new file mode 100644 index 000000000..02c2d7414 --- /dev/null +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingTaskQuestionService.cs @@ -0,0 +1,288 @@ +using IRaCIS.Core.Domain.Share; +using Microsoft.AspNetCore.Mvc; +using IRaCIS.Core.Application.Service.Reading.Dto; +using MassTransit; +using IRaCIS.Core.Infra.EFCore.Common; +using Panda.DynamicWebApi.Attributes; +using AutoMapper; +using IRaCIS.Core.Application.Contracts; +using IRaCIS.Core.Infrastructure; +using Newtonsoft.Json; +using IRaCIS.Core.Application.Service; +using IRaCIS.Core.Application.ViewModel; + +namespace IRaCIS.Application.Services +{ + + /// + /// 问题 + /// + public partial class ReadingImageTaskService : BaseService, IReadingImageTaskService + { + #region 获取项目已确认的标准 + /// + /// 获取项目已确认的标准 + /// + /// + /// + [HttpPost] + public async Task> GetTrialConfirmCriterionList(GetConfirmCriterionInDto inDto) + { + var result = await _visitTaskRepository.Where(x => x.TrialId == inDto.TrialId && x.TrialReadingCriterion.IsConfirm) + .WhereIf(inDto.VisitTaskId != null, t => t.Id == inDto.VisitTaskId) + .Select(x => new GetTrialConfirmCriterionListOutDto() + { + ReadingQuestionCriterionTrialId = x.TrialReadingCriterion.Id, + ReadingQuestionCriterionTrialName = x.TrialReadingCriterion.CriterionName + }).Distinct().ToListAsync(); + return result; + } + #endregion + + #region 获取项目的阅片问题 + /// + /// 获取项目的阅片问题ECRF预览 + /// + /// + /// SinglePage 单页 + /// + /// MultiPage 多页 + /// + /// PublicPage 公共 + /// + /// + /// + [HttpPost] + public async Task<(GetTrialReadingQuestionPageDto, object)> GetTrialReadingQuestion(GetTrialReadingQuestionInDto inDto) + { + 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 formType = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.ReadingQuestionCriterionTrialId).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(); + if (inDto.FormType != null) + { + formType = inDto.FormType.Value; + } + + if (formType == FormType.MultiplePage) + { + qusetionList = qusetionList.Where(x => x.ReadingCriterionPageId != null).ToList(); + var readingCriterionPageIds = qusetionList.OrderBy(x => x.PageShowOrder).Select(x => x.ReadingCriterionPageId).Distinct().ToList(); + foreach (var item in readingCriterionPageIds) + { + var newPageQusetionList = qusetionList.Where(x => x.ReadingCriterionPageId == item).ToList(); + var firstData = newPageQusetionList.FirstOrDefault(); + var page = new GetTrialReadingQuestionOutDto() + { + PageName = firstData.PageName, + IsPage = true, + IsPublicPage = firstData.IsPublicPage, + }; + + var pageGroupList = newPageQusetionList.Where(x => x.Type == ReadingQestionType.Group || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList(); + pageGroupList.ForEach(x => + { + this.FindChildQuestion(x, newPageQusetionList, tableQuestionList); + }); + + page.Childrens = pageGroupList.Where(x => !(x.Type == ReadingQestionType.Group && x.Childrens.Count() == 0)).ToList(); + groupList.Add(page); + } + + result.PublicPage = groupList.Where(x => x.IsPublicPage.Value).ToList(); + result.MultiPage = groupList.Where(x => !x.IsPublicPage.Value).ToList(); + } + else + { + qusetionList = qusetionList.Where(x => x.ReadingCriterionPageId == null).ToList(); + + groupList = qusetionList.Where(x => x.Type == ReadingQestionType.Group || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList(); + groupList.ForEach(x => + { + this.FindChildQuestion(x, qusetionList, tableQuestionList); + }); + + groupList = groupList.Where(x => !(x.Type == ReadingQestionType.Group && x.Childrens.Count() == 0)).ToList(); + + result.SinglePage = groupList; + + + } + + + return (result, new + { + readingTaskState = readingTaskState, + FormType = formType + + }); + } + + /// + /// 或者阅片答案预览 + /// + /// + /// + /// + private async Task> GetReadingAnswerView(Guid readingQuestionCriterionTrialId, Guid? visitTaskId) + { + var query = from data in _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == readingQuestionCriterionTrialId) + + join page in _readingCriterionPageRepository.AsQueryable() on data.ReadingCriterionPageId ?? default(Guid) equals page.Id into pageTemp + from leftpage in pageTemp.DefaultIfEmpty() + + join questionAnswer in _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == visitTaskId) on data.Id equals questionAnswer.ReadingQuestionTrialId into questionAnswerTemp + from leftquestionAnswer in questionAnswerTemp.DefaultIfEmpty() + select new GetTrialReadingQuestionOutDto() + { + + Id = data.Id, + ReadingQuestionCriterionTrialId = data.ReadingQuestionCriterionTrialId, + TrialId = data.TrialId, + Type = data.Type, + ParentTriggerValue = data.ParentTriggerValue, + GroupName = data.GroupName, + QuestionName = data.QuestionName, + IsRequired = data.IsRequired, + ShowQuestion = data.ShowQuestion, + LesionType = data.LesionType, + QuestionGenre = data.QuestionGenre, + DictionaryCode = data.DictionaryCode, + + ShowOrder = data.ShowOrder, + RelevanceId = data.RelevanceId, + IsShowInDicom = data.IsShowInDicom, + MaxQuestionCount = data.MaxQuestionCount, + RelevanceValue = data.RelevanceValue, + ImageCount = data.ImageCount, + ParentId = data.ParentId, + TypeValue = data.TypeValue, + Answer = leftquestionAnswer.Answer, + ReadingCriterionPageId = data.ReadingCriterionPageId, + PageName = leftpage.PageName, + PageShowOrder = leftpage.ShowOrder, + IsPublicPage = leftpage.IsPublicPage, + }; + + var qusetionList = await query.Where(x => x.ShowQuestion != ShowQuestion.Hide).OrderBy(x => x.ShowOrder).ToListAsync(); + + return qusetionList; + } + #endregion + + #region 获取系统的阅片问题 + + /// + /// 获取系统的阅片问题 + /// + /// + /// + [HttpPost] + public async Task GetSystemReadingQuestion(GetSystemReadingQuestionInDto inDto) + { + var result = new GetSystemReadingQuestionPageDto(); + var qusetionList = await _readingQuestionSystem.Where(x => x.ReadingQuestionCriterionSystemId == inDto.Id) + .ProjectTo(_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)) + .ProjectTo(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync(); + + var groupList = new List(); + + //qusetionList = qusetionList.Where(x => x.ParentId == null).ToList(); + + groupList = qusetionList.Where(x => x.Type == ReadingQestionType.Group || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList(); + groupList.ForEach(x => + { + this.FindSystemChildQuestion(x, qusetionList, tableQuestionList); + }); + + groupList = groupList.Where(x => !(x.Type == ReadingQestionType.Group && x.Childrens.Count() == 0)).ToList(); + + result.SinglePage = groupList; + + + return result; + } + + + /// + /// 获取系统 + /// + /// + /// + /// + public void FindSystemChildQuestion(GetSystemReadingQuestionOutDto item, List questionlists, List 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.AddRange(tableQuestions.Where(x => x.ReadingQuestionId == item.Id).Select(x => new GetSystemReadingQuestionOutDto + { + Childrens = new List(), + ShowOrder = x.ShowOrder, + GroupName = string.Empty, + Id = x.Id, + Type = x.Type, + DictionaryCode = x.DictionaryCode, + TableQuestionType = x.TableQuestionType, + DependParentId = x.DependParentId, + IsDepend = x.IsDepend, + QuestionMark = x.QuestionMark, + TypeValue = x.TypeValue, + RelevanceId = x.RelevanceId, + IsRequired = x.IsRequired, + RelevanceValue = x.RelevanceValue, + ImageCount = 0, + ParentId = item.Id, + DataTableColumn = x.DataTableColumn, + LesionType = item.LesionType, + QuestionName = x.QuestionName, + RelationQuestions = tableQuestions.Where(z => (z.DependParentId ?? default(Guid)) == x.Id).Select(x => new GetSystemReadingQuestionOutDto + { + Childrens = new List(), + ShowOrder = x.ShowOrder, + GroupName = string.Empty, + Id = x.Id, + DictionaryCode = x.DictionaryCode, + Type = x.Type, + TableQuestionType = x.TableQuestionType, + DependParentId = x.DependParentId, + IsDepend = x.IsDepend, + QuestionMark = x.QuestionMark, + TypeValue = x.TypeValue, + RelevanceId = x.RelevanceId, + RelevanceValue = x.RelevanceValue, + ImageCount = 0, + ParentId = item.Id, + DataTableColumn = x.DataTableColumn, + LesionType = item.LesionType, + QuestionName = x.QuestionName, + RelationQuestions = new List(), + Remark = x.Remark, + + }).ToList(), + Remark = x.Remark, + + })); + + if (item.Childrens != null && item.Childrens.Count != 0) + { + item.Childrens.ForEach(x => + { + this.FindSystemChildQuestion(x, questionlists, tableQuestions); + }); + } + } + #endregion + } +}