定时任务
parent
3ddbd59995
commit
38fc05e0d9
|
@ -27,10 +27,13 @@ namespace IRaCIS.Core.API
|
|||
q.AddTrigger(t => t
|
||||
.WithIdentity("TrialStatusTrigger")
|
||||
.ForJob(jobKey)
|
||||
|
||||
.WithCronSchedule("0 0 * * * ?")
|
||||
.WithDescription("My regular trial work trigger")
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
// ASP.NET Core hosting
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EasyCaching.Core;
|
||||
using IRaCIS.Core.Domain;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Quartz;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
|
||||
namespace IRaCIS.Application.Services.BackGroundJob
|
||||
{
|
||||
|
||||
public class CancelTaskQuartZJob : IJob
|
||||
{
|
||||
|
||||
private readonly IRepository<Subject> _subjectRepository;
|
||||
private readonly ILogger<CancelTaskQuartZJob> _logger;
|
||||
private readonly IRepository<VisitTask> _visitTaskRepository;
|
||||
|
||||
public CancelTaskQuartZJob(IRepository<Subject> subjectRepository, IEasyCachingProvider provider, ILogger<CancelTaskQuartZJob> logger, IRepository<VisitTask> visitTaskRepository)
|
||||
{
|
||||
_subjectRepository = subjectRepository;
|
||||
_logger = logger;
|
||||
_visitTaskRepository = visitTaskRepository;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
|
||||
{
|
||||
_logger.LogInformation($"开始执行QuartZ定时取消任务作业");
|
||||
|
||||
try
|
||||
{
|
||||
JobDataMap dataMap = context.JobDetail.JobDataMap;
|
||||
|
||||
bool isInOrder = (bool)dataMap.Get("IsInOrder");
|
||||
|
||||
if (isInOrder)
|
||||
{
|
||||
Guid id = (Guid)dataMap.Get("SubjectId");
|
||||
|
||||
await _subjectRepository.UpdatePartialFromQueryAsync(t => t.Id ==id, u => new Subject() { ClaimUserId = null }, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Guid id = (Guid)dataMap.Get("VisitTaskId");
|
||||
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.Id == id, u => new VisitTask() { ClaimUserId = null }, true);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError($"QuartZ定时取消任务异常" + e.Message);
|
||||
}
|
||||
_logger.LogInformation("QuartZ定时取消任务作业结束");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -259,6 +259,9 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
public Guid SubjectId { get; set; }
|
||||
public string SubjectCode { get; set; } = String.Empty;
|
||||
|
||||
public Guid? ClaimUserId { get;set; }
|
||||
|
||||
|
||||
public bool IsUrgent => UnReadTaskList.Any(t => t.IsUrgent);
|
||||
|
||||
public int UnReadTaskCount { get; set; }
|
||||
|
@ -417,15 +420,15 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
/// </summary>
|
||||
public int FinishTaskCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 未完成裁判任务数量
|
||||
/// </summary>
|
||||
public int UnReadJudgeTaskCount { get; set; }
|
||||
///// <summary>
|
||||
///// 未完成裁判任务数量
|
||||
///// </summary>
|
||||
//public int UnReadJudgeTaskCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 完成裁判任务数量
|
||||
/// </summary>
|
||||
public int FinishJudgeTaskCount { get; set; }
|
||||
///// <summary>
|
||||
///// 完成裁判任务数量
|
||||
///// </summary>
|
||||
//public int FinishJudgeTaskCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 建议完成时间
|
||||
|
@ -798,6 +801,17 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
CancelAssign = 4,
|
||||
}
|
||||
|
||||
public class ClaimSubjectDto
|
||||
{
|
||||
public bool IsInOrder { get; set; }
|
||||
|
||||
public Guid? VisitTaskId { get; set; }
|
||||
|
||||
public Guid SubejctId { get; set; }
|
||||
|
||||
public bool IsClaim { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ using System.Linq;
|
|||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using IRaCIS.Core.Domain.Share.Reading;
|
||||
using Quartz;
|
||||
using IRaCIS.Application.Services.BackGroundJob;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service.Allocation
|
||||
{
|
||||
|
@ -914,10 +916,10 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
|
||||
var trialReadingCriterionId = iRUnReadSubjectQuery.TrialReadingCriterionId;
|
||||
|
||||
var criterionConfig = await _trialReadingCriterionRepository.Where(x => x.Id == iRUnReadSubjectQuery.TrialReadingCriterionId).FirstNotNullAsync();
|
||||
var critrion = await _trialReadingCriterionRepository.Where(x => x.Id == iRUnReadSubjectQuery.TrialReadingCriterionId).FirstNotNullAsync();
|
||||
|
||||
var readingTool = criterionConfig.ReadingTool;
|
||||
var isReadingTaskViewInOrder = criterionConfig.IsReadingTaskViewInOrder;
|
||||
var readingTool = critrion.ReadingTool;
|
||||
var isReadingTaskViewInOrder = critrion.IsReadingTaskViewInOrder;
|
||||
|
||||
#region 按照Subject 维度
|
||||
if (isReadingTaskViewInOrder)
|
||||
|
@ -961,87 +963,61 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
RandomReadInfo = new IRUnReadOutDto(),
|
||||
IsReadingTaskViewInOrder = isReadingTaskViewInOrder,
|
||||
ReadingTool = readingTool,
|
||||
IseCRFShowInDicomReading = criterionConfig.IseCRFShowInDicomReading,
|
||||
IsReadingShowSubjectInfo = criterionConfig.IsReadingShowSubjectInfo,
|
||||
IsReadingShowPreviousResults = criterionConfig.IsReadingShowPreviousResults,
|
||||
DigitPlaces = criterionConfig.DigitPlaces,
|
||||
CriterionType = criterionConfig.CriterionType,
|
||||
IseCRFShowInDicomReading = critrion.IseCRFShowInDicomReading,
|
||||
IsReadingShowSubjectInfo = critrion.IsReadingShowSubjectInfo,
|
||||
IsReadingShowPreviousResults = critrion.IsReadingShowPreviousResults,
|
||||
DigitPlaces = critrion.DigitPlaces,
|
||||
CriterionType = critrion.CriterionType,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var taskQuery = _visitTaskRepository.Where(x => x.TrialId == iRUnReadSubjectQuery.TrialId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect && x.TrialReadingCriterionId == trialReadingCriterionId)
|
||||
// .Where(x=>x.Subject.ClinicalDataList.Any(c => c.IsSign && (c.ReadingId == x.SouceReadModuleId || c.ReadingId == x.SourceSubjectVisitId)))
|
||||
.Where(x => !x.Subject.IsDeleted).Where(x => (x.IsNeedClinicalDataSign && x.IsClinicalDataSign) || !x.IsNeedClinicalDataSign);
|
||||
|
||||
var readingDivisionEnum = critrion.ReadingDivisionEnum;
|
||||
|
||||
var piReadingScopenEnum = critrion.PIReadingScopenEnum;
|
||||
|
||||
var taskQuery = _visitTaskRepository.Where(x => x.TrialId == iRUnReadSubjectQuery.TrialId /*&& x.DoctorUserId == _userInfo.Id*/ && x.TaskState == TaskState.Effect && x.TrialReadingCriterionId == trialReadingCriterionId)
|
||||
|
||||
.Where(x => (x.IsNeedClinicalDataSign && x.IsClinicalDataSign) || !x.IsNeedClinicalDataSign)
|
||||
.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SR, t => t.Subject.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.Id))
|
||||
// 仅仅SR阅片 PI 没有任务列表
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.OnlySR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI, t => t.TrialId == Guid.Empty)
|
||||
|
||||
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.PIandSR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI && piReadingScopenEnum == PIReadingScopenEnum.AllBaseline,
|
||||
t => t.SourceSubjectVisit.IsBaseLine == true)
|
||||
|
||||
//PI 阅片所有
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.PIandSR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI && piReadingScopenEnum == PIReadingScopenEnum.AllBaselineandVisit,
|
||||
t => true)
|
||||
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.PIandSR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI && piReadingScopenEnum == PIReadingScopenEnum.AllVisit,
|
||||
t => t.SourceSubjectVisit.IsBaseLine == false)
|
||||
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.PIandSR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SR && piReadingScopenEnum == PIReadingScopenEnum.AllBaseline,
|
||||
t => t.SourceSubjectVisit.IsBaseLine == false)
|
||||
|
||||
//SR 不阅片
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.PIandSR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SR && piReadingScopenEnum == PIReadingScopenEnum.AllBaselineandVisit,
|
||||
t => t.TrialId == Guid.Empty)
|
||||
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.PIandSR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SR && piReadingScopenEnum == PIReadingScopenEnum.AllVisit,
|
||||
t => t.SourceSubjectVisit.IsBaseLine == true);
|
||||
|
||||
IRUnReadOutDto iRUnReadOut = new IRUnReadOutDto()
|
||||
{
|
||||
FinishJudgeTaskCount = await taskQuery.Where(x => x.ReadingCategory == ReadingCategory.Judge && x.ReadingTaskState == ReadingTaskState.HaveSigned).CountAsync(),
|
||||
FinishTaskCount = await taskQuery.Where(x => x.ReadingCategory != ReadingCategory.Judge && x.ReadingTaskState == ReadingTaskState.HaveSigned).CountAsync(),
|
||||
SuggesteFinishedTime = await taskQuery.Where(x => x.ReadingTaskState != ReadingTaskState.HaveSigned).MaxAsync(x => x.SuggesteFinishedTime),
|
||||
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(),
|
||||
};
|
||||
|
||||
|
||||
|
||||
var visitGroupQuery = taskQuery.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,
|
||||
|
||||
SuggesteFinishedTime = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Min(x => x.SuggesteFinishedTime),
|
||||
|
||||
//未读任务量
|
||||
UnReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Count(),
|
||||
|
||||
//未读 里可读任务量
|
||||
UnReadCanReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned && y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true)
|
||||
//不能对包含聚合或子查询的表达式执行聚合函数
|
||||
//&& !x.Any(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.IsNeedClinicalDataSign == true && t.IsClinicalDataSign == false && t.VisitTaskNum<y.VisitTaskNum )
|
||||
).Count(),
|
||||
|
||||
|
||||
//已读任务量
|
||||
HaveReadTaskCount = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState == ReadingTaskState.HaveSigned).Count(),
|
||||
|
||||
ExistReadingApply = x.Any(y => (y.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed && y.TrialReadingCriterionId == trialReadingCriterionId) || y.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed),
|
||||
|
||||
//查出所有未读的 未读的可读的 在这个列表基础上 过滤下 y.IsFrontTaskNeedSignButNotSign==false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true) 这样容易排错 确认这三个字段是否维护有误
|
||||
UnReadTaskList = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).OrderBy(x => x.VisitTaskNum)
|
||||
.Select(u => new IRUnreadTaskView()
|
||||
{
|
||||
Id = u.Id,
|
||||
IsUrgent = u.IsUrgent,
|
||||
VisitNum = u.VisitTaskNum,
|
||||
TaskBlindName = u.TaskBlindName,
|
||||
VisistId = u.SourceSubjectVisitId,
|
||||
SuggesteFinishedTime = u.SuggesteFinishedTime,
|
||||
ReadingCategory = u.ReadingCategory,
|
||||
IsAnalysisCreate = u.IsAnalysisCreate,
|
||||
ArmEnum = u.ArmEnum,
|
||||
TrialReadingCriterionId = u.TrialReadingCriterionId,
|
||||
IsNeedClinicalDataSign = u.IsNeedClinicalDataSign,
|
||||
IsClinicalDataSign = u.IsClinicalDataSign,
|
||||
IsFrontTaskNeedSignButNotSign = u.IsFrontTaskNeedSignButNotSign
|
||||
})
|
||||
.ToList(),
|
||||
}).Where(x => x.UnReadCanReadTaskCount > 0);
|
||||
|
||||
|
||||
var totalCount = await visitGroupQuery.CountAsync();
|
||||
var currentPageData = await visitTaskQuery.ToListAsync();
|
||||
|
||||
var result = new PageOutput<IRUnReadSubjectView>()
|
||||
{
|
||||
PageSize = iRUnReadSubjectQuery.PageSize,
|
||||
PageIndex = iRUnReadSubjectQuery.PageIndex,
|
||||
TotalCount = totalCount,
|
||||
CurrentPageData = currentPageData,
|
||||
};
|
||||
|
||||
return (result, new
|
||||
|
@ -1049,11 +1025,11 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
IsReadingTaskViewInOrder = isReadingTaskViewInOrder,
|
||||
RandomReadInfo = iRUnReadOut,
|
||||
ReadingTool = readingTool,
|
||||
IseCRFShowInDicomReading = criterionConfig.IseCRFShowInDicomReading,
|
||||
IsReadingShowSubjectInfo = criterionConfig.IsReadingShowSubjectInfo,
|
||||
IsReadingShowPreviousResults = criterionConfig.IsReadingShowPreviousResults,
|
||||
DigitPlaces = criterionConfig.DigitPlaces,
|
||||
CriterionType = criterionConfig.CriterionType,
|
||||
IseCRFShowInDicomReading = critrion.IseCRFShowInDicomReading,
|
||||
IsReadingShowSubjectInfo = critrion.IsReadingShowSubjectInfo,
|
||||
IsReadingShowPreviousResults = critrion.IsReadingShowPreviousResults,
|
||||
DigitPlaces = critrion.DigitPlaces,
|
||||
CriterionType = critrion.CriterionType,
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -1081,18 +1057,18 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
|
||||
var readingDivisionEnum = critrion.ReadingDivisionEnum;
|
||||
|
||||
var piReadingScopenEnum= critrion.PIReadingScopenEnum;
|
||||
var piReadingScopenEnum = critrion.PIReadingScopenEnum;
|
||||
|
||||
var visitQuery = _visitTaskRepository
|
||||
.Where(x => x.TrialId == inDto.TrialId && x.TaskState == TaskState.Effect)
|
||||
|
||||
.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SR, t => t.Subject.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.Id))
|
||||
// 仅仅SR阅片 PI 没有任务列表
|
||||
.WhereIf( readingDivisionEnum== ReadingDivisionEnum.OnlySR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI , t=>t.TrialId==Guid.Empty)
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.OnlySR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI, t => t.TrialId == Guid.Empty)
|
||||
|
||||
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.PIandSR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI && piReadingScopenEnum== PIReadingScopenEnum.AllBaseline,
|
||||
t => t.SourceSubjectVisit.IsBaseLine ==true)
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.PIandSR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI && piReadingScopenEnum == PIReadingScopenEnum.AllBaseline,
|
||||
t => t.SourceSubjectVisit.IsBaseLine == true)
|
||||
|
||||
//PI 阅片所有
|
||||
.WhereIf(readingDivisionEnum == ReadingDivisionEnum.PIandSR && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI && piReadingScopenEnum == PIReadingScopenEnum.AllBaselineandVisit,
|
||||
|
@ -1112,19 +1088,20 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
t => t.SourceSubjectVisit.IsBaseLine == true)
|
||||
|
||||
//前序 不存在 未生成任务的访视
|
||||
.WhereIf(critrion.IsAutoCreate == false, t => !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum) )
|
||||
.WhereIf(critrion.IsAutoCreate == false, t => !t.Subject.SubjectCriteriaEvaluationVisitFilterList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId).Any(f => f.IsGeneratedTask == false && t.VisitTaskNum > f.SubjectVisit.VisitNum))
|
||||
|
||||
// 前序 不存在 未一致性核查未通过的
|
||||
.Where( t=>! t.Subject.SubjectVisitList.Any(sv => sv.CheckState != CheckStateEnum.CVPassed && t.VisitTaskNum > sv.VisitNum))
|
||||
.Where(t => !t.Subject.SubjectVisitList.Any(sv => sv.CheckState != CheckStateEnum.CVPassed && t.VisitTaskNum > sv.VisitNum))
|
||||
.WhereIf(!string.IsNullOrEmpty(inDto.SubjectCode), t => (t.Subject.Code.Contains(inDto.SubjectCode) && t.IsAnalysisCreate == false) || (t.BlindSubjectCode.Contains(inDto.SubjectCode) && t.IsAnalysisCreate));
|
||||
|
||||
|
||||
var visitGroupQuery = visitQuery.GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode });
|
||||
var visitGroupQuery = visitQuery.GroupBy(x => new { x.SubjectId, x.Subject.Code, x.BlindSubjectCode, x.Subject.ClaimUserId });
|
||||
|
||||
var visitTaskQuery = visitGroupQuery.Select(x => new IRUnReadSubjectView()
|
||||
{
|
||||
SubjectId = x.Key.SubjectId,
|
||||
SubjectCode = x.Key.BlindSubjectCode == string.Empty ? x.Key.Code : x.Key.BlindSubjectCode,
|
||||
ClaimUserId = x.Key.ClaimUserId,
|
||||
|
||||
SuggesteFinishedTime = x.Where(y => y.TrialReadingCriterionId == trialReadingCriterionId && y.ReadingTaskState != ReadingTaskState.HaveSigned).Min(x => x.SuggesteFinishedTime),
|
||||
|
||||
|
@ -1438,7 +1415,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
//添加申请记录
|
||||
var visitTaskReReading = await _visitTaskReReadingRepository.AddAsync(new VisitTaskReReading()
|
||||
{
|
||||
TrialId=applyReReadingCommand.TrialId,
|
||||
TrialId = applyReReadingCommand.TrialId,
|
||||
RootReReadingTaskId = rootReReadingTaskId == Guid.Empty ? task.Id : rootReReadingTaskId,
|
||||
OriginalReReadingTaskId = task.Id,
|
||||
RequestReReadingTime = DateTime.Now,
|
||||
|
@ -2635,10 +2612,10 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
{
|
||||
|
||||
// 1.1 基线任务影响BM任务
|
||||
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && _subjectVisitRepository.Any(t=>t.Id==filterObj.SourceSubjectVisitId && t.IsBaseLine==true))
|
||||
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager && _subjectVisitRepository.Any(t => t.Id == filterObj.SourceSubjectVisitId && t.IsBaseLine == true))
|
||||
{
|
||||
|
||||
isIR1Point1AdditionalAssessmentBaseline=true;
|
||||
isIR1Point1AdditionalAssessmentBaseline = true;
|
||||
//filterExpression = filterExpression.And(t => t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId || t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB);
|
||||
|
||||
|
||||
|
@ -2713,7 +2690,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
// 裁判 肿瘤学是另外的医生做
|
||||
|| t.ReadingCategory == ReadingCategory.Judge
|
||||
|| t.ReadingCategory == ReadingCategory.Oncology
|
||||
)&& t.TrialReadingCriterionId==filterObj.TrialReadingCriterionId )||( t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB))
|
||||
) && t.TrialReadingCriterionId == filterObj.TrialReadingCriterionId) || (t.TrialReadingCriterion.CriterionType == CriterionType.RECIST1Pointt1_MB))
|
||||
);
|
||||
}
|
||||
else
|
||||
|
@ -3061,228 +3038,5 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
}
|
||||
|
||||
|
||||
#region 暂时废弃
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 自动一次性分配所有未分配的 Subject 给医生 暂时废弃
|
||||
///// </summary>
|
||||
///// <param name="autoSubjectAssignCommand"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpPost]
|
||||
//[UnitOfWork]
|
||||
//[Obsolete]
|
||||
//public async Task<IResponseOutput> AutoSubjectAssignDoctor(AutoSubjectAssignCommand autoSubjectAssignCommand)
|
||||
//{
|
||||
// //自动分配的话,需要把手动分配的给删掉
|
||||
|
||||
|
||||
// var trialId = autoSubjectAssignCommand.TrialId;
|
||||
// var isJudge = autoSubjectAssignCommand.IsJudgeDoctor;
|
||||
|
||||
|
||||
// //获取项目配置 判断应该分配几个医生
|
||||
// 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 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())
|
||||
// ////过滤掉 那些回退的subject
|
||||
// //.Where(t => !t.SubjectVisitList.Any(t => t.IsPMBackOrReReading))
|
||||
// .Select(t => new
|
||||
// {
|
||||
// SubjectId = t.Id,
|
||||
|
||||
// //给Subject分配医生的时候, 未确认绑定关系的
|
||||
// DoctorUserList = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).Select(t => new { t.DoctorUserId, t.ArmEnum }),
|
||||
// //IsApplyed = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).SelectMany(t => t.SubjectArmVisitTaskList).Any(c => c.DoctorUserId != null)
|
||||
// IsApplyed = false
|
||||
// }).ToList();
|
||||
|
||||
// //已产生任务的Subject数量(裁判情况下,就是产生裁判任务Subject 的数量)
|
||||
// var subjectCount = subjectList.Count;
|
||||
|
||||
// //获取医生列表(裁判是裁判的医生列表)
|
||||
// var waitAllocationDoctorList = _taskAllocationRuleRepository.Where(t => t.TrialId == trialId && t.IsEnable)
|
||||
// .Where(t => t.IsJudgeDoctor == isJudge)
|
||||
// .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, c.DoctorUserId, c.ArmEnum })).ToList();
|
||||
|
||||
// //将目前已分配的情况 换到医生的维度
|
||||
// foreach (var waitAllocationDoctor in waitAllocationDoctorList)
|
||||
// {
|
||||
// waitAllocationDoctor.SubjectArmList = haveAssignedSubjectDoctorList.Where(t => t.DoctorUserId == waitAllocationDoctor.DoctorUserId)
|
||||
// .Select(g => new SubjectArm()
|
||||
// {
|
||||
// SubjectId = g.SubjectId,
|
||||
// ArmEnum = g.ArmEnum
|
||||
// }).ToList();
|
||||
// }
|
||||
|
||||
|
||||
// #region 完全按照Subject 遍历去分
|
||||
|
||||
|
||||
// //仅仅分配未应用的 而且 没有分配医生的
|
||||
// foreach (var subject in subjectList.Where(t => t.IsApplyed == false && !t.DoctorUserList.Any()))
|
||||
// {
|
||||
// //该Subject 已经分配的医生数量
|
||||
// var hasAssignDoctorCount = subject.DoctorUserList.Count();
|
||||
|
||||
// if (isJudge)
|
||||
// {
|
||||
// if (hasAssignDoctorCount > 1)
|
||||
// {
|
||||
// throw new BusinessValidationFailedException("当前有Subject裁判绑定医生数量大于1");
|
||||
|
||||
// }
|
||||
|
||||
// var allocateDoctor = waitAllocationDoctorList.OrderByDescending(t => t.Weight).ThenByDescending(t => t.PlanReadingRatio).FirstOrDefault();
|
||||
|
||||
// //将分配结果记录
|
||||
// waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctor.DoctorUserId).SubjectArmList.Add(new SubjectArm()
|
||||
// {
|
||||
// SubjectId = subject.SubjectId,
|
||||
// ArmEnum = Arm.JudgeArm
|
||||
// });
|
||||
|
||||
// await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctor.DoctorUserId, ArmEnum = Arm.JudgeArm, AssignTime = DateTime.Now });
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// //分配两个医生
|
||||
// if (trialConfig.ReadingType == ReadingMethod.Double)
|
||||
// {
|
||||
|
||||
|
||||
// if (hasAssignDoctorCount > 2)
|
||||
// {
|
||||
// throw new BusinessValidationFailedException("双重阅片当前有Subject绑定医生数量大于2");
|
||||
|
||||
// }
|
||||
|
||||
// var allocateDoctorList = waitAllocationDoctorList.OrderByDescending(t => t.Weight).ThenByDescending(t => t.PlanReadingRatio).Take(2).ToList();
|
||||
|
||||
|
||||
// #region 看阅片人之前在Subject哪个组做的多
|
||||
|
||||
// var preferredDoctor1Arm = waitAllocationDoctorList.Where(t => t.DoctorUserId == allocateDoctorList[0].DoctorUserId)
|
||||
// .SelectMany(t => t.SubjectArmList).GroupBy(t => t.ArmEnum)
|
||||
// .Select(g => new { ArmEnum = g.Key, SubjectCount = g.Count() })
|
||||
// .OrderByDescending(t => t.SubjectCount).FirstOrDefault()?.ArmEnum;
|
||||
|
||||
// var preferredDoctor2Arm = waitAllocationDoctorList.Where(t => t.DoctorUserId == allocateDoctorList[1].DoctorUserId)
|
||||
// .SelectMany(t => t.SubjectArmList).GroupBy(t => t.ArmEnum)
|
||||
// .Select(g => new { ArmEnum = g.Key, SubjectCount = g.Count() })
|
||||
// .OrderByDescending(t => t.SubjectCount).FirstOrDefault()?.ArmEnum;
|
||||
|
||||
// //存放医生分配的Arm
|
||||
// var doctor1Arm = Arm.DoubleReadingArm1;
|
||||
// var doctor2Arm = Arm.DoubleReadingArm2;
|
||||
|
||||
// if (preferredDoctor1Arm == null && preferredDoctor2Arm == null ||
|
||||
// preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm2 ||
|
||||
// preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == null ||
|
||||
// preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == Arm.DoubleReadingArm2
|
||||
// )
|
||||
// {
|
||||
// doctor1Arm = Arm.DoubleReadingArm1;
|
||||
// doctor2Arm = Arm.DoubleReadingArm2;
|
||||
// }
|
||||
// else if (preferredDoctor1Arm == null && preferredDoctor2Arm == Arm.DoubleReadingArm1 ||
|
||||
// preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == Arm.DoubleReadingArm1 ||
|
||||
// preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == null)
|
||||
// {
|
||||
// doctor1Arm = Arm.DoubleReadingArm2;
|
||||
// doctor2Arm = Arm.DoubleReadingArm1;
|
||||
// }
|
||||
|
||||
// else if (preferredDoctor1Arm == Arm.DoubleReadingArm1 && preferredDoctor2Arm == Arm.DoubleReadingArm1)
|
||||
// {
|
||||
// doctor1Arm = Arm.DoubleReadingArm1;
|
||||
// doctor2Arm = Arm.DoubleReadingArm2;
|
||||
// }
|
||||
// else if (preferredDoctor1Arm == Arm.DoubleReadingArm2 && preferredDoctor2Arm == Arm.DoubleReadingArm2)
|
||||
// {
|
||||
// doctor1Arm = Arm.DoubleReadingArm2;
|
||||
// doctor2Arm = Arm.DoubleReadingArm1;
|
||||
// }
|
||||
|
||||
// #endregion
|
||||
|
||||
|
||||
// await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctorList[0].DoctorUserId, ArmEnum = doctor1Arm, AssignTime = DateTime.Now });
|
||||
|
||||
|
||||
// //将分配结果记录
|
||||
// waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctorList[0].DoctorUserId).SubjectArmList.Add(new SubjectArm()
|
||||
// {
|
||||
// SubjectId = subject.SubjectId,
|
||||
// ArmEnum = doctor1Arm
|
||||
// });
|
||||
|
||||
|
||||
// await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctorList[1].DoctorUserId, ArmEnum = doctor2Arm, AssignTime = DateTime.Now });
|
||||
|
||||
// //将分配结果记录
|
||||
// waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctorList[1].DoctorUserId).SubjectArmList.Add(new SubjectArm()
|
||||
// {
|
||||
// SubjectId = subject.SubjectId,
|
||||
// ArmEnum = doctor2Arm
|
||||
// });
|
||||
// }
|
||||
// else if (trialConfig.ReadingType == ReadingMethod.Single)
|
||||
// {
|
||||
// if (hasAssignDoctorCount > 1)
|
||||
// {
|
||||
// throw new BusinessValidationFailedException("单重阅片当前有Subject绑定医生数量大于1");
|
||||
// }
|
||||
|
||||
// var allocateDoctor = waitAllocationDoctorList.OrderByDescending(t => t.Weight).ThenByDescending(t => t.PlanReadingRatio).FirstOrDefault();
|
||||
|
||||
// //将分配结果记录
|
||||
// waitAllocationDoctorList.FirstOrDefault(t => t.DoctorUserId == allocateDoctor.DoctorUserId).SubjectArmList.Add(new SubjectArm()
|
||||
// {
|
||||
// SubjectId = subject.SubjectId,
|
||||
// ArmEnum = Arm.SingleReadingArm
|
||||
// });
|
||||
|
||||
// await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = trialId, SubjectId = subject.SubjectId, DoctorUserId = allocateDoctor.DoctorUserId, ArmEnum = Arm.SingleReadingArm, AssignTime = DateTime.Now });
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// #endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// await _subjectUserRepository.SaveChangesAsync();
|
||||
// return ResponseOutput.Ok();
|
||||
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ using Newtonsoft.Json.Linq;
|
|||
using Microsoft.Extensions.Caching.Memory;
|
||||
using IRaCIS.Core.Application.Filter;
|
||||
using DocumentFormat.OpenXml.Drawing;
|
||||
using Quartz;
|
||||
using IRaCIS.Application.Services.BackGroundJob;
|
||||
|
||||
namespace IRaCIS.Application.Services
|
||||
{
|
||||
|
@ -57,7 +59,7 @@ namespace IRaCIS.Application.Services
|
|||
private readonly IRepository<ReadingQuestionSystem> _readingQuestionSystem;
|
||||
private readonly IRepository<NoneDicomStudyFile> _noneDicomStudyFileSystem;
|
||||
private readonly IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository;
|
||||
|
||||
private readonly IScheduler _scheduler;
|
||||
private readonly IMemoryCache _cache;
|
||||
private readonly ITrialEmailNoticeConfigService _trialEmailNoticeConfigService;
|
||||
|
||||
|
@ -97,9 +99,11 @@ namespace IRaCIS.Application.Services
|
|||
IRepository<ReadingQuestionSystem> ReadingQuestionSystem,
|
||||
ITrialEmailNoticeConfigService trialEmailNoticeConfigService,
|
||||
IRepository<NoneDicomStudyFile> noneDicomStudyFileSystem,
|
||||
IRepository<ReadingQuestionTrial> readingQuestionTrialRepository
|
||||
IRepository<ReadingQuestionTrial> readingQuestionTrialRepository,
|
||||
IScheduler scheduler
|
||||
)
|
||||
{
|
||||
_scheduler = scheduler;
|
||||
base._mapper = mapper;
|
||||
this._noneDicomStudyRepository = noneDicomStudyRepository;
|
||||
this._visitTaskRepository = visitTaskRepository;
|
||||
|
@ -159,9 +163,9 @@ namespace IRaCIS.Application.Services
|
|||
return await _trialDocumentRepository.Where(x => x.TrialId == inDto.TrialId
|
||||
&& x.TrialDocConfirmedUserList.Any(y => y.ConfirmUserId == _userInfo.Id && y.ConfirmTime != null)
|
||||
&& x.NeedConfirmedUserTypeList.Any(y => y.NeedConfirmUserTypeId == _userInfo.UserTypeId))
|
||||
.WhereIf(userType== UserTypeEnum.IndependentReviewer, t => t.FileType.Code == "2" || t.FileType.Code == "6")
|
||||
.WhereIf(userType == UserTypeEnum.IndependentReviewer, t => t.FileType.Code == "2" || t.FileType.Code == "6")
|
||||
.WhereIf(userType == UserTypeEnum.IQC, t => t.FileType.Code == "4" || t.FileType.Code == "5")
|
||||
.WhereIf(!canViewUserType.Contains(userType),t=>false)
|
||||
.WhereIf(!canViewUserType.Contains(userType), t => false)
|
||||
.IgnoreQueryFilters()
|
||||
.Select(x => new GetManualListOutDto()
|
||||
{
|
||||
|
@ -490,8 +494,8 @@ namespace IRaCIS.Application.Services
|
|||
VisitTaskNum = x.VisitTaskNum,
|
||||
IsBaseLineTask = x.SourceSubjectVisitId == baselineVisitId,
|
||||
IsCurrentTask = x.Id == inDto.VisitTaskId,
|
||||
IsConvertedTask=x.IsConvertedTask,
|
||||
IsFirstChangeTask=x.BeforeConvertedTaskId!=null,
|
||||
IsConvertedTask = x.IsConvertedTask,
|
||||
IsFirstChangeTask = x.BeforeConvertedTaskId != null,
|
||||
|
||||
}).ToListAsync();
|
||||
|
||||
|
@ -627,9 +631,9 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
|
||||
if (await _visitTaskRepository.AnyAsync(x => x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
|
||||
&&x.IsAnalysisCreate&&taskInfo.IsAnalysisCreate
|
||||
&&x.SubjectId== taskInfo.SubjectId&&x.TaskState==TaskState.Effect&&
|
||||
((x.ReReadingApplyState==ReReadingApplyState.DocotorHaveApplyed && x.DoctorUserId == taskInfo.DoctorUserId)|| x.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed)
|
||||
&& x.IsAnalysisCreate && taskInfo.IsAnalysisCreate
|
||||
&& x.SubjectId == taskInfo.SubjectId && x.TaskState == TaskState.Effect &&
|
||||
((x.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed && x.DoctorUserId == taskInfo.DoctorUserId) || x.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed)
|
||||
|
||||
))
|
||||
{
|
||||
|
@ -708,7 +712,7 @@ namespace IRaCIS.Application.Services
|
|||
{
|
||||
questions.ForEach(x =>
|
||||
{
|
||||
x.IsFirstChangeTask =true;
|
||||
x.IsFirstChangeTask = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -786,7 +790,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).ProjectTo<VisitTaskDto>(_mapper.ConfigurationProvider).FirstNotNullAsync();
|
||||
|
||||
if (taskInfo.IsConvertedTask &&taskInfo.BeforeConvertedTaskId!=null)
|
||||
if (taskInfo.IsConvertedTask && taskInfo.BeforeConvertedTaskId != null)
|
||||
{
|
||||
result.ForEach(x =>
|
||||
{
|
||||
|
@ -960,7 +964,7 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
|
||||
|
||||
if (inDto.TaskId != null )
|
||||
if (inDto.TaskId != null)
|
||||
{
|
||||
if (taskInfo.IsConvertedTask)
|
||||
{
|
||||
|
@ -1031,18 +1035,18 @@ namespace IRaCIS.Application.Services
|
|||
&& x.VisitTaskNum < taskInfo.VisitTaskNum
|
||||
&& x.ArmEnum == taskInfo.ArmEnum
|
||||
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
|
||||
&& x.ReadingCategory == ReadingCategory.Visit)||x.Id==taskInfo.BeforeConvertedTaskId
|
||||
).OrderByDescending(x=>x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
&& x.ReadingCategory == ReadingCategory.Visit) || x.Id == taskInfo.BeforeConvertedTaskId
|
||||
).OrderByDescending(x => x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
if (!criterionInfo.IsReadingTaskViewInOrder)
|
||||
{
|
||||
// 无序的话 不要查
|
||||
laskTaskId = Guid.NewGuid();
|
||||
}
|
||||
|
||||
lastTaskTableAnswer= await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == laskTaskId).Include(x => x.ReadingTableQuestionTrial).ToListAsync();
|
||||
lastTaskTableAnswer = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == laskTaskId).Include(x => x.ReadingTableQuestionTrial).ToListAsync();
|
||||
|
||||
|
||||
if (taskInfo.BeforeConvertedTaskId!=null )
|
||||
if (taskInfo.BeforeConvertedTaskId != null)
|
||||
{
|
||||
isFirstChangeTask = true;
|
||||
|
||||
|
@ -1104,7 +1108,7 @@ namespace IRaCIS.Application.Services
|
|||
/// <param name="item"></param>
|
||||
/// <param name="questionlists"></param>
|
||||
/// <param name="tableQuestionLists"></param>
|
||||
private async void FindChildQuestion(TrialReadQuestionData item, List<TrialReadQuestionData> questionlists, List<TableQuestionTrial> tableQuestionLists, List<ReadingTableQuestionAnswerInfo> tableAnswers, List<TableAnsweRowInfo> tableAnsweRowInfos, List<OrganInfo> organInfos, List<ReadingTableQuestionAnswer> baseLineTableAnswer,bool isFirstChangeTask, List<ReadingTableQuestionAnswer> lastTaskTableAnswer,Guid? TaskId)
|
||||
private async void FindChildQuestion(TrialReadQuestionData item, List<TrialReadQuestionData> questionlists, List<TableQuestionTrial> tableQuestionLists, List<ReadingTableQuestionAnswerInfo> tableAnswers, List<TableAnsweRowInfo> tableAnsweRowInfos, List<OrganInfo> organInfos, List<ReadingTableQuestionAnswer> baseLineTableAnswer, bool isFirstChangeTask, List<ReadingTableQuestionAnswer> lastTaskTableAnswer, Guid? TaskId)
|
||||
{
|
||||
item.Childrens = questionlists.Where(x => x.ParentId == item.Id || (x.GroupId == item.Id && x.ParentId == null)).ToList();
|
||||
item.TableQuestions = new TrialReadTableQuestion();
|
||||
|
@ -1241,14 +1245,14 @@ namespace IRaCIS.Application.Services
|
|||
answers.Add("MarkTool", rowInfo.MarkTool);
|
||||
answers.Add("StudyId", rowInfo.StudyId.ToString());
|
||||
answers.Add("OrganInfoId", rowInfo.OrganInfoId.ToString());
|
||||
answers.Add("IsFristAdd", (rowInfo.FristAddTaskId== TaskId).ToString());
|
||||
answers.Add("IsFristAdd", (rowInfo.FristAddTaskId == TaskId).ToString());
|
||||
answers.Add("IsCanEditPosition", rowInfo.IsCanEditPosition.ToString());
|
||||
answers.Add("InstanceId", rowInfo == null ? string.Empty : rowInfo.InstanceId.ToString());
|
||||
answers.Add("SeriesId", rowInfo == null ? string.Empty : rowInfo.SeriesId.ToString());
|
||||
answers.Add("IsCurrentTaskAdd", rowInfo == null ? false.ToString() : rowInfo.IsCurrentTaskAdd.ToString());
|
||||
answers.Add("SplitOrMergeLesionName", rowInfo.SplitName.IsNullOrEmpty() ? rowInfo.MergeName : rowInfo.SplitName);
|
||||
answers.Add("SplitOrMergeType", rowInfo.SplitOrMergeType == null ? string.Empty : ((int)rowInfo.SplitOrMergeType).ToString());
|
||||
answers.Add("LastTaskState", lastTaskTableAnswer.Where(n=>n.QuestionId== item.Id&&n.ReadingTableQuestionTrial.QuestionMark==QuestionMark.State&&n.RowIndex==x).Select(n=>n.Answer).FirstOrDefault()??string.Empty);
|
||||
answers.Add("LastTaskState", lastTaskTableAnswer.Where(n => n.QuestionId == item.Id && n.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && n.RowIndex == x).Select(n => n.Answer).FirstOrDefault() ?? string.Empty);
|
||||
answers.Add("LastTaskMajorAxis", lastTaskTableAnswer.Where(n => n.QuestionId == item.Id && n.ReadingTableQuestionTrial.QuestionMark == QuestionMark.MajorAxis && n.RowIndex == x).Select(n => n.Answer).FirstOrDefault() ?? string.Empty);
|
||||
answers.Add("LastTaskShortAxis", lastTaskTableAnswer.Where(n => n.QuestionId == item.Id && n.ReadingTableQuestionTrial.QuestionMark == QuestionMark.ShortAxis && n.RowIndex == x).Select(n => n.Answer).FirstOrDefault() ?? string.Empty);
|
||||
if (rowInfo.LesionType == LesionType.BaselineLesions)
|
||||
|
@ -1436,10 +1440,11 @@ namespace IRaCIS.Application.Services
|
|||
if (tumorAnswer != null)
|
||||
{
|
||||
var isConvertedTask = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.IsConvertedTask).FirstOrDefaultAsync();
|
||||
var reportVerify = await _readingCalculateService.GetReportVerify(new GetReportVerifyInDto() {
|
||||
BeforeConvertedTaskId= taskInfo.BeforeConvertedTaskId,
|
||||
IsConvertTask= isConvertedTask,
|
||||
VisitTaskId=inDto.VisitTaskId
|
||||
var reportVerify = await _readingCalculateService.GetReportVerify(new GetReportVerifyInDto()
|
||||
{
|
||||
BeforeConvertedTaskId = taskInfo.BeforeConvertedTaskId,
|
||||
IsConvertTask = isConvertedTask,
|
||||
VisitTaskId = inDto.VisitTaskId
|
||||
});
|
||||
|
||||
if (tumorAnswer.Answer == reportVerify.TumorEvaluate)
|
||||
|
@ -1997,7 +2002,7 @@ namespace IRaCIS.Application.Services
|
|||
StudyId = rowInfo.StudyId,
|
||||
IsCanEditPosition = rowInfo.IsCanEditPosition,
|
||||
ReportMark = rowInfo.ReportMark
|
||||
}) ;
|
||||
});
|
||||
|
||||
|
||||
foreach (var item in inDto.AnswerList)
|
||||
|
@ -2174,9 +2179,9 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
// 转化后的任务不应该有新病灶
|
||||
|
||||
var isConvertedTask = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x=>x.IsConvertedTask).FirstNotNullAsync();
|
||||
var isConvertedTask = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.IsConvertedTask).FirstNotNullAsync();
|
||||
|
||||
if (isConvertedTask&&(await _readingTableAnswerRowInfoRepository.AnyAsync(x => x.ReadingQuestionTrial.LesionType == LesionType.NewLesions && x.VisitTaskId == inDto.VisitTaskId)))
|
||||
if (isConvertedTask && (await _readingTableAnswerRowInfoRepository.AnyAsync(x => x.ReadingQuestionTrial.LesionType == LesionType.NewLesions && x.VisitTaskId == inDto.VisitTaskId)))
|
||||
{
|
||||
throw new BusinessValidationFailedException(_localizer["ReadingImage_NotNewFocus"]);
|
||||
}
|
||||
|
@ -2266,6 +2271,7 @@ namespace IRaCIS.Application.Services
|
|||
throw new BusinessValidationFailedException(_localizer["ReadingImage_IDMust"]);
|
||||
}
|
||||
|
||||
//看已阅的任务
|
||||
if (inDto.VisitTaskId != null)
|
||||
{
|
||||
task = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => new GetReadingTaskDto()
|
||||
|
@ -2327,13 +2333,20 @@ namespace IRaCIS.Application.Services
|
|||
}).FirstOrDefault();
|
||||
|
||||
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
// 有序 自动领取该Subject
|
||||
await ClaimOrCancelSubjectAsync(new ClaimSubjectDto() { IsClaim = true, SubejctId = task.SubjectId, IsInOrder = true }, _scheduler);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
task = await _visitTaskRepository.Where(x => x.TrialId == inDto.TrialId && x.TrialReadingCriterionId == trialReadingCriterionId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.DoctorUserId == _userInfo.Id
|
||||
//无序取数据
|
||||
task = await _visitTaskRepository.Where(x => x.TrialId == inDto.TrialId && x.TrialReadingCriterionId == trialReadingCriterionId && x.ReadingTaskState != ReadingTaskState.HaveSigned /*&& x.DoctorUserId == _userInfo.Id*/
|
||||
&& x.TrialReadingCriterionId == trialReadingCriterionId
|
||||
&& x.TaskState == TaskState.Effect).Select(x => new GetReadingTaskDto()
|
||||
&& x.TaskState == TaskState.Effect)
|
||||
.Where(x => (x.IsNeedClinicalDataSign && x.IsClinicalDataSign) || !x.IsNeedClinicalDataSign)
|
||||
.Select(x => new GetReadingTaskDto()
|
||||
{
|
||||
VisitTaskId = x.Id,
|
||||
ArmEnum = x.ArmEnum,
|
||||
|
@ -2344,8 +2357,13 @@ namespace IRaCIS.Application.Services
|
|||
SubjectId = x.SubjectId,
|
||||
SubjectCode = x.Subject.Code,
|
||||
TrialReadingCriterionId = x.TrialReadingCriterionId,
|
||||
}).FirstOrDefaultAsync();
|
||||
}).OrderByDescending(t => t.TaskBlindName).FirstOrDefaultAsync();
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
// 有序 自动领取该Subject
|
||||
await ClaimOrCancelSubjectAsync(new ClaimSubjectDto() { IsClaim = true, VisitTaskId = task.VisitTaskId, IsInOrder = false }, _scheduler);
|
||||
}
|
||||
}
|
||||
|
||||
if (task == null)
|
||||
|
@ -2474,6 +2492,70 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task ClaimOrCancelSubjectAsync(ClaimSubjectDto claimSubjectDto, IScheduler _scheduler)
|
||||
{
|
||||
if (claimSubjectDto.IsInOrder)
|
||||
{
|
||||
if (claimSubjectDto.IsClaim)
|
||||
{
|
||||
await _subjectRepository.UpdatePartialFromQueryAsync(t => t.Id == claimSubjectDto.SubejctId, u => new Subject() { ClaimUserId = _userInfo.Id }, true);
|
||||
|
||||
//定时任务24h取消
|
||||
|
||||
// 创建一个任务
|
||||
IJobDetail job = JobBuilder.Create<CancelTaskQuartZJob>()
|
||||
.WithIdentity($"CancelTaskQuartZJob_{_userInfo.Id}", "group")
|
||||
.UsingJobData("SubjectId", claimSubjectDto.SubejctId) // 传递GUID参数给任务
|
||||
.UsingJobData("IsInOrder", claimSubjectDto.IsInOrder)
|
||||
.Build();
|
||||
|
||||
// 创建一个触发器,设置任务执行时间为24小时后
|
||||
ITrigger trigger = TriggerBuilder.Create()
|
||||
.WithIdentity("CancelTaskQuartZJob", "group1")
|
||||
.StartAt(DateTimeOffset.UtcNow.AddHours(24))
|
||||
.Build();
|
||||
|
||||
// 将任务和触发器关联起来,将任务安排到调度器中
|
||||
await _scheduler.ScheduleJob(job, trigger);
|
||||
|
||||
//BackgroundJob.Schedule<IObtainTaskAutoCancelJob>(t => t.CancelQCObtaion(subjectVisitId, DateTime.Now), TimeSpan.FromHours(1));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
await _subjectRepository.UpdatePartialFromQueryAsync(t => t.Id == claimSubjectDto.SubejctId, u => new Subject() { ClaimUserId = null }, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (claimSubjectDto.IsClaim)
|
||||
{
|
||||
await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.Id == claimSubjectDto.VisitTaskId, u => new VisitTask() { ClaimUserId = _userInfo.Id }, true);
|
||||
|
||||
IJobDetail job = JobBuilder.Create<CancelTaskQuartZJob>()
|
||||
.WithIdentity($"CancelTaskQuartZJob_{_userInfo.Id}", "group")
|
||||
.UsingJobData("VisitTaskId",(Guid) claimSubjectDto.VisitTaskId) // 传递GUID参数给任务
|
||||
.UsingJobData("IsInOrder", claimSubjectDto.IsInOrder).Build();
|
||||
|
||||
// 创建一个触发器,设置任务执行时间为24小时后
|
||||
ITrigger trigger = TriggerBuilder.Create()
|
||||
.WithIdentity($"CancelTaskQuartZJob_{_userInfo.Id}", "group")
|
||||
.StartAt(DateTimeOffset.UtcNow.AddHours(24))
|
||||
.Build();
|
||||
|
||||
// 将任务和触发器关联起来,将任务安排到调度器中
|
||||
await _scheduler.ScheduleJob(job, trigger);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -2494,9 +2576,9 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
bool isConverted = false;
|
||||
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Include(x=>x.TrialReadingCriterion).FirstNotNullAsync();
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
|
||||
|
||||
var isConvertedTask=await _visitTaskRepository.Where(x => x.Id == visitTaskId).Select(x=>x.IsConvertedTask).FirstNotNullAsync();
|
||||
var isConvertedTask = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Select(x => x.IsConvertedTask).FirstNotNullAsync();
|
||||
switch (taskinfo.TrialReadingCriterion.CriterionType)
|
||||
{
|
||||
case CriterionType.IRECIST1Point1:
|
||||
|
@ -2505,7 +2587,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
if (!isConvertedTask &&
|
||||
(await _readingTaskQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId
|
||||
&& x.ReadingQuestionTrial.QuestionType == QuestionType.Tumor && x.Answer==(((int)OverallAssessment.PD)).ToString()))
|
||||
&& x.ReadingQuestionTrial.QuestionType == QuestionType.Tumor && x.Answer == (((int)OverallAssessment.PD)).ToString()))
|
||||
)
|
||||
{
|
||||
|
||||
|
@ -2583,7 +2665,7 @@ namespace IRaCIS.Application.Services
|
|||
x.IsAnalysisCreate == taskInfo.IsAnalysisCreate &&
|
||||
x.ReadingCategory == taskInfo.ReadingCategory &&
|
||||
x.Id != taskInfo.Id
|
||||
).OrderBy(x=>x.VisitTaskNum).ThenBy(x=>x.TaskState).Select(x => x.Id).ToListAsync();
|
||||
).OrderBy(x => x.VisitTaskNum).ThenBy(x => x.TaskState).Select(x => x.Id).ToListAsync();
|
||||
|
||||
|
||||
reportRelatedTaskIdList = await _visitTaskRepository.Where(x =>
|
||||
|
@ -2594,7 +2676,7 @@ namespace IRaCIS.Application.Services
|
|||
x.DoctorUserId == taskInfo.DoctorUserId &&
|
||||
x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId &&
|
||||
x.ReadingTaskState == ReadingTaskState.HaveSigned &&
|
||||
(x.TaskState == TaskState.Effect||x.TaskState==TaskState.Freeze) &&
|
||||
(x.TaskState == TaskState.Effect || x.TaskState == TaskState.Freeze) &&
|
||||
x.IsSelfAnalysis == taskInfo.IsSelfAnalysis &&
|
||||
x.IsAnalysisCreate == taskInfo.IsAnalysisCreate &&
|
||||
x.ReadingCategory == taskInfo.ReadingCategory &&
|
||||
|
|
|
@ -736,14 +736,14 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
|
||||
var trialSiteSurvey = (await _trialSiteSurveyRepository.Where(t => t.Id == trialSiteSurveyId).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurvey.SiteId == trialSiteSurvey.SiteId).Select(t => new { t.TrialSiteSurveyId, t.IsGenerateAccount, t.UserTypeId, t.UserTypeRole.UserTypeEnum, t.TrialRoleName.Code }).ToListAsync();
|
||||
var siteUserList = await _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurvey.SiteId == trialSiteSurvey.SiteId).Select(t => new { t.TrialSiteSurveyId, t.IsGenerateAccount, t.IsGenerateSuccess, t.UserTypeId, t.UserTypeRole.UserTypeEnum, t.TrialRoleName.Code }).ToListAsync();
|
||||
|
||||
|
||||
|
||||
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined)
|
||||
{
|
||||
//是第一次
|
||||
if(!siteUserList.Any(t=>t.IsGenerateAccount))
|
||||
if(!siteUserList.Any(t=>t.IsGenerateSuccess))
|
||||
{
|
||||
var currentUserList = siteUserList.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId).ToList();
|
||||
|
||||
|
@ -760,7 +760,7 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
|
||||
|
||||
//是第一次
|
||||
if (!siteUserList.Any(t => t.IsGenerateAccount))
|
||||
if (!siteUserList.Any(t => t.IsGenerateSuccess))
|
||||
{
|
||||
var currentUserList = siteUserList.Where(t => t.TrialSiteSurveyId == trialSiteSurveyId).ToList();
|
||||
|
||||
|
|
|
@ -426,6 +426,8 @@ namespace IRaCIS.Core.Domain.Models
|
|||
}
|
||||
}
|
||||
|
||||
public Guid? ClaimUserId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -123,6 +123,9 @@ namespace IRaCIS.Core.Domain.Models
|
|||
public bool IsReReadingOrBackInfluenceAnalysis { get; set; }
|
||||
|
||||
|
||||
public Guid? ClaimUserId { get; set; }
|
||||
|
||||
|
||||
//是否分配了读片医生
|
||||
//public bool IsAssignDoctorUser{get;set;}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue