From c352be0eafaff7b06225db4c489ccf8c54849373 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 26 Jul 2022 15:53:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 14 +- .../DTO/TaskAllocationRuleViewModel.cs | 3 +- .../Allocation/TaskAllocationRuleService.cs | 14 +- .../Service/Allocation/VisitTaskService.cs | 168 +++++++++--------- 4 files changed, 103 insertions(+), 96 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 826fc1936..debfad6b2 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -218,6 +218,13 @@ + + + 任务 手动分配 重新分配 确认 取消分配 + 分配 + + + 获取手动分配 未分配的Subject列表(IsHaveAssigned 传递false) @@ -251,13 +258,6 @@ - - - 任务 手动分配 重新分配 确认 取消分配 - 分配 - - - 访视任务 diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs index 4542c894d..e22200d5d 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs @@ -129,7 +129,7 @@ namespace IRaCIS.Core.Application.ViewModel public Guid? Id { get; set; } public Guid TrialId { get; set; } - //public Guid EnrollId { get; set; } + public Guid EnrollId { get; set; } [NotDefault] public Guid DoctorUserId { get; set; } @@ -147,7 +147,6 @@ namespace IRaCIS.Core.Application.ViewModel public ReadingMethod ReadingType { get; set; } - public Guid? DoctorUserId { get; set; } public string UserCode { get; set; } diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs index 6971a86d1..faf8e5b38 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs @@ -42,7 +42,7 @@ namespace IRaCIS.Core.Application.Service /// /// /// - public async Task > GetDoctorPlanAllocationRuleList(Guid trialId) + public async Task> GetDoctorPlanAllocationRuleList(Guid trialId) { var list = await _taskAllocationRuleRepository.Where(t => t.TrialId == trialId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); @@ -62,6 +62,12 @@ namespace IRaCIS.Core.Application.Service VerifyMsg = "已有该医生配置,不允许继续增加" }; + //冗余 存 + + var enrollId = _repository.Where(t => t.TrialId == addOrEditTaskAllocationRule.TrialId && t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId).Select(t => t.Id).FirstOrDefault(); + + addOrEditTaskAllocationRule.EnrollId = enrollId; + var entity = await _taskAllocationRuleRepository.InsertOrUpdateAsync(addOrEditTaskAllocationRule, true, verifyExp1); return ResponseOutput.Ok(entity.Id.ToString()); @@ -72,7 +78,7 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{taskAllocationRuleId:guid}")] public async Task DeleteTaskAllocationRule(Guid taskAllocationRuleId) { - if (await _taskAllocationRuleRepository.Where(t => t.Id == taskAllocationRuleId).AnyAsync(t => t.DoctorUser.VisitTaskList.Any())) + if (await _taskAllocationRuleRepository.Where(t => t.Id == taskAllocationRuleId).AnyAsync(t => t.DoctorUser.VisitTaskList.Where(u=>u.TrialId==t.TrialId).Any())) { return ResponseOutput.NotOk("已分配任务给该医生,不允许删除"); } @@ -141,7 +147,7 @@ namespace IRaCIS.Core.Application.Service [HttpPost] public async Task> GetDoctorSelectList(DoctorSelectQuery selectQuery, [FromServices] IRepository _enrollRepository) { - var query = from allocationRule in _taskAllocationRuleRepository.Where(t => t.TrialId == selectQuery.TrialId && t.IsEnable) + var query = from allocationRule in _taskAllocationRuleRepository.Where(t => t.TrialId == selectQuery.TrialId && t.IsEnable) join user in _userRepository.AsQueryable() on allocationRule.DoctorUserId equals user.Id select new TrialDoctorUserSelectView() { @@ -154,7 +160,7 @@ namespace IRaCIS.Core.Application.Service UserTypeEnum = user.UserTypeRole.UserTypeEnum }; - return await query.ToListAsync(); + return await query.ToListAsync(); } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index b11663917..8a36940ca 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -173,6 +173,91 @@ namespace IRaCIS.Core.Application.Service.Allocation + /// + /// 任务 手动分配 重新分配 确认 取消分配 + /// 分配 + /// + /// + [HttpPost] + [UnitOfWork] + public async Task AssignSubjectTaskToDoctor(AssignSubjectTaskToDoctorCommand assignSubjectTaskToDoctorCommand) + { + var visitTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == assignSubjectTaskToDoctorCommand.Id); + + if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.Assign || assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.ReAssign) + { + //手动分配验证规则 + + if (visitTask.SourceSubjectVisitId != null) + { + + if (await _visitTaskRepository.AnyAsync(t => t.SourceSubjectVisitId == visitTask.SourceSubjectVisitId && t.TaskAllocationState == TaskAllocationState.Allocated && t.DoctorUserId == assignSubjectTaskToDoctorCommand.DoctorUserId && t.Id != visitTask.Id)) + { + return ResponseOutput.NotOk("其中一个任务已分配给该医生,不允许分配"); + } + } + else if (visitTask.SouceReadModuleId != null) + { + if (await _visitTaskRepository.AnyAsync(t => t.SouceReadModuleId == visitTask.SouceReadModuleId && t.TaskAllocationState == TaskAllocationState.Allocated && t.DoctorUserId == assignSubjectTaskToDoctorCommand.DoctorUserId && t.Id != visitTask.Id)) + { + return ResponseOutput.NotOk("其中一个任务已分配给该医生,不允许分配"); + } + } + else + { + throw new BusinessValidationFailedException("出现脏数据 任务来源字段没有值"); + } + + //PM 回退了 但是还没生成任务 当前任务编号前有访视进行了回退就不允许分配 + if (await _subjectVisitRepository.AnyAsync(t => t.SubjectId == visitTask.SubjectId && t.IsPMBackOrReReading && t.VisitNum <= visitTask.VisitTaskNum)) + { + return ResponseOutput.NotOk("该受试者有访视进入了退回流程,还未经过一致性核查通过,不允许分配"); + } + + + visitTask.AllocateTime = DateTime.Now; + visitTask.DoctorUserId = assignSubjectTaskToDoctorCommand.DoctorUserId; + visitTask.TaskAllocationState = TaskAllocationState.Allocated; + + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.ImageReading }); + + await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.ImageReading }); + } + + else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.ReAssign) + { + //验证 是不是两个任务都给了同一个医生 + + + + //是否删除配置规则表里的 Subject 医生绑定关系 重新添加绑定关系 + + //是否其该Subject 其他访视 绑定的医生 也同时变更? + + + } + + else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.Confirm) + { + visitTask.TaskAllocationState = TaskAllocationState.Allocated; + } + else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.CancelAssign) + { + visitTask.AllocateTime = null; + visitTask.DoctorUserId = null; + visitTask.TaskAllocationState = TaskAllocationState.NotAllocate; + + await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.TaskAllocate }); + + await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.TaskAllocate }); + } + await _visitTaskRepository.SaveChangesAsync(); + return ResponseOutput.Ok(); + } + + + + /// /// 获取手动分配 未分配的Subject列表(IsHaveAssigned 传递false) /// @@ -637,89 +722,6 @@ namespace IRaCIS.Core.Application.Service.Allocation - /// - /// 任务 手动分配 重新分配 确认 取消分配 - /// 分配 - /// - /// - [HttpPost] - [UnitOfWork] - public async Task AssignSubjectTaskToDoctor(AssignSubjectTaskToDoctorCommand assignSubjectTaskToDoctorCommand) - { - var visitTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == assignSubjectTaskToDoctorCommand.Id); - - if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.Assign || assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.ReAssign) - { - //手动分配验证规则 - - if (visitTask.SourceSubjectVisitId != null) - { - - if (await _visitTaskRepository.AnyAsync(t => t.SourceSubjectVisitId == visitTask.SourceSubjectVisitId && t.TaskAllocationState == TaskAllocationState.Allocated && t.DoctorUserId == assignSubjectTaskToDoctorCommand.DoctorUserId && t.Id != visitTask.Id)) - { - return ResponseOutput.NotOk("其中一个任务已分配给该医生,不允许分配"); - } - } - else if (visitTask.SouceReadModuleId != null) - { - if (await _visitTaskRepository.AnyAsync(t => t.SouceReadModuleId == visitTask.SouceReadModuleId && t.TaskAllocationState == TaskAllocationState.Allocated && t.DoctorUserId == assignSubjectTaskToDoctorCommand.DoctorUserId && t.Id != visitTask.Id)) - { - return ResponseOutput.NotOk("其中一个任务已分配给该医生,不允许分配"); - } - } - else - { - throw new BusinessValidationFailedException("出现脏数据 任务来源字段没有值"); - } - - //PM 回退了 但是还没生成任务 当前任务编号前有访视进行了回退就不允许分配 - if (await _subjectVisitRepository.AnyAsync(t => t.SubjectId == visitTask.SubjectId && t.IsPMBackOrReReading && t.VisitNum <= visitTask.VisitTaskNum)) - { - return ResponseOutput.NotOk("该受试者有访视进入了退回流程,还未经过一致性核查通过,不允许分配"); - } - - - visitTask.AllocateTime = DateTime.Now; - visitTask.DoctorUserId = assignSubjectTaskToDoctorCommand.DoctorUserId; - visitTask.TaskAllocationState = TaskAllocationState.Allocated; - - await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.ImageReading }); - - await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.ImageReading }); - } - - else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.ReAssign) - { - //验证 是不是两个任务都给了同一个医生 - - - - //是否删除配置规则表里的 Subject 医生绑定关系 重新添加绑定关系 - - //是否其该Subject 其他访视 绑定的医生 也同时变更? - - - } - - else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.Confirm) - { - visitTask.TaskAllocationState = TaskAllocationState.Allocated; - } - else if (assignSubjectTaskToDoctorCommand.TaskOptType == TaskOptType.CancelAssign) - { - visitTask.AllocateTime = null; - visitTask.DoctorUserId = null; - visitTask.TaskAllocationState = TaskAllocationState.NotAllocate; - - await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SourceSubjectVisitId, u => new SubjectVisit() { ReadingStatus = ReadingStatusEnum.TaskAllocate }); - - await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == visitTask.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.TaskAllocate }); - } - await _visitTaskRepository.SaveChangesAsync(); - return ResponseOutput.Ok(); - } - - ///