取消分配

Uat_Study
hang 2022-07-26 10:57:00 +08:00
parent 3431ba83e4
commit 406fea9ea5
5 changed files with 117 additions and 8 deletions

View File

@ -39,6 +39,13 @@
分配规则
</summary>
</member>
<member name="M:IRaCIS.Core.Application.Service.TaskAllocationRuleService.GetDoctorPlanAllocationRuleList(System.Guid)">
<summary>
获取计划列表 医生带阅片类型
</summary>
<param name="trialId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.TaskAllocationRuleService.GetSubjectApplyDoctorTaskStatList(IRaCIS.Core.Application.ViewModel.ApplySubjectCommand)">
<summary>
获取访视任务 应用Subject后 医生比率情况
@ -196,6 +203,21 @@
<param name="trialId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.Allocation.VisitTaskService.GetSubjectAssignedDoctorList(System.Guid)">
<summary>
获取Subject 分配医生情况
</summary>
<param name="subjectId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.Allocation.VisitTaskService.CancelSubjectAssignedDoctor(System.Collections.Generic.List{IRaCIS.Core.Application.ViewModel.CancelSubjectAssignedDoctorCommand})">
<summary>
取消Subject 分配的医生
</summary>
<param name="commandList"></param>
<returns></returns>
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
</member>
<member name="M:IRaCIS.Core.Application.Service.Allocation.VisitTaskService.GetSubjectAssignList(IRaCIS.Core.Application.ViewModel.SubjectAssignQuery)">
<summary>
获取手动分配 未分配的Subject列表(IsHaveAssigned 传递false)

View File

@ -332,7 +332,7 @@ namespace IRaCIS.Core.Application.ViewModel
public class BatchAssignDoctorToSubjectCommand
{
[NotDefault]
public Guid TrialId { get; set; }
public List<Guid> 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

View File

@ -37,7 +37,11 @@ namespace IRaCIS.Core.Application.Service
/// <summary>
/// 获取计划列表 医生带阅片类型
/// </summary>
/// <param name="trialId"></param>
/// <returns></returns>
public async Task<List<TaskAllocationRuleDTO> > GetDoctorPlanAllocationRuleList(Guid trialId)
{

View File

@ -88,8 +88,12 @@ namespace IRaCIS.Core.Application.Service.Allocation
foreach (var subjectId in command.SubjectIdList)
{
foreach (var doctorArm in command.DoctorArmList)
{
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();
}
/// <summary>
/// 阅片人维度 Subject统计表
/// </summary>
@ -112,6 +118,53 @@ namespace IRaCIS.Core.Application.Service.Allocation
}
/// <summary>
/// 获取Subject 分配医生情况
/// </summary>
/// <param name="subjectId"></param>
/// <returns></returns>
public async Task<List<SubjectUserDTO>> GetSubjectAssignedDoctorList(Guid subjectId)
{
var list = await _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.OrignalSubjectUserId == null && t.IsConfirmed).ProjectTo<SubjectUserDTO>(_mapper.ConfigurationProvider).ToListAsync();
return list;
}
/// <summary>
/// 取消Subject 分配的医生
/// </summary>
/// <param name="commandList"></param>
/// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception>
[HttpPost]
public async Task<IResponseOutput> CancelSubjectAssignedDoctor(List<CancelSubjectAssignedDoctorCommand> 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();
}
/// <summary>
/// 获取手动分配 未分配的Subject列表(IsHaveAssigned 传递false)

View File

@ -91,6 +91,11 @@ namespace IRaCIS.Core.Application.Service
CreateMap<SubjectUser, SubjectUserView>()
.ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.DoctorUser));
CreateMap<SubjectUser, SubjectUserDTO>().IncludeBase<SubjectUser, SubjectUserView>()
.ForMember(o => o.IsHaveReading, t => t.MapFrom(u => u.SubjectArmVisitTaskList.Any(t=>t.ReadingTaskState != ReadingTaskState.WaitReading)));
CreateMap<SubjectVisit, VisitGenerataTaskDTO>();