From f5cef1fa7a3496dcfadb7b784e900561d95c6544 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 15 Jul 2022 09:40:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=BB=E5=8A=A1=E7=94=9F?= =?UTF-8?q?=E6=88=90=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Allocation/VisitTaskHelpeService.cs | 191 +++++-- .../Service/Allocation/VisitTaskService.cs | 488 ++++++++++-------- IRaCIS.Core.Application/TestService.cs | 41 +- 3 files changed, 467 insertions(+), 253 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index 575d76100..970a61473 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -151,6 +151,7 @@ namespace IRaCIS.Core.Application.Service if (allocateSubjectArmList.Count != 0) { #region 验证历史任务 + if (_taskAllocationRuleRepository.Where(t => t.TrialId == trialId && t.IsEnable && t.IsJudgeDoctor == false).Count() < 2) { throw new BusinessValidationFailedException("能参与读片的医生数量必须大于2,自动分配任务中止"); @@ -166,6 +167,7 @@ namespace IRaCIS.Core.Application.Service { throw new BusinessValidationFailedException("请确认是否改了配置,或者手动分配时,只分配了一个Arm "); } + #endregion @@ -184,6 +186,89 @@ namespace IRaCIS.Core.Application.Service task1.AllocateTime = DateTime.Now; task2.AllocateTime = DateTime.Now; + + + + #region 重阅/退回的时候,需要将取消分配的访视类型的 任务重新分配 + + + //后续未分配的访视 PM 有序退回 或者PM 有序 申请重阅 + + var notAllocateList = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.TaskState == TaskState.Effect && t.DoctorUserId == null + && t.VisitTaskNum > subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit, true).ToListAsync(); + + + foreach (var notAllocate in notAllocateList) + { + notAllocate.TaskAllocationState = TaskAllocationState.Allocated; + notAllocate.AllocateTime = DateTime.Now; + + notAllocate.DoctorUserId = notAllocate.ArmEnum == Arm.DoubleReadingArm1 ? task1.DoctorUserId : task2.DoctorUserId; + } + + //后续 废弃的任务 重阅重置,或者失效的 访视 需要重新生成 + + var needAddTaskList = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && (t.TaskState == TaskState.Adbandon || t.TaskState == TaskState.HaveReturned) && t.VisitTaskNum > subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit).ToListAsync(); + + //可能存在多次申请重阅 所以这里会有重复 + + foreach (var group in needAddTaskList.GroupBy(t => new { t.SubjectId, t.VisitTaskNum })) + { + var latestTask = group.OrderByDescending(t=>t.CreateTime).First(); + + var taskOne = await _visitTaskRepository.AddAsync(new VisitTask() + { + TrialId = trialId, + SubjectId = subjectVisit.SubjectId, + IsUrgent = subjectVisit.IsUrgent, + TaskBlindName = subjectVisit.BlindName, + TaskName = subjectVisit.VisitName, + VisitTaskNum = subjectVisit.VisitNum, + ArmEnum = Arm.DoubleReadingArm1,//特殊 + Code = currentMaxCodeInt + 1, + SourceSubjectVisitId = subjectVisit.Id, + TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), + ReadingCategory = ReadingCategory.Visit, + + IsAnalysisCreate= latestTask.IsAnalysisCreate, + IsSelfAnalysis= latestTask.IsSelfAnalysis, + TaskAllocationState=TaskAllocationState.Allocated, + AllocateTime=DateTime.Now, + DoctorUserId= task1.DoctorUserId + }); + + var taskTwo = await _visitTaskRepository.AddAsync(new VisitTask() + { + TrialId = trialId, + SubjectId = subjectVisit.SubjectId, + IsUrgent = subjectVisit.IsUrgent, + TaskBlindName = subjectVisit.BlindName, + TaskName = subjectVisit.VisitName, + VisitTaskNum = subjectVisit.VisitNum, + //CheckPassedTime = subjectVisit.CheckPassedTime, + ArmEnum = Arm.DoubleReadingArm2,//特殊 + Code = currentMaxCodeInt + 2, + SourceSubjectVisitId = subjectVisit.Id, + TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 2, nameof(VisitTask)), + ReadingCategory = ReadingCategory.Visit, + + IsAnalysisCreate = latestTask.IsAnalysisCreate, + IsSelfAnalysis = latestTask.IsSelfAnalysis, + TaskAllocationState = TaskAllocationState.Allocated, + AllocateTime = DateTime.Now, + DoctorUserId = task2.DoctorUserId + }); + + + + currentMaxCodeInt = currentMaxCodeInt + 2; + + _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30)); + } + + + #endregion + } else //后续访视不自动分配,或者配置的医生数量不足,就不进行分配 @@ -195,7 +280,7 @@ namespace IRaCIS.Core.Application.Service else // 当前任务没有分配医生,初次分配 { - return; + //return; } } @@ -205,30 +290,7 @@ namespace IRaCIS.Core.Application.Service #endregion - if (assignConfigList.Count>0) - { - #region 重阅/退回的时候,需要将之前取消分配的访视类型的 任务重新分配 - var arm1DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm1).DoctorUserId; - var arm2DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm2).DoctorUserId; - - await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.TaskState == TaskState.Effect && t.DoctorUserId == null - && t.VisitTaskNum > subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit && t.ArmEnum == Arm.DoubleReadingArm1, u => new VisitTask() - { - TaskAllocationState = TaskAllocationState.Allocated, - DoctorUserId = arm1DoctorUserId, - AllocateTime = DateTime.Now, - }); - - await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.TaskState == TaskState.Effect && t.DoctorUserId == null && t.VisitTaskNum > subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit && t.ArmEnum == Arm.DoubleReadingArm2, u => new VisitTask() - { - TaskAllocationState = TaskAllocationState.Allocated, - DoctorUserId = arm2DoctorUserId, - AllocateTime = DateTime.Now, - }); - - #endregion - } @@ -292,20 +354,81 @@ namespace IRaCIS.Core.Application.Service singleTask.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 0).DoctorUserId; + singleTask.AllocateTime = DateTime.Now; + + + + #region 重阅/退回的时候,需要将取消分配的访视类型的 任务重新分配 + + + //后续未分配的访视 PM 有序退回 或者PM 有序 申请重阅 + + var notAllocateList = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.TaskState == TaskState.Effect && t.DoctorUserId == null + && t.VisitTaskNum > subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit, true).ToListAsync(); + + + foreach (var notAllocate in notAllocateList) + { + + notAllocate.TaskAllocationState = TaskAllocationState.Allocated; + notAllocate.AllocateTime = DateTime.Now; + + notAllocate.DoctorUserId = singleTask.DoctorUserId; + } + + //后续 废弃的任务 重阅重置,或者失效的 访视 需要重新生成 + + var needAddTaskList = await _visitTaskRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && (t.TaskState == TaskState.Adbandon || t.TaskState == TaskState.HaveReturned) && t.VisitTaskNum > subjectVisit.VisitNum && t.ReadingCategory == ReadingCategory.Visit).ToListAsync(); + + //可能存在多次申请重阅 所以这里会有重复 + + foreach (var group in needAddTaskList.GroupBy(t => new { t.SubjectId, t.VisitTaskNum })) + { + var latestTask = group.OrderByDescending(t => t.CreateTime).First(); + + var taskOne = await _visitTaskRepository.AddAsync(new VisitTask() + { + TrialId = trialId, + SubjectId = subjectVisit.SubjectId, + IsUrgent = subjectVisit.IsUrgent, + TaskBlindName = subjectVisit.BlindName, + TaskName = subjectVisit.VisitName, + VisitTaskNum = subjectVisit.VisitNum, + ArmEnum = Arm.DoubleReadingArm1,//特殊 + Code = currentMaxCodeInt + 1, + SourceSubjectVisitId = subjectVisit.Id, + TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), + ReadingCategory = ReadingCategory.Visit, + + IsAnalysisCreate = latestTask.IsAnalysisCreate, + IsSelfAnalysis = latestTask.IsSelfAnalysis, + TaskAllocationState = TaskAllocationState.Allocated, + AllocateTime = DateTime.Now, + DoctorUserId = singleTask.DoctorUserId + }); + + + currentMaxCodeInt = currentMaxCodeInt + 1; + + _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30)); + } + + + #endregion } } - - } else { //后续Subect 不自动分配 不处理 - return; } + + + + } - singleTask.AllocateTime = DateTime.Now; } #endregion @@ -398,8 +521,6 @@ namespace IRaCIS.Core.Application.Service VisitTaskNum = task.VisitTaskNum, ReadingCategory = task.ReadingCategory, - IsAnalysisCreate = true, - //TaskConsistentRuleId=task.TaskConsistentRuleId, TaskState = TaskState.Effect, Code = currentMaxCodeInt + 1, TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), @@ -411,7 +532,7 @@ namespace IRaCIS.Core.Application.Service BlindTrialSiteCode = task.BlindTrialSiteCode, BlindSubjectCode = task.BlindSubjectCode, ConsistentAnalysisOriginalTaskId = task.Id, - + IsAnalysisCreate = true, IsSelfAnalysis = true, }; @@ -440,7 +561,6 @@ namespace IRaCIS.Core.Application.Service VisitTaskNum = task.VisitTaskNum, ReadingCategory = task.ReadingCategory, - IsAnalysisCreate = true, TaskState = TaskState.Effect, Code = currentMaxCodeInt + 1, TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), @@ -450,7 +570,7 @@ namespace IRaCIS.Core.Application.Service AllocateTime = DateTime.Now, - + IsAnalysisCreate = true, IsSelfAnalysis = false, }; @@ -487,6 +607,11 @@ namespace IRaCIS.Core.Application.Service DoctorUserId = subjectUser == null ? null : subjectUser.Id, TaskAllocationState = subjectUser == null ? TaskAllocationState.NotAllocate : TaskAllocationState.Allocated, AllocateTime = subjectUser == null ? null : DateTime.Now, + + BlindTrialSiteCode = firstTask.BlindTrialSiteCode, + BlindSubjectCode = firstTask.BlindSubjectCode, + IsAnalysisCreate = firstTask.IsAnalysisCreate, + IsSelfAnalysis = firstTask.IsSelfAnalysis, }; await _visitTaskRepository.AddAsync(visitTask); currentMaxCodeInt = currentMaxCodeInt + 1; diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index f6723847c..11d40a448 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -1039,7 +1039,6 @@ namespace IRaCIS.Core.Application.Service public async Task ConfirmReReading(ConfirmReReadingCommand agreeReReadingCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService) { - throw new BusinessValidationFailedException("正在更新开发ing,不允许操作"); var trialId = agreeReReadingCommand.TrialId; @@ -1065,17 +1064,244 @@ namespace IRaCIS.Core.Application.Service if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree) { - //裁判任务 同意重阅 - if (origenalTask.ReadingCategory == ReadingCategory.Judge) + #region 废弃 + ////裁判任务 同意重阅 + //if (origenalTask.ReadingCategory == ReadingCategory.Judge) + //{ + + // //项目组 SPM同意 IR PM同意 + // if ((visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM) || + // (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + // ) + // { + + // //产生的新任务 + // await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() + // { + // TrialId = trialId, + + // ReadingCategory = GenerateTaskCategory.ReReading, + + // ReReadingTask = origenalTask, + + // //同步才可以 + // Action = (newTask) => + // { + // //申请表 设置新任务Id + // visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; + + // //生成的任务分配给原始医生 + // newTask.DoctorUserId = origenalTask.DoctorUserId; + // newTask.TaskAllocationState = TaskAllocationState.Allocated; + // newTask.AllocateTime = DateTime.Now; + + // } + // }); + // } + + //} + ////访视任务 同意重阅 + //else + #endregion + + //PM申请 SPM / CPM审批 回退访视,在此不生成访视任务 + if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM)) { - //项目组 SPM同意 IR PM同意 - if ((visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM) || - (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) - ) + //有序阅片 + if (trialConfig.IsReadingTaskViewInOrder) + { + Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && t.TaskState == TaskState.Effect; + + //是否是一致性分析任务 + filterExpression = filterExpression.And(t => t.IsAnalysisCreate == origenalTask.IsAnalysisCreate); + + //访视影响当前以及当前之后的 两个阅片人的 + filterExpression = filterExpression.And(t => (t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId) || (t.VisitTaskNum >= origenalTask.VisitTaskNum && t.DoctorUserId != origenalTask.DoctorUserId)); + + + #region 影响的任务(排除申请的任务) + + var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync(); + + foreach (var influenceTask in influenceTaskList) + { + if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + influenceTask.TaskState = TaskState.HaveReturned; + } + else + { + influenceTask.TaskState = TaskState.Adbandon; + } + + } + + #endregion + + + } + //无序阅片 + else + { + //阅片任务产生了裁判 + if (origenalTask.JudgeVisitTaskId != null) + { + + //裁判任务是否已阅片完成 + var judgeTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == origenalTask.JudgeVisitTaskId); + + if (judgeTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + judgeTask.TaskState = TaskState.HaveReturned; + } + //裁判任务未完 + else + { + judgeTask.TaskState = TaskState.Adbandon; + } + + } + + //不管是否触发裁判 阅片任务退回,待影像重传后重新分 配给原阅片人 + + if (trialConfig.ReadingType == ReadingMethod.Double) + { + //考虑该访视 另外一个阅片人的任务也同时退回 + + var otherTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.SourceSubjectVisitId == origenalTask.SourceSubjectVisitId && t.Id != origenalTask.Id && t.TaskState == TaskState.Effect); + + if (otherTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + otherTask.TaskState = TaskState.HaveReturned; + } + else + { + otherTask.TaskState = TaskState.Adbandon; + } + + } + + // 无序阅片没有 全局 肿瘤学 + + } + + // 不管有序 无序 都会 回退访视 + if (origenalTask.ReadingCategory == ReadingCategory.Visit) + { + //执行类似一致性核查回退流程 + await VisitBackAsync(origenalTask.SourceSubjectVisitId); + } + + } + //IR申请 PM 审批 注意这里有一致性分析的申请同意 不会回退访视,在此要生成影响的访视任务 + else if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + { + + + //有序阅片 + if (trialConfig.IsReadingTaskViewInOrder) { - //产生的新任务 + #region 有序 IR 申请 重阅 影响的其他访视查询 + + Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && t.TaskState == TaskState.Effect; + + //是否是一致性分析任务 + filterExpression = filterExpression.And(t => t.IsAnalysisCreate == origenalTask.IsAnalysisCreate); + + switch (origenalTask.ReadingCategory) + { + case ReadingCategory.Visit: + //影响后续访视已经读完的,未读的不做处理 以及其他类型任务 + + filterExpression = filterExpression.And(t => t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && + ((t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit) || + t.ReadingCategory == ReadingCategory.Global || + t.ReadingCategory == ReadingCategory.Oncology || + t.ReadingCategory == ReadingCategory.Judge) + ); + break; + + case ReadingCategory.Global: + + //全局不影响后续访视任务 + filterExpression = filterExpression.And(t => t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && + ( + t.ReadingCategory == ReadingCategory.Global || + t.ReadingCategory == ReadingCategory.Oncology || + t.ReadingCategory == ReadingCategory.Judge) + ); + break; + + case ReadingCategory.Oncology: + + //仅仅影响自己 后续任务如果是访视任务、全局任务或裁判任务,均不处理 + filterExpression = filterExpression.And(t => /*t.Id == origenalTask.Id*/ t.Id == Guid.Empty); + break; + + case ReadingCategory.Judge: + + //裁判的影响自己 和后续肿瘤学阅片 + filterExpression = filterExpression.And(t => /*(t.Id == origenalTask.Id) ||*/ (t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && t.ReadingCategory == ReadingCategory.Oncology)); + + break; + + + default: + throw new BusinessValidationFailedException("不支持重阅的任务类型"); + + } + #endregion + + #region 这里时影响其他的任务 不包括申请的任务 申请的任务,在上面会统一处理 + + var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync(); + + foreach (var influenceTask in influenceTaskList) + { + if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + influenceTask.TaskState = TaskState.HaveReturned; + } + else + { + influenceTask.TaskState = TaskState.Adbandon; + } + + //影响其他的任务 如果是访视类型 需要重新生成 + if (influenceTask.ReadingCategory == ReadingCategory.Visit) + { + + await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() + { + TrialId = trialId, + + ReadingCategory = GenerateTaskCategory.ReReading, + + ReReadingTask = origenalTask, + + //同步才可以 + Action = (newTask) => + { + //申请表 设置新任务Id + visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; + + //生成的任务分配给原始医生 + newTask.DoctorUserId = origenalTask.DoctorUserId; + newTask.TaskAllocationState = TaskAllocationState.Allocated; + newTask.AllocateTime = DateTime.Now; + + } + }); + } + } + + #endregion + + #region 申请任务 重新生成 + + //申请的任务 重新生成 await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() { TrialId = trialId, @@ -1087,10 +1313,59 @@ namespace IRaCIS.Core.Application.Service //同步才可以 Action = (newTask) => { - //申请表 设置新任务Id + //申请表 设置新任务Id visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; - //生成的任务分配给原始医生 + //生成的任务分配给原始医生 + newTask.DoctorUserId = origenalTask.DoctorUserId; + newTask.TaskAllocationState = TaskAllocationState.Allocated; + newTask.AllocateTime = DateTime.Now; + + } + }); + + #endregion + + + } + //无序阅片 只会申请访视类型和裁判类型的任务 注意这里有一致性分析的申请同意 + else + { + //访视任务产生了裁判 + if (origenalTask.ReadingCategory == ReadingCategory.Visit && origenalTask.JudgeVisitTaskId != null) + { + + //裁判任务是否已阅片完成 + var judgeTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == origenalTask.JudgeVisitTaskId); + + if (judgeTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + judgeTask.TaskState = TaskState.HaveReturned; + } + //裁判任务未完 + else + { + judgeTask.TaskState = TaskState.Adbandon; + } + + } + + // 不管是访视还是裁判 都会立马产生的新任务并分配出去 + await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() + { + TrialId = trialId, + + ReadingCategory = GenerateTaskCategory.ReReading, + + ReReadingTask = origenalTask, + + //同步才可以 + Action = (newTask) => + { + //申请表 设置新任务Id + visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; + + //生成的任务分配给原始医生 newTask.DoctorUserId = origenalTask.DoctorUserId; newTask.TaskAllocationState = TaskAllocationState.Allocated; newTask.AllocateTime = DateTime.Now; @@ -1098,201 +1373,12 @@ namespace IRaCIS.Core.Application.Service } }); } - } - //访视任务 同意重阅 else { - //PM申请 SPM / CPM审批 - if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM)) - { - - //有序阅片 - if (trialConfig.IsReadingTaskViewInOrder) - { - - } - //无序阅片 - else - { - //阅片任务产生了裁判 - if (origenalTask.JudgeVisitTaskId != null) - { - - //裁判任务是否已阅片完成 - var judgeTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == origenalTask.JudgeVisitTaskId); - - if (judgeTask.ReadingTaskState == ReadingTaskState.HaveSigned) - { - judgeTask.TaskState = TaskState.HaveReturned; - } - //裁判任务未完 - else - { - judgeTask.TaskState = TaskState.Adbandon; - } - - } - - //不管是否触发裁判 阅片任务退回,待影像重传后重新分 配给原阅片人 - - if (trialConfig.ReadingType == ReadingMethod.Double) - { - //考虑该访视 另外一个阅片人的任务也同时退回 - - var otherTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.SourceSubjectVisitId == origenalTask.SourceSubjectVisitId && t.Id != origenalTask.Id && t.TaskState == TaskState.Effect); - - if (otherTask.ReadingTaskState == ReadingTaskState.HaveSigned) - { - otherTask.TaskState = TaskState.HaveReturned; - } - else - { - otherTask.TaskState = TaskState.Adbandon; - } - - } - - //回退访视 - - if (origenalTask.ReadingCategory == ReadingCategory.Visit) - { - //执行类似一致性核查回退流程 - await VisitBackAsync(origenalTask.SourceSubjectVisitId); - } - // 无序阅片没有 全局 肿瘤学 - - - } - } - //IR申请 PM 审批 注意这里有一致性分析的申请同意 - else if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) - { - - - //有序阅片 - if (trialConfig.IsReadingTaskViewInOrder) - { - Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && t.TaskState == TaskState.Effect; - - //是否是一致性分析任务 - filterExpression = filterExpression.And(t => t.IsAnalysisCreate == origenalTask.IsAnalysisCreate); - - switch (origenalTask.ReadingCategory) - { - case ReadingCategory.Visit: - //影响后续访视已经读完的,未读的不做处理 以及其他类型任务 - - filterExpression = filterExpression.And(t => t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && - ((t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit) || - t.ReadingCategory == ReadingCategory.Global || - t.ReadingCategory == ReadingCategory.Oncology || - t.ReadingCategory == ReadingCategory.Judge) - ); - break; - - case ReadingCategory.Global: - - //全局不影响后续访视任务 - filterExpression = filterExpression.And(t => t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && - ( - t.ReadingCategory == ReadingCategory.Global || - t.ReadingCategory == ReadingCategory.Oncology || - t.ReadingCategory == ReadingCategory.Judge) - ); - break; - - case ReadingCategory.Oncology: - - //仅仅影响自己 后续任务如果是访视任务、全局任务或裁判任务,均不处理 - filterExpression = filterExpression.And(t => /*t.Id == origenalTask.Id*/ t.Id == Guid.Empty); - break; - - case ReadingCategory.Judge: - - - //裁判的影响自己 和后续肿瘤学阅片 - filterExpression = filterExpression.And(t => /*(t.Id == origenalTask.Id) ||*/ (t.VisitTaskNum > origenalTask.VisitTaskNum && t.DoctorUserId == origenalTask.DoctorUserId && t.ReadingCategory == ReadingCategory.Oncology)); - - break; - - - default: - throw new BusinessValidationFailedException("不支持重阅的任务类型"); - - } - - - - var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync(); - - foreach (var influenceTask in influenceTaskList) - { - if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned) - { - influenceTask.TaskState = TaskState.HaveReturned; - } - else - { - influenceTask.TaskState = TaskState.Adbandon; - } - } - - - - } - //无序阅片 只会申请访视类型和裁判类型的任务 注意这里有一致性分析的申请同意 - else - { - //访视任务产生了裁判 - if (origenalTask.ReadingCategory == ReadingCategory.Visit && origenalTask.JudgeVisitTaskId != null) - { - - //裁判任务是否已阅片完成 - var judgeTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == origenalTask.JudgeVisitTaskId); - - if (judgeTask.ReadingTaskState == ReadingTaskState.HaveSigned) - { - judgeTask.TaskState = TaskState.HaveReturned; - } - //裁判任务未完 - else - { - judgeTask.TaskState = TaskState.Adbandon; - } - - } - - // 不管是访视还是裁判 都会立马产生的新任务并分配出去 - await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() - { - TrialId = trialId, - - ReadingCategory = GenerateTaskCategory.ReReading, - - ReReadingTask = origenalTask, - - //同步才可以 - Action = (newTask) => - { - //申请表 设置新任务Id - visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; - - //生成的任务分配给原始医生 - newTask.DoctorUserId = origenalTask.DoctorUserId; - newTask.TaskAllocationState = TaskAllocationState.Allocated; - newTask.AllocateTime = DateTime.Now; - - } - }); - } - } - else - { - throw new BusinessValidationFailedException("不符合 PM申请 SPM / CPM审批 | IR申请 PM 审批 "); - } - + throw new BusinessValidationFailedException("不符合 PM申请 SPM / CPM审批 | IR申请 PM 审批 "); } + } diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index ea54d4b3d..1dc59989b 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -22,28 +22,31 @@ namespace IRaCIS.Application.Services public async Task Get() { - var subject1 = Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391693"); - var subject2 = Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391694"); + //var subject1 = Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391693"); + //var subject2 = Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391694"); - var subjectList = new List() { Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391693") , - Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391694") , - Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391695") - }; + // var subjectList = new List() { Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391693") , + // Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391694") , + // Guid.Parse("431D0C58-ABC5-4166-B9BC-08DA0E391695") + // }; - string[] citys = new string[] { "广州", "深圳", "上海", "北京" }; - foreach (var item in subjectList) - { - Console.WriteLine(await BNRFactory.Default.Create($"[CN:{item}][N:[CN:{item}]/0000000]")); - } - foreach (var item in subjectList) - { - Console.WriteLine(await BNRFactory.Default.Create($"[N:[CN:{item}]/0000000]")); - } + //string[] citys = new string[] { "广州", "深圳", "上海", "北京" }; + //foreach (var item in subjectList) + //{ + // Console.WriteLine(await BNRFactory.Default.Create($"[CN:{item}][N:[CN:{item}]/0000000]")); + //} + //foreach (var item in subjectList) + //{ + // Console.WriteLine(await BNRFactory.Default.Create($"[N:[CN:{item}]/0000000]")); + //} + + //foreach (var item in subjectList) + //{ + // Console.WriteLine(await BNRFactory.Default.Create($"[CN:{item}][redis:city/0000000]")); + //} + + var needAddVisitList = await _repository.Where(t => t.TrialId == Guid.Empty).DistinctBy(t => t.VisitTaskNum).ToListAsync(); - foreach (var item in subjectList) - { - Console.WriteLine(await BNRFactory.Default.Create($"[CN:{item}][redis:city/0000000]")); - } return _userInfo.LocalIp; }