一致性分析
This commit is contained in:
@@ -59,7 +59,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
public Guid SiteId => VisitTaskList.Select(t => t.SiteId).First();
|
||||
|
||||
public String TrialSiteCode => VisitTaskList.Select(t => t.TrialSiteCode).First();
|
||||
public string SubjectCode => VisitTaskList.Select(t => t.TrialSiteCode).First();
|
||||
public string SubjectCode => VisitTaskList.Select(t => t.SubjectCode).First();
|
||||
|
||||
public Guid SubjectId { get; set; }
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
|
||||
public List<VisitTaskSimpleView> VisitTaskList { get; set; }
|
||||
|
||||
//public List<UserSimpleInfo> HistoryDoctorUserList => VisitTaskList.Select(t => t.DoctorUser).Distinct().ToList();
|
||||
public List<UserSimpleInfo> HistoryDoctorUserList => VisitTaskList.SelectMany(t => t.RelationDoctorUserList).DistinctBy(t=>t.UserId).ToList();
|
||||
}
|
||||
|
||||
public class VisitTaskSimpleView
|
||||
@@ -99,12 +99,13 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
public String TrialSiteCode { get; set; } = String.Empty;
|
||||
public string SubjectCode { get; set; } = String.Empty;
|
||||
|
||||
//public UserSimpleInfo DoctorUser { get; set; }
|
||||
public List<UserSimpleInfo> RelationDoctorUserList { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Guid? DoctorUserId { get; set; }
|
||||
[JsonIgnore]
|
||||
public Guid? TaskConsistentRuleId { get; set; }
|
||||
public bool IsHaveGeneratedTask { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -86,13 +86,17 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||
|
||||
public ReadingTaskState ReadingTaskState { get; set; }
|
||||
|
||||
|
||||
|
||||
public ReReadingApplyState ReReadingApplyState { get; set; }
|
||||
public DateTime? SuggesteFinishedTime { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class AnalysisTaskView: ReadingTaskView
|
||||
{
|
||||
public bool IsSelfAnalysis { get; set; }
|
||||
}
|
||||
|
||||
//public class IRReReadingTaskView: ReReadingTaskView
|
||||
//{
|
||||
|
||||
|
||||
@@ -24,12 +24,14 @@ namespace IRaCIS.Core.Application.Service
|
||||
private readonly IRepository<TaskConsistentRule> _taskConsistentRuleRepository;
|
||||
private readonly IRepository<VisitTask> _visitTaskRepository;
|
||||
private readonly IRepository<SubjectUser> _subjectUserRepository;
|
||||
private readonly IRepository<Subject> _subjectRepository;
|
||||
|
||||
public TaskConsistentRuleService(IRepository<VisitTask> visitTaskRepository, IRepository<TaskConsistentRule> taskConsistentRuleRepository, IRepository<SubjectUser> subjectUserRepository)
|
||||
public TaskConsistentRuleService(IRepository<VisitTask> visitTaskRepository, IRepository<TaskConsistentRule> taskConsistentRuleRepository, IRepository<SubjectUser> subjectUserRepository ,IRepository<Subject> subjectRepository)
|
||||
{
|
||||
_taskConsistentRuleRepository = taskConsistentRuleRepository;
|
||||
_visitTaskRepository = visitTaskRepository;
|
||||
_subjectUserRepository = subjectUserRepository;
|
||||
_subjectRepository = subjectRepository;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +41,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
/// <param name="queryVisitTask"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<ReadingTaskView>> GetAnalysisTaskList(VisitTaskQuery queryVisitTask)
|
||||
public async Task<PageOutput<AnalysisTaskView>> GetAnalysisTaskList(VisitTaskQuery queryVisitTask)
|
||||
{
|
||||
var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == queryVisitTask.TrialId)
|
||||
.Where(t => t.IsAnalysisCreate)
|
||||
@@ -55,7 +57,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
.WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.Subject.Code.Contains(queryVisitTask.SubjectCode))
|
||||
.WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.AllocateTime > queryVisitTask.BeginAllocateDate)
|
||||
.WhereIf(queryVisitTask.EndAllocateDate != null, t => t.AllocateTime < queryVisitTask.EndAllocateDate.Value.AddDays(1))
|
||||
.ProjectTo<ReadingTaskView>(_mapper.ConfigurationProvider);
|
||||
.ProjectTo<AnalysisTaskView>(_mapper.ConfigurationProvider);
|
||||
|
||||
var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId) };
|
||||
|
||||
@@ -90,34 +92,36 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
var doctorUserId = isSelfAnalysis ? filterObj.AnalysisDoctorUserId : filterObj.CompareDoctorUserId;
|
||||
|
||||
var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId)
|
||||
// 自身一致性分析
|
||||
.WhereIf(isSelfAnalysis, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId)
|
||||
// 组内一致性分析
|
||||
.WhereIf(isSelfAnalysis == false && subjectfilter !=null, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId && subjectfilter.Contains(t.SubjectId))
|
||||
.Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect)
|
||||
.Where(t => t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7 + 1) > DateTime.Now)
|
||||
//重阅产生的访视任务 要把之前的访视任务去除
|
||||
.Where(t => t.ReReadingApplyState == ReReadingApplyState.Default || t.ReReadingApplyState == ReReadingApplyState.Reject)
|
||||
|
||||
.WhereIf(filterObj.IsHaveReadingPeriod == false, t => t.ReadingCategory == ReadingCategory.Visit)
|
||||
.WhereIf(filterObj.IsHaveReadingPeriod == true, t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global)
|
||||
.GroupBy(t => t.SubjectId)
|
||||
.Where(g => g.Count() >= filterObj.PlanVisitCount);
|
||||
#region 以任务为维度
|
||||
var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId && t.IsAnalysisCreate==false)
|
||||
// 自身一致性分析
|
||||
.WhereIf(isSelfAnalysis, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId)
|
||||
// 组内一致性分析
|
||||
.WhereIf(isSelfAnalysis == false && subjectfilter != null, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId && subjectfilter.Contains(t.SubjectId))
|
||||
.Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect)
|
||||
.Where(t => t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7 + 1) > DateTime.Now)
|
||||
//重阅产生的访视任务 要把之前的访视任务去除
|
||||
.Where(t => t.ReReadingApplyState == ReReadingApplyState.Default || t.ReReadingApplyState == ReReadingApplyState.Reject)
|
||||
|
||||
.WhereIf(filterObj.IsHaveReadingPeriod == false, t => t.ReadingCategory == ReadingCategory.Visit)
|
||||
.WhereIf(filterObj.IsHaveReadingPeriod == true, t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global)
|
||||
.GroupBy(t => t.SubjectId)
|
||||
.Where(g => g.Count() >= filterObj.PlanVisitCount);
|
||||
|
||||
var query = group.Select(g => new DoctorConsistentRuleSubjectView()
|
||||
{
|
||||
SubjectId = g.Key,
|
||||
|
||||
IsHaveGeneratedTask = g.Any(t => t.IsAnalysisCreate && t.SubjectId == g.Key && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id),
|
||||
IsHaveGeneratedTask = g.Any(c => c.Subject.SubjectVisitTaskList.Any(t => t.IsAnalysisCreate && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id)),
|
||||
|
||||
VisitTaskList = g.Where(t => t.IsAnalysisCreate == false).OrderBy(t => t.VisitTaskNum)
|
||||
VisitTaskList = g.OrderBy(t => t.VisitTaskNum)
|
||||
|
||||
.Select(c => new VisitTaskSimpleView()
|
||||
{
|
||||
Id = c.Id,
|
||||
ReadingCategory = c.ReadingCategory,
|
||||
ReadingTaskState=c.ReadingTaskState,
|
||||
ReadingTaskState = c.ReadingTaskState,
|
||||
TaskBlindName = c.TaskBlindName,
|
||||
TaskCode = c.TaskCode,
|
||||
TaskName = c.TaskName,
|
||||
@@ -129,18 +133,24 @@ namespace IRaCIS.Core.Application.Service
|
||||
SubjectCode = c.Subject.Code,
|
||||
TrialSiteCode = c.Subject.TrialSite.TrialSiteCode,
|
||||
|
||||
//DoctorUser=new UserSimpleInfo()
|
||||
//{
|
||||
// FullName=c.DoctorUser.FullName,
|
||||
// UserCode=c.DoctorUser.UserCode,
|
||||
// UserId=c.DoctorUser.Id,
|
||||
// UserName=c.DoctorUser.UserName
|
||||
//}
|
||||
RelationDoctorUserList=c.SameVisitTaskList/*Where(t=>t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect)*/.Select(c=> new UserSimpleInfo()
|
||||
{
|
||||
FullName = c.DoctorUser.FullName,
|
||||
UserCode = c.DoctorUser.UserCode,
|
||||
UserId = c.DoctorUser.Id,
|
||||
UserName = c.DoctorUser.UserName
|
||||
}).ToList(),
|
||||
|
||||
IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.IsAnalysisCreate && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id),
|
||||
|
||||
}).ToList(),
|
||||
|
||||
ValidTaskCount = g.Count()
|
||||
|
||||
});
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
var count = group.Count();
|
||||
|
||||
@@ -185,10 +195,10 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
|
||||
|
||||
var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId && inCommand.SubejctIdList.Contains(t.SubjectId))
|
||||
// 自身一致性分析
|
||||
var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId && inCommand.SubejctIdList.Contains(t.SubjectId) && t.IsAnalysisCreate == false)
|
||||
// 自身一致性分析
|
||||
.WhereIf(isSelfAnalysis, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId)
|
||||
// 组内一致性分析
|
||||
// 组内一致性分析
|
||||
.WhereIf(isSelfAnalysis == false && subjectfilter != null, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId && subjectfilter.Contains(t.SubjectId))
|
||||
.Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect)
|
||||
.Where(t => t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7 + 1) > DateTime.Now)
|
||||
@@ -205,9 +215,9 @@ namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
SubjectId = g.Key,
|
||||
|
||||
IsHaveGeneratedTask = g.Any(t => t.IsAnalysisCreate && t.SubjectId == g.Key && t.DoctorUserId == doctorUserId),
|
||||
IsHaveGeneratedTask = g.Any(c => c.Subject.SubjectVisitTaskList.Any(t => t.IsAnalysisCreate && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id)),
|
||||
|
||||
VisitTaskList = g.Where(t => t.IsAnalysisCreate == false).OrderBy(t => t.VisitTaskNum).Select(c => new VisitTaskSimpleView()
|
||||
VisitTaskList = g.OrderBy(t => t.VisitTaskNum).Select(c => new VisitTaskSimpleView()
|
||||
{
|
||||
Id = c.Id,
|
||||
ReadingCategory = c.ReadingCategory,
|
||||
@@ -217,28 +227,31 @@ namespace IRaCIS.Core.Application.Service
|
||||
TaskState = c.TaskState,
|
||||
ArmEnum = c.ArmEnum,
|
||||
SubjectId = c.SubjectId,
|
||||
SiteId=c.Subject.SiteId,
|
||||
SiteId = c.Subject.SiteId,
|
||||
TrialId = c.TrialId,
|
||||
SubjectCode = c.Subject.Code,
|
||||
TrialSiteCode = c.Subject.TrialSite.TrialSiteCode,
|
||||
}).Take(filterObj.PlanVisitCount).ToList(),
|
||||
|
||||
IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.IsAnalysisCreate && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id),
|
||||
|
||||
}).ToList(),
|
||||
|
||||
ValidTaskCount = g.Count()
|
||||
|
||||
});
|
||||
|
||||
var list = query.ToList();
|
||||
var list = query.OrderByDescending(t=>t.IsHaveGeneratedTask).ToList();
|
||||
|
||||
foreach (var subject in list)
|
||||
{
|
||||
subject.VisitTaskList.ForEach(t => { t.DoctorUserId = doctorUserId; t.TaskConsistentRuleId = filterObj.Id; });
|
||||
subject.VisitTaskList.Take(filterObj.PlanVisitCount).ForEach(t => { t.DoctorUserId = doctorUserId; t.TaskConsistentRuleId = filterObj.Id; });
|
||||
|
||||
|
||||
await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
|
||||
{
|
||||
TrialId= filterObj.TrialId,
|
||||
TrialId = filterObj.TrialId,
|
||||
ReadingCategory = ReadingCategory.Consistent,
|
||||
GenerataConsistentTaskList = subject.VisitTaskList
|
||||
GenerataConsistentTaskList = subject.VisitTaskList.Where(t=>t.IsHaveGeneratedTask==false).ToList()
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -201,11 +201,6 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PM 重阅追踪
|
||||
/// </summary>
|
||||
|
||||
@@ -83,14 +83,15 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
|
||||
|
||||
CreateMap<VisitTask, JudgeVisitTaskView>().IncludeBase<VisitTask,VisitTaskView>()
|
||||
CreateMap<VisitTask, JudgeVisitTaskView>().IncludeBase<VisitTask, VisitTaskView>()
|
||||
|
||||
|
||||
.ForMember(o => o.HistoryReadingDoctorUserList, t => t.MapFrom(u => u.JudgeVisitList));
|
||||
|
||||
CreateMap<VisitTask, ReadingTaskView>().IncludeBase<VisitTask, VisitTaskView>();
|
||||
|
||||
|
||||
CreateMap<VisitTask, AnalysisTaskView>().IncludeBase<VisitTask, VisitTaskView>()
|
||||
.ForMember(o => o.IsSelfAnalysis, t => t.MapFrom(u => u.TaskConsistentRule.CompareDoctorUserId == null));
|
||||
|
||||
|
||||
|
||||
@@ -105,8 +106,8 @@ namespace IRaCIS.Core.Application.Service
|
||||
|
||||
CreateMap<VisitTask, IRHaveReadView>()
|
||||
.ForMember(o => o.SiteId, t => t.MapFrom(u => u.Subject.SiteId))
|
||||
.ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.IsAnalysisCreate? u.BlindTrialSiteCode: u.Subject.TrialSite.TrialSiteCode))
|
||||
.ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.IsAnalysisCreate ? u.BlindSubjectCode: u.Subject.Code));
|
||||
.ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.IsAnalysisCreate ? u.BlindTrialSiteCode : u.Subject.TrialSite.TrialSiteCode))
|
||||
.ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.IsAnalysisCreate ? u.BlindSubjectCode : u.Subject.Code));
|
||||
|
||||
|
||||
|
||||
@@ -193,7 +194,7 @@ namespace IRaCIS.Core.Application.Service
|
||||
//.ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.DoctorUser))
|
||||
.ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.Subject.TrialSite.TrialSiteCode))
|
||||
.ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.Subject.Code));
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace IRaCIS.Application.Services
|
||||
SubjectId=x.SubjectId,
|
||||
ReadingCategory = x.ReadingCategory,
|
||||
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId,
|
||||
VisitNum = x.SourceSubjectVisitId != null ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum,
|
||||
VisitNum = x.SourceSubjectVisitId != null ? x.SourceSubjectVisit.VisitNum : x.ReadModule.VisitNum,
|
||||
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace IRaCIS.Application.Services
|
||||
TaskBlindName=x.TaskBlindName,
|
||||
ReadingCategory = x.ReadingCategory,
|
||||
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId,
|
||||
VisitNum = x.SourceSubjectVisitId != null ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum,
|
||||
VisitNum = x.SourceSubjectVisitId != null ? x.SourceSubjectVisit.VisitNum : x.ReadModule.VisitNum,
|
||||
}).OrderBy(x => x.VisitNum).ThenBy(x => x.ReadingCategory);
|
||||
|
||||
task =await taskquery.FirstOrDefaultAsync();
|
||||
@@ -142,7 +142,7 @@ namespace IRaCIS.Application.Services
|
||||
TaskBlindName = x.TaskBlindName,
|
||||
ReadingCategory = x.ReadingCategory,
|
||||
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId,
|
||||
VisitNum = x.SourceSubjectVisitId != null ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum,
|
||||
VisitNum = x.SourceSubjectVisitId != null ? x.SourceSubjectVisit.VisitNum : x.ReadModule.VisitNum,
|
||||
SubjectId=x.SubjectId,
|
||||
SubjectCode=x.Subject.Code,
|
||||
}).FirstOrDefaultAsync();
|
||||
|
||||
Reference in New Issue
Block a user