diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index 7539253c8..48d2e69c1 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -79,6 +79,20 @@
+
+
+ 组间一致性分析 选择Subejct 列表
+
+
+
+
+
+
+ 确认生成组间一致性分析任务
+
+
+
+
仅仅组内一致性时使用(
diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs
index e983144d5..1aab3c5b5 100644
--- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs
@@ -152,8 +152,14 @@ namespace IRaCIS.Core.Application.ViewModel
//public ReReadingApplyGenerateTaskCommand ReReadingApplyGenerateTaskCommand { get; set; } = new ReReadingApplyGenerateTaskCommand();
+ //自身一致性
public List GenerataConsistentTaskList { get; set; }
+ //组间一致性
+
+ public List GenerataGroupConsistentTaskList { get; set; }
+
+
}
diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs
index 7baac4b07..a6df371d2 100644
--- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs
@@ -65,7 +65,17 @@ namespace IRaCIS.Core.Application.ViewModel
public List SubejctIdList { get; set; }
}
- public class DoctorSelfConsistentSubjectView
+ public class DoctorSelfConsistentSubjectView: ConsistentCommonView
+ {
+
+ public string? BlindSubjectCode { get; set; }
+
+ public List VisitTaskList { get; set; }
+
+ }
+
+
+ public class ConsistentCommonView
{
public Guid TrialId { get; set; }
public Guid SiteId { get; set; }
@@ -73,27 +83,28 @@ namespace IRaCIS.Core.Application.ViewModel
public String TrialSiteCode { get; set; }
public string SubjectCode { get; set; }
- public string? BlindSubjectCode { get; set; }
-
public Guid SubjectId { get; set; }
public bool IsHaveGeneratedTask { get; set; }
public int? ValidVisitCount { get; set; }
-
- public List VisitTaskList { get; set; }
}
- public class VisitTaskSimpleDTO
+ public class DoctorGroupConsistentSubjectView: ConsistentCommonView
+ {
+
+ public List TaskList => VisitTaskList.GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).SelectMany(g => g.ToList()).OrderBy(t=>t.VisitTaskNum).ToList();
+
+ public List VisitTaskList { get; set; } = new List();
+ }
+
+ public class VisitTaskGroupSimpleDTO
{
- public Guid Id { get; set; }
public Guid TrialId { get; set; }
public Guid SubjectId { get; set; }
- public Arm ArmEnum { get; set; }
- public string TaskCode { get; set; }
public string TaskName { get; set; }
public string TaskBlindName { get; set; }
@@ -107,7 +118,22 @@ namespace IRaCIS.Core.Application.ViewModel
public TaskState TaskState { get; set; }
+ public Guid? DoctorUserId { get; set; }
+ public Arm ArmEnum { get; set; }
+
+ [JsonIgnore]
+ public VisitTask GroupFirstVisitTask { get; set; }
+ }
+
+ public class VisitTaskSimpleDTO :VisitTaskGroupSimpleDTO
+ {
+ public Guid? Id { get; set; }
+
+
+ public string TaskCode { get; set; }
+
+
//可以不查询
public List GlobalVisitTaskList { get; set; }
@@ -118,9 +144,9 @@ namespace IRaCIS.Core.Application.ViewModel
public string BlindSubjectCode { get; set; } = string.Empty;
public string BlindTrialSiteCode { get; set; } = string.Empty;
- public Guid? DoctorUserId { get; set; }
- public Guid? TaskConsistentRuleId { get; set; }
+
+ //public Guid? TaskConsistentRuleId { get; set; }
}
diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs
index 5966948fa..56dcd87e5 100644
--- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs
@@ -13,6 +13,7 @@ using IRaCIS.Core.Domain.Share;
using System.Linq.Expressions;
using IRaCIS.Core.Infra.EFCore.Common;
using System.Linq;
+using Nito.AsyncEx;
namespace IRaCIS.Core.Application.Service
{
@@ -29,6 +30,8 @@ namespace IRaCIS.Core.Application.Service
private readonly IRepository _subjectRepository;
private readonly IRepository _enrollRepository;
+ private readonly AsyncLock _mutex = new AsyncLock();
+
public TaskConsistentRuleService(IRepository visitTaskRepository, IRepository enrollRepository, IRepository taskConsistentRuleRepository, IRepository subjectUserRepository, IRepository subjectRepository)
{
_taskConsistentRuleRepository = taskConsistentRuleRepository;
@@ -88,14 +91,13 @@ namespace IRaCIS.Core.Application.Service
-
-
///
/// 确认生成自身一致性分析任务
///
///
///
[HttpPost]
+ [UnitOfWork]
public async Task ConfirmGenerateSelfConsistentTask(ConsistentConfirmGenerateCommand inCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
{
var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inCommand.TaskConsistentRuleId);
@@ -107,54 +109,243 @@ namespace IRaCIS.Core.Application.Service
//var list = query.OrderByDescending(t => t.IsHaveGeneratedTask).ToList();
- foreach (var subject in list)
+ using (await _mutex.LockAsync())
{
- //处理 Subject 编号
-
- var blindSubjectCode = string.Empty;
-
- var subjectTask = _visitTaskRepository.Where(t => t.SubjectId == subject.SubjectId).OrderByDescending(t => t.BlindSubjectCode).FirstOrDefault().IfNullThrowException();
- if (subjectTask.BlindSubjectCode != String.Empty)
+ foreach (var subject in list)
{
- blindSubjectCode = subjectTask.BlindSubjectCode;
+ //处理 Subject 编号
+
+ var blindSubjectCode = string.Empty;
+
+ var subjectTask = _visitTaskRepository.Where(t => t.SubjectId == subject.SubjectId).OrderByDescending(t => t.BlindSubjectCode).FirstOrDefault().IfNullThrowException();
+ if (subjectTask.BlindSubjectCode != String.Empty)
+ {
+ blindSubjectCode = subjectTask.BlindSubjectCode;
+ }
+ else
+ {
+ var maxCodeStr = _visitTaskRepository.Where(t => t.TrialId == subject.TrialId).OrderByDescending(t => t.BlindSubjectCode).Select(t => t.BlindSubjectCode).FirstOrDefault();
+
+ int maxCodeInt = 0;
+ int.TryParse(maxCodeStr, out maxCodeInt);
+
+ blindSubjectCode = (maxCodeInt + 1).ToString($"D{filterObj.BlindSubjectNumberOfPlaces}");
+ }
+
+ subject.VisitTaskList = subject.VisitTaskList.Take(filterObj.PlanVisitCount).ToList();
+
+ subject.VisitTaskList.ForEach(t =>
+ {
+ t.DoctorUserId = doctorUserId;
+ //t.TaskConsistentRuleId = filterObj.Id;
+ t.BlindTrialSiteCode = filterObj.BlindTrialSiteCode;
+ t.BlindSubjectCode = blindSubjectCode;
+ });
+
+
+ //最后一个访视添加全局
+
+ var globalTask = (subject.VisitTaskList.Last()).Clone();
+ globalTask.ReadingCategory = ReadingCategory.Global;
+ globalTask.VisitTaskNum += ReadingCommon.TaskNumDic[ReadingCategory.Global];
+ subject.VisitTaskList.Add(globalTask);
+
+ await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
+ {
+ TrialId = filterObj.TrialId,
+
+ ReadingCategory = GenerateTaskCategory.SelfConsistent,
+
+
+ //产生的过滤掉已经生成的
+ GenerataConsistentTaskList = subject.VisitTaskList.Where(t => t.IsHaveGeneratedTask == false).ToList()
+ });
+
}
- else
+ }
+
+ return ResponseOutput.Ok();
+
+
+ }
+
+
+
+ private async Task> GetGroupConsistentQueryAsync(TaskConsistentRule filterObj, List? subejctIdList = null)
+ {
+
+ var trialId = filterObj.TrialId;
+ var trialConfig = (await _repository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.ReadingType, t.IsReadingTaskViewInOrder }).FirstOrDefaultAsync()).IfNullThrowException();
+
+
+
+ Expression> comonTaskFilter = u => u.TrialId == trialId && u.IsAnalysisCreate == false && u.TaskState == TaskState.Effect && u.ReadingTaskState == ReadingTaskState.HaveSigned
+ && (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject);
+
+ Expression> visitTaskFilter = comonTaskFilter.And(t => t.ReadingCategory == ReadingCategory.Visit);
+
+ if (subejctIdList != null && subejctIdList?.Count > 0)
+ {
+ visitTaskFilter = visitTaskFilter.And(t => subejctIdList.Contains(t.SubjectId));
+ }
+
+ //所选访视数量 的访视 其中必有一个访视后有全局任务
+ if (filterObj.IsHaveReadingPeriod == true)
+ {
+ visitTaskFilter = visitTaskFilter.And(t => t.Subject.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Any(u => u.VisitTaskNum == t.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && u.ReadingCategory == ReadingCategory.Global));
+ }
+
+
+ IQueryable subjectQuery = default;
+
+ //单重阅片没有组件一致性
+
+ subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId && t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Select(t=>t.DoctorUserId).Distinct().Count()==2
+ && t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count() >= filterObj.PlanVisitCount);
+
+
+
+ var query = subjectQuery.Select(t => new DoctorGroupConsistentSubjectView()
+ {
+ TrialId = t.TrialId,
+ SiteId = t.SiteId,
+ SubjectCode = t.Code,
+ TrialSiteCode = t.TrialSite.TrialSiteCode,
+ SubjectId = t.Id,
+
+
+ IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.IsSelfAnalysis == false),
+
+
+ ValidVisitCount = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).GroupBy(t => new { t.SubjectId, t.VisitTaskNum }).Where(g => g.Count() == 2).Count(),
+
+ VisitTaskList = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter)
+ .Select(c => new VisitTaskGroupSimpleDTO()
{
- var maxCodeStr = _visitTaskRepository.Where(t => t.TrialId == subject.TrialId).OrderByDescending(t => t.BlindSubjectCode).Select(t => t.BlindSubjectCode).FirstOrDefault();
+ ReadingCategory = c.ReadingCategory,
+ ReadingTaskState = c.ReadingTaskState,
+ TaskBlindName = c.TaskBlindName,
+ TaskName = c.TaskName,
+ TaskState = c.TaskState,
+ SubjectId = c.SubjectId,
+ VisitTaskNum = c.VisitTaskNum,
+ TrialId = c.TrialId,
+ DoctorUserId = c.DoctorUserId
+ }).ToList()
- int maxCodeInt = 0;
- int.TryParse(maxCodeStr,out maxCodeInt);
+ //
+ });
- blindSubjectCode = (maxCodeInt + 1).ToString($"D{filterObj.BlindSubjectNumberOfPlaces}");
+ query = query.OrderByDescending(t => t.IsHaveGeneratedTask);
+
+ return query;
+ }
+
+ ///
+ /// 组间一致性分析 选择Subejct 列表
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task> GetGroupConsistentRuleSubjectList(GroupConsistentQuery inQuery)
+ {
+ var trialId = inQuery.TrialId;
+
+ var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.IsSelfAnalysis == false);
+
+
+ if (filterObj == null)
+ {
+ throw new BusinessValidationFailedException("请先配置后,再进行数据查询");
+ }
+
+ var query = await GetGroupConsistentQueryAsync(filterObj);
+
+
+ var pagedList = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(DoctorSelfConsistentSubjectView.SubjectCode) : inQuery.SortField, inQuery.Asc);
+
+ return pagedList;
+ }
+
+
+
+ ///
+ /// 确认生成组间一致性分析任务
+ ///
+ ///
+ ///
+ [HttpPost]
+ [UnitOfWork]
+ public async Task ConfirmGenerateGroupConsistentTask(GroupConsistentConfirmGenrateCommand inCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
+ {
+ var trialId = inCommand.TrialId;
+
+ var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.IsSelfAnalysis == false);
+
+
+ var query = await GetGroupConsistentQueryAsync(filterObj, inCommand.SubejctIdList);
+
+ var subjectList = query.ToList();
+
+ var doctorUserIdQuery = from enroll in _repository.Where(t => t.TrialId == trialId).Where(t => t.EnrollReadingCategoryList.Any(c => c.ReadingCategory == ReadingCategory.Global || c.ReadingCategory == ReadingCategory.Visit))
+ join user in _repository.Where() on enroll.DoctorId equals user.DoctorId
+ select user.Id;
+
+ var configDoctorUserIdList = await doctorUserIdQuery.ToListAsync();
+
+
+
+ foreach (var subject in subjectList.Where(t => t.IsHaveGeneratedTask == false))
+ {
+
+ var subjectAddTaskList = new List();
+
+
+ //需要处理的医生
+
+ var needAddDoctorUserIdList = configDoctorUserIdList.Except(subject.VisitTaskList.Select(t => (Guid)t.DoctorUserId)).ToList();
+
+
+ foreach (var needAddDoctorUserId in needAddDoctorUserIdList)
+ {
+
+ //每个医生 都生成处理的任务
+ foreach (var task in subject.TaskList.Take(filterObj.PlanVisitCount))
+ {
+
+ subjectAddTaskList.Add( new VisitTaskGroupSimpleDTO()
+ {
+ ReadingCategory = task.ReadingCategory,
+ ReadingTaskState = task.ReadingTaskState,
+ TaskBlindName = task.TaskBlindName,
+ TaskName = task.TaskName,
+ TaskState = task.TaskState,
+ SubjectId = task.SubjectId,
+ VisitTaskNum = task.VisitTaskNum,
+ TrialId = task.TrialId,
+ DoctorUserId = needAddDoctorUserId,
+ ArmEnum=Arm.GroupConsistentArm
+ });
+
+ }
+
+ //最后一个访视添加全局
+ var globalTask = (subject.TaskList.Last()).Clone();
+ globalTask.ReadingCategory = ReadingCategory.Global;
+ globalTask.VisitTaskNum += ReadingCommon.TaskNumDic[ReadingCategory.Global];
+
+ subjectAddTaskList.Add(globalTask);
}
- subject.VisitTaskList= subject.VisitTaskList.Take(filterObj.PlanVisitCount).ToList();
-
- subject.VisitTaskList.ForEach(t =>
- {
- t.DoctorUserId = doctorUserId;
- t.TaskConsistentRuleId = filterObj.Id;
- t.BlindTrialSiteCode = filterObj.BlindTrialSiteCode;
- t.BlindSubjectCode = blindSubjectCode;
- });
-
-
- //最后一个访视添加全局
-
- var globalTask = (subject.VisitTaskList.Last()).Clone();
- globalTask.ReadingCategory = ReadingCategory.Global;
- globalTask.VisitTaskNum += ReadingCommon.TaskNumDic[ReadingCategory.Global];
- subject.VisitTaskList.Add(globalTask);
await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
{
TrialId = filterObj.TrialId,
- ReadingCategory = GenerateTaskCategory.SelfConsistent,
+ ReadingCategory = GenerateTaskCategory.GroupConsistent,
- //产生的过滤掉已经生成的
- GenerataConsistentTaskList = subject.VisitTaskList.Where(t => t.IsHaveGeneratedTask == false).ToList()
+ GenerataGroupConsistentTaskList = subjectAddTaskList
});
}
@@ -167,81 +358,6 @@ namespace IRaCIS.Core.Application.Service
- /////
- ///// 组间一致性分析 选择Subejct 列表
- /////
- /////
- /////
- //[HttpPost]
- //public async Task> GetGroupConsistentRuleSubjectList(GroupConsistentQuery inQuery)
- //{
- // var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.TrialId == inQuery.TrialId && t.IsSelfAnalysis == false);
-
-
-
-
- // var pagedList = await GetIQueryableDoctorSelfConsistentSubjectView(filterObj).ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(DoctorSelfConsistentSubjectView.SubjectCode) : inQuery.SortField, inQuery.Asc);
-
- // return pagedList;
- //}
-
-
-
- /////
- ///// 确认生成组间一致性分析任务
- /////
- /////
- /////
- //[HttpPost]
- //public async Task ConfirmGenerateGroupConsistentTask(GroupConsistentConfirmGenrateCommand inCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
- //{
- // throw new BusinessValidationFailedException("正在更新开发ing,不允许操作");
-
- // var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.TrialId == inCommand.TrialId && t.IsSelfAnalysis==false);
-
- // var list = await GetIQueryableDoctorSelfConsistentSubjectView(filterObj, null, inCommand.SubejctIdList).ToListAsync();
-
-
-
- // foreach (var subject in list)
- // {
-
-
- // //subject.VisitTaskList.Take(filterObj.PlanVisitCount).ForEach(t =>
- // //{
- // // t.DoctorUserId = doctorUserId;
- // // t.TaskConsistentRuleId = filterObj.Id;
-
- // //});
-
-
- // //最后一个访视添加全局
- // //var globalTask = (subject.VisitTaskList[filterObj.PlanVisitCount - 1]).Clone();
- // //globalTask.ReadingCategory = ReadingCategory.Global;
- // //globalTask.VisitTaskNum += ReadingCommon.TaskNumDic[ReadingCategory.Global];
- // //subject.VisitTaskList.Add(globalTask);
-
- // await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
- // {
- // TrialId = filterObj.TrialId,
-
- // ReadingCategory = GenerateTaskCategory.SelfConsistent,
-
-
- // //产生的过滤掉已经生成的
- // GenerataConsistentTaskList = subject.VisitTaskList.Where(t => t.IsHaveGeneratedTask == false).ToList()
- // });
-
- // }
-
-
- // return ResponseOutput.Ok();
-
-
- //}
-
-
-
///
/// 仅仅组内一致性时使用(
@@ -256,38 +372,25 @@ namespace IRaCIS.Core.Application.Service
#region Subejct 维度
- Expression> visitTaskFilter = t => t.IsAnalysisCreate == false && t.ReadingCategory == ReadingCategory.Visit && t.DoctorUserId == doctorUserId &&
- t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect &&
- t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now &&
- (t.ReReadingApplyState == ReReadingApplyState.Default || t.ReReadingApplyState == ReReadingApplyState.Reject);
+ Expression> comonTaskFilter = u => u.TrialId == trialId && u.IsAnalysisCreate == false && u.TaskState == TaskState.Effect && u.ReadingTaskState == ReadingTaskState.HaveSigned &&
+ u.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now && (u.ReReadingApplyState == ReReadingApplyState.Default || u.ReReadingApplyState == ReReadingApplyState.Reject);
- Expression> subjectIsHaveGeneratedTaskFilter = c => c.IsAnalysisCreate;
+ Expression> visitTaskFilter = comonTaskFilter.And(t => t.ReadingCategory == ReadingCategory.Visit && t.DoctorUserId == doctorUserId);
+
- ////组间一致性
- //if (doctorUserId == null)
- //{
- // subjectIsHaveGeneratedTaskFilter = subjectIsHaveGeneratedTaskFilter.And(c => c.IsSelfAnalysis == false);
- //}
- ////组内
- //else
- //{
- // subjectIsHaveGeneratedTaskFilter = subjectIsHaveGeneratedTaskFilter.And(c => c.DoctorUserId == doctorUserId && c.IsSelfAnalysis == true);
- //}
if (subejctIdList != null && subejctIdList?.Count > 0)
{
- visitTaskFilter= visitTaskFilter.And(t => subejctIdList.Contains(t.SubjectId));
+ visitTaskFilter = visitTaskFilter.And(t => subejctIdList.Contains(t.SubjectId));
}
//所选访视数量 的访视 其中必有一个访视后有全局任务
if (filterObj.IsHaveReadingPeriod == true)
{
- visitTaskFilter = visitTaskFilter.And(t => t.Subject.SubjectVisitTaskList.Any(u => u.VisitTaskNum == t.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]
- && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now));
+ visitTaskFilter = visitTaskFilter.And(t => t.Subject.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Any(u => u.VisitTaskNum == t.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && u.ReadingCategory == ReadingCategory.Global));
}
- //var globalWithVisitFilter = visitTaskFilter.And(t => t.VisitTaskNum <=)
var subjectQuery = _subjectRepository.Where(t => t.TrialId == trialId && t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count() >= filterObj.PlanVisitCount);
@@ -300,9 +403,9 @@ namespace IRaCIS.Core.Application.Service
TrialSiteCode = t.TrialSite.TrialSiteCode,
SubjectId = t.Id,
- BlindSubjectCode=t.SubjectVisitTaskList.Where(t=>t.IsAnalysisCreate).OrderByDescending(t=>t.BlindSubjectCode).Select(t=>t.BlindSubjectCode).FirstOrDefault(),
+ BlindSubjectCode = t.SubjectVisitTaskList.Where(t => t.IsAnalysisCreate).OrderByDescending(t => t.BlindSubjectCode).Select(t => t.BlindSubjectCode).FirstOrDefault(),
- IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.DoctorUserId == doctorUserId && c.IsSelfAnalysis == true),
+ IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.DoctorUserId == doctorUserId && c.IsSelfAnalysis == true),
ValidVisitCount = t.SubjectVisitTaskList.AsQueryable().Where(visitTaskFilter).Count(),
@@ -324,7 +427,7 @@ namespace IRaCIS.Core.Application.Service
//自身一致性才有意义
//IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.ConsistentAnalysisOriginalTaskId == c.Id),
- GlobalVisitTaskList = c.Subject.SubjectVisitTaskList.Where(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now).Select(c => new VisitTaskSimpleDTO()
+ GlobalVisitTaskList = c.Subject.SubjectVisitTaskList.AsQueryable().Where(comonTaskFilter).Where(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]).Select(c => new VisitTaskSimpleDTO()
{
Id = c.Id,
ReadingCategory = c.ReadingCategory,
@@ -387,7 +490,7 @@ namespace IRaCIS.Core.Application.Service
IsHaveReadingPeriod = taskConsistentRule.IsHaveReadingPeriod,
PlanVisitCount = taskConsistentRule.PlanVisitCount,
- GeneratedSubjectCount = taskConsistentRule.Trial.VisitTaskList.Where(t => t.IsAnalysisCreate && t.IsSelfAnalysis == true && t.DoctorUserId==user.Id).Select(t => t.SubjectId).Distinct().Count(),
+ GeneratedSubjectCount = taskConsistentRule.Trial.VisitTaskList.Where(t => t.IsAnalysisCreate && t.IsSelfAnalysis == true && t.DoctorUserId == user.Id).Select(t => t.SubjectId).Distinct().Count(),
AnalysisDoctorUser = new UserSimpleInfo()
{
@@ -492,7 +595,7 @@ namespace IRaCIS.Core.Application.Service
VerifyMsg = "已有该项目配置,不允许继续增加"
};
- if( await _visitTaskRepository.AnyAsync(t=>t.IsSelfAnalysis==addOrEditTaskConsistentRule.IsSelfAnalysis && t.TrialId == addOrEditTaskConsistentRule.TrialId))
+ if (await _visitTaskRepository.AnyAsync(t => t.IsSelfAnalysis == addOrEditTaskConsistentRule.IsSelfAnalysis && t.TrialId == addOrEditTaskConsistentRule.TrialId))
{
return ResponseOutput.NotOk("已有Subject 生成了任务,不允许修改配置");
}
diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs
index c5fc07da8..d6666e01e 100644
--- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs
@@ -356,7 +356,6 @@ namespace IRaCIS.Core.Application.Service
break;
case GenerateTaskCategory.SelfConsistent:
- case GenerateTaskCategory.GroupConsistent:
foreach (var task in generateTaskCommand.GenerataConsistentTaskList)
{
@@ -368,11 +367,52 @@ namespace IRaCIS.Core.Application.Service
TaskName = task.TaskName,
TaskBlindName = task.TaskBlindName,
+ VisitTaskNum = task.VisitTaskNum,
+ ReadingCategory = task.ReadingCategory,
+
+ IsAnalysisCreate = true,
+ //TaskConsistentRuleId=task.TaskConsistentRuleId,
+ TaskState = TaskState.Effect,
+ Code = currentMaxCodeInt + 1,
+ TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)),
+
+ DoctorUserId = task.DoctorUserId,
+ TaskAllocationState = TaskAllocationState.Allocated,
+ AllocateTime = DateTime.Now,
+
+ BlindTrialSiteCode = task.BlindTrialSiteCode,
+ BlindSubjectCode = task.BlindSubjectCode,
+ ConsistentAnalysisOriginalTaskId = task.Id ,
+
+ IsSelfAnalysis = true,
+
+ };
+
+ await _visitTaskRepository.AddAsync(consistentTask);
+
+ currentMaxCodeInt = currentMaxCodeInt + 1;
+
+ _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30));
+ }
+
+ break;
+
+ case GenerateTaskCategory.GroupConsistent:
+
+ foreach (var task in generateTaskCommand.GenerataGroupConsistentTaskList)
+ {
+ var consistentTask = new VisitTask()
+ {
+ TrialId = task.TrialId,
+ SubjectId = task.SubjectId,
+ ArmEnum = task.ArmEnum,
+ TaskName = task.TaskName,
+ TaskBlindName = task.TaskBlindName,
+
VisitTaskNum = task.VisitTaskNum,
ReadingCategory = task.ReadingCategory,
IsAnalysisCreate = true,
- TaskConsistentRuleId=task.TaskConsistentRuleId,
TaskState = TaskState.Effect,
Code = currentMaxCodeInt + 1,
TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)),
@@ -383,9 +423,9 @@ namespace IRaCIS.Core.Application.Service
BlindTrialSiteCode=task.BlindTrialSiteCode,
BlindSubjectCode=task.BlindSubjectCode,
- ConsistentAnalysisOriginalTaskId=task.Id,
+ ConsistentAnalysisOriginalTaskId= null,
- IsSelfAnalysis= generateTaskCommand.ReadingCategory== GenerateTaskCategory.SelfConsistent,
+ IsSelfAnalysis= false,
};
diff --git a/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs b/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs
index 71c304559..8026302a3 100644
--- a/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs
+++ b/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs
@@ -157,6 +157,8 @@ namespace IRaCIS.Core.Domain.Share
JudgeArm = 3,
TumorArm = 4,
+
+ GroupConsistentArm=8
}
///
diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs
index 9bff95cb7..f64b57249 100644
--- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs
+++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs
@@ -176,7 +176,7 @@ namespace IRaCIS.Core.Domain.Models
public string BlindTrialSiteCode { get; set; } = string.Empty;
//一致性分析规则Id 用于最后统计
- public Guid? TaskConsistentRuleId { get; set; }
+ //public Guid? TaskConsistentRuleId { get; set; }
///
/// 针对产生的一致性任务而言,这个字段存储的是原始任务