分配规则修改

Uat_Study
hang 2022-07-22 13:12:08 +08:00
parent e1a778c93d
commit b2f093f79d
13 changed files with 262 additions and 215 deletions

View File

@ -184,7 +184,7 @@
</member> </member>
<member name="M:IRaCIS.Core.Application.Service.Allocation.VisitTaskService.BatchAssignDoctorToSubject(IRaCIS.Core.Application.ViewModel.BatchAssignDoctorToSubjectCommand)"> <member name="M:IRaCIS.Core.Application.Service.Allocation.VisitTaskService.BatchAssignDoctorToSubject(IRaCIS.Core.Application.ViewModel.BatchAssignDoctorToSubjectCommand)">
<summary> <summary>
一次性分配所有医生 批量分配(添加),后端现在没限制
</summary> </summary>
<param name="command"></param> <param name="command"></param>
<returns></returns> <returns></returns>

View File

@ -91,16 +91,34 @@ namespace IRaCIS.Core.Application.ViewModel
public bool IsJudgeDoctor { get; set; } 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> ///<summary> TaskAllocationRuleAddOrEdit 列表查询参数模型</summary>
public class TaskAllocationRuleAddOrEdit public class TaskAllocationRuleAddOrEdit
{ {
public Guid? Id { get; set; } public Guid? Id { get; set; }
public Guid TrialId { 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 IsEnable { get; set; }
public bool IsJudgeDoctor { get; set; }
public string Note { get; set; } = string.Empty; public string Note { get; set; } = string.Empty;
} }
@ -110,6 +128,9 @@ namespace IRaCIS.Core.Application.ViewModel
public ReadingMethod ReadingType { get; set; } public ReadingMethod ReadingType { get; set; }
[NotDefault]
public Guid EnrollId { get; set; }
public Guid? DoctorUserId { get; set; } public Guid? DoctorUserId { get; set; }
public string UserCode { get; set; } public string UserCode { get; set; }

View File

@ -321,7 +321,7 @@ namespace IRaCIS.Core.Application.ViewModel
public Guid TrialId { get; set; } public Guid TrialId { get; set; }
public Guid SubjectId { get; set; } public List<Guid> SubjectIdList { get; set; }
public List<DoctorArm> DoctorArmList { get; set; } public List<DoctorArm> DoctorArmList { get; set; }

View File

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

View File

@ -34,16 +34,49 @@ namespace IRaCIS.Core.Application.Service
_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();
return list;
}
var trialTaskConfig= _trialRepository.Where(t=>t.Id==queryTaskAllocationRule.TrialId).ProjectTo<TrialTaskConfigView>(_mapper.ConfigurationProvider, new { isJudgeDoctor = queryTaskAllocationRule.IsJudgeDoctor }).FirstOrDefault();
return (await taskAllocationRuleQueryable.ToListAsync(), trialTaskConfig);
public async Task<IResponseOutput> AddOrUpdateTaskAllocationRule(TaskAllocationRuleAddOrEdit addOrEditTaskAllocationRule)
{
var verifyExp1 = new EntityVerifyExp<TaskAllocationRule>()
{
VerifyExp = t => t.EnrollId == addOrEditTaskAllocationRule.EnrollId && t.TrialId == addOrEditTaskAllocationRule.TrialId,
VerifyMsg = "已有该医生配置,不允许继续增加"
};
var entity = await _taskAllocationRuleRepository.InsertOrUpdateAsync(addOrEditTaskAllocationRule, true, verifyExp1);
return ResponseOutput.Ok(entity.Id.ToString());
}
[HttpDelete("{taskAllocationRuleId:guid}")]
public async Task<IResponseOutput> DeleteTaskAllocationRule(Guid taskAllocationRuleId)
{
if (await _taskAllocationRuleRepository.Where(t => t.Id == taskAllocationRuleId).AnyAsync(t => t.DoctorVisitTaskList.Any()))
{
return ResponseOutput.NotOk("已分配任务给该医生,不允许删除");
}
var success = await _taskAllocationRuleRepository.DeleteFromQueryAsync(t => t.Id == taskAllocationRuleId, true);
return ResponseOutput.Ok();
} }
@ -62,35 +95,19 @@ namespace IRaCIS.Core.Application.Service
public async Task<IResponseOutput> AddOrUpdateTaskAllocationRule(TaskAllocationRuleAddOrEdit addOrEditTaskAllocationRule) [HttpPost]
public async Task<(List<DoctorVisitTaskStatView>, object)> GetTaskAllocationRuleList(TaskAllocationRuleQuery queryTaskAllocationRule)
{ {
var verifyExp1 = new EntityVerifyExp<TaskAllocationRule>() var taskAllocationRuleQueryable = _taskAllocationRuleRepository.Where(t => t.TrialId == queryTaskAllocationRule.TrialId /*&& t.IsJudgeDoctor == queryTaskAllocationRule.IsJudgeDoctor*/)
{ .ProjectTo<DoctorVisitTaskStatView>(_mapper.ConfigurationProvider);
VerifyExp = t => t.DoctorUserId == addOrEditTaskAllocationRule.DoctorUserId && t.TrialId== addOrEditTaskAllocationRule.TrialId && t.IsJudgeDoctor==addOrEditTaskAllocationRule.IsJudgeDoctor,
VerifyMsg = "已有该医生配置,不允许继续增加"
};
var entity = await _taskAllocationRuleRepository.InsertOrUpdateAsync(addOrEditTaskAllocationRule, true, verifyExp1);
return ResponseOutput.Ok(entity.Id.ToString()); var trialTaskConfig = _trialRepository.Where(t => t.Id == queryTaskAllocationRule.TrialId).ProjectTo<TrialTaskConfigView>(_mapper.ConfigurationProvider, new { isJudgeDoctor = queryTaskAllocationRule.IsJudgeDoctor }).FirstOrDefault();
return (await taskAllocationRuleQueryable.ToListAsync(), trialTaskConfig);
} }
[HttpDelete("{taskAllocationRuleId:guid}/{isJudgeDoctor:bool}")]
public async Task<IResponseOutput> DeleteTaskAllocationRule( Guid taskAllocationRuleId, bool isJudgeDoctor )
{
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))
{
return ResponseOutput.NotOk("已分配任务给该医生,不允许删除");
}
var success = await _taskAllocationRuleRepository.DeleteFromQueryAsync(t => t.Id == taskAllocationRuleId, true);
return ResponseOutput.Ok();
}
/// <summary> /// <summary>
/// 获取项目下 医生账户信息下拉 /// 获取项目下 医生账户信息下拉
/// </summary> /// </summary>
@ -106,6 +123,7 @@ namespace IRaCIS.Core.Application.Service
{ {
TrialId = enroll.TrialId, TrialId = enroll.TrialId,
ReadingType = enroll.Trial.ReadingType, ReadingType = enroll.Trial.ReadingType,
EnrollId =enroll.Id,
DoctorUserId = user.Id, DoctorUserId = user.Id,
FullName = user.FullName, FullName = user.FullName,
UserCode = user.UserCode, UserCode = user.UserCode,

View File

@ -76,15 +76,36 @@ namespace IRaCIS.Core.Application.Service.Allocation
} }
/// <summary> /// <summary>
/// /// 一次性分配所有医生 批量分配(添加),后端现在没限制
/// </summary> /// </summary>
/// <param name="command"></param> /// <param name="command"></param>
/// <returns></returns> /// <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(); 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
//}
@ -1198,15 +1219,16 @@ namespace IRaCIS.Core.Application.Service.Allocation
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 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) && t.OriginalReReadingTask.ReadingTaskState == ReadingTaskState.HaveSigned && t.OriginalReReadingTask.VisitTaskNum > origenalTask.VisitTaskNum && t.RequestReReadingResultEnum == RequestReReadingResult.Default)
// .Where(t => t.OriginalReReadingTask.IsAnalysisCreate == origenalTask.IsAnalysisCreate); .Where(t => t.OriginalReReadingTask.IsAnalysisCreate == origenalTask.IsAnalysisCreate);
//if(await query.AnyAsync()) if (await query.AnyAsync())
//{ {
// return ResponseOutput.NotOk("当前为有序阅片,当前访视之后,也申请了重阅 必须从后向前处理"); 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;
@ -1233,6 +1255,8 @@ namespace IRaCIS.Core.Application.Service.Allocation
// }); // });
//} //}
//PM申请 SPM / CPM审批 回退访视,在此不生成访视任务 //PM申请 SPM / CPM审批 回退访视,在此不生成访视任务
if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM)) if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM))
{ {
@ -1274,6 +1298,12 @@ namespace IRaCIS.Core.Application.Service.Allocation
influenceTask.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = t.Id }); 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 });
} }
//申请的访视 要不是重阅重置,要不就是失效 不会存在取消分配 //申请的访视 要不是重阅重置,要不就是失效 不会存在取消分配

