导航属性修改
parent
71a380c2a9
commit
407205ec79
|
@ -61,7 +61,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public Guid SubjectId { get; set; }
|
||||
|
||||
public bool IsHaveCreatedTask { get; set; }
|
||||
public bool IsHaveGeneratedTask { get; set; }
|
||||
public int? ValidTaskCount { get; set; }
|
||||
|
||||
public int? ValidVisitCount => VisitTaskList.Select(t => t.TaskName).Distinct().Count();
|
||||
|
|
|
@ -12,12 +12,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
/// <summary> TaskMedicalReviewView 列表视图模型 </summary>
|
||||
public class TaskMedicalReviewView: VisitTaskViewBasic
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid CreateUserId { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
public DateTime UpdateTime { get; set; }
|
||||
public Guid UpdateUserId { get; set; }
|
||||
public DateTime? AllocateTime { get; set; }
|
||||
|
||||
public int AuditState { get; set; }
|
||||
public DateTime? AuditSignTime { get; set; }
|
||||
public int DoctorUserIdeaEnum { get; set; }
|
||||
|
@ -26,7 +21,6 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
|
||||
|
||||
|
||||
public UserSimpleInfo DoctorUser { get; set; }
|
||||
|
||||
public UserSimpleInfo MedicalManagerUser { get; set; }
|
||||
|
|
|
@ -10,6 +10,7 @@ using IRaCIS.Core.Application.Interfaces;
|
|||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
|
@ -22,11 +23,13 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
private readonly IRepository<TaskConsistentRule> _taskConsistentRuleRepository;
|
||||
private readonly IRepository<VisitTask> _visitTaskRepository;
|
||||
private readonly IRepository<SubjectUser> _subjectUserRepository;
|
||||
|
||||
public TaskConsistentRuleService(IRepository<VisitTask> visitTaskRepository, IRepository<TaskConsistentRule> taskConsistentRuleRepository)
|
||||
public TaskConsistentRuleService(IRepository<VisitTask> visitTaskRepository, IRepository<TaskConsistentRule> taskConsistentRuleRepository, IRepository<SubjectUser> subjectUserRepository)
|
||||
{
|
||||
_taskConsistentRuleRepository = taskConsistentRuleRepository;
|
||||
_visitTaskRepository = visitTaskRepository;
|
||||
_subjectUserRepository = subjectUserRepository;
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,11 +75,26 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inQuery.TaskConsistentRuleId);
|
||||
|
||||
var doctorUserId = filterObj.CompareDoctorUserId == null ? filterObj.AnalysisDoctorUserId : filterObj.CompareDoctorUserId;
|
||||
|
||||
bool isSelfAnalysis = filterObj.CompareDoctorUserId == null;
|
||||
|
||||
IQueryable<Guid> subjectfilter = default;
|
||||
|
||||
if (isSelfAnalysis == false)
|
||||
{
|
||||
//过滤不满足的Subject
|
||||
|
||||
subjectfilter = _subjectUserRepository.Where(t => t.TrialId == filterObj.TrialId).GroupBy(t => t.SubjectId)
|
||||
.Where(g => g.Any(t => t.DoctorUserId == filterObj.AnalysisDoctorUserId) && !g.Any(t => t.DoctorUserId == filterObj.CompareDoctorUserId)).Select(g => g.Key);
|
||||
}
|
||||
|
||||
var doctorUserId = isSelfAnalysis ? filterObj.AnalysisDoctorUserId : filterObj.CompareDoctorUserId;
|
||||
|
||||
var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId)
|
||||
.WhereIf(filterObj.CompareDoctorUserId == null, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId)
|
||||
.WhereIf(filterObj.CompareDoctorUserId != null, t => t.DoctorUserId == filterObj.CompareDoctorUserId)
|
||||
// 自身一致性分析
|
||||
.WhereIf(isSelfAnalysis, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId)
|
||||
// 组内一致性分析
|
||||
.WhereIf(isSelfAnalysis == false, 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)
|
||||
//重阅产生的访视任务 要把之前的访视任务去除
|
||||
|
@ -91,7 +109,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
SubjectId = g.Key,
|
||||
|
||||
IsHaveCreatedTask = g.Any(t => t.IsAnalysisCreate && t.SubjectId == g.Key && t.DoctorUserId == doctorUserId),
|
||||
IsHaveGeneratedTask = g.Any(t => t.IsAnalysisCreate && t.SubjectId == g.Key && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id),
|
||||
|
||||
VisitTaskList = g.Where(t => t.IsAnalysisCreate == false).OrderBy(t => t.VisitTaskNum).Select(c => new VisitTaskSimpleView()
|
||||
{
|
||||
|
@ -114,7 +132,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
var count = group.Count();
|
||||
|
||||
query = query.OrderByDescending(t => t.IsHaveCreatedTask).Skip((inQuery.PageIndex - 1) * inQuery.PageSize);
|
||||
query = query.OrderByDescending(t => t.IsHaveGeneratedTask).Skip((inQuery.PageIndex - 1) * inQuery.PageSize);
|
||||
var items = await query.Take(inQuery.PageSize).ToArrayAsync().ConfigureAwait(false);
|
||||
|
||||
var pagedList = new PageOutput<DoctorConsistentRuleSubjectView>()
|
||||
|
@ -139,13 +157,27 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inCommand.TaskConsistentRuleId);
|
||||
|
||||
var doctorUserId = filterObj.CompareDoctorUserId == null ? filterObj.AnalysisDoctorUserId : filterObj.CompareDoctorUserId;
|
||||
bool isSelfAnalysis = filterObj.CompareDoctorUserId == null;
|
||||
|
||||
IQueryable<Guid> subjectfilter = default;
|
||||
|
||||
if (isSelfAnalysis == false)
|
||||
{
|
||||
//过滤不满足的Subject
|
||||
|
||||
subjectfilter = _subjectUserRepository.Where(t => t.TrialId == filterObj.TrialId).GroupBy(t => t.SubjectId)
|
||||
.Where(g => g.Any(t => t.DoctorUserId == filterObj.AnalysisDoctorUserId) && !g.Any(t => t.DoctorUserId == filterObj.CompareDoctorUserId)).Select(g => g.Key);
|
||||
}
|
||||
|
||||
var doctorUserId = isSelfAnalysis ? filterObj.AnalysisDoctorUserId : filterObj.CompareDoctorUserId;
|
||||
|
||||
|
||||
|
||||
var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId && inCommand.SubejctIdList.Contains(t.SubjectId))
|
||||
.WhereIf(filterObj.CompareDoctorUserId == null, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId)
|
||||
.WhereIf(filterObj.CompareDoctorUserId != null, t => t.DoctorUserId == filterObj.CompareDoctorUserId)
|
||||
// 自身一致性分析
|
||||
.WhereIf(isSelfAnalysis, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId)
|
||||
// 组内一致性分析
|
||||
.WhereIf(isSelfAnalysis == false, 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)
|
||||
//重阅产生的访视任务 要把之前的访视任务去除
|
||||
|
@ -161,7 +193,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
SubjectId = g.Key,
|
||||
|
||||
IsHaveCreatedTask = g.Any(t => t.IsAnalysisCreate && t.SubjectId == g.Key && t.DoctorUserId == doctorUserId),
|
||||
IsHaveGeneratedTask = g.Any(t => t.IsAnalysisCreate && t.SubjectId == g.Key && t.DoctorUserId == doctorUserId),
|
||||
|
||||
VisitTaskList = g.Where(t => t.IsAnalysisCreate == false).OrderBy(t => t.VisitTaskNum).Select(c => new VisitTaskSimpleView()
|
||||
{
|
||||
|
@ -187,6 +219,8 @@ namespace IRaCIS.Core.Application.Service
|
|||
foreach (var subject in list)
|
||||
{
|
||||
|
||||
|
||||
|
||||
await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
|
||||
{
|
||||
ReadingCategory = ReadingCategory.Consistent,
|
||||
|
@ -222,9 +256,6 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<IResponseOutput> AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule)
|
||||
{
|
||||
|
||||
|
|
|
@ -68,14 +68,11 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
var trialId = generateCommand.TrialId;
|
||||
|
||||
var mimUserList = await _trialUserRepository.Where(t => t.User.UserTypeEnum == Domain.Share.UserTypeEnum.MIM && t.TrialId == trialId).Select(t => t.User).ProjectTo<UserSimpleInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
//var mimUserList = await _trialUserRepository.Where(t => t.User.UserTypeEnum == Domain.Share.UserTypeEnum.MIM && t.TrialId == trialId).Select(t => t.User).ProjectTo<UserSimpleInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
//if (mimUserList.Count == 0)
|
||||
//{
|
||||
// return ResponseOutput.NotOk("没有MIM");
|
||||
//}
|
||||
|
||||
var defalutMIMUserId = mimUserList.FirstOrDefault()?.UserId;
|
||||
|
||||
Guid? defalutMIMUserId = null /*mimUserList.FirstOrDefault()?.UserId*/;
|
||||
|
||||
//获取当前医生数据 已经生成的,和配置的数量
|
||||
var taskTaskMedicalReviewRuleList = await _taskMedicalReviewRuleRepository.Where(t => t.TrialId == trialId).ProjectTo<TaskMedicalReviewRuleView>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
|
|
@ -215,8 +215,8 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
CreateMap<TaskConsistentRule, TaskConsistentRuleView>()
|
||||
.ForMember(o => o.GeneratedSubjectCount, t => t.MapFrom(u => u.DoctorConsistentTaskList.Select(t => t.SubjectId).Distinct().Count()))
|
||||
.ForMember(o => o.GeneratedVisitCount, t => t.MapFrom(u => u.DoctorConsistentTaskList.Count()));
|
||||
.ForMember(o => o.GeneratedSubjectCount, t => t.MapFrom(u => u.DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == u.Id).Select(t => t.SubjectId).Distinct().Count()))
|
||||
.ForMember(o => o.GeneratedVisitCount, t => t.MapFrom(u => u.DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == u.Id).Count()));
|
||||
|
||||
CreateMap<TaskConsistentRuleAddOrEdit, TaskConsistentRule>();
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ namespace IRaCIS.Core.Domain.Models
|
|||
public List<VisitTask> DoctorVisitTaskList { get; set; }
|
||||
|
||||
|
||||
[Projectable]
|
||||
public List<VisitTask> DoctorConsistentTaskList => DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == Id).ToList();
|
||||
//[Projectable]
|
||||
//public List<VisitTask> DoctorConsistentTaskList => DoctorVisitTaskList.Where(t => t.IsAnalysisCreate && t.TaskConsistentRuleId == Id).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue