修改裁判任务分配

Uat_Study
hang 2022-06-20 15:54:09 +08:00
parent 522d7eca07
commit 243cbec782
15 changed files with 143 additions and 59 deletions

View File

@ -3344,7 +3344,14 @@
</member>
<member name="M:IRaCIS.Core.Application.TrialConfigService.ConfigTrialReadingTaskViewRule(IRaCIS.Core.Application.Contracts.TrialReadingTaskViewConfig)">
<summary>
配置项目赌片规则信息
配置项目读片查看规则
</summary>
<param name="trialConfig"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.TrialConfigService.ConfigJudgeTaskAllocateRule(IRaCIS.Core.Application.Contracts.TrialJudgeTaskConfig)">
<summary>
配置项目 裁判任务 分配规则
</summary>
<param name="trialConfig"></param>
<returns></returns>

View File

@ -39,37 +39,42 @@ namespace IRaCIS.Core.Application.ViewModel
//该医生未应用Subject 数量 不是两者相减 跟批量勾选有关系
public int? WaitApplySelfSubjectCount { get; set; }
//该医生未应用的任务数
public int? WaitApplySelfTaskCount { get; set; }
//该医生已应用的任务数
public int? SelfApplyedTaskCount { get; set; }
//总共未应用的Subejct 数量
public int? WaitApplyTotalSubjectCount { get; set; }
public int? WaitApplyTotalTaskCount { get; set; }
//该医生已应用的任务数
public int? SelfApplyedTaskCount { get; set; }
//已分配但是未读片签名的数量
//已分配该医生但是未读片签名的数量
public int? SelfUndoTaskCount { get; set; }
//总共已应用 的Subject 数
public int? ApplyedTotalSubjectCount { get; set; }
//总共 已经应用的任务总数
public int? ApplyedTotalTaskCount { get; set; }
//系统 Subject数
public int? TotalSubjectCount { get; set; }
//总任务数
public int? TotalTaskCount { get; set; }
//总共 已经应用的任务总数
public int? ApplyedTotalTaskCount { get; set; }
@ -106,6 +111,8 @@ namespace IRaCIS.Core.Application.ViewModel
{
[NotDefault]
public Guid TrialId { get; set; }
public bool? IsJudgeDoctor { get; set; }
}
///<summary> TaskAllocationRuleAddOrEdit 列表查询参数模型</summary>
@ -116,6 +123,8 @@ namespace IRaCIS.Core.Application.ViewModel
public int PlanReadingRatio { get; set; }
public Guid DoctorUserId { get; set; }
public bool IsEnable { get; set; }
public bool IsJudgeDoctor { get; set; }
public string Note { get; set; } = string.Empty;
}

View File

@ -30,7 +30,7 @@ namespace IRaCIS.Core.Application.ViewModel
public string TaskCode { get; set; }
public bool IsUrgent { get; set; }
public int ArmEnum { get; set; }
public Arm ArmEnum { get; set; }
public Guid? DoctorUserId { get; set; }
@ -254,7 +254,7 @@ namespace IRaCIS.Core.Application.ViewModel
public DateTime? AssignTime { get; set; }
public int ArmEnum { get; set; }
public Arm ArmEnum { get; set; }
public bool IsAssignDoctorApplyedTask { get; set; }
}
@ -276,7 +276,7 @@ namespace IRaCIS.Core.Application.ViewModel
{
public Guid DoctorUserId { get; set; }
public int ArmEnum { get; set; }
public Arm ArmEnum { get; set; }
}
public class CancelSubjectAssignCommand
@ -304,7 +304,7 @@ namespace IRaCIS.Core.Application.ViewModel
{
public Guid SubjectId { get; set; }
public int ArmEnum { get; set; }
public Arm ArmEnum { get; set; }
}
@ -312,6 +312,8 @@ namespace IRaCIS.Core.Application.ViewModel
{
public Guid TrialId { get; set; }
public bool? IsJudgeDoctor { get; set; }
public List<Guid> SubjectIdList { get; set; } = new List<Guid>();
}

View File

@ -18,7 +18,7 @@ namespace IRaCIS.Core.Application.Interfaces
Task<IResponseOutput> AddOrUpdateTaskAllocationRule(TaskAllocationRuleAddOrEdit addOrEditTaskAllocationRule);
Task<IResponseOutput> DeleteTaskAllocationRule(Guid taskAllocationRuleId);
Task<IResponseOutput> DeleteTaskAllocationRule(Guid taskAllocationRuleId, bool isJudgeDoctor);
}

View File