View File

@ -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>() CreateMap<Subject, SubjectAssignStat>()
.ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.TrialSite.TrialSiteCode)) .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.TrialSite.TrialSiteCode))

View File

@ -392,6 +392,8 @@ namespace IRaCIS.Application.Services
{ {
await _trialUserRepository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId }); await _trialUserRepository.AddAsync(new TrialUser() { TrialId = trialId, UserId = userId });
await _enrollRepository.BatchUpdateNoTrackingAsync(t => t.Id == intoGroupItem.Id, u => new Enroll() { DoctorUserId = userId });
await _taskAllocationRuleRepository.AddAsync(new TaskAllocationRule() { TrialId = trialId, DoctorUserId = userId }); await _taskAllocationRuleRepository.AddAsync(new TaskAllocationRule() { TrialId = trialId, DoctorUserId = userId });
} }

View File

@ -63,7 +63,7 @@ namespace IRaCIS.Core.Domain.Models
public Arm ArmEnum { get; set; } public Arm ArmEnum { get; set; }
public bool IsConfirmed { get; set; } public bool IsConfirmed { get; set; } = true;
//该属性有值 说明该医生被替换了 分配的时候 要过滤掉 //该属性有值 说明该医生被替换了 分配的时候 要过滤掉
public Guid? OrignalSubjectUserId { get; set; } public Guid? OrignalSubjectUserId { get; set; }

