From e5d08cdb3e780622d178952351a849e416b34521 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Mon, 4 Mar 2024 14:11:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BB=E7=94=9F=E5=AE=A1=E6=A0=B8=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=B8=80=E4=BB=B6=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/ReadingMedicineQuestionViewModel.cs | 11 ++- .../ReadingMedicineQuestionService.cs | 87 +++++++++++++++++-- 2 files changed, 91 insertions(+), 7 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicineQuestionViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicineQuestionViewModel.cs index e2e9128a2..730a1fec2 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicineQuestionViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicineQuestionViewModel.cs @@ -91,7 +91,16 @@ namespace IRaCIS.Core.Application.ViewModel { public Guid SystemQuestionId { get; set; } } - public class AddTrialDataFromSystemInDto + + public class AddDefaultQuestionsInDto + { + public Guid TrialId { get; set; } + + [NotDefault] + public Guid TrialReadingCriterionId { get; set; } + } + + public class AddTrialDataFromSystemInDto { public Guid TrialId { get; set; } diff --git a/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicineQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicineQuestionService.cs index a82e5e672..31252ff65 100644 --- a/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicineQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicineQuestionService.cs @@ -6,6 +6,8 @@ using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Application.Filter; +using DocumentFormat.OpenXml.Office2010.Excel; +using System.Linq.Dynamic.Core; namespace IRaCIS.Core.Application.Service { @@ -491,13 +493,86 @@ namespace IRaCIS.Core.Application.Service return ResponseOutput.Result(true); } + /// + /// 一键添加默认医学审核问题 + /// + /// + /// + [HttpPost] + public async Task AddDefaultQuestions(AddDefaultQuestionsInDto inDto) + { + if (await _readingMedicineTrialQuestionRepository.AnyAsync(x => x.TrialReadingCriterionId == inDto.TrialReadingCriterionId)) + { + throw new BusinessValidationFailedException(_localizer["Medicine_ExistsMedicineQuestion"]); + } + var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.TrialReadingCriterionId).FirstNotNullAsync(); + List needAddCategory = new List() { ReadingCategory.Visit }; + if(criterionInfo.IsReadingPeriod) + { + needAddCategory.Add(ReadingCategory.Global); + } + if (criterionInfo.IsArbitrationReading) + { + needAddCategory.Add(ReadingCategory.Judge); + } + if (criterionInfo.IsOncologyReading) + { + needAddCategory.Add(ReadingCategory.Oncology); + } - /// - /// 从系统里面选择问题添加到项目里面 - /// - /// - /// - [HttpPost] + var maxOrder = await _readingMedicineTrialQuestionRepository.Where(x => x.TrialId == inDto.TrialId && x.TrialReadingCriterionId == inDto.TrialReadingCriterionId).OrderByDescending(x => x.ShowOrder).Select(x => x.ShowOrder).FirstOrDefaultAsync(); + List needList = await _readingMedicineSystemQuestionRepository + .WhereIf(_userInfo.IsEn_Us, x => x.LanguageType == LanguageType.English) + .WhereIf(!_userInfo.IsEn_Us, x => x.LanguageType == LanguageType.Chinese) + .Where(x => x.CriterionTypeEnum == criterionInfo.CriterionType && needAddCategory.Contains(x.ReadingCategory)) + .Select(x => new TrialDataFromSystem() + { + Id = NewId.NextGuid(), + ShowOrder = x.ShowOrder, + IsEnable = x.IsEnable, + LanguageType = x.LanguageType, + IsRequired = x.IsRequired, + QuestionName = x.QuestionName, + TrialReadingCriterionId = inDto.TrialReadingCriterionId, + Type = x.Type, + ParentId = x.ParentId, + SystemQuestionId = x.Id, + ReadingCategory = x.ReadingCategory, + TypeValue = x.TypeValue, + TrialId = inDto.TrialId, + }).ToListAsync(); + + needList.ForEach(x => { + maxOrder++; + x.ShowOrder = maxOrder; + }); + + foreach (var item in needList.Where(x => x.ParentId != null)) + { + var parent = needList.Where(x => x.SystemQuestionId == item.ParentId).FirstOrDefault(); + if (parent == null) + { + item.ParentId = null; + item.ParentTriggerValue = String.Empty; + } + else + { + item.ParentId = parent.Id; + } + } + + await _readingMedicineTrialQuestionRepository.AddRangeAsync(_mapper.Map>(needList)); + var result = await _readingMedicineTrialQuestionRepository.SaveChangesAsync(); + return ResponseOutput.Result(result); + + } + + /// + /// 从系统里面选择问题添加到项目里面 + /// + /// + /// + [HttpPost] public async Task AddTrialDataFromSystem(AddTrialDataFromSystemInDto inDto) { // 直接写??