医生分配组
parent
1bd1779c18
commit
aa4573fdf1
|
@ -135,6 +135,8 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||||
|
|
||||||
public DateTime? AssignTime { get; set; }
|
public DateTime? AssignTime { get; set; }
|
||||||
|
|
||||||
|
public int ArmEnum { get; set; }
|
||||||
|
|
||||||
public bool IsAssignDoctorApplyedTask { get; set; }
|
public bool IsAssignDoctorApplyedTask { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,19 +26,21 @@ namespace IRaCIS.Core.Application.Service
|
||||||
private readonly IEasyCachingProvider _provider;
|
private readonly IEasyCachingProvider _provider;
|
||||||
private readonly IRepository<SubjectVisit> _subjectVisitRepository;
|
private readonly IRepository<SubjectVisit> _subjectVisitRepository;
|
||||||
private readonly IRepository<TaskAllocationRule> _taskAllocationRuleRepository;
|
private readonly IRepository<TaskAllocationRule> _taskAllocationRuleRepository;
|
||||||
|
private readonly IRepository<SubjectUser> _subjectUserRepository;
|
||||||
|
|
||||||
|
|
||||||
public VisitTaskHelpeService(IRepository<VisitTask> visitTaskRepository, IRepository<Trial> trialRepository, IEasyCachingProvider provider, IRepository<SubjectVisit> subjectVisitRepository, IRepository<TaskAllocationRule> taskAllocationRuleRepository)
|
public VisitTaskHelpeService(IRepository<VisitTask> visitTaskRepository, IRepository<SubjectUser> subjectUserRepository, IRepository<Trial> trialRepository, IEasyCachingProvider provider, IRepository<SubjectVisit> subjectVisitRepository, IRepository<TaskAllocationRule> taskAllocationRuleRepository)
|
||||||
{
|
{
|
||||||
_visitTaskRepository = visitTaskRepository;
|
_visitTaskRepository = visitTaskRepository;
|
||||||
_trialRepository = trialRepository;
|
_trialRepository = trialRepository;
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
_subjectVisitRepository = subjectVisitRepository;
|
_subjectVisitRepository = subjectVisitRepository;
|
||||||
_taskAllocationRuleRepository = taskAllocationRuleRepository;
|
_taskAllocationRuleRepository = taskAllocationRuleRepository;
|
||||||
|
_subjectUserRepository = subjectUserRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询列表的时候,一致性核查通过未产生任务的 自动产生任务
|
//查询列表的时候,一致性核查通过未产生任务的 自动产生任务
|
||||||
public async Task GenerateVisitTaskAsync(Guid trialId, List<Guid> subjectVisitIdList, bool isAssignSubjectToDoctor=false)
|
public async Task GenerateVisitTaskAsync(Guid trialId, List<Guid> subjectVisitIdList, bool isAssignSubjectToDoctor = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (subjectVisitIdList.Count == 0)
|
if (subjectVisitIdList.Count == 0)
|
||||||
|
@ -48,7 +50,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
//以前访视未产生任务的,在查询这里要产生 后期维护到一块
|
//以前访视未产生任务的,在查询这里要产生 后期维护到一块
|
||||||
|
|
||||||
var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.ReadingType, t.IsFollowVisitAutoAssign, t.IsFollowGlobalVisitAutoAssign,t.FollowGlobalVisitAutoAssignDefaultState,t.FollowVisitAutoAssignDefaultState, t.TaskAllocateObjEnum }).FirstOrDefaultAsync()).IfNullThrowException();
|
var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.ReadingType, t.IsFollowVisitAutoAssign, t.IsFollowGlobalVisitAutoAssign, t.FollowGlobalVisitAutoAssignDefaultState, t.FollowVisitAutoAssignDefaultState, t.TaskAllocateObjEnum }).FirstOrDefaultAsync()).IfNullThrowException();
|
||||||
|
|
||||||
var dbMaxCode = _visitTaskRepository.Where(t => t.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max();
|
var dbMaxCode = _visitTaskRepository.Where(t => t.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max();
|
||||||
|
|
||||||
|
@ -56,12 +58,15 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
int currentMaxCodeInt = cacheMaxCodeInt > dbMaxCode ? cacheMaxCodeInt : dbMaxCode;
|
int currentMaxCodeInt = cacheMaxCodeInt > dbMaxCode ? cacheMaxCodeInt : dbMaxCode;
|
||||||
|
|
||||||
var subjectVisitList = _subjectVisitRepository.Where(t => subjectVisitIdList.Contains(t.Id)).Select(t => new {t.Id, t.SubjectId, t.IsUrgent, t.BlindName, t.VisitName, t.CheckPassedTime, t.TrialId }).Distinct().ToList();
|
var subjectVisitList = _subjectVisitRepository.Where(t => subjectVisitIdList.Contains(t.Id)).Select(t => new { t.Id, t.SubjectId, t.IsUrgent, t.BlindName, t.VisitName, t.CheckPassedTime, t.TrialId }).Distinct().ToList();
|
||||||
|
|
||||||
|
|
||||||
foreach (var subjectVisit in subjectVisitList)
|
foreach (var subjectVisit in subjectVisitList)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId).Select(u => new { u.DoctorUserId, u.ArmEnum).ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
if (trialConfig.ReadingType == ReadingMethod.Double)
|
if (trialConfig.ReadingType == ReadingMethod.Double)
|
||||||
{
|
{
|
||||||
//每个访视 根据项目配置生成任务 双审生成两个
|
//每个访视 根据项目配置生成任务 双审生成两个
|
||||||
|
@ -107,21 +112,23 @@ namespace IRaCIS.Core.Application.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (trialConfig.TaskAllocateObjEnum == TaskAllocateObj.Subject )
|
if (trialConfig.TaskAllocateObjEnum == TaskAllocateObj.Subject)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (trialConfig.IsFollowVisitAutoAssign )
|
if (trialConfig.IsFollowVisitAutoAssign)
|
||||||
{
|
{
|
||||||
var defaultState = trialConfig.FollowVisitAutoAssignDefaultState==TaskAllocateDefaultState.InitAllocated?TaskState.InitAllocated:TaskState.Allocated;
|
var defaultState = trialConfig.FollowVisitAutoAssignDefaultState == TaskAllocateDefaultState.InitAllocated ? TaskState.InitAllocated : TaskState.Allocated;
|
||||||
|
|
||||||
|
|
||||||
task1.TaskState = defaultState;
|
task1.TaskState = defaultState;
|
||||||
task2.TaskState = defaultState;
|
task2.TaskState = defaultState;
|
||||||
|
|
||||||
|
|
||||||
|
#region 验证历史任务
|
||||||
|
|
||||||
var allocateSubjectArmList = _visitTaskRepository.Where(t => t.SubjectId == subjectVisit.SubjectId && t.TrialId == subjectVisit.TrialId && t.DoctorUserId != null).Select(t => new { t.DoctorUserId, t.ArmEnum }).Distinct().ToList();
|
var allocateSubjectArmList = _visitTaskRepository.Where(t => t.SubjectId == subjectVisit.SubjectId && t.TrialId == subjectVisit.TrialId && t.DoctorUserId != null).Select(t => new { t.DoctorUserId, t.ArmEnum }).Distinct().ToList();
|
||||||
|
|
||||||
|
|
||||||
//不是初次分配 直接分配给Subject 之前的医生
|
//不是初次分配 直接分配给Subject 之前的医生
|
||||||
if (allocateSubjectArmList.Count != 0)
|
if (allocateSubjectArmList.Count != 0)
|
||||||
{
|
{
|
||||||
|
@ -138,10 +145,20 @@ namespace IRaCIS.Core.Application.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//分配给对应Arm的人
|
|
||||||
task1.DoctorUserId = allocateSubjectArmList.FirstOrDefault(t => t.ArmEnum == 1).DoctorUserId;
|
|
||||||
task2.DoctorUserId = allocateSubjectArmList.FirstOrDefault(t => t.ArmEnum == 2).DoctorUserId;
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
//分配给对应Arm的人
|
||||||
|
task1.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 1).DoctorUserId;
|
||||||
|
task2.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 2).DoctorUserId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//找到配置规则表 进行分配
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//后续Subect 不自动分配 不处理
|
//后续Subect 不自动分配 不处理
|
||||||
|
@ -159,7 +176,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
task1.AllocateTime = DateTime.Now;
|
task1.AllocateTime = DateTime.Now;
|
||||||
task2.AllocateTime = DateTime.Now;
|
task2.AllocateTime = DateTime.Now;
|
||||||
|
@ -219,7 +236,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
//不是初次分配
|
//不是初次分配
|
||||||
if (allocateSubjectArmList.Count != 0)
|
if (allocateSubjectArmList.Count != 0)
|
||||||
{
|
{
|
||||||
singleTask.DoctorUserId = allocateSubjectArmList.FirstOrDefault(t => t.ArmEnum == 0).DoctorUserId;
|
singleTask.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 0).DoctorUserId;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue