From 4ead6408eb0d185724b80795fb95c5b3444f021a Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Fri, 1 Jul 2022 10:34:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reading/ReadingMedicalReviewService.cs | 258 +----------------- .../Service/Reading/ReadingQuestionService.cs | 4 +- .../Reading/ReadingMedicalReviewDialog.cs | 56 ++++ .../Reading/ReadingMedicineQuestionAnswer.cs | 62 +++++ .../Context/IRaCISDBContext.cs | 4 + IRaCIS.Core.Test/DbHelper.ttinclude | 2 +- 6 files changed, 126 insertions(+), 260 deletions(-) create mode 100644 IRaCIS.Core.Domain/Reading/ReadingMedicalReviewDialog.cs create mode 100644 IRaCIS.Core.Domain/Reading/ReadingMedicineQuestionAnswer.cs diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingMedicalReviewService.cs index c43cab5f1..8657a0c30 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingMedicalReviewService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingMedicalReviewService.cs @@ -32,263 +32,7 @@ namespace IRaCIS.Core.Application.Service } - /// - /// 获取系统的医学审核问题 - /// - /// - /// - [HttpPost] - public async Task> GetReadingMedicineSystemQuestionList(ReadingMedicineSystemQuestionQuery inDto) - { - var query = _readingMedicineSystemQuestionRepository.AsQueryable() - .WhereIf(!inDto.TypeValue.IsNullOrEmpty(), x => x.TypeValue.Contains(inDto.TypeValue)) - .WhereIf(!inDto.ParentTriggerValue.IsNullOrEmpty(), x => x.ParentTriggerValue.Contains(inDto.ParentTriggerValue)) - .WhereIf(!inDto.QuestionName.IsNullOrEmpty(), x => x.QuestionName.Contains(inDto.QuestionName)) - .WhereIf(!inDto.Type.IsNullOrEmpty(), x => x.Type.Contains(inDto.Type)) - .ProjectTo(_mapper.ConfigurationProvider).OrderBy(x=>x.ShowOrder); - return await query.ToListAsync(); - } - - /// - /// 新增或修改系统医学审核问题 - /// - /// - /// - [HttpPost] - public async Task AddOrUpdateReadingMedicineSystemQuestion(ReadingMedicineSystemQuestionAddOrEdit inDto) - { - var existsQuery = _readingMedicineSystemQuestionRepository - .WhereIf(inDto.Id != null, x => x.Id != inDto.Id) - .Where(x => x.QuestionName == inDto.QuestionName ||x.ShowOrder == inDto.ShowOrder); - - if (await existsQuery.AnyAsync()) - { - return ResponseOutput.NotOk("当前问题名称或序号存在重复"); - } - var entity = await _readingMedicineSystemQuestionRepository.InsertOrUpdateAsync(inDto); - await _readingMedicineSystemQuestionRepository.SaveChangesAsync(); - return ResponseOutput.Ok(entity.Id.ToString()); - } - - - - - /// - /// 删除系统的医学审核问题 - /// - /// - /// - [HttpDelete("{id:guid}")] - public async Task DeleteReadingMedicineSystemQuestion(Guid id) - { - if (await _readingMedicineSystemQuestionRepository.AnyAsync(x => x.ParentId == id)) - { - return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题"); - } - var success = await _readingMedicineSystemQuestionRepository.DeleteFromQueryAsync(t => t.Id == id); - var result = await _readingMedicineSystemQuestionRepository.SaveChangesAsync(); - return ResponseOutput.Result(result); - } - - /// - /// 获取项目的医学审核问题 - /// - /// - /// - [HttpPost] - public async Task<(List,object)> GetReadingMedicineTrialQuestionList(ReadingMedicineTrialQuestionQuery inDto) - { - var query = _readingMedicineTrialQuestionRepository.AsQueryable() - .Where(x=>x.TrialId==inDto.TrialId) - .WhereIf(!inDto.TypeValue.IsNullOrEmpty(), x => x.TypeValue.Contains(inDto.TypeValue)) - .WhereIf(!inDto.ParentTriggerValue.IsNullOrEmpty(), x => x.ParentTriggerValue.Contains(inDto.ParentTriggerValue)) - .WhereIf(!inDto.QuestionName.IsNullOrEmpty(), x => x.QuestionName.Contains(inDto.QuestionName)) - .WhereIf(!inDto.Type.IsNullOrEmpty(), x => x.Type.Contains(inDto.Type)) - .ProjectTo(_mapper.ConfigurationProvider).OrderBy(x=>x.ShowOrder); - - - var isConfirmMedicineQuestion = await _trialRepository.Where(x => x.Id == inDto.TrialId).Select(x => x.IsConfirmMedicineQuestion).FirstOrDefaultAsync(); - var questionList = await query.ToListAsync(); - return (questionList, new { - IsConfirmMedicineQuestion= isConfirmMedicineQuestion, - QuestionCount= questionList.Count(), - }); - } - - /// - /// 获取预览问题信息 - /// - /// - /// - [HttpPost] - public async Task> GetMedicineQuestionPreview(GetMedicineQuestionPreviewInDto inDto) - { - var trialQuestionList = await _readingMedicineTrialQuestionRepository.Where(x=>x.TrialId==inDto.TrialId) - .ProjectTo(_mapper.ConfigurationProvider).OrderBy(x=>x.ShowOrder).ToListAsync(); - - List readingQuestionList = trialQuestionList.Where(x => x.ParentId == null).ToList(); - readingQuestionList.ForEach(x => - { - FindChildQuestion(x, trialQuestionList); - }); - - return readingQuestionList; - } - - private void FindChildQuestion(GetMedicineQuestionPreviewOutDto trialReadingQuestion, List questionlists) - { - trialReadingQuestion.Childrens = questionlists.Where(x => x.ParentId == trialReadingQuestion.Id).ToList(); - if (trialReadingQuestion.Childrens != null && trialReadingQuestion.Childrens.Count != 0) - { - trialReadingQuestion.Childrens.ForEach(x => - { - this.FindChildQuestion(x, questionlists); - }); - } - } - - /// - /// 新增或修改项目医学审核问题 - /// - /// - /// - [HttpPost] - public async Task AddOrUpdateReadingMedicineTrialQuestion(ReadingMedicineTrialQuestionAddOrEdit inDto) - { - var existsQuery = _readingMedicineTrialQuestionRepository - .WhereIf(inDto.Id != null, x => x.Id != inDto.Id) - .Where(x => x.TrialId==inDto.TrialId) - .Where(x => x.QuestionName == inDto.QuestionName || x.ShowOrder == inDto.ShowOrder); - - if (await existsQuery.AnyAsync()) - { - return ResponseOutput.NotOk("当前问题名称或序号存在重复"); - } - var entity = await _readingMedicineTrialQuestionRepository.InsertOrUpdateAsync(inDto); - await _readingMedicineTrialQuestionRepository.SaveChangesAsync(); - return ResponseOutput.Ok(entity.Id.ToString()); - - } - - /// - /// 获取项目的其他医学审核问题 - /// - /// - /// - [HttpPost] - public async Task> GetReadingMedicineTrialOtherQuestion(GetReadingMedicineTrialOtherQuestionInDto inDto) - { - var types = new List() - { - "select","radio" - }; - - var questionList = await _readingMedicineTrialQuestionRepository.Where(x => x.TrialId == inDto.TrialId) - .Where(x => types.Contains(x.Type)) - .WhereIf(inDto.Id != null, x => x.Id != inDto.Id && x.ParentId != inDto.Id) - .WhereIf(inDto.ShowOrder != null, x => x.ShowOrder new GetReadingMedicineTrialOtherQuestionOutDto() - { - Id = x.Id, - QuestionName = x.QuestionName, - TypeValue=x.TypeValue, - - }).ToListAsync(); - - return questionList; - } - - /// - /// 从系统里面选择问题添加到项目里面 - /// - /// - /// - [HttpPost] - public async Task AddTrialDataFromSystem(AddTrialDataFromSystemInDto inDto) - { - // 直接写?? - var systemList = await _readingMedicineSystemQuestionRepository.Where(x => inDto.SystemQuestionIds.Contains(x.Id)).ToListAsync(); - var needList= systemList.Select(x => new ReadingMedicineTrialQuestion() - { - Id = NewId.NextGuid(), - ShowOrder = x.ShowOrder, - IsEnable = x.IsEnable, - IsRequired = x.IsRequired, - QuestionName = x.QuestionName, - Type = x.Type, - TypeValue = x.TypeValue, - TrialId=inDto.TrialId, - }).ToList(); - - await _readingMedicineTrialQuestionRepository.AddRangeAsync(needList); - var result = await _readingMedicineTrialQuestionRepository.SaveChangesAsync(); - return ResponseOutput.Result(result); - } - - /// - /// 删除项目的医学审核问题 - /// - /// - /// - [HttpPost] - public async Task DeleteReadingMedicineTrialQuestion(DeleteReadingMedicineTrialQuestion inDto) - { - if (await _readingMedicineTrialQuestionRepository.AnyAsync(x => x.ParentId == inDto.Id)) - { - return ResponseOutput.NotOk("此问题存在子问题,请先删除子问题"); - } - var success = await _readingMedicineTrialQuestionRepository.DeleteFromQueryAsync(t => t.Id == inDto.Id); - var result = await _readingMedicineTrialQuestionRepository.SaveChangesAsync(); - return ResponseOutput.Result(result); - } - - - /// - /// 确认医学审核问题 - /// - /// - public async Task ConfirmReadingMedicineQuestion(ConfirmReadingMedicineQuestionInDto inDto) - { - var readingMedicineQuestionList = await _readingMedicineTrialQuestionRepository.Where(x => x.TrialId == inDto.TrialId) - .Select(x => new TrialQuestion() { - Id = x.Id, - ParentShowOrder = (int?)x.ParentQuestion.ShowOrder, - - }).ToListAsync(); - if (readingMedicineQuestionList.Count == 0) - { - throw new BusinessValidationFailedException("当前未添加医学审核问题。请先添加医学审核问题,再进行确认。"); - } - - if (readingMedicineQuestionList.Count() != readingMedicineQuestionList.Select(t => t.ShowOrder).Distinct().Count()) - { - throw new BusinessValidationFailedException("影像医学审核问题显示序号不能重复。"); - } - - - if (readingMedicineQuestionList.Where(t => t.ParentShowOrder != null).Any(t => t.ParentShowOrder > t.ShowOrder)) - { - throw new BusinessValidationFailedException("父问题的显示序号要比子问题的显示序号小,请确认。"); - } - - - await _readingMedicineTrialQuestionRepository.BatchUpdateNoTrackingAsync(x => x.TrialId == inDto.TrialId, x => new ReadingMedicineTrialQuestion() - { - IsConfirm = true - }); - - await _trialRepository.UpdatePartialFromQueryAsync(inDto.TrialId, x => new Trial() - { - IsConfirmMedicineQuestion = true - }); - - var result = await _trialRepository.SaveChangesAsync(); - return ResponseOutput.Result(result); - - - - } - + } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs index e721876fd..9ff0d96f2 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs @@ -349,7 +349,7 @@ namespace IRaCIS.Application.Services } } - if (await _readingQuestionSystemRepository.AnyAsync(x => x.Id != indto.Id && x.ShowOrder == indto.ShowOrder)) + if (await _readingQuestionSystemRepository.AnyAsync(x => x.Id != indto.Id && x.ShowOrder == indto.ShowOrder&&x.ReadingQuestionCriterionSystemId==indto.ReadingQuestionCriterionSystemId)) { throw new BusinessValidationFailedException("问题编号重复"); } @@ -658,7 +658,7 @@ namespace IRaCIS.Application.Services } } - if (await _readingQuestionTrialRepository.AnyAsync(x => x.Id != indto.Id && x.ShowOrder == indto.ShowOrder&&x.TrialId==indto.TrialId)) + if (await _readingQuestionTrialRepository.AnyAsync(x => x.Id != indto.Id && x.ShowOrder == indto.ShowOrder&&x.TrialId==indto.TrialId&&x.ReadingQuestionCriterionTrialId==indto.ReadingQuestionCriterionTrialId)) { throw new BusinessValidationFailedException("问题编号重复"); } diff --git a/IRaCIS.Core.Domain/Reading/ReadingMedicalReviewDialog.cs b/IRaCIS.Core.Domain/Reading/ReadingMedicalReviewDialog.cs new file mode 100644 index 000000000..98a43da8c --- /dev/null +++ b/IRaCIS.Core.Domain/Reading/ReadingMedicalReviewDialog.cs @@ -0,0 +1,56 @@ + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2022-07-01 10:28:40 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +using System; +using IRaCIS.Core.Domain.Share; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +namespace IRaCIS.Core.Domain.Models +{ + /// + ///阅片医学审核对话 + /// + [Table("ReadingMedicalReviewDialog")] + public class ReadingMedicalReviewDialog : Entity, IAuditAdd + { + /// + /// 医学审核Id + /// + public Guid TaskMedicalReviewId { get; set; } + + /// + /// 任务Id + /// + public Guid VisitTaskId { get; set; } + + /// + /// 对话内容 + /// + public string Content { get; set; } + + /// + /// 用户角色 + /// + public string UserTypeShortName { get; set; } + + /// + /// 用户角色枚举 + /// + public int UserTypeEnumInt { get; set; } + + /// + /// 创建人 + /// + public Guid CreateUserId { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreateTime { get; set; } + + } + + +} diff --git a/IRaCIS.Core.Domain/Reading/ReadingMedicineQuestionAnswer.cs b/IRaCIS.Core.Domain/Reading/ReadingMedicineQuestionAnswer.cs new file mode 100644 index 000000000..ea9ae408f --- /dev/null +++ b/IRaCIS.Core.Domain/Reading/ReadingMedicineQuestionAnswer.cs @@ -0,0 +1,62 @@ + +using System; +using IRaCIS.Core.Domain.Share; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +namespace IRaCIS.Core.Domain.Models +{ + /// + /// 阅片医学问题答案 + /// + [Table("ReadingMedicineQuestionAnswer")] + public class ReadingMedicineQuestionAnswer : Entity, IAuditUpdate, IAuditAdd + { + + + + /// + /// 医学审核Id + /// + + public Guid TaskMedicalReviewId { get; set; } + + /// + /// 任务Id + /// + + public Guid VisitTaskId { get; set; } + + /// + /// 答案 + /// + + public string Answer { get; set; } + + /// + /// 创建人 + /// + + public Guid CreateUserId { get; set; } + + /// + /// 创建时间 + /// + + public DateTime CreateTime { get; set; } + + /// + /// 修改时间 + /// + + public DateTime UpdateTime { get; set; } + + /// + /// 修改人 + /// + + public Guid UpdateUserId { get; set; } + + } + + +} diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index a6e6b9fb0..db02b2e8b 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -216,6 +216,10 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet ReadingMedicineTrialQuestion { get; set; } + public virtual DbSet ReadingMedicineQuestionAnswer { get; set; } + + public virtual DbSet ReadingMedicalReviewDialog { get; set; } + #endregion #region Subject and Visit and study diff --git a/IRaCIS.Core.Test/DbHelper.ttinclude b/IRaCIS.Core.Test/DbHelper.ttinclude index 4611c41b3..0fa70c738 100644 --- a/IRaCIS.Core.Test/DbHelper.ttinclude +++ b/IRaCIS.Core.Test/DbHelper.ttinclude @@ -4,7 +4,7 @@ public static readonly string ConnectionString = "Server=123.56.94.154,1433\\MSSQLSERVER;Database=IRaCIS_New_Tet;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"; public static readonly string DbDatabase = "IRaCIS_New_Tet"; //ַ,ƴ - public static readonly string TableName = "TaskTaskMedicalReviewRule"; + public static readonly string TableName = "ReadingMedicalReviewDialog"; //ļ service Ƿҳ } #>