From ac220ab4953e0ce4f8ba6208d38d967a72588f77 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 15 Jul 2022 15:23:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Allocation/TaskAllocationRuleService.cs | 5 ++-- .../Service/Allocation/VisitTaskService.cs | 29 ++++++++++++++----- .../SubjectVisitCheckPassedTrigger.cs | 2 ++ IRaCIS.Core.Domain/Visit/SubjectVisit.cs | 2 ++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs index 68725a224..81d3865c7 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.Contracts; +using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.Application.Service { @@ -65,7 +66,7 @@ namespace IRaCIS.Core.Application.Service { var verifyExp1 = new EntityVerifyExp() { - VerifyExp = t => t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId && t.TrialId== addOrEditTaskAllocationRule.TrialId && t.IsJudgeDoctor, + VerifyExp = t => t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId && t.TrialId== addOrEditTaskAllocationRule.TrialId && t.IsJudgeDoctor==addOrEditTaskAllocationRule.IsJudgeDoctor, VerifyMsg = "已有该医生配置,不允许继续增加" }; @@ -99,7 +100,7 @@ namespace IRaCIS.Core.Application.Service [HttpGet("{trialId:guid}")] public async Task> GetDoctorUserSelectList(Guid trialId,[FromServices] IRepository _enrollRepository) { - var query = from enroll in _enrollRepository.Where(t => t.TrialId == trialId) + var query = from enroll in _enrollRepository.Where(t => t.TrialId == trialId && t.EnrollStatus >= (int)EnrollStatus.ConfirmIntoGroup) join user in _userRepository.AsQueryable() on enroll.DoctorId equals user.DoctorId select new TrialDoctorUserSelectView() { diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 7fd62db99..fe0fd27ff 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -107,7 +107,7 @@ namespace IRaCIS.Core.Application.Service await _visitTaskCommonService.GenerateVisitTaskAsync(queryVisitTask.TrialId, svIdList); - var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == queryVisitTask.TrialId && t.IsAnalysisCreate==false) + var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == queryVisitTask.TrialId && t.IsAnalysisCreate == false) .WhereIf(queryVisitTask.ReadingCategory != null, t => t.ReadingCategory == queryVisitTask.ReadingCategory) .WhereIf(queryVisitTask.ReadingCategory == null, t => t.ReadingCategory != ReadingCategory.Judge) @@ -667,6 +667,8 @@ namespace IRaCIS.Core.Application.Service var subjectList = _subjectRepository.Where(t => t.TrialId == trialId) .WhereIf(isJudge == false, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum != Arm.JudgeArm).Any()) .WhereIf(isJudge, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum == Arm.JudgeArm).Any()) + //过滤掉 那些回退的subject + .Where(t=>! t.SubjectVisitList.Any(t=>t.IsPMBackOrReReading)) .Select(t => new { SubjectId = t.Id, @@ -894,6 +896,11 @@ namespace IRaCIS.Core.Application.Service throw new BusinessValidationFailedException("出现脏数据 任务来源字段没有值"); } + //PM 回退了 但是还没生成任务 + if( await _subjectVisitRepository.AnyAsync(t=>t.SubjectId== visitTask.SubjectId && t.IsPMBackOrReReading)) + { + return ResponseOutput.NotOk("该受试者有访视进入了退回流程,还未经过一致性核查通过,不允许分配"); + } visitTask.AllocateTime = DateTime.Now; @@ -1287,10 +1294,10 @@ 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; @@ -1316,10 +1323,10 @@ 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; @@ -1365,10 +1372,10 @@ 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; @@ -1406,6 +1413,11 @@ namespace IRaCIS.Core.Application.Service var task = (await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == taskId)).IfNullThrowException(); + if (task.TaskState != TaskState.Effect) + { + return ResponseOutput.NotOk("仅仅允许针对生效的任务进行退回操作,请刷新页面数据"); + } + //申请的任务 肯定是未完成阅片的 并且是访视类型的 if (task.ReadingCategory != ReadingCategory.Visit || task.ReadingTaskState == ReadingTaskState.HaveSigned) { @@ -1473,6 +1485,7 @@ namespace IRaCIS.Core.Application.Service influenceTask.DoctorUserId = null; influenceTask.AllocateTime = null; + influenceTask.SuggesteFinishedTime = null; influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate; break; @@ -1521,6 +1534,7 @@ namespace IRaCIS.Core.Application.Service influenceTask.DoctorUserId = null; influenceTask.AllocateTime = null; + influenceTask.SuggesteFinishedTime = null; influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate; break; @@ -1564,6 +1578,7 @@ namespace IRaCIS.Core.Application.Service //需要重新产生任务 sv.IsVisitTaskGenerated = false; + sv.IsPMBackOrReReading = true; sv.AuditState = AuditStateEnum.None; sv.SubmitState = SubmitStateEnum.ToSubmit; diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs index 40062ae3c..5c7a110a2 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitCheckPassedTrigger.cs @@ -231,6 +231,8 @@ namespace IRaCIS.Core.Application.Triggers #endregion + context.Entity.IsPMBackOrReReading = false; + await _visitTaskHelpeService.GenerateVisitTaskAsync(subjectVisit.TrialId, new List() { subjectVisit.Id }, true); } diff --git a/IRaCIS.Core.Domain/Visit/SubjectVisit.cs b/IRaCIS.Core.Domain/Visit/SubjectVisit.cs index 1e7ae54de..69d9eb2c0 100644 --- a/IRaCIS.Core.Domain/Visit/SubjectVisit.cs +++ b/IRaCIS.Core.Domain/Visit/SubjectVisit.cs @@ -157,6 +157,8 @@ namespace IRaCIS.Core.Domain.Models public bool IsVisitTaskGenerated { get; set; } + public bool IsPMBackOrReReading { get; set; } + /// /// 关闭一致性质疑原因 ///