From 035f39f2176e21e00dc8a11f74bb335b41f33623 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Fri, 5 Aug 2022 13:16:39 +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 --- .../DTO/TaskAllocationRuleViewModel.cs | 1 + .../Service/QC/QCOperationService.cs | 1 + .../Service/QC/TrialQCQuestionService.cs | 3 + .../Interface/IReadingClinicalDataService.cs | 5 + .../Interface/IReadingImageTaskService.cs | 2 + .../Reading/ReadingClinicalDataService.cs | 69 +++++--- .../Reading/ReadingImageTaskService.cs | 161 +++++++++--------- 7 files changed, 140 insertions(+), 102 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs index 9249a3a51..2ea403ce3 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs @@ -245,6 +245,7 @@ namespace IRaCIS.Core.Application.ViewModel public bool IsUrgent { get; set; } + public string ReadingName { get; set; } public ReadingCategory ReadingCategory { get; set; } diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 04a9dd5c8..3942d912c 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -581,6 +581,7 @@ namespace IRaCIS.Core.Application.Image.QA } + /// /// 1、设置为不读片,2 设置为读片(取消 先前设置为不读片) 4 设置为删除(数据库记录软删除) 5 恢复为未删除 /// diff --git a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs index b58c89124..19a3645d8 100644 --- a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs +++ b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs @@ -195,6 +195,9 @@ namespace IRaCIS.Core.Application.Contracts } + + + [HttpDelete("{trialId:guid}/{trialQCQuestionConfigureId:guid}")] [Authorize(Policy = IRaCISPolicy.IQC)] public async Task DeleteTrialQCQuestionConfigure(Guid trialQCQuestionConfigureId, Guid trialId) diff --git a/IRaCIS.Core.Application/Service/Reading/Interface/IReadingClinicalDataService.cs b/IRaCIS.Core.Application/Service/Reading/Interface/IReadingClinicalDataService.cs index 84ff697f2..21d0a8d0b 100644 --- a/IRaCIS.Core.Application/Service/Reading/Interface/IReadingClinicalDataService.cs +++ b/IRaCIS.Core.Application/Service/Reading/Interface/IReadingClinicalDataService.cs @@ -18,5 +18,10 @@ namespace IRaCIS.Core.Application.Contracts Task ReadClinicalDataSign(ReadingClinicalDataSignIndto inDto); Task> GetClinicalDataList(GetReadingOrTaskClinicalDataListInDto inDto); + + + Task<(List, object)> GetReadingClinicalDataList(GetReadingClinicalDataListIndto inDto); + + Task> GetReadingClinicalList(GetReadingClinicalDataListIndto inDto); } } \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Reading/Interface/IReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/Interface/IReadingImageTaskService.cs index 01a1436e8..46f834617 100644 --- a/IRaCIS.Core.Application/Service/Reading/Interface/IReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/Interface/IReadingImageTaskService.cs @@ -21,5 +21,7 @@ namespace IRaCIS.Core.Application.Contracts Task SubmitGlobalReadingInfo(SubmitGlobalReadingInfoInDto inDto); Task SubmitOncologyReadingInfo(SubmitOncologyReadingInfoInDto inDto); + + Task AddOncologyTask(Guid oncologModuleId); } } \ No newline at end of file diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingClinicalDataService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingClinicalDataService.cs index 4561c2842..eb7592f6e 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingClinicalDataService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingClinicalDataService.cs @@ -32,6 +32,7 @@ namespace IRaCIS.Application.Services private readonly IRepository _previousHistoryRepository; private readonly IRepository _previousOtherRepository; private readonly IRepository _previousSurgeryRepository; + private readonly IReadingImageTaskService readingImageTaskService; private readonly IRepository _subjectRepository; private readonly IRepository _readModuleRepository; private readonly IRepository _readingClinicalDataPDFRepository; @@ -43,6 +44,7 @@ namespace IRaCIS.Application.Services IRepository previousHistoryRepository, IRepository previousOtherRepository, IRepository previousSurgeryRepository, + IReadingImageTaskService readingImageTaskService, IRepository subjectRepository, IRepository readModuleRepository, IRepository readingClinicalDataPDFRepository, @@ -55,6 +57,7 @@ namespace IRaCIS.Application.Services this._previousHistoryRepository = previousHistoryRepository; this._previousOtherRepository = previousOtherRepository; this._previousSurgeryRepository = previousSurgeryRepository; + this.readingImageTaskService = readingImageTaskService; this._subjectRepository = subjectRepository; this._readModuleRepository = readModuleRepository; this._readingClinicalDataPDFRepository = readingClinicalDataPDFRepository; @@ -281,6 +284,11 @@ namespace IRaCIS.Application.Services var result = await _readingClinicalDataRepository.SaveChangesAsync(); + + var readingId = await _readingClinicalDataRepository.Where(x => x.Id == inDto.ReadingClinicalDataId).Select(x => x.ReadingId).FirstOrDefaultAsync(); + + await readingImageTaskService.AddOncologyTask(readingId); + return ResponseOutput.Result(result); } @@ -396,31 +404,10 @@ namespace IRaCIS.Application.Services inDto.UploadRole = UploadRole.CRC; } var isBaseLine = await _subjectVisitRepository.AnyAsync(x => x.Id == inDto.ReadingId && x.IsBaseLine); - var resultQuery = _readingClinicalDataRepository.Where(x => x.SubjectId == inDto.SubjectId) - .Where(x => x.ReadingId == inDto.ReadingId) - .WhereIf(inDto.UploadRole == UploadRole.CRC, x => x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC) - .Select(x => new GetReadingClinicalDataListOutDto() - { - ClinicalDataLevel = x.ClinicalDataTrialSet.ClinicalDataLevel, - SubjectId = x.SubjectId, - ClinicalDataSetName = x.ClinicalDataTrialSet.ClinicalDataSetName, - ClinicalDataTrialSetId = x.ClinicalDataTrialSetId, - IsSign = x.IsSign, - ClinicalUploadType = x.ClinicalDataTrialSet.ClinicalUploadType, - Id = x.Id, - UploadRole = x.ClinicalDataTrialSet.UploadRole, - IsCRCUpload = x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC, - FileList = x.ReadingClinicalDataPDFList.Select(y => new GetFileDto() - { - Id = y.Id, - FileName = y.FileName, - Path = y.Path, - CreateTime = y.CreateTime, - }).ToList() - }); + - var result = await resultQuery.ToListAsync(); - result = result.Where(x => !(x.UploadRole == UploadRole.CRC && x.ClinicalUploadType == ClinicalUploadType.PDF && x.FileList.Count() == 0)).ToList(); + var result =await this.GetReadingClinicalList(inDto); + var previousHistoryList = await _previousHistoryRepository.Where(x => x.SubjectVisitId == inDto.ReadingId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); var previousOtherList = await _previousOtherRepository.Where(x => x.SubjectVisitId == inDto.ReadingId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); @@ -441,6 +428,40 @@ namespace IRaCIS.Application.Services }) ; } + /// + /// 获取临床数据集合 + /// + /// + [NonDynamicMethod] + public async Task> GetReadingClinicalList(GetReadingClinicalDataListIndto inDto) + { + var resultQuery = _readingClinicalDataRepository.Where(x => x.SubjectId == inDto.SubjectId) + .Where(x => x.ReadingId == inDto.ReadingId) + .WhereIf(inDto.UploadRole == UploadRole.CRC, x => x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC) + .Select(x => new GetReadingClinicalDataListOutDto() + { + ClinicalDataLevel = x.ClinicalDataTrialSet.ClinicalDataLevel, + SubjectId = x.SubjectId, + ClinicalDataSetName = x.ClinicalDataTrialSet.ClinicalDataSetName, + ClinicalDataTrialSetId = x.ClinicalDataTrialSetId, + IsSign = x.IsSign, + ClinicalUploadType = x.ClinicalDataTrialSet.ClinicalUploadType, + Id = x.Id, + UploadRole = x.ClinicalDataTrialSet.UploadRole, + IsCRCUpload = x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC, + FileList = x.ReadingClinicalDataPDFList.Select(y => new GetFileDto() + { + Id = y.Id, + FileName = y.FileName, + Path = y.Path, + CreateTime = y.CreateTime, + }).ToList() + }); + + var result = await resultQuery.ToListAsync(); + result = result.Where(x => !(x.UploadRole == UploadRole.CRC && x.ClinicalUploadType == ClinicalUploadType.PDF && x.FileList.Count() == 0)).ToList(); + return result; + } /// /// 获取单个阅片临床数据的所有文件 diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs index 578021f9e..43935698f 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs @@ -53,6 +53,7 @@ namespace IRaCIS.Application.Services IRepository visitTaskRepository, IRepository TrialRepository, IRepository ReadingOncologyTaskInfoRepository, + IVisitTaskHelpeService visitTaskHelpeService, IVisitTaskService visitTaskService, IReadingClinicalDataService readingClinicalDataService, @@ -1214,28 +1215,9 @@ namespace IRaCIS.Application.Services var visitId = await _readModuleRepository.Where(x => x.Id == taskInfo.SouceReadModuleId).Select(x => x.SubjectVisitId).FirstOrDefaultAsync(); - // 肿瘤学信息 - List needReadList = await _readModuleRepository.Where(x => x.SubjectVisitId == visitId && x.ModuleType == ModuleTypeEnum.Oncology) - .Select(x => new ReadingGenerataTaskDTO - { - IsUrgent = x.IsUrgent ?? false, - SubjectId = x.SubjectId, - ReadingName = x.ModuleName, - VisitNum = x.VisitNum, - ReadModuleId = x.Id, - ReadingCategory = ReadingCategory.Oncology, - }).ToListAsync(); - - await _visitTaskHelpeService.AddTaskAsync(new GenerateTaskCommand() - { - - ReadingCategory = GenerateTaskCategory.Oncology, - TrialId = taskInfo.TrialId, - ReadingGenerataTaskList = needReadList - }); - - + var oncologModuleId = await _readModuleRepository.Where(x => x.SubjectVisitId == visitId && x.ModuleType == ModuleTypeEnum.Oncology).Select(x => x.Id).FirstOrDefaultAsync(); + await AddOncologyTask(oncologModuleId); } @@ -1384,34 +1366,8 @@ namespace IRaCIS.Application.Services // 肿瘤学 case ReadingCategory.Global: var subjectVisitId = await _readModuleRepository.Where(x => x.Id == taskInfo.SouceReadModuleId).Select(x => x.SubjectVisitId).FirstOrDefaultAsync(); - needReadList=await _readModuleRepository.Where(x => x.SubjectVisitId == subjectVisitId && x.ModuleType==ModuleTypeEnum.Oncology) - .Select(x => new ReadingGenerataTaskDTO - { - IsUrgent = x.IsUrgent ?? false, - SubjectId = x.SubjectId, - ReadingName = x.ModuleName, - VisitNum = x.VisitNum, - ReadModuleId = x.Id, - ReadingCategory = typeChangeDic[x.ModuleType], - }).ToListAsync(); - - var readingType=await _trialRepository.Where(x => x.Id == taskInfo.TrialId).Select(x => x.ReadingType).FirstOrDefaultAsync(); - - if (taskInfo.JudgeVisitTaskId == null&&(await _visitTaskRepository.Where(x=>x.TaskState==TaskState.Effect&&x.ReadingCategory==ReadingCategory.Global - &&x.ReadingTaskState==ReadingTaskState.HaveSigned - ).CountAsync()== (int)readingType)) - { - // 有裁判要等裁判完成之后才进行添加 - await _visitTaskHelpeService.AddTaskAsync(new GenerateTaskCommand() - { - - ReadingCategory = GenerateTaskCategory.Oncology, - TrialId = taskInfo.TrialId, - ReadingGenerataTaskList = needReadList - }); - } - //needReadList = needReadList.Where(x => _visitTaskRepository.Where(y => y.SouceReadModuleId == x.ReadModuleId).Count() == 0).ToList(); - + var oncologyReadId= await _readModuleRepository.Where(x => x.SubjectVisitId == subjectVisitId && x.ModuleType == ModuleTypeEnum.Oncology).Select(x => x.Id).FirstOrDefaultAsync(); + await AddOncologyTask(oncologyReadId); break; } } @@ -1423,39 +1379,88 @@ namespace IRaCIS.Application.Services } /// - /// 添加肿瘤学阅片任务 + /// 添加肿瘤学阅片任务 其实这里无非是要判断临床数据是否签名 但是对于添加新的阅片期 其实没有临床数据 可以走之前的逻辑 /// /// - //public async Task AddOncologyTask(Guid readModuleId) - //{ - // var readModuleInfo=await _readModuleRepository.Where(x=>x.Id==readModuleId&& x.ModuleType == ModuleTypeEnum.Oncology).Select(x => new ReadingGenerataTaskDTO - // { - // IsUrgent = x.IsUrgent ?? false, - // SubjectId = x.SubjectId, - // ReadingName = x.ModuleName, - // VisitNum = x.VisitNum, - // ReadModuleId = x.Id, - // ReadingCategory = ReadingCategory.Oncology, - // }).ToListAsync(); + [NonDynamicMethod] + public async Task AddOncologyTask(Guid oncologModuleId) + { - // // 如果当前是肿瘤学 - // if (readModuleInfo.Count != 0) - // { - // if (taskInfo.JudgeVisitTaskId == null && (await _visitTaskRepository.Where(x => x.TaskState == TaskState.Effect && x.ReadingCategory == ReadingCategory.Global - // && x.ReadingTaskState == ReadingTaskState.HaveSigned - // ).CountAsync() == (int)readingType)) - // { - // // 有裁判要等裁判完成之后才进行添加 - // await _visitTaskHelpeService.AddTaskAsync(new GenerateTaskCommand() - // { + // 判断是否读片完成 + var finishReading = false; - // ReadingCategory = GenerateTaskCategory.Oncology, - // TrialId = taskInfo.TrialId, - // ReadingGenerataTaskList = needReadList - // }); - // } - // } - //} + + var readModuleInfo = await _readModuleRepository.Where(x => x.Id == oncologModuleId && x.ModuleType == ModuleTypeEnum.Oncology).FirstOrDefaultAsync(); + + + + // 如果当前是肿瘤学 + if (readModuleInfo != null) + { + // 先找到对应的全局阅片模块Id + var globalreadModuleId = await _readModuleRepository.Where(x => x.SubjectVisitId == readModuleInfo.SubjectVisitId && x.ModuleType == ModuleTypeEnum.Global).Select(x => x.Id).FirstOrDefaultAsync(); + + // 找到一个全局阅片任务是否有裁判任务 + + var judgeVisitTaskId = await _visitTaskRepository.Where(x => x.SouceReadModuleId == globalreadModuleId && x.TaskState == TaskState.Effect && x.ReadingCategory == ReadingCategory.Global + && x.ReadingTaskState == ReadingTaskState.HaveSigned).Select(x => x.JudgeVisitTaskId).FirstOrDefaultAsync(); + + // 获取系统配置 + var readingType = await _trialRepository.Where(x => x.Id == readModuleInfo.TrialId).Select(x => x.ReadingType).FirstOrDefaultAsync(); + + // 判断阅片是否完成 + if (judgeVisitTaskId == null && (await _visitTaskRepository.Where(x => x.SouceReadModuleId == globalreadModuleId && x.TaskState == TaskState.Effect && x.ReadingCategory == ReadingCategory.Global + && x.ReadingTaskState == ReadingTaskState.HaveSigned && !x.IsAnalysisCreate + ).CountAsync() == (int)readingType)) + { + finishReading = true; + } + else if(judgeVisitTaskId!=null&& (await _visitTaskRepository.AnyAsync(x=>x.Id== judgeVisitTaskId.Value&&x.ReadingTaskState== ReadingTaskState.HaveSigned))) + { + finishReading = true; + } + + if (finishReading) + { + // 获取临床数据 + var clinicalData = await _readingClinicalDataService.GetReadingClinicalList(new GetReadingClinicalDataListIndto() + { + SubjectId = readModuleInfo.SubjectId, + ReadingId = readModuleInfo.Id, + TrialId = readModuleInfo.TrialId, + + }); + + // 判断是否临床数据都已经签名 + if (!clinicalData.Any(x => !x.IsSign)) + { + + List needReadList = new List(); + + needReadList.Add(new ReadingGenerataTaskDTO() + { + IsUrgent = readModuleInfo.IsUrgent ?? false, + SubjectId = readModuleInfo.SubjectId, + ReadingName = readModuleInfo.ModuleName, + VisitNum = readModuleInfo.VisitNum, + ReadModuleId = readModuleInfo.Id, + ReadingCategory = ReadingCategory.Oncology, + }); + + await _visitTaskHelpeService.AddTaskAsync(new GenerateTaskCommand() + { + + ReadingCategory = GenerateTaskCategory.Oncology, + TrialId = readModuleInfo.TrialId, + ReadingGenerataTaskList = needReadList + }); + } + } + + + + } + } ///