@ -37,10 +37,11 @@ namespace IRaCIS.Core.Application.Service
public async Task<(List<TaskAllocationRuleView>,object)> GetTaskAllocationRuleList(TaskAllocationRuleQuery queryTaskAllocationRule)
{
var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t=>t.TrialId== queryTaskAllocationRule.TrialId)
.WhereIf(queryTaskAllocationRule.IsJudgeDoctor!=null ,t=>t.IsJudgeDoctor== queryTaskAllocationRule.IsJudgeDoctor)
.ProjectTo<TaskAllocationRuleView>(_mapper.ConfigurationProvider);
var trialTaskConfig= _trialRepository.Where(t=>t.Id==queryTaskAllocationRule.TrialId).ProjectTo<TrialTaskConfig>(_mapper.ConfigurationProvider).FirstOrDefault();
var trialTaskConfig= _trialRepository.Where(t=>t.Id==queryTaskAllocationRule.TrialId).ProjectTo<TrialTaskConfigView>(_mapper.ConfigurationProvider).FirstOrDefault();
return (await taskAllocationRuleQueryable.ToListAsync(), trialTaskConfig);
}
@ -54,6 +55,7 @@ namespace IRaCIS.Core.Application.Service
public async Task<List<TaskAllocationRuleView>> GetSubjectApplyDoctorTaskStatList(ApplySubjectCommand assignConfirmCommand)
{
var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t => t.TrialId == assignConfirmCommand.TrialId)
.WhereIf(assignConfirmCommand.IsJudgeDoctor != null, t => t.IsJudgeDoctor == assignConfirmCommand.IsJudgeDoctor)
.ProjectTo<TaskAllocationRuleView>(_mapper.ConfigurationProvider, new { subjectIdList = assignConfirmCommand.SubjectIdList });
return await taskAllocationRuleQueryable.ToListAsync();
@ -76,9 +78,14 @@ namespace IRaCIS.Core.Application.Service
}
[HttpDelete("{taskAllocationRuleId:guid}")]
public async Task<IResponseOutput> DeleteTaskAllocationRule(Guid taskAllocationRuleId)
[HttpDelete("{taskAllocationRuleId:guid}/{isJudgeDoctor:bool}")]
public async Task<IResponseOutput> DeleteTaskAllocationRule(Guid taskAllocationRuleId, bool isJudgeDoctor )
{
if(await _taskAllocationRuleRepository.Where(t => t.Id == taskAllocationRuleId && t.IsJudgeDoctor== isJudgeDoctor).AnyAsync(t => t.DoctorVisitTaskList.Count() > 0))
{
return ResponseOutput.NotOk("已分配任务给该医生,不允许删除");
}
var success = await _taskAllocationRuleRepository.DeleteFromQueryAsync(t => t.Id == taskAllocationRuleId, true);

View File

@ -78,7 +78,7 @@ namespace IRaCIS.Core.Application.Service
TaskBlindName = subjectVisit.BlindName,
TaskName = subjectVisit.VisitName,
CheckPassedTime = subjectVisit.CheckPassedTime,
ArmEnum = 1,//特殊
ArmEnum = Arm.DoubleReadingArm1,//特殊
Code = currentMaxCodeInt + 1,
SourceSubjectVisitId=subjectVisit.Id,
TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)),
@ -93,7 +93,7 @@ namespace IRaCIS.Core.Application.Service
TaskBlindName = subjectVisit.BlindName,
TaskName = subjectVisit.VisitName,
CheckPassedTime = subjectVisit.CheckPassedTime,
ArmEnum = 2,//特殊
ArmEnum = Arm.DoubleReadingArm2,//特殊
Code = currentMaxCodeInt + 2,
SourceSubjectVisitId = subjectVisit.Id,
TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 2, nameof(VisitTask)),
@ -117,10 +117,6 @@ namespace IRaCIS.Core.Application.Service
if (trialConfig.IsFollowVisitAutoAssign)
{
#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();
@ -140,7 +136,7 @@ namespace IRaCIS.Core.Application.Service
}
//手动分配的时候 如果只分配了Arm1 没有分配Arm2 就会有问题
if (!(allocateSubjectArmList.Any(t => t.ArmEnum == 1) && allocateSubjectArmList.Any(t => t.ArmEnum == 2)))
if (!(allocateSubjectArmList.Any(t => t.ArmEnum == Arm.DoubleReadingArm1) && allocateSubjectArmList.Any(t => t.ArmEnum == Arm.DoubleReadingArm2)))
{
throw new BusinessValidationFailedException("请确认是否改了配置或者手动分配时只分配了一个Arm ");
}
@ -155,8 +151,8 @@ namespace IRaCIS.Core.Application.Service
task2.TaskState = defaultState;
//分配给对应Arm的人
task1.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 1).DoctorUserId;
task2.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 2).DoctorUserId;
task1.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm1).DoctorUserId;
task2.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm1).DoctorUserId;
}
}
@ -210,7 +206,7 @@ namespace IRaCIS.Core.Application.Service
TaskBlindName = subjectVisit.BlindName,
TaskName = subjectVisit.VisitName,
CheckPassedTime = subjectVisit.CheckPassedTime,
ArmEnum = 0, //特殊
ArmEnum = Arm.DoubleReadingArm1, //特殊
Code = currentMaxCodeInt + 1,
SourceSubjectVisitId = subjectVisit.Id,
TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)),

