diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCQuestionConfigureViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCQuestionConfigureViewModel.cs index 6d2a7b8c7..fc589669a 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCQuestionConfigureViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCQuestionConfigureViewModel.cs @@ -57,6 +57,9 @@ namespace IRaCIS.Core.Application.Contracts public string ChildInvalidValue { get; set; } = String.Empty; public int ShowOrder { get; set; } + + public string ParentTriggerValue { get; set; } + } diff --git a/IRaCIS.Core.Application/Service/QC/DTO/TrialQCQuestionConfigureViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/TrialQCQuestionConfigureViewModel.cs index f5e0e3e58..35ceb551d 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/TrialQCQuestionConfigureViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/TrialQCQuestionConfigureViewModel.cs @@ -83,6 +83,7 @@ namespace IRaCIS.Core.Application.Contracts public class TrialQCQuestionConfigureBatchAdd { + public Guid Id { get; set; } public string QuestionName { get; set; } = string.Empty; public bool IsRequired { get; set; } public bool IsEnable { get; set; } diff --git a/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs b/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs index cbb6761d3..a9df2ee82 100644 --- a/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCQuestionService.cs @@ -4,6 +4,7 @@ // 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 //-------------------------------------------------------------------- +using IRaCIS.Core.Infrastructure; using Microsoft.AspNetCore.Mvc; namespace IRaCIS.Core.Application.Contracts @@ -19,6 +20,68 @@ namespace IRaCIS.Core.Application.Contracts public QCQuestionConfigureService(IRepository qcQuestionRepository) { _qcQuestionRepository = qcQuestionRepository; + + + + } + + + /// + /// 父问题 下拉框选项 需要排除自己 、把自己设置为父亲 (互为父亲) 、是自己孙辈的(明明是自己子孙,却设置为自己父亲) + /// + /// + /// + [HttpPost] + public async Task> GetQCQuestionSelectList(TrialQCQuestionFilterSelect trialQCQuestionFilterSelect) + { + + //设置父亲的时候,不允许设置为自己的孙子 这种会形成环 + + var initList = await _qcQuestionRepository + .WhereIf(trialQCQuestionFilterSelect.TypeArray.Count() > 0, t => trialQCQuestionFilterSelect.TypeArray.Contains(t.Type)) + //.WhereIf(trialQCQuestionFilterSelect.Id != null, t => t.Id != trialQCQuestionFilterSelect.Id /*&& t.ParentId != trialQCQuestionFilterSelect.Id*/) + .OrderBy(t => t.ShowOrder).Select(x=>new TrialQCQuestionSelect() { + ShowOrder=x.ShowOrder, + Id=x.Id, + ParentId=x.ParentId, + QuestionName=x.QuestionName, + TypeValue=x.TypeValue, + + }).ToListAsync(); + + //父亲的序号肯定要比自己小 + if (trialQCQuestionFilterSelect.Id != null) + { + var selectItem = initList.FirstOrDefault(t => t.Id == trialQCQuestionFilterSelect.Id); + + initList = initList.WhereIf(selectItem != null, t => t.Id != selectItem!.Id && t.ShowOrder < selectItem.ShowOrder).ToList(); + } + + + var exceptList = GetChildId(trialQCQuestionFilterSelect.Id ?? Guid.Empty, initList); + + + return initList.Where(t => !exceptList.Contains(t.Id)).ToList(); + } + + private List GetChildId(Guid parentId, List list) + { + + var ids = new List(); + + var childIds = list.Where(t => t.ParentId == parentId).Select(t => t.Id).ToList(); + + foreach (var childId in childIds) + { + ids.AddRange(childId); + + var childs = GetChildId(childId, list); + + ids.AddRange(childs); + + } + + return ids; } @@ -46,6 +109,10 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{qCQuestionConfigureId:guid}")] public async Task DeleteQCQuestionConfigure(Guid qCQuestionConfigureId) { + if (await _qcQuestionRepository.AnyAsync(x => x.ParentId == qCQuestionConfigureId)) + { + throw new BusinessValidationFailedException("当前任务存在子问题,删除失败"); + } var success = await _qcQuestionRepository.BatchDeleteNoTrackingAsync(t => t.Id == qCQuestionConfigureId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs index 04d1c8aef..43e9e1f09 100644 --- a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs +++ b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs @@ -19,10 +19,15 @@ namespace IRaCIS.Core.Application.Contracts public class TrialQCQuestionConfigureService : BaseService, ITrialQCQuestionConfigureService { private readonly IRepository _trialQcQuestionRepository; + private readonly IRepository _qCQuestionRepository; - public TrialQCQuestionConfigureService(IRepository trialQcQuestionRepository) + public TrialQCQuestionConfigureService( + IRepository trialQcQuestionRepository, + IRepository qCQuestionRepository + ) { _trialQcQuestionRepository = trialQcQuestionRepository; + this._qCQuestionRepository = qCQuestionRepository; } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs index 161bc0ad3..89dc0c009 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs @@ -190,7 +190,6 @@ namespace IRaCIS.Application.Services x.EvaluationResult = oncologyData.EvaluationResult; x.EvaluationReason = oncologyData.EvaluationReason; } - x.QuestionList = globalTaskReadingInfo.TaskList.Where(y => x.VisitTaskId == y.VisitTaskId).SelectMany(y => y.AfterQuestionList).Where(x => x.QuestionId != null) .Select(y => new OncologyQuestion { @@ -198,10 +197,6 @@ namespace IRaCIS.Application.Services QuestionName = y.QuestionName, Answer = y.Answer }).ToList(); - - - - x.IsHaveChange = globalTaskReadingInfo.TaskList.Where(y => x.VisitTaskId == y.VisitTaskId).SelectMany(y => y.AfterQuestionList).Any(y => y.IsHaveChange); x.VisitRemark = globalTaskReadingInfo.TaskList.Where(y => x.VisitTaskId == y.VisitTaskId).SelectMany(y => y.AfterQuestionList).Where(y => y.QuestionId == null).Select(x => x.Answer).FirstOrDefault() ?? string.Empty; diff --git a/IRaCIS.Core.Domain/QC/TrialQCQuestion.cs b/IRaCIS.Core.Domain/QC/TrialQCQuestion.cs index dd3309fc6..2f0920175 100644 --- a/IRaCIS.Core.Domain/QC/TrialQCQuestion.cs +++ b/IRaCIS.Core.Domain/QC/TrialQCQuestion.cs @@ -99,8 +99,11 @@ namespace IRaCIS.Core.Domain.Models /// public bool? IsConfirm { get; set; } - + /// + /// 系统的问题ID + /// + public Guid? SystemQuestionId { get; set; } public List TrialQCQuestionAnswerList { get; set; }