重阅任务产生和确认提交
parent
a9022b4c02
commit
97b01343d7
|
@ -143,6 +143,11 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
/// 阅片期
|
||||
/// </summary>
|
||||
public List<ReadingGenerataTaskDTO> ReadingGenerataTaskList= new List<ReadingGenerataTaskDTO>();
|
||||
|
||||
|
||||
//重阅 产生任务
|
||||
|
||||
public List<VisitTask> ReReadingTaskList = new List<VisitTask>();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
public Guid? OriginalReReadingId { get; set; }
|
||||
}
|
||||
|
||||
public class IRUnReadSubjectQuery:PageInput
|
||||
public class IRUnReadSubjectQuery : PageInput
|
||||
{
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
|
@ -271,12 +271,12 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
[JsonIgnore]
|
||||
public bool IsJudge { get; set; }
|
||||
|
||||
public bool IsConfirmed => DoctorUserList.Where(t=> IsJudge? t.ArmEnum==Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).All(t => t.IsConfirmed)
|
||||
public bool IsConfirmed => DoctorUserList.Where(t => IsJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).All(t => t.IsConfirmed)
|
||||
&& DoctorUserList.Where(t => IsJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Count() > 0;
|
||||
|
||||
public List<Guid> DoctorUserIdList => DoctorUserList.Select(t => t.DoctorUserId).ToList();
|
||||
|
||||
//.ForEach(t => t.HistoryDoctorList = TotalDoctorUserList.Where(c => (Guid?)t.Id == c.OrignalSubjectUserId).ToList())
|
||||
//.ForEach(t => t.HistoryDoctorList = TotalDoctorUserList.Where(c => (Guid?)t.Id == c.OrignalSubjectUserId).ToList())
|
||||
public List<AssignDoctorView> DoctorUserList => TotalDoctorUserList.Where(t => t.IsConfirmed && t.OrignalSubjectUserId == null).ToList()
|
||||
;
|
||||
|
||||
|
@ -412,6 +412,31 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
}
|
||||
|
||||
|
||||
public class ApplyReReadingCommand
|
||||
{
|
||||
|
||||
|
||||
public List<Guid> TaskIdList { get; set; }
|
||||
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public RequestReReadingType RequestReReadingTypeEnum { get; set; }
|
||||
|
||||
public string RequestReReadingReason { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
public class ConfirmReReadingCommand
|
||||
{
|
||||
public List<Guid> TaskIdList { get; set; }
|
||||
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public RequestReReadingResult RequestReReadingResultEnum { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public enum TaskOptType
|
||||
{
|
||||
Assign = 1,
|
||||
|
|
|
@ -199,9 +199,6 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
#endregion
|
||||
|
||||
await _visitTaskRepository.AddAsync(task1);
|
||||
await _visitTaskRepository.AddAsync(task2);
|
||||
|
||||
}
|
||||
else if (trialConfig.ReadingType == ReadingMethod.Single)
|
||||
{
|
||||
|
@ -222,7 +219,6 @@ namespace IRaCIS.Core.Application.Service
|
|||
ReadingCategory = ReadingCategory.Visit
|
||||
});
|
||||
|
||||
singleTask.AllocateTime = DateTime.Now;
|
||||
|
||||
currentMaxCodeInt = currentMaxCodeInt + 1;
|
||||
|
||||
|
@ -260,6 +256,8 @@ namespace IRaCIS.Core.Application.Service
|
|||
singleTask.TaskState = defaultState;
|
||||
|
||||
singleTask.DoctorUserId = assignConfigList.FirstOrDefault(t => t.ArmEnum == 0).DoctorUserId;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,16 +270,36 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
}
|
||||
|
||||
singleTask.AllocateTime = DateTime.Now;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
await _visitTaskRepository.AddAsync(singleTask);
|
||||
}
|
||||
|
||||
|
||||
await _subjectVisitRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.Id == subjectVisit.Id, u => new SubjectVisit() { IsVisitTaskGenerated = true });
|
||||
}
|
||||
break;
|
||||
case ReadingCategory.ReReading:
|
||||
|
||||
foreach (var reReadingVisitTask in generateTaskCommand.ReReadingTaskList)
|
||||
{
|
||||
reReadingVisitTask.OriginalReReadingId = reReadingVisitTask.Id;
|
||||
reReadingVisitTask.OriginalReReadingId = Guid.Empty;
|
||||
reReadingVisitTask. Code = currentMaxCodeInt + 1;
|
||||
reReadingVisitTask.TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask));
|
||||
|
||||
//是否增加任务类别
|
||||
|
||||
currentMaxCodeInt = currentMaxCodeInt + 1;
|
||||
|
||||
_provider.Set<int>($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 1, TimeSpan.FromMinutes(30));
|
||||
|
||||
await _visitTaskRepository.AddAsync(reReadingVisitTask);
|
||||
}
|
||||
|
||||
break;
|
||||
case ReadingCategory.Judge:
|
||||
var firstTask = await _visitTaskRepository.Where(x => generateTaskCommand.JudgeVisitTaskIdList.Contains(x.Id)).FirstOrDefaultAsync();
|
||||
|
|
|
@ -230,7 +230,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<(PageOutput<IRUnReadSubjectView>,object)> GetIRUnReadSubjectTaskList(IRUnReadSubjectQuery iRUnReadSubjectQuery)
|
||||
public async Task<(PageOutput<IRUnReadSubjectView>, object)> GetIRUnReadSubjectTaskList(IRUnReadSubjectQuery iRUnReadSubjectQuery)
|
||||
{
|
||||
var trialId = iRUnReadSubjectQuery.TrialId;
|
||||
|
||||
|
@ -267,16 +267,17 @@ namespace IRaCIS.Core.Application.Service
|
|||
.Where(t => t.UnReadTaskCount > 0);
|
||||
|
||||
|
||||
var result= await subjectQuery.ToPagedListAsync(iRUnReadSubjectQuery.PageIndex, iRUnReadSubjectQuery.PageSize, String.IsNullOrEmpty(iRUnReadSubjectQuery.SortField) ? nameof(IRUnReadSubjectView.SubjectId) : iRUnReadSubjectQuery.SortField, iRUnReadSubjectQuery.Asc);
|
||||
return (result, new {
|
||||
var result = await subjectQuery.ToPagedListAsync(iRUnReadSubjectQuery.PageIndex, iRUnReadSubjectQuery.PageSize, String.IsNullOrEmpty(iRUnReadSubjectQuery.SortField) ? nameof(IRUnReadSubjectView.SubjectId) : iRUnReadSubjectQuery.SortField, iRUnReadSubjectQuery.Asc);
|
||||
return (result, new
|
||||
{
|
||||
RandomReadInfo = new IRUnReadOutDto(),
|
||||
IsReadingTaskViewInOrder =isReadingTaskViewInOrder,
|
||||
IsReadingTaskViewInOrder = isReadingTaskViewInOrder,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var taskQuery = _visitTaskRepository.Where(x => x.TrialId == iRUnReadSubjectQuery.TrialId&&x.DoctorUserId == _userInfo.Id);
|
||||
var taskQuery = _visitTaskRepository.Where(x => x.TrialId == iRUnReadSubjectQuery.TrialId && x.DoctorUserId == _userInfo.Id);
|
||||
|
||||
IRUnReadOutDto iRUnReadOut = new IRUnReadOutDto()
|
||||
{
|
||||
|
@ -287,15 +288,15 @@ namespace IRaCIS.Core.Application.Service
|
|||
UnReadJudgeTaskCount = await taskQuery.Where(x => x.ReadingCategory == ReadingCategory.Judge && x.ReadingTaskState != ReadingTaskState.HaveSigned).CountAsync(),
|
||||
UnReadTaskCount = await taskQuery.Where(x => x.ReadingCategory != ReadingCategory.Judge && x.ReadingTaskState != ReadingTaskState.HaveSigned).CountAsync(),
|
||||
};
|
||||
|
||||
|
||||
return (new PageOutput<IRUnReadSubjectView>(), new
|
||||
{
|
||||
IsReadingTaskViewInOrder = isReadingTaskViewInOrder,
|
||||
RandomReadInfo= iRUnReadOut,
|
||||
RandomReadInfo = iRUnReadOut,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
@ -373,7 +374,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -418,7 +419,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
await _subjectUserRepository.BatchDeleteNoTrackingAsync(t => doctorUserIdList.Contains(t.DoctorUserId) && assginSubjectDoctorCommand.SubjectIdList.Contains(t.SubjectId) && t.ArmEnum != Arm.JudgeArm);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
foreach (var subjectId in assginSubjectDoctorCommand.SubjectIdList)
|
||||
|
@ -428,7 +429,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
var armEnum = assginSubjectDoctorCommand.DoctorUserIdArmList.Where(t => t.DoctorUserId == doctorUserId).First().ArmEnum;
|
||||
|
||||
|
||||
|
||||
if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum != armEnum))
|
||||
{
|
||||
throw new BusinessValidationFailedException("有Subject 在其他Arm组已有该医生,不允许在新的组添加该医生");
|
||||
|
@ -512,7 +513,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
//将关系确认
|
||||
if (assignConfirmCommand.SubjectDoctorUserList.Count == 0)
|
||||
{
|
||||
await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed==false && t.OrignalSubjectUserId == null, u => new SubjectUser() { IsConfirmed = true });
|
||||
await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.OrignalSubjectUserId == null, u => new SubjectUser() { IsConfirmed = true });
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -522,7 +523,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
var taskList = _visitTaskRepository.Where(t => t.TrialId == assignConfirmCommand.TrialId && t.DoctorUserId == null, true)
|
||||
.WhereIf(subjectIdList.Count() > 0 && assignConfirmCommand.IsJudgeDoctor==false, t => subjectIdList.Contains(t.SubjectId) && t.Subject.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
|
||||
.WhereIf(subjectIdList.Count() > 0 && assignConfirmCommand.IsJudgeDoctor == false, t => subjectIdList.Contains(t.SubjectId) && t.Subject.SubjectDoctorList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
|
||||
.WhereIf(subjectIdList.Count() > 0 && assignConfirmCommand.IsJudgeDoctor, t => subjectIdList.Contains(t.SubjectId) && t.Subject.SubjectDoctorList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
|
||||
.ToList();
|
||||
|
||||
|
@ -531,7 +532,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
var subjectId = subjectTaskGroup.Key;
|
||||
|
||||
|
||||
|
||||
|
||||
//如果数据为空 那么就是确认所有已分配的
|
||||
List<DoctorArm> subjectDoctorIdArmList = new List<DoctorArm>();
|
||||
|
@ -541,7 +542,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
subjectDoctorIdArmList = _subjectUserRepository.Where(t => t.SubjectId == subjectId).Select(t => new DoctorArm() { DoctorUserId = t.DoctorUserId, ArmEnum = t.ArmEnum }).ToList();
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -567,7 +568,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
await _readModuleRepository.BatchUpdateNoTrackingAsync(t => t.Id == task.SouceReadModuleId, u => new ReadModule() { ReadingStatus = ReadingStatusEnum.ImageReading });
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -609,12 +610,13 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
//获取 已产生任务的Subject 目前分配情况
|
||||
var subjectList = _subjectRepository.Where(t => t.TrialId == trialId)
|
||||
.WhereIf(isJudge==false,t => t.SubjectVisitTaskList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
|
||||
.WhereIf(isJudge , t => t.SubjectVisitTaskList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
|
||||
.Select(t => new {
|
||||
.WhereIf(isJudge == false, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum != Arm.JudgeArm).Any())
|
||||
.WhereIf(isJudge, t => t.SubjectVisitTaskList.Where(t => t.ArmEnum == Arm.JudgeArm).Any())
|
||||
.Select(t => new
|
||||
{
|
||||
SubjectId = t.Id,
|
||||
DoctorUserList = t.SubjectDoctorList.Where(t => isJudge? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Select(t => new { t.DoctorUserId, t.ArmEnum }),
|
||||
IsApplyed = t.SubjectDoctorList.Where(t => isJudge? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).SelectMany(t=>t.SubjectArmVisitTaskList).Any(c => c.DoctorUserId != null)
|
||||
DoctorUserList = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Select(t => new { t.DoctorUserId, t.ArmEnum }),
|
||||
IsApplyed = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).SelectMany(t => t.SubjectArmVisitTaskList).Any(c => c.DoctorUserId != null)
|
||||
}).ToList();
|
||||
|
||||
//已产生任务的Subject数量(裁判情况下,就是产生裁判任务Subject 的数量)
|
||||
|
@ -622,7 +624,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
//获取医生列表(裁判是裁判的医生列表)
|
||||
var waitAllocationDoctorList = _taskAllocationRuleRepository.Where(t => t.TrialId == trialId && t.IsEnable)
|
||||
.Where(t=> t.IsJudgeDoctor == isJudge)
|
||||
.Where(t => t.IsJudgeDoctor == isJudge)
|
||||
.Select(t => new AutoAssignResultDTO() { DoctorUserId = t.DoctorUserId, PlanReadingRatio = t.PlanReadingRatio, SubjectCount = subjectCount })
|
||||
.ToList();
|
||||
|
||||
|
@ -812,9 +814,9 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
if (visitTask.SourceSubjectVisitId != null)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
else if(visitTask.SouceReadModuleId != null)
|
||||
else if (visitTask.SouceReadModuleId != null)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -823,7 +825,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
throw new BusinessValidationFailedException("出现脏数据 任务来源字段没有值");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
visitTask.AllocateTime = DateTime.Now;
|
||||
visitTask.DoctorUserId = assignSubjectTaskToDoctorCommand.DoctorUserId;
|
||||
|
@ -866,5 +868,71 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 申请重阅 1:IR 2:PM
|
||||
/// </summary>
|
||||
/// <param name="applyReReadingCommand"></param>
|
||||
/// <param name="_visitTaskCommonService"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public async Task<IResponseOutput> ApplyReReading(ApplyReReadingCommand applyReReadingCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
|
||||
{
|
||||
var taskList = await _visitTaskRepository.Where(t => applyReReadingCommand.TaskIdList.Contains(t.Id), true).ToListAsync();
|
||||
|
||||
var reReadingTaskList = taskList.Clone();
|
||||
|
||||
foreach (var task in taskList)
|
||||
{
|
||||
task.IsReReading = true;
|
||||
task.RequestReReadingReason = applyReReadingCommand.RequestReReadingReason;
|
||||
task.RequestReReadingType = applyReReadingCommand.RequestReReadingTypeEnum;
|
||||
task.RequestReReadingTime = DateTime.Now;
|
||||
task.RequestReReadingUserId = _userInfo.Id;
|
||||
}
|
||||
|
||||
await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
|
||||
{
|
||||
TrialId = applyReReadingCommand.TrialId,
|
||||
ReadingCategory = ReadingCategory.ReReading,
|
||||
ReReadingTaskList = reReadingTaskList
|
||||
});
|
||||
|
||||
//产生新的任务
|
||||
|
||||
await _visitTaskRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 确认重阅与否 1同意 2 拒绝
|
||||
/// </summary>
|
||||
/// <param name="agreeReReadingCommand"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[UnitOfWork]
|
||||
public async Task<IResponseOutput> ConfirmReReading(ConfirmReReadingCommand agreeReReadingCommand)
|
||||
{
|
||||
//var taskList = await _visitTaskRepository.Where(t => agreeReReadingCommand.TaskIdList.Contains(t.Id), true).ToListAsync();
|
||||
|
||||
//foreach (var task in taskList)
|
||||
//{
|
||||
// task.RequestReReadingResultEnum = agreeReReadingCommand.RequestReReadingResultEnum;
|
||||
// task.RequestReReadingConfirmUserId = _userInfo.Id;
|
||||
//}
|
||||
//await _visitTaskRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(t => agreeReReadingCommand.TaskIdList.Contains(t.Id), u => new VisitTask()
|
||||
{
|
||||
RequestReReadingResultEnum = agreeReReadingCommand.RequestReReadingResultEnum,
|
||||
RequestReReadingConfirmUserId = _userInfo.Id
|
||||
}, true);
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ namespace IRaCIS.Core.Domain.Share
|
|||
Oncology=5,
|
||||
|
||||
|
||||
|
||||
ReReading=6,
|
||||
}
|
||||
|
||||
public enum TaskState
|
||||
|
|
|
@ -171,7 +171,13 @@ namespace IRaCIS.Core.Domain.Models
|
|||
|
||||
public string RequestReReadingReason { get; set; } = string.Empty;
|
||||
|
||||
public Guid? RequestReReadingUserId { get; set; }
|
||||
|
||||
public User RequestReReadingUser { get; set; }
|
||||
|
||||
public Guid? RequestReReadingConfirmUserId { get; set; }
|
||||
|
||||
public User RequestReReadingConfirmUser { get; set; }
|
||||
|
||||
public RequestReReadingResult RequestReReadingResultEnum { get; set; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue