diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index 432202624..070ebbb4f 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -324,6 +324,8 @@ namespace IRaCIS.Core.Application.Service ReadingCategory = ReadingCategory.Judge, TrialId = firstTask.TrialId, Code = currentMaxCodeInt + 1, + SourceSubjectVisitId= firstTask.SourceSubjectVisitId, + SouceReadModuleId=firstTask.SouceReadModuleId, TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), }; diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index 946846908..93a869671 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -32,7 +32,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public Guid SubjectId { get; set; } - public string SubjectCode { get; set; } + public string SubjectCode { get; set; }=String.Empty; public ReadingCategory ReadingCategory { get; set; } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs index 6185cd63b..33d04ed51 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs @@ -79,15 +79,15 @@ namespace IRaCIS.Application.Services { VisistTaskId = x.Id, ReadingCategory = x.ReadingCategory, - VisistId = x.ReadingCategory == ReadingCategory.Visit ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId, - VisitNum = x.ReadingCategory == ReadingCategory.Visit ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum, + VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId, + VisitNum = x.SourceSubjectVisitId != null ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum, }).FirstOrDefaultAsync(); task.SubjectId = await _subjectVisitRepository.Where(x => x.Id == task.VisistId).Select(x => x.SubjectId).FirstOrDefaultAsync(); - return task; + } - if (subjectId != null) + else if (subjectId != null) { var subjectList =await _subjectRepository.Where(t => t.TrialId == trialId) @@ -107,13 +107,16 @@ namespace IRaCIS.Application.Services var subjectIndex = subjectList.Where(x => x.SubjectId == subjectId).Select(x=>x.Index).FirstOrDefault(); var newSubjectId = subjectList.Where(x => x.Index >= subjectIndex && x.UnReadTaskCount != 0).Select(x=>x.SubjectId).FirstOrDefault(); - task = await _visitTaskRepository.Where(x => x.TrialId == trialId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.SubjectId == newSubjectId && x.DoctorUserId == _userInfo.Id).Select(x => new GetReadingTaskDto() + + var taskquery = _visitTaskRepository.Where(x => x.TrialId == trialId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.SubjectId == newSubjectId && x.DoctorUserId == _userInfo.Id).Select(x => new GetReadingTaskDto() { - VisistTaskId=x.Id, + VisistTaskId = x.Id, ReadingCategory = x.ReadingCategory, - VisistId = x.ReadingCategory == ReadingCategory.Visit ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId, - VisitNum = x.ReadingCategory == ReadingCategory.Visit ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum - }).OrderBy(x => x.VisitNum).ThenBy(x => x.ReadingCategory).FirstOrDefaultAsync(); + VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId, + VisitNum = x.SourceSubjectVisitId != null ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum, + }).OrderBy(x => x.VisitNum).ThenBy(x => x.ReadingCategory); + + task =await taskquery.FirstOrDefaultAsync(); if (task == null) { throw new BusinessValidationFailedException("任务都已经完成"); @@ -128,8 +131,8 @@ namespace IRaCIS.Application.Services { VisistTaskId = x.Id, ReadingCategory = x.ReadingCategory, - VisistId = x.ReadingCategory == ReadingCategory.Visit ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId, - VisitNum = x.ReadingCategory == ReadingCategory.Visit ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum + VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId, + VisitNum = x.SourceSubjectVisitId != null ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum, }).FirstOrDefaultAsync(); if (task == null) { diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs index 927f47df4..db445c12c 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingQuestionService.cs @@ -30,6 +30,7 @@ namespace IRaCIS.Application.Services private readonly IRepository _clinicalDataTrialSetRepository; private readonly IRepository _clinicalDataSystemSetRepository; private readonly IRepository _dictionaryRepository; + private readonly IRepository _readingTaskQuestionAnswer; private readonly IRepository _previousPDFRepository; public ReadingQuestionService( @@ -41,6 +42,7 @@ namespace IRaCIS.Application.Services IRepository ClinicalDataTrialSetRepository, IRepository ClinicalDataSystemSetRepository, IRepository dictionaryRepository, + IRepository readingTaskQuestionAnswer, IRepository previousPDFRepository ) { @@ -52,6 +54,7 @@ namespace IRaCIS.Application.Services this._clinicalDataTrialSetRepository = ClinicalDataTrialSetRepository; this._clinicalDataSystemSetRepository = ClinicalDataSystemSetRepository; this._dictionaryRepository = dictionaryRepository; + this._readingTaskQuestionAnswer = readingTaskQuestionAnswer; this._previousPDFRepository = previousPDFRepository; } @@ -138,6 +141,15 @@ namespace IRaCIS.Application.Services // ResponseOutput.NotOk("当前标准已经运用到项目,操作失败"); //} + if (!inDto.IsCompleteConfig) + { + var trialCriterionIds =await _readingQuestionCriterionTrialRepository.Where(x => x.ReadingQuestionCriterionSystemId == inDto.Id).Select(x => x.Id).ToListAsync(); + if (await _readingTaskQuestionAnswer.AnyAsync(x => trialCriterionIds.Contains(x.ReadingQuestionCriterionTrialId))) + { + return ResponseOutput.NotOk("此标准在项目里面已被使用,操作失败"); + } + } + await _readingQuestionCriterionSystemRepository.UpdatePartialFromQueryAsync(inDto.Id, x => new ReadingQuestionCriterionSystem() { IsCompleteConfig = inDto.IsCompleteConfig