SPM 列表

Uat_Study
hang 2022-07-18 10:16:02 +08:00
parent 5836b3c109
commit f0bf2f6b1e
1 changed files with 206 additions and 145 deletions

View File

@ -281,7 +281,6 @@ namespace IRaCIS.Core.Application.Service
public async Task<PageOutput<ReReadingTaskView>> GetSPMReReadingTaskList(VisitTaskQuery queryVisitTask)
{
var visitTaskQueryable = _visitTaskReReadingRepository.Where(t => t.RequestReReadingType == RequestReReadingType.TrialGroupApply && t.OriginalReReadingTask.IsAnalysisCreate == false)
.Where(t => t.OriginalReReadingTask.DoctorUserId == _userInfo.Id)
.Where(t => t.OriginalReReadingTask.TrialId == queryVisitTask.TrialId)
.WhereIf(queryVisitTask.RootReReadingTaskId != null, t => t.RootReReadingTaskId == queryVisitTask.RootReReadingTaskId || t.OriginalReReadingTaskId == queryVisitTask.RootReReadingTaskId)
.WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(queryVisitTask.TaskCode) || t.RootReReadingTask.TaskCode.Contains(queryVisitTask.TaskCode))
@ -355,23 +354,24 @@ namespace IRaCIS.Core.Application.Service
.Where(t => t.ReadingTaskState != ReadingTaskState.HaveSigned)
.GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode });
var visitTaskQuery = visitGroupQuery.Select(x=> new IRUnReadSubjectView() {
SubjectId=x.Key.SubjectId,
SubjectCode=x.Key.BlindSubjectCode==string.Empty?x.Key.Code: x.Key.BlindSubjectCode,
UnReadTaskCount=x.Count(),
UnReadTaskList=x.Select(u => new IRUnreadTaskView() { Id = u.Id, IsUrgent = u.IsUrgent, SuggesteFinishedTime = u.SuggesteFinishedTime }).ToList(),
});
var visitTaskQuery = visitGroupQuery.Select(x => new IRUnReadSubjectView()
{
SubjectId = x.Key.SubjectId,
SubjectCode = x.Key.BlindSubjectCode == string.Empty ? x.Key.Code : x.Key.BlindSubjectCode,
UnReadTaskCount = x.Count(),
UnReadTaskList = x.Select(u => new IRUnreadTaskView() { Id = u.Id, IsUrgent = u.IsUrgent, SuggesteFinishedTime = u.SuggesteFinishedTime }).ToList(),
});
var totalCount = visitGroupQuery.Count();
var currentPageData = await visitTaskQuery.OrderBy(x => x.SubjectCode).Skip((iRUnReadSubjectQuery.PageIndex - 1) * iRUnReadSubjectQuery.PageSize)
.Take(iRUnReadSubjectQuery.PageSize).ToListAsync();
var result = new PageOutput<IRUnReadSubjectView>()
{
PageSize = iRUnReadSubjectQuery.PageSize,
PageIndex = iRUnReadSubjectQuery.PageIndex,
TotalCount = totalCount,
CurrentPageData= currentPageData,
CurrentPageData = currentPageData,
};
/// 封装的方法有问题
@ -688,7 +688,7 @@ namespace IRaCIS.Core.Application.Service
.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())
//过滤掉 那些回退的subject
.Where(t=>! t.SubjectVisitList.Any(t=>t.IsPMBackOrReReading))
.Where(t => !t.SubjectVisitList.Any(t => t.IsPMBackOrReReading))
.Select(t => new
{
SubjectId = t.Id,
@ -917,7 +917,7 @@ namespace IRaCIS.Core.Application.Service
}
//PM 回退了 但是还没生成任务 当前任务编号前有访视进行了回退就不允许分配
if( await _subjectVisitRepository.AnyAsync(t=>t.SubjectId== visitTask.SubjectId && t.IsPMBackOrReReading &&t.VisitNum <= visitTask.VisitTaskNum))
if (await _subjectVisitRepository.AnyAsync(t => t.SubjectId == visitTask.SubjectId && t.IsPMBackOrReReading && t.VisitNum <= visitTask.VisitTaskNum))
{
return ResponseOutput.NotOk("该受试者有访视进入了退回流程,还未经过一致性核查通过,不允许分配");
}
@ -1092,46 +1092,6 @@ namespace IRaCIS.Core.Application.Service
if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree)
{
#region 废弃
////裁判任务 同意重阅
//if (origenalTask.ReadingCategory == ReadingCategory.Judge)
//{
// //项目组 SPM同意 IR PM同意
// if ((visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM) ||
// (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager)
// )
// {
// //产生的新任务
// await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
// {
// TrialId = trialId,
// ReadingCategory = GenerateTaskCategory.ReReading,
// ReReadingTask = origenalTask,
// //同步才可以
// Action = (newTask) =>
// {
// //申请表 设置新任务Id
// visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id;
// //生成的任务分配给原始医生
// newTask.DoctorUserId = origenalTask.DoctorUserId;
// newTask.TaskAllocationState = TaskAllocationState.Allocated;
// newTask.AllocateTime = DateTime.Now;
// }
// });
// }
//}
////访视任务 同意重阅
//else
#endregion
//PM申请 SPM / CPM审批 回退访视,在此不生成访视任务
if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM))
{
@ -1154,22 +1114,45 @@ namespace IRaCIS.Core.Application.Service
foreach (var influenceTask in influenceTaskList)
{
if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
//申请的访视 要不是重阅重置,要不就是失效 不会存在取消分配
if (influenceTask.ReadingCategory == ReadingCategory.Visit && influenceTask.VisitTaskNum != origenalTask.VisitTaskNum)
{
influenceTask.TaskState = TaskState.HaveReturned;
if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
influenceTask.TaskState = TaskState.HaveReturned;
}
else if (influenceTask.ReadingTaskState == ReadingTaskState.Reading)
{
influenceTask.TaskState = TaskState.Adbandon;
}
else
{
influenceTask.DoctorUserId = null;
influenceTask.AllocateTime = null;
influenceTask.SuggesteFinishedTime = null;
influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate;
}
}
else
{
influenceTask.TaskState = TaskState.Adbandon;
if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
influenceTask.TaskState = TaskState.HaveReturned;
}
else
{
influenceTask.TaskState = TaskState.Adbandon;
}
}
}
#endregion
}
//无序阅片
//无序阅片 没有 全局 肿瘤学
else
{
//阅片任务产生了裁判
@ -1210,7 +1193,6 @@ namespace IRaCIS.Core.Application.Service
}
// 无序阅片没有 全局 肿瘤学
}
@ -1430,7 +1412,7 @@ namespace IRaCIS.Core.Application.Service
var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.IsReadingTaskViewInOrder, t.ReadingType }).FirstOrDefaultAsync()).IfNullThrowException();
var task = (await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == taskId)).IfNullThrowException();
var task = (await _visitTaskRepository.Where(t => t.Id == taskId).FirstOrDefaultAsync()).IfNullThrowException();
if (task.TaskState != TaskState.Effect)
{
@ -1455,28 +1437,13 @@ namespace IRaCIS.Core.Application.Service
#region 有序 无序公用流程
// 当前任务标为失效
task.TaskState = TaskState.Adbandon;
//执行类似一致性核查回退流程 回退访视到影像上传流程
await VisitBackAsync(task.SourceSubjectVisitId);
//考虑该访视 另外一个阅片人的任务
var otherReviewerTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.SourceSubjectVisitId == task.SourceSubjectVisitId && t.Id != task.Id && t.TaskState == TaskState.Effect);
#endregion
if (otherReviewerTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
//另外阅片人完成阅片了 就设置为重阅重置
otherReviewerTask.TaskState = TaskState.HaveReturned;
}
else
{
otherReviewerTask.TaskState = TaskState.Adbandon;
}
//有序
if (trialConfig.IsReadingTaskViewInOrder)
@ -1484,104 +1451,198 @@ namespace IRaCIS.Core.Application.Service
Expression<Func<VisitTask, bool>> filterExpression = t => t.TrialId == trialId && t.SubjectId == task.SubjectId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false;
//自己的后续任务 取消分配 注意这里条件是>
//另一个阅片人的任务根据任务进度自动进入PM退回或PM申请重阅
filterExpression = filterExpression.And(t => t.VisitTaskNum > task.VisitTaskNum);
filterExpression = filterExpression.And(t => t.VisitTaskNum >= task.VisitTaskNum);
var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync();
#region 方式一
//foreach (var influenceTask in influenceTaskList)
//{
// //申请任务的阅片人 后续任务肯定没做, 只有访视任务,没有其他任务 取消分配
// if (influenceTask.DoctorUserId == task.DoctorUserId)
// {
// switch (influenceTask.ReadingCategory)
// {
// case ReadingCategory.Visit:
// influenceTask.DoctorUserId = null;
// influenceTask.AllocateTime = null;
// influenceTask.SuggesteFinishedTime = null;
// influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate;
// break;
// case ReadingCategory.Global:
// case ReadingCategory.Judge:
// case ReadingCategory.Oncology:
// throw new BusinessValidationFailedException("不支持回退任务类型");
// }
// }
// //另外一个阅片人
// else
// {
// //另外一个阅片人 有序PM 申请重阅流程
// if (otherReviewerTask.ReadingTaskState == ReadingTaskState.HaveSigned)
// {
// switch (influenceTask.ReadingCategory)
// {
// case ReadingCategory.Visit:
// if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
// {
// influenceTask.TaskState = TaskState.HaveReturned;
// }
// else if (influenceTask.ReadingTaskState == ReadingTaskState.Reading)
// {
// influenceTask.TaskState = TaskState.Adbandon;
// }
// else
// {
// influenceTask.DoctorUserId = null;
// influenceTask.AllocateTime = null;
// influenceTask.SuggesteFinishedTime = null;
// influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate;
// }
// break;
// case ReadingCategory.Global:
// case ReadingCategory.Oncology:
// if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
// {
// influenceTask.TaskState = TaskState.HaveReturned;
// }
// else
// {
// influenceTask.TaskState = TaskState.Adbandon;
// }
// break;
// case ReadingCategory.Judge:
// default:
// throw new BusinessValidationFailedException("不支持回退任务类型");
// }
// }
// //另外一个阅片人 有序 PM 回退流程
// else
// {
// switch (influenceTask.ReadingCategory)
// {
// case ReadingCategory.Visit:
// influenceTask.DoctorUserId = null;
// influenceTask.AllocateTime = null;
// influenceTask.SuggesteFinishedTime = null;
// influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate;
// break;
// case ReadingCategory.Global:
// case ReadingCategory.Judge:
// case ReadingCategory.Oncology:
// throw new BusinessValidationFailedException("不支持回退任务类型");
// }
// }
// }
//}
#endregion
#region 方式二
foreach (var influenceTask in influenceTaskList)
{
//申请任务的阅片人 后续任务肯定没做, 只有访视任务,没有其他任务 取消分配
if (influenceTask.DoctorUserId == task.DoctorUserId)
//申请的访视 要不是重阅重置,要不就是失效 不会存在取消分配
if (influenceTask.ReadingCategory == ReadingCategory.Visit && influenceTask.VisitTaskNum != task.VisitTaskNum)
{
switch (influenceTask.ReadingCategory)
//后续访视处理访视
if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
case ReadingCategory.Visit:
influenceTask.DoctorUserId = null;
influenceTask.AllocateTime = null;
influenceTask.SuggesteFinishedTime = null;
influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate;
break;
case ReadingCategory.Global:
case ReadingCategory.Judge:
case ReadingCategory.Oncology:
throw new BusinessValidationFailedException("不支持回退任务类型");
influenceTask.TaskState = TaskState.HaveReturned;
}
}
//另外一个阅片人
else
{
//另外一个阅片人 有序PM 申请重阅流程
if (otherReviewerTask.ReadingTaskState == ReadingTaskState.HaveSigned)
else if (influenceTask.ReadingTaskState == ReadingTaskState.Reading)
{
switch (influenceTask.ReadingCategory)
{
case ReadingCategory.Visit:
case ReadingCategory.Global:
case ReadingCategory.Oncology:
if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
influenceTask.TaskState = TaskState.HaveReturned;
}
else if (influenceTask.ReadingTaskState == ReadingTaskState.Reading)
{
influenceTask.TaskState = TaskState.Adbandon;
}
else
{
influenceTask.DoctorUserId = null;
influenceTask.AllocateTime = null;
influenceTask.SuggesteFinishedTime = null;
influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate;
}
break;
case ReadingCategory.Judge:
default:
throw new BusinessValidationFailedException("不支持回退任务类型");
}
influenceTask.TaskState = TaskState.Adbandon;
}
//另外一个阅片人 有序 PM 申请回退流程
else
{
switch (influenceTask.ReadingCategory)
{
case ReadingCategory.Visit:
influenceTask.DoctorUserId = null;
influenceTask.AllocateTime = null;
influenceTask.SuggesteFinishedTime = null;
influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate;
break;
case ReadingCategory.Global:
case ReadingCategory.Judge:
case ReadingCategory.Oncology:
throw new BusinessValidationFailedException("不支持回退任务类型");
}
influenceTask.DoctorUserId = null;
influenceTask.AllocateTime = null;
influenceTask.SuggesteFinishedTime = null;
influenceTask.TaskAllocationState = TaskAllocationState.NotAllocate;
}
}
else
{
//申请的访视 全局肿瘤学
if (influenceTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
influenceTask.TaskState = TaskState.HaveReturned;
}
else
{
influenceTask.TaskState = TaskState.Adbandon;
}
}
}
#endregion
}
else
{
//无序 无序阅片没有 全局 肿瘤学
//没有额外特殊的操作
//// 当前任务标为失效
//task.TaskState = TaskState.Adbandon;
////考虑该访视 另外一个阅片人的任务
//var otherReviewerTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.SourceSubjectVisitId == task.SourceSubjectVisitId && t.Id != task.Id && t.TaskState == TaskState.Effect);
//if (otherReviewerTask.ReadingTaskState == ReadingTaskState.HaveSigned)
//{
// //另外阅片人完成阅片了 就设置为重阅重置
// otherReviewerTask.TaskState = TaskState.HaveReturned;
//}
//else
//{
// otherReviewerTask.TaskState = TaskState.Adbandon;
//}
// 申请该访视的任务 申请人失效 另外一个人重阅重置或者失效
var currentVisitList = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == task.SourceSubjectVisitId && t.ReadingCategory == ReadingCategory.Visit && t.TaskState == TaskState.Effect && t.VisitTaskNum == task.VisitTaskNum,true).ToListAsync();
foreach (var visitTask in currentVisitList)
{
if (visitTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
//另外阅片人完成阅片了 就设置为重阅重置
visitTask.TaskState = TaskState.HaveReturned;
}
else
{
visitTask.TaskState = TaskState.Adbandon;
}
}
}