View File

@ -79,7 +79,7 @@ namespace IRaCIS.Core.Application.Service
var pageList = await visitTaskQueryable.ToPagedListAsync(queryVisitTask.PageIndex, queryVisitTask.PageSize, queryVisitTask.SortField, queryVisitTask.Asc, string.IsNullOrWhiteSpace(queryVisitTask.SortField), defalutSortArray);
var trialTaskConfig = _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).ProjectTo<TrialTaskConfig>(_mapper.ConfigurationProvider).FirstOrDefault();
var trialTaskConfig = _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).ProjectTo<TrialTaskConfigView>(_mapper.ConfigurationProvider).FirstOrDefault();
return (pageList, trialTaskConfig);
}
@ -791,35 +791,35 @@ namespace IRaCIS.Core.Application.Service
.OrderByDescending(t => t.SubjectCount).FirstOrDefault()?.ArmEnum;
//存放医生分配的Arm
var doctor1Arm = 1;
var doctor2Arm = 2;
var doctor1Arm = Arm.DoubleReadingArm1;
var doctor2Arm = Arm.DoubleReadingArm2;
if ((preferredDoctor1Arm == null && preferredDoctor2Arm == null) ||
(preferredDoctor1Arm == null && preferredDoctor2Arm == 2) ||
(preferredDoctor1Arm == 1 && preferredDoctor2Arm == null) ||
(preferredDoctor1Arm == 1 && preferredDoctor2Arm == 2)
(preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm2) ||
(preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == null) ||
(preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == Arm.DoubleReadingArm2)
)
{
doctor1Arm = 1;
doctor2Arm = 2;
doctor1Arm = Arm.DoubleReadingArm1;
doctor2Arm = Arm.DoubleReadingArm2;
}
else if ((preferredDoctor1Arm == null && preferredDoctor2Arm == 1) ||
(preferredDoctor1Arm == 2 && preferredDoctor2Arm == 1) ||
(preferredDoctor1Arm == 2 && preferredDoctor2Arm == null))
else if ((preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm1) ||
(preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == Arm.DoubleReadingArm1) ||
(preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == null))
{
doctor1Arm = 2;
doctor2Arm = 1;
doctor1Arm = Arm.DoubleReadingArm2;
doctor2Arm = Arm.DoubleReadingArm1;
}
else if (preferredDoctor1Arm == 1 && preferredDoctor2Arm == 1)
else if (preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == Arm.DoubleReadingArm1)
{
doctor1Arm = 1;
doctor2Arm = 2;
doctor1Arm = Arm.DoubleReadingArm1;
doctor2Arm = Arm.DoubleReadingArm2;
}
else if (preferredDoctor1Arm == 2 && preferredDoctor2Arm == 2)
else if (preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == Arm.DoubleReadingArm2)
{
doctor1Arm = 2;
doctor2Arm = 1;
doctor1Arm = Arm.DoubleReadingArm2;
doctor2Arm = Arm.DoubleReadingArm1;
}
@ -861,10 +861,10 @@ namespace IRaCIS.Core.Application.Service
waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctor.DoctorUserId).SubjectArmList.Add(new SubjectArm()
{
SubjectId = subject.SubjectId,
ArmEnum = 0
ArmEnum = Arm.SingleReadingArm
});
await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctor.DoctorUserId, ArmEnum = 0, AssignTime = DateTime.Now });
await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctor.DoctorUserId, ArmEnum = Arm.SingleReadingArm, AssignTime = DateTime.Now });
}

View File

