diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 81350d7f6..826fc1936 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -39,6 +39,13 @@ 分配规则 + + + 获取计划列表 医生带阅片类型 + + + + 获取访视任务 应用Subject后 医生比率情况 @@ -196,6 +203,21 @@ + + + 获取Subject 分配医生情况 + + + + + + + 取消Subject 分配的医生 + + + + + 获取手动分配 未分配的Subject列表(IsHaveAssigned 传递false) diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index 424342d23..eb492075f 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -332,7 +332,7 @@ namespace IRaCIS.Core.Application.ViewModel public class BatchAssignDoctorToSubjectCommand { - + [NotDefault] public Guid TrialId { get; set; } public List SubjectIdList { get; set; } @@ -345,6 +345,9 @@ namespace IRaCIS.Core.Application.ViewModel + + + public class SubjectAssignStat { public Guid TrialId { get; set; } @@ -374,8 +377,10 @@ namespace IRaCIS.Core.Application.ViewModel public class SubjectUserView { + public Guid Id { get; set; } public DateTime? AssignTime { get; set; } + public Guid DoctorUserId { get; set; } public Arm ArmEnum { get; set; } public bool IsConfirmed { get; set; } @@ -387,6 +392,26 @@ namespace IRaCIS.Core.Application.ViewModel } + public class SubjectUserDTO: SubjectUserView + { + public bool IsHaveReading { get; set; } + } + + + public class CancelSubjectAssignedDoctorCommand + { + public Guid Id { get; set; } + public Guid TrialId { get; set; } + public Guid SubjectId { get; set; } + public Guid DoctorUserId { get; set; } + public Arm ArmEnum { get; set; } + + + public bool IsCancelAssign { get; set; } + + } + + public class SubjectAssignView diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs index ae5781a95..fe4856296 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskAllocationRuleService.cs @@ -37,7 +37,11 @@ namespace IRaCIS.Core.Application.Service - + /// + /// 获取计划列表 医生带阅片类型 + /// + /// + /// public async Task > GetDoctorPlanAllocationRuleList(Guid trialId) { diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 18a8ac161..e064d2c8b 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -62,7 +62,7 @@ namespace IRaCIS.Core.Application.Service.Allocation /// /// [HttpPost] - public async Task<(PageOutput,object)> GetSubjectAssignAndTaskStatList(SubjectAssignStatQuery querySubjectAssign) + public async Task<(PageOutput, object)> GetSubjectAssignAndTaskStatList(SubjectAssignStatQuery querySubjectAssign) { var subjectQuery = _subjectRepository.Where(t => t.TrialId == querySubjectAssign.TrialId && t.SubjectVisitTaskList.Any()) .WhereIf(querySubjectAssign.SiteId != null, t => t.SiteId == querySubjectAssign.SiteId) @@ -89,7 +89,11 @@ namespace IRaCIS.Core.Application.Service.Allocation { foreach (var doctorArm in command.DoctorArmList) { - await _subjectUserRepository.AddAsync(new SubjectUser() { ArmEnum = doctorArm.ArmEnum, DoctorUserId = doctorArm.DoctorUserId, SubjectId = subjectId, AssignTime = DateTime.Now }); + if(!await _subjectUserRepository.AnyAsync(t=>t.SubjectId == subjectId && t.DoctorUserId == doctorArm.DoctorUserId && t.ArmEnum == doctorArm.ArmEnum && t.IsConfirmed && t.OrignalSubjectUserId == null)) + { + await _subjectUserRepository.AddAsync(new SubjectUser() { ArmEnum = doctorArm.ArmEnum, DoctorUserId = doctorArm.DoctorUserId, SubjectId = subjectId, AssignTime = DateTime.Now }); + + } } } @@ -99,6 +103,8 @@ namespace IRaCIS.Core.Application.Service.Allocation return ResponseOutput.Ok(); } + + /// /// 阅片人维度 Subject统计表 /// @@ -112,6 +118,53 @@ namespace IRaCIS.Core.Application.Service.Allocation } + /// + /// 获取Subject 分配医生情况 + /// + /// + + /// + public async Task> GetSubjectAssignedDoctorList(Guid subjectId) + { + var list = await _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.OrignalSubjectUserId == null && t.IsConfirmed).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + + return list; + } + + + /// + /// 取消Subject 分配的医生 + /// + /// + /// + /// + [HttpPost] + public async Task CancelSubjectAssignedDoctor(List commandList) + { + foreach (var command in commandList.Where(t => t.IsCancelAssign)) + { + if(await _visitTaskRepository.AnyAsync(t=>t.SubjectId==command.SubjectId && t.DoctorUserId==command.DoctorUserId && t.ArmEnum==command.ArmEnum && t.ReadingTaskState != ReadingTaskState.WaitReading)) + { + throw new BusinessValidationFailedException("当前医生已开始做该Subject的任务,不允许取消分配"); + } + + await _subjectUserRepository.DeleteFromQueryAsync(t => t.Id == command.Id); + + await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.SubjectId == command.SubjectId && t.DoctorUserId == command.DoctorUserId && t.ArmEnum == command.ArmEnum, u => new VisitTask() + { + AllocateTime=null, + DoctorUserId=null, + TaskAllocationState=TaskAllocationState.NotAllocate + }); + } + + await _visitTaskRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(); + } + + + /// /// 获取手动分配 未分配的Subject列表(IsHaveAssigned 传递false) @@ -767,7 +820,7 @@ namespace IRaCIS.Core.Application.Service.Allocation .WhereIf(queryVisitTask.ReadingCategory != null, t => t.ReadingCategory == queryVisitTask.ReadingCategory) .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.ReadingTaskState == queryVisitTask.ReadingTaskState) .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.TaskAllocationState == queryVisitTask.TaskAllocationState) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(queryVisitTask.TrialSiteCode)&& t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(queryVisitTask.TrialSiteCode) && t.IsAnalysisCreate==false)) + .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TrialSiteCode), t => (t.BlindTrialSiteCode.Contains(queryVisitTask.TrialSiteCode) && t.IsAnalysisCreate) || (t.Subject.TrialSite.TrialSiteCode.Contains(queryVisitTask.TrialSiteCode) && t.IsAnalysisCreate == false)) .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.TaskName.Contains(queryVisitTask.TaskName) || t.TaskBlindName.Contains(queryVisitTask.TaskName)) .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.Subject.Code.Contains(queryVisitTask.SubjectCode) || t.BlindSubjectCode.Contains(queryVisitTask.SubjectCode)) .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.AllocateTime > queryVisitTask.BeginAllocateDate) @@ -879,7 +932,7 @@ namespace IRaCIS.Core.Application.Service.Allocation .WhereIf(queryVisitTask.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == queryVisitTask.DoctorUserId) .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == queryVisitTask.ReadingTaskState) .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == queryVisitTask.TaskAllocationState) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(queryVisitTask.TrialSiteCode)&& t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(queryVisitTask.TrialSiteCode)&& t.OriginalReReadingTask.IsAnalysisCreate==false)) + .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(queryVisitTask.TrialSiteCode) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(queryVisitTask.TrialSiteCode) && t.OriginalReReadingTask.IsAnalysisCreate == false)) .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(queryVisitTask.TaskName) || t.NewReReadingTask.TaskBlindName.Contains(queryVisitTask.TaskName)) .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.OriginalReReadingTask.Subject.Code.Contains(queryVisitTask.SubjectCode) || t.OriginalReReadingTask.BlindSubjectCode.Contains(queryVisitTask.SubjectCode)) .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > queryVisitTask.BeginAllocateDate) @@ -1305,7 +1358,7 @@ namespace IRaCIS.Core.Application.Service.Allocation #region 影响的任务 - + var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync(); @@ -1949,7 +2002,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { influenceTask.TaskState = TaskState.HaveReturned; - origenalTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id,OptType=ReReadingOrBackOptType.Return }); + origenalTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Return }); } else if (influenceTask.ReadingTaskState == ReadingTaskState.Reading) { diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 92e36de18..7eb8ff08e 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -91,6 +91,11 @@ namespace IRaCIS.Core.Application.Service CreateMap() .ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.DoctorUser)); + + CreateMap().IncludeBase() + .ForMember(o => o.IsHaveReading, t => t.MapFrom(u => u.SubjectArmVisitTaskList.Any(t=>t.ReadingTaskState != ReadingTaskState.WaitReading))); + + CreateMap();