diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index b9cb0fa27..6b38dec3c 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -65,7 +65,7 @@ - 批量为 多个Subject 分配医生 手动分配 + 批量为 多个Subject 分配医生 手动分配 IsReAssign 为true 批量删除 重新分配 diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index b9cdb143e..84f33fb15 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -133,6 +133,8 @@ namespace IRaCIS.Core.Application.ViewModel { public Guid TrialId { get; set; } + public bool IsReAssign { get; set; } + public List SubjectIdList { get; set; } public List DoctorUserIdList { get; set; } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index d3ac6235a..00f76298f 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -83,25 +83,30 @@ namespace IRaCIS.Core.Application.Service .WhereIf(querySubjectAssign.DoctorUserId != null, t => t.SubjectDoctorList.Any(t => t.DoctorUserId == querySubjectAssign.DoctorUserId)) .ProjectTo(_mapper.ConfigurationProvider); - var pageList = await subjectQuery.ToPagedListAsync(querySubjectAssign.PageIndex, querySubjectAssign.PageSize, string.IsNullOrWhiteSpace(querySubjectAssign.SortField) ? nameof(querySubjectAssign.SubjectId) : querySubjectAssign.SortField, querySubjectAssign.Asc ); + var pageList = await subjectQuery.ToPagedListAsync(querySubjectAssign.PageIndex, querySubjectAssign.PageSize, string.IsNullOrWhiteSpace(querySubjectAssign.SortField) ? nameof(querySubjectAssign.SubjectId) : querySubjectAssign.SortField, querySubjectAssign.Asc); return pageList; } /// - /// 批量为 多个Subject 分配医生 手动分配 + /// 批量为 多个Subject 分配医生 手动分配 IsReAssign 为true 批量删除 重新分配 /// /// /// [HttpPost] - public async Task AssignSubjectDoctor(AssginSubjectDoctorCommand assginSubjectDoctorCommand) + public async Task AssignSubjectDoctor(AssginSubjectDoctorCommand assginSubjectDoctorCommand) { + if (assginSubjectDoctorCommand.IsReAssign) + { + await _subjectUserRepository.BatchDeleteNoTrackingAsync(t => assginSubjectDoctorCommand.DoctorUserIdList.Contains(t.DoctorUserId) && assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId)); + } + foreach (var subjectId in assginSubjectDoctorCommand.SubjectIdList) { foreach (var doctorUserId in assginSubjectDoctorCommand.DoctorUserIdList) { - await _subjectUserRepository.AddAsync(new SubjectUser() {TrialId= assginSubjectDoctorCommand.TrialId, SubjectId = subjectId, DoctorUserId = doctorUserId, AssignTime = DateTime.Now }); + await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = assginSubjectDoctorCommand.TrialId, SubjectId = subjectId, DoctorUserId = doctorUserId, AssignTime = DateTime.Now }); } await _subjectRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectId, u => new Subject() { IsAssignDoctorUser = true }); @@ -121,7 +126,7 @@ namespace IRaCIS.Core.Application.Service { foreach (var subjectId in cancelSubjectAssignCommand.SubjectIdList) { - await _subjectUserRepository.DeleteFromQueryAsync(t=>t.SubjectId== subjectId); + await _subjectUserRepository.DeleteFromQueryAsync(t => t.SubjectId == subjectId); await _subjectRepository.BatchUpdateNoTrackingAsync(t => t.Id == subjectId, u => new Subject() { IsAssignDoctorUser = false }); } @@ -130,6 +135,6 @@ namespace IRaCIS.Core.Application.Service return ResponseOutput.Ok(); } - + } } diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 5d818d45d..3b81449c8 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -19,8 +19,8 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.ArmList, t => t.MapFrom(u => u.VisitTaskList.Where(c => c.TrialId == u.TrialId).Select(t => t.ArmEnum).Distinct())) .ForMember(o => o.TotalTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count())) .ForMember(o => o.SelfTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId == u.DoctorUserId))) - .ForMember(o => o.TotalSubjectCount, t => t.MapFrom(u => u.Trial.SubjectList.Count())) - /* .ForMember(o => o.SelfSubjectCount, t => t.MapFrom(u => u.Trial.su.Where(t => t.DoctorUserId == u.DoctorUserId).Select(t=>t.SubjectId).Distinct().Count())*/; + .ForMember(o => o.TotalSubjectCount, t => t.MapFrom(u => u.Trial.SubjectList.Count())) + .ForMember(o => o.SelfSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId).Count())); CreateMap() .ForMember(o => o.ArmList, t => t.MapFrom(u => u.VisitTaskList.Where(c => c.TrialId == u.TrialId).Select(t => t.ArmEnum).Distinct())) diff --git a/IRaCIS.Core.Domain/Trial/Trial.cs b/IRaCIS.Core.Domain/Trial/Trial.cs index e644561a7..a4aa1cfd8 100644 --- a/IRaCIS.Core.Domain/Trial/Trial.cs +++ b/IRaCIS.Core.Domain/Trial/Trial.cs @@ -15,6 +15,7 @@ namespace IRaCIS.Core.Domain.Models TrialDicList = new List(); } + public List SubjectDoctorUserList { get; set; }=new List(); public List VisitTaskList { get; set; }=new List(){ }; public List TrialSiteSurveyList { get; set; } = new List();