@ -144,10 +144,19 @@ namespace IRaCIS.Core.Application.Contracts
public TaskAllocateDefaultState FollowGlobalVisitAutoAssignDefaultState { get; set; }
}
public class TrialTaskConfigView : TrialTaskConfig
{
public ReadingTaskViewMethod ReadingTaskViewEnum { get; set; }
public bool IsReadingTaskViewInOrder { get; set; } = true;
public bool IsFollowJudgeTaskAutoAssign { get; set; }
public TaskAllocateDefaultState FollowJudgeTaskAutoAssignDefaultState { get; set; }
}
public class TrialReadingTaskViewConfig
@ -159,6 +168,16 @@ namespace IRaCIS.Core.Application.Contracts
public bool IsReadingTaskViewInOrder { get; set; } = true;
}
public class TrialJudgeTaskConfig
{
public Guid TrialId { get; set; }
public bool IsFollowJudgeTaskAutoAssign { get; set; }
public TaskAllocateDefaultState FollowJudgeTaskAutoAssignDefaultState { get; set; }
}
public class TrialUrgentConfig
{
public Guid TrialId { get; set; }

View File

@ -406,7 +406,7 @@ namespace IRaCIS.Core.Application
_mapper.Map(trialConfig, trialInfo);
if (_taskAllocationRuleRepository.Where(t => t.TrialId == trialConfig.TrialId && t.IsEnable).Sum(t => t.PlanReadingRatio) != 100)
if (_taskAllocationRuleRepository.Where(t => t.TrialId == trialConfig.TrialId && t.IsEnable && t.IsJudgeDoctor==false).Sum(t => t.PlanReadingRatio) != 100)
{
return ResponseOutput.NotOk("已启用医生比率不为百分之100");
}
@ -416,7 +416,7 @@ namespace IRaCIS.Core.Application
/// <summary>
/// 配置项目赌片规则信息
/// 配置项目读片查看规则
/// </summary>
/// <param name="trialConfig"></param>
/// <returns></returns>
@ -430,6 +430,28 @@ namespace IRaCIS.Core.Application
return ResponseOutput.Ok(await _trialRepository.SaveChangesAsync());
}
/// <summary>
/// 配置项目 裁判任务 分配规则
/// </summary>
/// <param name="trialConfig"></param>
/// <returns></returns>
[HttpPut]
public async Task<IResponseOutput> ConfigJudgeTaskAllocateRule(TrialJudgeTaskConfig trialConfig)
{
var trialInfo = (await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialConfig.TrialId)).IfNullThrowException();
_mapper.Map(trialConfig, trialInfo);
if (_taskAllocationRuleRepository.Where(t => t.TrialId == trialConfig.TrialId && t.IsEnable && t.IsJudgeDoctor ).Sum(t => t.PlanReadingRatio) != 100)
{
return ResponseOutput.NotOk("已启用医生比率不为百分之100");
}
return ResponseOutput.Ok(await _trialRepository.SaveChangesAsync());
}
}

View File

@ -18,11 +18,14 @@ namespace IRaCIS.Core.Application.Service
CreateMap<TrialTaskConfigView, Trial>().ForMember(d => d.Id, u => u.MapFrom(s => s.TrialId)).ReverseMap();
CreateMap<TrialTaskConfig, Trial>().ForMember(d => d.Id, u => u.MapFrom(s => s.TrialId)).ReverseMap();
CreateMap<TrialReadingTaskViewConfig, Trial>().ForMember(d => d.Id, u => u.MapFrom(s => s.TrialId)).ReverseMap();
CreateMap<TrialJudgeTaskConfig, Trial>().ForMember(d => d.Id, u => u.MapFrom(s => s.TrialId));
CreateMap<UserTrialCommand, TrialUser>();

View File

@ -29,6 +29,17 @@ namespace IRaCIS.Core.Domain.Share
Allocated = 2,
}
public enum Arm
{
SingleReadingArm=0,
DoubleReadingArm1 = 1,
DoubleReadingArm2 = 2,
JudgeArm=3
}
/// <summary>
/// 分配对象
/// </summary>

View File

@ -61,7 +61,7 @@ namespace IRaCIS.Core.Domain.Models
public User DoctorUser { get; set; }
public int ArmEnum { get; set; }
public Arm ArmEnum { get; set; }
public List<VisitTask> SubjectArmVisitTaskList { get; set; }

View File

@ -71,6 +71,10 @@ namespace IRaCIS.Core.Domain.Models
public string Note { get; set; } = string.Empty;
//是否是裁判医生 裁判医生单独加入
public bool IsJudgeDoctor {get;set;}
public List<VisitTask> DoctorVisitTaskList { get; set; } = new List<VisitTask>();

View File

@ -117,7 +117,7 @@ namespace IRaCIS.Core.Domain.Models
/// 0 代表 单重阅片 产生的任务 否则就是双重 任务 1 任务 2
/// </summary>
[Required]
public int ArmEnum { get; set; }
public Arm ArmEnum { get; set; }
//分配状态

View File

@ -328,6 +328,10 @@ namespace IRaCIS.Core.Domain.Models
//后续全局自动分配
public bool IsFollowGlobalVisitAutoAssign { get; set; }
public bool IsFollowJudgeTaskAutoAssign { get; set; }
public TaskAllocateDefaultState FollowJudgeTaskAutoAssignDefaultState { get; set; }
//后续访视自动分配默认状态
public TaskAllocateDefaultState FollowVisitAutoAssignDefaultState { get; set; }