修改重阅逻辑

Uat_Study
hang 2022-07-05 16:27:24 +08:00
parent ecef78fa6f
commit 9506f366d1
9 changed files with 293 additions and 51 deletions

View File

@ -35,7 +35,7 @@ namespace IRaCIS.Core.Application.Service
private readonly IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository;
public VisitTaskService(IRepository<VisitTask> visitTaskRepository, IRepository<Trial> trialRepository, IRepository<SubjectVisit> subjectVisitRepository,
public VisitTaskService(IRepository<SubjectVisit> subjectVisitRepository, IRepository<VisitTask> visitTaskRepository, IRepository<Trial> trialRepository,
IRepository<Subject> subjectRepository, IRepository<SubjectUser> subjectUserRepository, IRepository<TaskAllocationRule> taskAllocationRuleRepository,
IRepository<ReadModule> readModuleRepository, IRepository<VisitTaskReReading> visitTaskReReadingRepository, IRepository<ReadingTaskQuestionAnswer> readingTaskQuestionAnswerRepository
)
@ -647,6 +647,11 @@ namespace IRaCIS.Core.Application.Service
.Select(t => new AutoAssignResultDTO() { DoctorUserId = t.DoctorUserId, PlanReadingRatio = t.PlanReadingRatio, SubjectCount = subjectCount })
.ToList();
if (waitAllocationDoctorList.Count == 0)
{
throw new BusinessValidationFailedException("启用的医生数量为0");
}
//已分配的 医生的情况
var haveAssignedSubjectDoctorList = subjectList.Clone().SelectMany(t => t.DoctorUserList.Select(c => new { t.SubjectId, DoctorUserId = c.DoctorUserId, c.ArmEnum })).ToList();
@ -903,12 +908,21 @@ namespace IRaCIS.Core.Application.Service
[UnitOfWork]
public async Task<IResponseOutput> ApplyReReading(ApplyReReadingCommand applyReReadingCommand)
{
throw new BusinessValidationFailedException("正在更新开发ing,不允许操作");
var taskList = await _visitTaskRepository.Where(t => applyReReadingCommand.TaskIdList.Contains(t.Id), true).Include(t => t.JudgeVisitTask).ToListAsync();
foreach (var task in taskList)
{
if (task.ReadingTaskState != ReadingTaskState.HaveSigned)
{
throw new BusinessValidationFailedException("未阅片完成,不允许申请重阅");
}
if (task.ReReadingApplyState == ReReadingApplyState.HaveApplyed || task.ReReadingApplyState == ReReadingApplyState.Agree)
{
throw new BusinessValidationFailedException("重阅已申请,或者重阅已同意状态下不允许申请重阅");
@ -921,21 +935,21 @@ namespace IRaCIS.Core.Application.Service
task.ReReadingApplyState = ReReadingApplyState.HaveApplyed;
//产生了裁判
if (task.JudgeVisitTaskId != null)
{
if (task.ReadingTaskState == ReadingTaskState.WaitReading || task.ReadingTaskState == ReadingTaskState.Reading)
{
task.JudgeVisitTask.TaskState = TaskState.Adbandon;
}
else
{
////产生了裁判
//if (task.JudgeVisitTaskId != null)
//{
// if (task.ReadingTaskState == ReadingTaskState.WaitReading || task.ReadingTaskState == ReadingTaskState.Reading)
// {
// task.JudgeVisitTask.TaskState = TaskState.Adbandon;
// }
// else
// {
task.JudgeVisitTask.TaskState = TaskState.HaveReturned;
// task.JudgeVisitTask.TaskState = TaskState.HaveReturned;
}
}
// }
//}
var rootReReadingTaskId = _visitTaskReReadingRepository.Where(t => t.NewReReadingTaskId == task.Id).Select(u => u.RootReReadingTaskId).FirstOrDefault();
@ -972,8 +986,13 @@ namespace IRaCIS.Core.Application.Service
[UnitOfWork]
public async Task<IResponseOutput> ConfirmReReading(ConfirmReReadingCommand agreeReReadingCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
{
throw new BusinessValidationFailedException("正在更新开发ing,不允许操作");
var trialId = agreeReReadingCommand.TrialId;
var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.IsReadingTaskViewInOrder, t.ReadingType }).FirstOrDefaultAsync()).IfNullThrowException();
foreach (var item in agreeReReadingCommand.ConfirmReReadingList)
{
var origenalTask = (await _visitTaskRepository.Where(t => item.OriginalReReadingTaskId == t.Id, true).FirstOrDefaultAsync()).IfNullThrowException();
@ -991,52 +1010,238 @@ namespace IRaCIS.Core.Application.Service
if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree)
{
//产生的新任务
await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
//裁判任务 同意重阅
if (origenalTask.ReadingCategory == ReadingCategory.Judge)
{
TrialId = trialId,
ReadingCategory = ReadingCategory.ReReading,
ReReadingTask = origenalTask,
//同步才可以
Action = (newTask) =>
//项目组 SPM同意 IR PM同意
if ((visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM) ||
(visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager)
)
{
visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id;
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer)
//产生的新任务
await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
{
TrialId = trialId,
if (visitTaskReReadingAppply.IsCopyOrigenalForms)
ReadingCategory = ReadingCategory.ReReading,
ReReadingTask = origenalTask,
//同步才可以
Action = (newTask) =>
{
var origenalAnswerList = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
//申请表 设置新任务Id
visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id;
origenalAnswerList.ForEach(t => { t.VisitTaskId = newTask.Id; t.Id = Guid.Empty; });
//生成的任务分配给原始医生
newTask.DoctorUserId = origenalTask.DoctorUserId;
newTask.TaskAllocationState = TaskAllocationState.Allocated;
newTask.AllocateTime = DateTime.Now;
_readingTaskQuestionAnswerRepository.AddRangeAsync(origenalAnswerList).Wait();
}
}
//PM 立即分配
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager)
{
newTask.DoctorUserId = origenalTask.DoctorUserId;
newTask.TaskAllocationState = TaskAllocationState.Allocated;
newTask.AllocateTime = DateTime.Now;
}
});
}
});
}
//访视任务 同意重阅
else
{
if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply)
{
//SPM同意
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM)
{
//有序阅片
if (trialConfig.IsReadingTaskViewInOrder)
{
}
//无序阅片
else
{
//阅片任务产生了裁判
if (origenalTask.JudgeVisitTaskId != null)
{
//裁判任务是否已阅片完成
var judgeTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == origenalTask.JudgeVisitTaskId);
if (judgeTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
judgeTask.TaskState = TaskState.HaveReturned;
}
//裁判任务未完
else
{
judgeTask.TaskState = TaskState.Adbandon;
}
}
//不管是否触发裁判 阅片任务退回,待影像重传后重新分 配给原阅片人
if (trialConfig.ReadingType == ReadingMethod.Double)
{
//考虑该访视 另外一个阅片人的任务也同时退回
var otherTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.SourceSubjectVisitId == origenalTask.SourceSubjectVisitId && t.Id != origenalTask.Id && t.TaskState == TaskState.Effect);
if (otherTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
otherTask.TaskState = TaskState.HaveReturned;
}
else
{
otherTask.TaskState = TaskState.Adbandon;
}
}
//回退访视
if (origenalTask.ReadingCategory == ReadingCategory.Visit)
{
//执行类似一致性核查回退流程
await VisitBackAsync(origenalTask.SourceSubjectVisitId);
}
// 无序阅片没有 全局 肿瘤学
}
}
}
//IR申请
else
{
//PM 同意
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager)
{
//有序阅片
if (trialConfig.IsReadingTaskViewInOrder)
{
}
//无序阅片
else
{
//阅片任务产生了裁判
if (origenalTask.JudgeVisitTaskId != null)
{
//裁判任务是否已阅片完成
var judgeTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == origenalTask.JudgeVisitTaskId);
if (judgeTask.ReadingTaskState == ReadingTaskState.HaveSigned)
{
judgeTask.TaskState = TaskState.HaveReturned;
}
//裁判任务未完
else
{
judgeTask.TaskState = TaskState.Adbandon;
}
}
//产生的新任务
await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
{
TrialId = trialId,
ReadingCategory = ReadingCategory.ReReading,
ReReadingTask = origenalTask,
//同步才可以
Action = (newTask) =>
{
//申请表 设置新任务Id
visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id;
//生成的任务分配给原始医生
newTask.DoctorUserId = origenalTask.DoctorUserId;
newTask.TaskAllocationState = TaskAllocationState.Allocated;
newTask.AllocateTime = DateTime.Now;
}
});
}
}
}
}
}
////产生的新任务
//await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
//{
// TrialId = trialId,
// ReadingCategory = ReadingCategory.ReReading,
// ReReadingTask = origenalTask,
// //同步才可以
// Action = (newTask) =>
// {
// visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id;
// if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer)
// {
// if (visitTaskReReadingAppply.IsCopyOrigenalForms)
// {
// var origenalAnswerList = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList();
// origenalAnswerList.ForEach(t => { t.VisitTaskId = newTask.Id; t.Id = Guid.Empty; });
// _readingTaskQuestionAnswerRepository.AddRangeAsync(origenalAnswerList).Wait();
// }
// }
// //IR申请 PM同意 立即分配
// if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager)
// {
// //有序阅片
// if (trialConfig.IsReadingTaskViewInOrder)
// {
// }
// else
// {
// //无序阅片
// newTask.DoctorUserId = origenalTask.DoctorUserId;
// newTask.TaskAllocationState = TaskAllocationState.Allocated;
// newTask.AllocateTime = DateTime.Now;
// }
// }
// }
//});
//}
}
@ -1053,6 +1258,51 @@ namespace IRaCIS.Core.Application.Service
private async Task VisitBackAsync(Guid? subjectVisitId)
{
var sv = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == subjectVisitId)).IfNullThrowException();
//需要重新产生任务
sv.IsVisitTaskGenerated = false;
sv.AuditState = AuditStateEnum.None;
sv.SubmitState = SubmitStateEnum.ToSubmit;
sv.ReadingStatus = ReadingStatusEnum.ImageNotSubmit;
//回退后,回退状态恢复
sv.RequestBackState = RequestBackStateEnum.NotRequest;
sv.IsCheckBack = true;
sv.CheckState = CheckStateEnum.None;
sv.CheckChallengeState = CheckChanllengeTypeEnum.None;
sv.SVENDTC = null;
sv.SVSTDTC = null;
sv.PreliminaryAuditTime = null;
sv.SubmitTime = null;
sv.ReviewAuditTime = null;
sv.CurrentActionUserExpireTime = null;
sv.IsTake = false;
sv.CurrentActionUserId = null;
sv.PreliminaryAuditUserId = null;
sv.ReviewAuditUserId = null;
//await _repository.AddAsync(new CheckChallengeDialog() { SubjectVisitId = subjectVisitId, TalkContent = "PM/APM同意一致性核查回退。", UserTypeEnum = (UserTypeEnum)_userInfo.UserTypeEnumInt });
await _repository.BatchDeleteAsync<TrialQCQuestionAnswer>(t => t.SubjectVisitId == subjectVisitId);
await _repository.BatchDeleteAsync<DicomInstance>(t => t.DicomSerie.IsDeleted);
await _repository.BatchDeleteAsync<DicomSeries>(t => t.IsDeleted);
var success = await _subjectVisitRepository.SaveChangesAsync();
}
/// <summary>
/// 重阅影响提示列表
/// </summary>
@ -1064,7 +1314,7 @@ namespace IRaCIS.Core.Application.Service
var filterObj = await _visitTaskRepository.FirstOrDefaultNoTrackingAsync(t => t.Id == taskId);
var list = await _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId && t.SubjectId == filterObj.SubjectId && t.VisitTaskNum >= filterObj.VisitTaskNum)
.Where(t => t.TaskState == TaskState.Effect && ! t.IsAnalysisCreate)
.Where(t => t.TaskState == TaskState.Effect && !t.IsAnalysisCreate)
.ProjectTo<VisitTaskSimpleView>(_mapper.ConfigurationProvider).ToListAsync();
return list;

View File

@ -4,7 +4,6 @@ using System;
using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Domain.Models
{

View File

@ -4,7 +4,6 @@ using System;
using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Domain.Models
{

View File

@ -4,7 +4,6 @@ using System;
using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Domain.Models
{

View File

@ -4,7 +4,6 @@ using System;
using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IRaCIS.Core.Domain.Share;
using System.Collections.Generic;
namespace IRaCIS.Core.Domain.Models

View File

@ -4,7 +4,6 @@ using System;
using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IRaCIS.Core.Domain.Share;
using System.Collections.Generic;
namespace IRaCIS.Core.Domain.Models

View File

@ -4,7 +4,6 @@ using System;
using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IRaCIS.Core.Domain.Share;
using System.Collections.Generic;
namespace IRaCIS.Core.Domain.Models

View File

@ -4,7 +4,6 @@ using System;
using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IRaCIS.Core.Domain.Share;
using System.Collections.Generic;
namespace IRaCIS.Core.Domain.Models

View File

@ -1,6 +1,5 @@
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Domain.Share;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;