分配规则修改

This commit is contained in:
2022-07-22 13:12:08 +08:00
parent e1a778c93d
commit b2f093f79d
13 changed files with 262 additions and 215 deletions
@@ -91,16 +91,34 @@ namespace IRaCIS.Core.Application.ViewModel
public bool IsJudgeDoctor { get; set; }
}
public class TaskAllocationRuleDTO : TaskAllocationRuleAddOrEdit
{
public Guid CreateUserId { get; set; }
public DateTime CreateTime { get; set; }
public DateTime UpdateTime { get; set; }
public Guid UpdateUserId { get; set; }
public UserSimpleInfo DoctorUser { get; set; }
public List<ReadingCategory> ReadingCategoryList { get; set; }
}
///<summary> TaskAllocationRuleAddOrEdit 列表查询参数模型</summary>
public class TaskAllocationRuleAddOrEdit
{
public Guid? Id { get; set; }
public Guid TrialId { get; set; }
public int PlanReadingRatio { get; set; }
public Guid DoctorUserId { get; set; }
public Guid EnrollId { get; set; }
//public Guid DoctorUserId { get; set; }
public int PlanSubjectCount { get; set; }
public bool IsEnable { get; set; }
public bool IsJudgeDoctor { get; set; }
public string Note { get; set; } = string.Empty;
}
@@ -110,6 +128,9 @@ namespace IRaCIS.Core.Application.ViewModel
public ReadingMethod ReadingType { get; set; }
[NotDefault]
public Guid EnrollId { get; set; }
public Guid? DoctorUserId { get; set; }
public string UserCode { get; set; }
@@ -151,7 +172,7 @@ namespace IRaCIS.Core.Application.ViewModel
//重阅 产生任务
public VisitTask ReReadingTask { get; set; }
public Action< VisitTask> Action;
public Action<VisitTask> Action;
//public ReReadingApplyGenerateTaskCommand ReReadingApplyGenerateTaskCommand { get; set; } = new ReReadingApplyGenerateTaskCommand();
@@ -161,7 +182,7 @@ namespace IRaCIS.Core.Application.ViewModel
//组间一致性
public List<VisitTaskGroupSimpleDTO> GenerataGroupConsistentTaskList { get; set; }
}
@@ -321,7 +321,7 @@ namespace IRaCIS.Core.Application.ViewModel
public Guid TrialId { get; set; }
public Guid SubjectId { get; set; }
public List<Guid> SubjectIdList { get; set; }
public List<DoctorArm> DoctorArmList { get; set; }
@@ -18,7 +18,7 @@ namespace IRaCIS.Core.Application.Interfaces
Task<IResponseOutput> AddOrUpdateTaskAllocationRule(TaskAllocationRuleAddOrEdit addOrEditTaskAllocationRule);
Task<IResponseOutput> DeleteTaskAllocationRule(Guid taskAllocationRuleId, bool isJudgeDoctor);
Task<IResponseOutput> DeleteTaskAllocationRule(Guid taskAllocationRuleId);
}
@@ -25,48 +25,36 @@ namespace IRaCIS.Core.Application.Service
private readonly IRepository<Trial> _trialRepository;
public TaskAllocationRuleService(IRepository<TaskAllocationRule> taskAllocationRuleRepository, IRepository<User> userRepository, IRepository<Trial> trialRepository)
{
_taskAllocationRuleRepository = taskAllocationRuleRepository;
_userRepository = userRepository;
_trialRepository= trialRepository;
_trialRepository = trialRepository;
}
[HttpPost]
public async Task<(List<DoctorVisitTaskStatView>,object)> GetTaskAllocationRuleList(TaskAllocationRuleQuery queryTaskAllocationRule)
public async Task<List<TaskAllocationRuleDTO> > GetDoctorPlanAllocationRuleList(Guid trialId)
{
var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t=>t.TrialId== queryTaskAllocationRule.TrialId && t.IsJudgeDoctor == queryTaskAllocationRule.IsJudgeDoctor)
.ProjectTo<DoctorVisitTaskStatView>(_mapper.ConfigurationProvider);
var list = await _taskAllocationRuleRepository.Where(t => t.TrialId == trialId).ProjectTo<TaskAllocationRuleDTO>(_mapper.ConfigurationProvider).ToListAsync();
var trialTaskConfig= _trialRepository.Where(t=>t.Id==queryTaskAllocationRule.TrialId).ProjectTo<TrialTaskConfigView>(_mapper.ConfigurationProvider, new { isJudgeDoctor = queryTaskAllocationRule.IsJudgeDoctor }).FirstOrDefault();
return (await taskAllocationRuleQueryable.ToListAsync(), trialTaskConfig);
return list;
}
/// <summary>
/// 获取访视任务 应用Subject后 医生比率情况
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<List<DoctorVisitTaskStatView>> GetSubjectApplyDoctorTaskStatList(ApplySubjectCommand assignConfirmCommand)
{
var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t => t.TrialId == assignConfirmCommand.TrialId && t.IsJudgeDoctor == assignConfirmCommand.IsJudgeDoctor)
.ProjectTo<DoctorVisitTaskStatView>(_mapper.ConfigurationProvider, new { subjectIdList = assignConfirmCommand.SubjectIdList , isJudgeDoctor = assignConfirmCommand.IsJudgeDoctor });
return await taskAllocationRuleQueryable.ToListAsync();
}
public async Task<IResponseOutput> AddOrUpdateTaskAllocationRule(TaskAllocationRuleAddOrEdit addOrEditTaskAllocationRule)
{
var verifyExp1 = new EntityVerifyExp<TaskAllocationRule>()
{
VerifyExp = t => t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId && t.TrialId== addOrEditTaskAllocationRule.TrialId && t.IsJudgeDoctor==addOrEditTaskAllocationRule.IsJudgeDoctor,
VerifyExp = t => t.EnrollId == addOrEditTaskAllocationRule.EnrollId && t.TrialId == addOrEditTaskAllocationRule.TrialId,
VerifyMsg = "已有该医生配置,不允许继续增加"
};
@@ -77,10 +65,10 @@ namespace IRaCIS.Core.Application.Service
}
[HttpDelete("{taskAllocationRuleId:guid}/{isJudgeDoctor:bool}")]
public async Task<IResponseOutput> DeleteTaskAllocationRule( Guid taskAllocationRuleId, bool isJudgeDoctor )
[HttpDelete("{taskAllocationRuleId:guid}")]
public async Task<IResponseOutput> DeleteTaskAllocationRule(Guid taskAllocationRuleId)
{
if(await _taskAllocationRuleRepository.Where(t => t.Id == taskAllocationRuleId ).AnyAsync(t => t.DoctorVisitTaskList.Where(t=>isJudgeDoctor?t.ArmEnum==Domain.Share.Arm.JudgeArm: t.ArmEnum != Domain.Share.Arm.JudgeArm).Count() > 0))
if (await _taskAllocationRuleRepository.Where(t => t.Id == taskAllocationRuleId).AnyAsync(t => t.DoctorVisitTaskList.Any()))
{
return ResponseOutput.NotOk("已分配任务给该医生,不允许删除");
}
@@ -91,6 +79,35 @@ namespace IRaCIS.Core.Application.Service
return ResponseOutput.Ok();
}
/// <summary>
/// 获取访视任务 应用Subject后 医生比率情况
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<List<DoctorVisitTaskStatView>> GetSubjectApplyDoctorTaskStatList(ApplySubjectCommand assignConfirmCommand)
{
var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t => t.TrialId == assignConfirmCommand.TrialId && t.IsJudgeDoctor == assignConfirmCommand.IsJudgeDoctor)
.ProjectTo<DoctorVisitTaskStatView>(_mapper.ConfigurationProvider, new { subjectIdList = assignConfirmCommand.SubjectIdList, isJudgeDoctor = assignConfirmCommand.IsJudgeDoctor });
return await taskAllocationRuleQueryable.ToListAsync();
}
[HttpPost]
public async Task<(List<DoctorVisitTaskStatView>, object)> GetTaskAllocationRuleList(TaskAllocationRuleQuery queryTaskAllocationRule)
{
var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t => t.TrialId == queryTaskAllocationRule.TrialId /*&& t.IsJudgeDoctor == queryTaskAllocationRule.IsJudgeDoctor*/)
.ProjectTo<DoctorVisitTaskStatView>(_mapper.ConfigurationProvider);
var trialTaskConfig = _trialRepository.Where(t => t.Id == queryTaskAllocationRule.TrialId).ProjectTo<TrialTaskConfigView>(_mapper.ConfigurationProvider, new { isJudgeDoctor = queryTaskAllocationRule.IsJudgeDoctor }).FirstOrDefault();
return (await taskAllocationRuleQueryable.ToListAsync(), trialTaskConfig);
}
/// <summary>
/// 获取项目下 医生账户信息下拉
/// </summary>
@@ -98,19 +115,20 @@ namespace IRaCIS.Core.Application.Service
/// <param name="_enrollRepository"></param>
/// <returns></returns>
[HttpGet("{trialId:guid}")]
public async Task<List<TrialDoctorUserSelectView>> GetDoctorUserSelectList(Guid trialId,[FromServices] IRepository<Enroll> _enrollRepository)
public async Task<List<TrialDoctorUserSelectView>> GetDoctorUserSelectList(Guid trialId, [FromServices] IRepository<Enroll> _enrollRepository)
{
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()
{
TrialId = enroll.TrialId,
ReadingType=enroll.Trial.ReadingType,
DoctorUserId= user.Id,
FullName=user.FullName,
UserCode=user.UserCode,
UserName=user.UserName,
UserTypeEnum=user.UserTypeRole.UserTypeEnum
ReadingType = enroll.Trial.ReadingType,
EnrollId =enroll.Id,
DoctorUserId = user.Id,
FullName = user.FullName,
UserCode = user.UserCode,
UserName = user.UserName,
UserTypeEnum = user.UserTypeRole.UserTypeEnum
};
return query.ToList();
@@ -72,7 +72,7 @@ namespace IRaCIS.Core.Application.Service
/// <param name="inQuery"></param>
/// <returns></returns>
[HttpPost]
public async Task<PageOutput<GenerateMedicalReviewTaskView>> GetGenerateMedicalReviewTaskList(GenerateMedicalReviewTaskQuery inQuery)
public async Task<PageOutput<GenerateMedicalReviewTaskView>> GetGenerateMedicalReviewTaskList(GenerateMedicalReviewTaskQuery inQuery)
{
var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId)
.Where(t => t.IsAnalysisCreate == false && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned)
@@ -84,7 +84,7 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inQuery.ReadingCategory != null, t => t.ReadingCategory == inQuery.ReadingCategory)
.WhereIf(inQuery.ReadingTaskState != null, t => t.ReadingTaskState == inQuery.ReadingTaskState)
.WhereIf(inQuery.IsGeneratedJudge != null, t => t.JudgeVisitTaskId != null)
.WhereIf(inQuery.IsGlobalHaveUpdate != null, t => t.IsGlobalHaveUpdate== inQuery.IsGlobalHaveUpdate)
.WhereIf(inQuery.IsGlobalHaveUpdate != null, t => t.IsGlobalHaveUpdate == inQuery.IsGlobalHaveUpdate)
.WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.TaskName.Contains(inQuery.TaskName) || t.TaskBlindName.Contains(inQuery.TaskName))
.WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.Subject.Code.Contains(inQuery.SubjectCode))
@@ -107,7 +107,7 @@ namespace IRaCIS.Core.Application.Service
foreach (var taskId in command.TaskIdList)
{
await _taskMedicalReviewRepository.AddAsync(new TaskMedicalReview() { TrialId = command.TrialId, VisitTaskId = taskId, MedicalManagerUserId = command.MedicalManagerUserId ,AllocateTime=DateTime.Now});
await _taskMedicalReviewRepository.AddAsync(new TaskMedicalReview() { TrialId = command.TrialId, VisitTaskId = taskId, MedicalManagerUserId = command.MedicalManagerUserId, AllocateTime = DateTime.Now });
}
await _taskMedicalReviewRepository.SaveChangesAsync();
@@ -76,15 +76,36 @@ namespace IRaCIS.Core.Application.Service.Allocation
}
/// <summary>
///
/// 一次性分配所有医生 批量分配(添加),后端现在没限制
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
public async Task<IResponseOutput> BatchAssignDoctorToSubject(BatchAssignDoctorToSubjectCommand command)
public async Task<IResponseOutput> BatchAssignDoctorToSubject(BatchAssignDoctorToSubjectCommand command)
{
foreach (var subjectId in command.SubjectIdList)
{
foreach (var doctorArm in command.DoctorArmList)
{
await _subjectUserRepository.AddAsync(new SubjectUser() { ArmEnum = doctorArm.ArmEnum, DoctorUserId = doctorArm.DoctorUserId, SubjectId = subjectId, AssignTime = DateTime.Now });
}
}
await _subjectUserRepository.SaveChangesAsync();
return ResponseOutput.Ok();
}
///// <summary>
///// 阅片人维度 Subject统计表
///// </summary>
///// <param name="command"></param>
///// <returns></returns>
//public async Task<IResponseOutput> GetDoctorSubjectStat(Guid trialId )
//{
// var query= from enroll in _repository.Where<Enroll>(t=>t.TrialId==trialId)
// join user in _repository.Where<User>() on enroll.DoctorId equals user.DoctorId
//}
@@ -1195,21 +1216,22 @@ namespace IRaCIS.Core.Application.Service.Allocation
var origenalTask = (await _visitTaskRepository.Where(t => item.OriginalReReadingTaskId == t.Id).FirstOrDefaultAsync()).IfNullThrowException();
// 当前访视之前 已有任务申请
if (trialConfig.IsReadingTaskViewInOrder )
if (trialConfig.IsReadingTaskViewInOrder)
{
//var query = _visitTaskReReadingRepository.Where(t => t.OriginalReReadingTask.SubjectId == origenalTask.SubjectId && t.OriginalReReadingTask.TaskState == TaskState.Effect && t.OriginalReReadingTask.ReadingCategory == ReadingCategory.Visit
// && t.OriginalReReadingTask.ReadingTaskState == ReadingTaskState.HaveSigned && t.OriginalReReadingTask.VisitTaskNum > origenalTask.VisitTaskNum && t.RequestReReadingResultEnum == RequestReReadingResult.Default)
// .Where(t => t.OriginalReReadingTask.IsAnalysisCreate == origenalTask.IsAnalysisCreate);
var query = _visitTaskReReadingRepository.Where(t => t.OriginalReReadingTask.SubjectId == origenalTask.SubjectId && t.OriginalReReadingTask.TaskState == TaskState.Effect && t.OriginalReReadingTask.ReadingCategory == ReadingCategory.Visit
&& t.OriginalReReadingTask.ReadingTaskState == ReadingTaskState.HaveSigned && t.OriginalReReadingTask.VisitTaskNum > origenalTask.VisitTaskNum && t.RequestReReadingResultEnum == RequestReReadingResult.Default)
.Where(t => t.OriginalReReadingTask.IsAnalysisCreate == origenalTask.IsAnalysisCreate);
//if(await query.AnyAsync())
//{
// return ResponseOutput.NotOk("当前为有序阅片,当前访视之后,也申请了重阅 必须从后向前处理");
if (await query.AnyAsync())
{
return ResponseOutput.NotOk("当前为有序阅片,当前访视之后,也申请了重阅 必须从后向前处理");
}
//}
}
Expression<Func<VisitTask, bool>> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && t.TaskState == TaskState.Effect && t.TaskAllocationState==TaskAllocationState.Allocated;
Expression<Func<VisitTask, bool>> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && t.TaskState == TaskState.Effect && t.TaskAllocationState == TaskAllocationState.Allocated;
//是否是一致性分析任务
filterExpression = filterExpression.And(t => t.IsAnalysisCreate == origenalTask.IsAnalysisCreate);
@@ -1233,6 +1255,8 @@ namespace IRaCIS.Core.Application.Service.Allocation
// });
//}
//PM申请 SPM / CPM审批 回退访视,在此不生成访视任务
if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM))
{
@@ -1254,7 +1278,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
//访视影响当前以及当前之后的 两个阅片人的
filterExpression = filterExpression.And(t => t.VisitTaskNum >= origenalTask.VisitTaskNum );
filterExpression = filterExpression.And(t => t.VisitTaskNum >= origenalTask.VisitTaskNum);
#region
@@ -1274,6 +1298,12 @@ namespace IRaCIS.Core.Application.Service.Allocation
influenceTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = t.Id });
});
//将医学审核设置为失效
var taskIdList = influenceTaskList.Select(t => t.Id).ToList();
await _taskMedicalReviewRepository.UpdatePartialFromQueryAsync(t => taskIdList.Contains(t.VisitTaskId) && t.AuditState != MedicalReviewAuditState.HaveSigned , u => new TaskMedicalReview() { IsInvalid = false });
}
//申请的访视 要不是重阅重置,要不就是失效 不会存在取消分配
@@ -65,6 +65,12 @@ namespace IRaCIS.Core.Application.Service
;
CreateMap<TaskAllocationRule, TaskAllocationRuleDTO>()
.ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.Enroll.DoctorUser))
.ForMember(o => o.ReadingCategoryList, t => t.MapFrom(u => u.Enroll.EnrollReadingCategoryList.Select(t=>t.ReadingCategory).ToList()));
CreateMap<Subject, SubjectAssignStat>()
.ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.TrialSite.TrialSiteCode))