diff --git a/IRaCIS.Core.API/Controllers/InspectionController.cs b/IRaCIS.Core.API/Controllers/InspectionController.cs index dd61544de..a1e3b69ac 100644 --- a/IRaCIS.Core.API/Controllers/InspectionController.cs +++ b/IRaCIS.Core.API/Controllers/InspectionController.cs @@ -9,6 +9,7 @@ using IRaCIS.Core.Application.Image.QA; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.Service.Inspection.DTO; using IRaCIS.Core.Application.Service.Inspection.Interface; +using IRaCIS.Core.Application.Service.Reading.Dto; using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infra.EFCore; @@ -29,6 +30,7 @@ namespace IRaCIS.Core.API.Controllers private readonly IUserInfo _userInfo; private readonly ITrialDocumentService _trialDocumentService; private readonly IQCListService _qCListService; + private readonly IReadingImageTaskService _iReadingImageTaskService; private readonly IHttpContextAccessor _httpContext; private readonly ITrialConfigService _trialConfigService; private readonly INoneDicomStudyService _noneDicomStudyService; @@ -38,6 +40,7 @@ namespace IRaCIS.Core.API.Controllers private readonly IQCOperationService _qCOperationService; private readonly IClinicalDataService _clinicalDataService; private readonly IVisitPlanService _visitPlanService; + private readonly IInspectionService _inspectionService; private readonly IRepository _dataInspectionRepository; @@ -49,6 +52,7 @@ namespace IRaCIS.Core.API.Controllers ITrialDocumentService trialDocumentService, IRepository dataInspectionRepository, IQCListService _qCListService, + IReadingImageTaskService _iReadingImageTaskService, IHttpContextAccessor httpContext, IInspectionService sinspectionService, ITrialConfigService _trialConfigService, @@ -67,6 +71,7 @@ namespace IRaCIS.Core.API.Controllers this._inspectionService = sinspectionService; this._trialDocumentService = trialDocumentService; this._qCListService = _qCListService; + this._iReadingImageTaskService = _iReadingImageTaskService; this._httpContext = httpContext; this._trialConfigService = _trialConfigService; this._noneDicomStudyService = noneDicomStudyService; @@ -95,8 +100,17 @@ namespace IRaCIS.Core.API.Controllers #endregion - - + + [HttpPost, Route("Inspection/ReadingImageTask/SubmitVisitTaskQuestionsInDto")] + [UnitOfWork] + public async Task SubmitVisitTaskQuestions(DataInspectionDto opt) + { + var singid = await _inspectionService.RecordSing(opt.SignInfo); + var result = await _iReadingImageTaskService.SubmitVisitTaskQuestions(opt.Data); + await _inspectionService.CompletedSign(singid, result); + return result; + } + /// /// 配置 基础逻辑信息并确认 diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 0a20f5ca0..dd6053382 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -4236,13 +4236,6 @@ IR影像阅片 - - - 获取阅片非Dicom文件 - - - - 获取项目已确认的标准 @@ -4257,6 +4250,13 @@ + + + 找子问题 + + + + 阅片期配置 @@ -4335,6 +4335,12 @@ + + + 设置系统标准被禁用 + + + 设置系统问题标准是否完成配置 diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs index ef5c61a11..4dc0c11c2 100644 --- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs @@ -3,6 +3,7 @@ using IRaCIS.Application.Contracts; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Domain.Share; +using IRaCIS.Core.Application.Contracts; namespace IRaCIS.Application.Services { @@ -18,15 +19,21 @@ namespace IRaCIS.Application.Services private readonly IRepository _trialDictionaryRepository; private readonly IRepository _doctorRepository; private readonly IRepository _trialRepository; + private readonly IReadingQuestionService _readingQuestionService; public DictionaryService(IRepository sysDicRepository, IRepository doctorDictionaryRepository, IRepository trialDictionaryRepository, - IRepository doctorRepository, IRepository trialRepository) + IRepository doctorRepository, IRepository trialRepository, + IReadingQuestionService readingQuestionService + + + ) { _dicRepository = sysDicRepository; _doctorDictionaryRepository = doctorDictionaryRepository; _trialDictionaryRepository = trialDictionaryRepository; _doctorRepository = doctorRepository; _trialRepository = trialRepository; + this._readingQuestionService = readingQuestionService; } /// @@ -101,8 +108,16 @@ namespace IRaCIS.Application.Services VerifyMsg = $"已有{addOrEditBasic.Code}名称的字典", IsVerify= addOrEditBasic.ParentId ==null }; + // 验证阅片标准是否可禁用 + if (!addOrEditBasic.IsEnable&&addOrEditBasic.Id!=null) + { + var result = await _readingQuestionService.SetSystemCriterionDisable(addOrEditBasic.Id.Value,addOrEditBasic.ParentId); + if (!result.IsSuccess) + { + return result; + } + } var entity = await _dicRepository.InsertOrUpdateAsync(addOrEditBasic, true, verifyExp1); - return ResponseOutput.Ok(entity.Id.ToString()); } @@ -187,7 +202,6 @@ namespace IRaCIS.Application.Services return searchList.GroupBy(t => t.ParentCode).ToDictionary(g => g.Key, g => g.OrderBy(t => t.ShowOrder).ToList()); } - #region 稽查相关 /// diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index 1fe363bbd..2d4c9dd48 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -18,7 +18,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public class GetReadingImgInDto { - public Guid SubjectVisitId { get; set; } + public Guid VisitTaskId { get; set; } } public class GetConfirmCriterionInDto @@ -34,12 +34,12 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// public class GetTrialConfirmCriterionListOutDto { - public Guid CriterionId { get; set; } + public Guid ReadingQuestionCriterionTrialId { get; set; } /// /// 标准 /// - public string CriterionName { get; set; } + public string ReadingQuestionCriterionTrialName { get; set; } } @@ -54,33 +54,42 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// public class SubmitVisitTaskQuestionsInDto { + + public Guid TrialId { get; set; } + public Guid VisitTaskId { get; set; } + public Guid ReadingQuestionCriterionTrialId { get; set; } + public List AnswerList { get; set; } = new List(); } public class QuestionAnswer { - public Guid TrialQuestionId { get; set; } + public Guid ReadingQuestionTrialId { get; set; } public string Answer { get; set; } } - public class GetTrialReadingQuestionDto - { - public Guid Id { get; set; } + //public class GetTrialReadingQuestionDto + //{ + // public Guid Id { get; set; } - public string GroupName { get; set; } + // public string GroupName { get; set; } - List Questions { get; set; } - } + // List Questions { get; set; } + //} public class GetTrialReadingQuestionOutDto { + public Guid ReadingQuestionTrialId { get; set; } - public Guid Id { get; set; } + /// + /// 项目标准Id + /// + public Guid ReadingQuestionCriterionTrialId { get; set; } /// /// 项目Id @@ -97,6 +106,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// public string ParentTriggerValue { get; set; } + public string GroupName { get; set; } + /// /// 问题名称 /// diff --git a/IRaCIS.Core.Application/Service/Reading/Interface/IReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/Interface/IReadingImageTaskService.cs new file mode 100644 index 000000000..a99495361 --- /dev/null +++ b/IRaCIS.Core.Application/Service/Reading/Interface/IReadingImageTaskService.cs @@ -0,0 +1,17 @@ +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2021-12-23 13:20:59 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + + +using IRaCIS.Core.Application.Service.Reading.Dto; +using IRaCIS.Core.Domain.Share.Reading; + +namespace IRaCIS.Core.Application.Contracts +{ + public interface IReadingImageTaskService + { + Task SubmitVisitTaskQuestions(SubmitVisitTaskQuestionsInDto inDto); + } +} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Reading/Interface/IReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/Interface/IReadingQuestionService.cs new file mode 100644 index 000000000..92946e12b --- /dev/null +++ b/IRaCIS.Core.Application/Service/Reading/Interface/IReadingQuestionService.cs @@ -0,0 +1,19 @@ +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2021-12-23 13:20:59 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +//-------------------------------------------------------------------- + + +using IRaCIS.Core.Application.Service.Reading.Dto; +using IRaCIS.Core.Domain.Share.Reading; + +namespace IRaCIS.Core.Application.Contracts +{ + public interface IReadingQuestionService + { + Task SetSystemCriterionDisable(Guid dictionaryId, Guid? parentId); + + + } +} \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs index 2b226272a..009fba6f8 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs @@ -11,6 +11,8 @@ using MassTransit; using IRaCIS.Core.Application.Service.Reading; using IRaCIS.Core.Infra.EFCore.Common; using Panda.DynamicWebApi.Attributes; +using AutoMapper; +using IRaCIS.Core.Application.Contracts; namespace IRaCIS.Application.Services { @@ -18,41 +20,49 @@ namespace IRaCIS.Application.Services /// IR影像阅片 /// [ApiExplorerSettings(GroupName = "Reading")] - public class ReadingImageTaskService : BaseService + public class ReadingImageTaskService : BaseService, IReadingImageTaskService { + private readonly IMapper mapper; private readonly IRepository _noneDicomStudyRepository; private readonly IRepository _visitTaskRepository; + private readonly IRepository _readingTaskQuestionAnswerRepository; private readonly IRepository _readingQuestionCriterionTrialRepository; private readonly IRepository _readingQuestionTrialRepository; public ReadingImageTaskService( + IMapper mapper, IRepository noneDicomStudyRepository, IRepository visitTaskRepository, + IRepository readingTaskQuestionAnswerRepository, IRepository readingQuestionCriterionTrialRepository, IRepository readingQuestionTrialRepository ) { + this.mapper = mapper; this._noneDicomStudyRepository = noneDicomStudyRepository; this._visitTaskRepository = visitTaskRepository; + this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository; this._readingQuestionCriterionTrialRepository = readingQuestionCriterionTrialRepository; this._readingQuestionTrialRepository = readingQuestionTrialRepository; } - /// - /// 获取阅片非Dicom文件 - /// - /// - /// - [HttpPost] - public async Task> GetReadingImageFile(GetReadingImgInDto inDto) - { - List imgList =await _noneDicomStudyRepository.Where(x => x.SubjectVisitId == inDto.SubjectVisitId) - .SelectMany(x => x.NoneDicomFileList).Select(x=> new GetReadingImgOutDto() { - FileName=x.FileName, - Path=x.Path - }).ToListAsync(); - return imgList; - } + ///// + ///// 获取阅片非Dicom文件 + ///// + ///// + ///// + //[HttpPost] + //public async Task> GetReadingImageFile(GetReadingImgInDto inDto) + //{ + // var subjectVisitId=await _visitTaskRepository.Where(x=>x.Id==inDto.VisitTaskId).Select(x=>x.vi) + + // List imgList =await _noneDicomStudyRepository.Where(x => x.SubjectVisitId == inDto.SubjectVisitId) + // .SelectMany(x => x.NoneDicomFileList).Select(x=> new GetReadingImgOutDto() { + // FileName=x.FileName, + // Path=x.Path + // }).ToListAsync(); + // return imgList; + //} /// /// 获取项目已确认的标准 @@ -62,11 +72,11 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task> GetTrialConfirmCriterionList(GetConfirmCriterionInDto inDto) { - var result= await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == inDto.TrialId&&x.IsConfirm) + var result= await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == inDto.TrialId&&x.IsConfirm&&x.IsCompleteConfig) .Select(x => new GetTrialConfirmCriterionListOutDto() { - CriterionId = x.Id, - CriterionName = x.CriterionName + ReadingQuestionCriterionTrialId = x.Id, + ReadingQuestionCriterionTrialName = x.CriterionName }).ToListAsync(); return result; } @@ -79,27 +89,69 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task> GetTrialReadingQuestion(GetTrialReadingQuestionInDto inDto) { - var qusetionList = await _readingQuestionTrialRepository.Where(x => x.Id == inDto.CriterionId).ToListAsync(); - //List groupNames + var qusetionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.CriterionId).ToListAsync(); - var result = await _readingQuestionTrialRepository.Where(x => x.Id == inDto.CriterionId) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - return result; + List groupList = _mapper.Map>(qusetionList.Where(x => x.ParentId == null)); + groupList.ForEach(x => + { + FindChildQuestion(x, qusetionList); + }); + return groupList; } - ///// - ///// - ///// - ///// - ///// - //public async Task SubmitVisitTaskQuestions(SubmitVisitTaskQuestionsInDto InDto) - //{ + + /// + /// 找子问题 + /// + /// + /// + + private void FindChildQuestion(GetTrialReadingQuestionOutDto trialReadingQuestion, List questionlists) + { + trialReadingQuestion.Childrens = _mapper.Map>(questionlists.Where(x => x.ParentId == trialReadingQuestion.ReadingQuestionTrialId)); + if (trialReadingQuestion.Childrens != null && trialReadingQuestion.Childrens.Count != 0) + { + trialReadingQuestion.Childrens.ForEach(x => + { + FindChildQuestion(x, questionlists); + }); + } + } - //} - + /// + /// 提交问题 + /// + /// + /// + [NonDynamicMethod] + public async Task SubmitVisitTaskQuestions(SubmitVisitTaskQuestionsInDto inDto) + { + var subjectId =await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.SubjectId).FirstOrDefaultAsync(); + List readingTaskAnswerList = inDto.AnswerList.Select(x => new ReadingTaskQuestionAnswer() + { + Id = NewId.NextGuid(), + SubjectId = subjectId, + Answer = x.Answer, + ReadingQuestionCriterionTrialId = inDto.ReadingQuestionCriterionTrialId, + ReadingQuestionTrialId = x.ReadingQuestionTrialId, + VisitTaskId = inDto.VisitTaskId, + TrialId = inDto.TrialId + }).ToList(); + await _readingTaskQuestionAnswerRepository.AddRangeAsync(readingTaskAnswerList); + await _visitTaskRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.VisitTaskId, x => new VisitTask() + { + ReadingTaskState = ReadingTaskState.HaveSigned + }); + var result = await _visitTaskRepository.SaveChangesAsync(); + return ResponseOutput.Ok(result); + + } + + + } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs index aacb4298f..df4fad54c 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs @@ -11,6 +11,7 @@ using MassTransit; using IRaCIS.Core.Application.Service.Reading; using IRaCIS.Core.Infra.EFCore.Common; using Panda.DynamicWebApi.Attributes; +using IRaCIS.Core.Application.Contracts; namespace IRaCIS.Application.Services { @@ -18,7 +19,7 @@ namespace IRaCIS.Application.Services /// 阅片问题.标准 /// [ApiExplorerSettings(GroupName = "Reading")] - public class ReadingQuestionService : BaseService + public class ReadingQuestionService : BaseService, IReadingQuestionService { private readonly IRepository _subjectVisitRepository; @@ -82,6 +83,31 @@ namespace IRaCIS.Application.Services inDto.Asc); } + + /// + /// 设置系统标准被禁用 + /// + /// + [NonDynamicMethod] + public async Task SetSystemCriterionDisable(Guid dictionaryId, Guid? parentId) + { + // 判断是否是阅片 + if (await _dictionaryRepository.AnyAsync(x => x.Id == parentId && x.Code == "ReadingStandard")) + { + // 判断当前阅片是否在项目里面存在 + var systemCriterion = await _readingQuestionCriterionSystemRepository.FirstOrDefaultAsync(x => x.CriterionId == dictionaryId); + if (systemCriterion != null) + { + var trialCriterionIds = await _readingQuestionCriterionTrialRepository.Where(x => x.ReadingQuestionCriterionSystemId == systemCriterion.Id).Select(x=>x.ReadingQuestionCriterionSystemId).ToListAsync(); + await _readingQuestionCriterionTrialRepository.BatchDeleteNoTrackingAsync(x => x.ReadingQuestionCriterionSystemId == systemCriterion.Id); + await _readingQuestionTrialRepository.BatchDeleteNoTrackingAsync(x => trialCriterionIds.Contains(x.ReadingQuestionCriterionTrialId)); + return ResponseOutput.Ok(); + } + } + + return ResponseOutput.Ok(); + } + ///// ///// 设置系统问题标准是否生效 ///// @@ -212,6 +238,9 @@ namespace IRaCIS.Application.Services return ResponseOutput.Ok(entity.Id.ToString()); } + + + /// /// 获取系统问题 /// diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index 22e4b960d..c627d3dbe 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -73,7 +73,8 @@ namespace IRaCIS.Core.Application.Service #endregion #region IR阅片 - CreateMap(); + CreateMap() + .ForMember(x=>x.ReadingQuestionTrialId, y=>y.MapFrom(z=>z.Id)); #endregion diff --git a/IRaCIS.Core.Domain/Reading/ReadingQuestionTrial.cs b/IRaCIS.Core.Domain/Reading/ReadingQuestionTrial.cs index b94e27df0..096f83fee 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingQuestionTrial.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingQuestionTrial.cs @@ -15,7 +15,7 @@ namespace IRaCIS.Core.Domain.Models public class ReadingQuestionTrial : Entity, IAuditAdd { /// - /// 系统标准Id + /// 项目标准Id /// public Guid ReadingQuestionCriterionTrialId { get; set; } diff --git a/IRaCIS.Core.Domain/Reading/ReadingTaskQuestionAnswer.cs b/IRaCIS.Core.Domain/Reading/ReadingTaskQuestionAnswer.cs index f32503a9d..e2e16a0ce 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingTaskQuestionAnswer.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingTaskQuestionAnswer.cs @@ -20,6 +20,11 @@ namespace IRaCIS.Core.Domain.Models /// public Guid ReadingQuestionTrialId { get; set; } + /// + /// 项目问题标准Id + /// + public Guid ReadingQuestionCriterionTrialId { get; set; } + /// /// 项目ID ///