View File

@ -19,77 +19,36 @@ namespace IRaCIS.Core.Domain.Models
{ {
public Trial Trial { get; set; } public Trial Trial { get; set; }
public Guid TrialId { get; set; } public Guid TrialId { get; set; }
/// <summary>
/// CreateUserId
/// </summary>
[Required]
public Guid CreateUserId { get; set; } public Guid CreateUserId { get; set; }
/// <summary>
/// CreateTime
/// </summary>
[Required]
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
/// <summary>
/// UpdateTime
/// </summary>
[Required]
public DateTime UpdateTime { get; set; } public DateTime UpdateTime { get; set; }
/// <summary>
/// UpdateUserId
/// </summary>
[Required]
public Guid UpdateUserId { get; set; } public Guid UpdateUserId { get; set; }
public int PlanSubjectCount { get; set; }
/// <summary> public bool IsEnable { get; set; }
/// 计划比率
/// </summary> public string Note { get; set; } = string.Empty;
[Required]
public int PlanReadingRatio { get; set; } public Guid EnrollId { get; set; }
public Enroll Enroll { get; set; }
//是否是裁判医生 裁判医生单独加入
public bool IsJudgeDoctor { get; set; }
public Guid DoctorUserId { get; set; } public Guid DoctorUserId { get; set; }
[ForeignKey("DoctorUserId")] [ForeignKey("DoctorUserId")]
public User DoctorUser { get; set; } public User DoctorUser { get; set; }
public int PlanReadingRatio { get; set; }
/// <summary>
/// IsEnable
/// </summary>
[Required]
public bool IsEnable { get; set; }
public string Note { get; set; } = string.Empty;
//是否是裁判医生 裁判医生单独加入
public bool IsJudgeDoctor {get;set;}
public List<VisitTask> DoctorVisitTaskList { get; set; } = new List<VisitTask>(); public List<VisitTask> DoctorVisitTaskList { get; set; } = new List<VisitTask>();
///// <summary>
///// Arm 组
///// </summary>
//[Required]
//public int GroupEnum { get; set; }
///// <summary>
///// 分配类型
///// </summary>
//[Required]
//public int AllocationObjectEnum { get; set; }
} }

View File

@ -165,7 +165,10 @@ namespace IRaCIS.Core.Domain.Models
public string DialogCloseReason { get; set; } = string.Empty; public string DialogCloseReason { get; set; } = string.Empty;
/// <summary>
/// 无效的
/// </summary>
public bool IsInvalid { get; set; }
} }
} }

View File

@ -7,8 +7,7 @@ namespace IRaCIS.Core.Domain.Models
[Table("Enroll")] [Table("Enroll")]
public partial class Enroll : Entity,IAuditUpdate,IAuditAdd public partial class Enroll : Entity,IAuditUpdate,IAuditAdd
{ {
[ForeignKey("TrialId")]
public virtual TaskConsistentRule TaskConsistentRule { get; set; }
[ForeignKey("TrialId")] [ForeignKey("TrialId")]
public virtual Trial Trial { get; set; } public virtual Trial Trial { get; set; }
@ -60,6 +59,15 @@ namespace IRaCIS.Core.Domain.Models
public int DoctorTrialState { get; set; } public int DoctorTrialState { get; set; }
/// <summary>
/// 生成账号 加入到项目中后 赋值
/// </summary>
public Guid? DoctorUserId { get; set; }
public User DoctorUser { get; set; }
public TaskAllocationRule TaskAllocationRule { get; set; }
public List<EnrollReadingCategory> EnrollReadingCategoryList { get; set; } public List<EnrollReadingCategory> EnrollReadingCategoryList { get; set; }
} }