修改 应用到任务
parent
1586e93acf
commit
d8120a2d85
|
@ -116,6 +116,8 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public bool IsAssignDoctorApplyedTask => DoctorUserList.All(t=>t.IsAssignDoctorApplyedTask);
|
||||
|
||||
public List<Guid> DoctorUserIdList => DoctorUserList.Select(t => t.DoctorUserId).ToList();
|
||||
|
||||
public List<AssignDoctorView> DoctorUserList { get; set; } = new List<AssignDoctorView>();
|
||||
}
|
||||
|
||||
|
@ -123,6 +125,8 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public class AssignDoctorView
|
||||
{
|
||||
public Guid DoctorUserId { get; set; }
|
||||
|
||||
public string UserCode { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string FullName { get; set; }
|
||||
|
|
|
@ -153,18 +153,39 @@ namespace IRaCIS.Core.Application.Service
|
|||
[UnitOfWork]
|
||||
public async Task<IResponseOutput> ManualAssignDoctorApplyTask(AssignConfirmCommand assignConfirmCommand)
|
||||
{
|
||||
var trialId= assignConfirmCommand.TrialId;
|
||||
|
||||
//获取项目配置 判断应该分配几个医生
|
||||
//var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.ReadingType, t.IsFollowVisitAutoAssign, t.IsFollowGlobalVisitAutoAssign, t.FollowGlobalVisitAutoAssignDefaultState, t.TaskAllocateObjEnum }).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
|
||||
|
||||
//需要确认的Subject
|
||||
var subjectIdList = assignConfirmCommand.SubjectDoctorUserList.Select(t => t.SubjectId).ToList();
|
||||
|
||||
var taskList = _visitTaskRepository.Where(t => t.TrialId == assignConfirmCommand.TrialId && t.DoctorUserId == null, true)
|
||||
.WhereIf(subjectIdList.Count() > 0, t => subjectIdList.Contains(t.SubjectId)).ToList();
|
||||
.WhereIf(subjectIdList.Count() > 0 /*&& trialConfig.ReadingType==ReadingMethod.Double*/, t => subjectIdList.Contains(t.SubjectId) && t.Subject.SubjectDoctorList.Any())
|
||||
.ToList();
|
||||
|
||||
|
||||
foreach (var subjectTaskGroup in taskList.GroupBy(t => t.SubjectId))
|
||||
{
|
||||
var subjectId = subjectTaskGroup.Key;
|
||||
|
||||
var subjectDoctorIdList = assignConfirmCommand.SubjectDoctorUserList.Where(t => t.SubjectId == subjectId).First().DoctorUserIdList;
|
||||
//如果数据为空 那么就是确认所有已分配的
|
||||
List<Guid> subjectDoctorIdList = new List<Guid>();
|
||||
|
||||
if (assignConfirmCommand.SubjectDoctorUserList.Count == 0)
|
||||
{
|
||||
|
||||
subjectDoctorIdList = _subjectUserRepository.Where(t => t.SubjectId == subjectId).Select(t => t.DoctorUserId).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
subjectDoctorIdList = assignConfirmCommand.SubjectDoctorUserList.Where(t => t.SubjectId == subjectId).First().DoctorUserIdList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
foreach (var task in subjectTaskGroup.OrderBy(t => t.ArmEnum).ToList())
|
||||
{
|
||||
|
@ -197,6 +218,9 @@ namespace IRaCIS.Core.Application.Service
|
|||
task.TaskState = TaskState.Allocated;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
await _visitTaskRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
|
|
Loading…
Reference in New Issue