自身一致性分析
parent
ac7a97706d
commit
2e4e88e39e
|
@ -65,23 +65,23 @@
|
|||
<param name="queryVisitTask"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.TaskConsistentRuleService.GetDoctorConsistentRuleSubjectList(IRaCIS.Core.Application.ViewModel.ConsistentQuery)">
|
||||
<member name="M:IRaCIS.Core.Application.Service.TaskConsistentRuleService.GetDoctorSelfConsistentRuleSubjectList(IRaCIS.Core.Application.ViewModel.ConsistentQuery)">
|
||||
<summary>
|
||||
为一致性分析医生,选择Subejct 列表
|
||||
为自身一致性分析医生,选择Subejct 列表
|
||||
</summary>
|
||||
<param name="inQuery"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.TaskConsistentRuleService.ConfirmGenerateConsistentTask(IRaCIS.Core.Application.ViewModel.ConsistentConfirmGenerateCommand,IRaCIS.Core.Application.Service.IVisitTaskHelpeService)">
|
||||
<member name="M:IRaCIS.Core.Application.Service.TaskConsistentRuleService.ConfirmGenerateSelfConsistentTask(IRaCIS.Core.Application.ViewModel.ConsistentConfirmGenerateCommand,IRaCIS.Core.Application.Service.IVisitTaskHelpeService)">
|
||||
<summary>
|
||||
确认生成一致性分析任务
|
||||
确认生成自身一致性分析任务
|
||||
</summary>
|
||||
<param name="inCommand"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.TaskConsistentRuleService.GetTaskConsistentRuleList(IRaCIS.Core.Application.ViewModel.TaskConsistentRuleQuery)">
|
||||
<member name="M:IRaCIS.Core.Application.Service.TaskConsistentRuleService.GetSelfConsistentRuleList(IRaCIS.Core.Application.ViewModel.TaskConsistentRuleQuery)">
|
||||
<summary>
|
||||
一致性分配 配置+ 统计已经生成数量统计表
|
||||
自身一致性分配 配置+ 统计已经生成数量统计表
|
||||
</summary>
|
||||
<param name="inQuery"></param>
|
||||
<returns></returns>
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public int? GeneratedVisitCount { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class ConsistentQuery : PageInput
|
||||
|
@ -70,7 +71,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public List<VisitTaskSimpleView> VisitTaskList { get; set; }
|
||||
|
||||
public List<UserSimpleInfo> HistoryDoctorUserList => VisitTaskList.SelectMany(t => t.RelationDoctorUserList).DistinctBy(t=>t.UserId).ToList();
|
||||
//public List<UserSimpleInfo> HistoryDoctorUserList => VisitTaskList.SelectMany(t => t.RelationDoctorUserList).DistinctBy(t=>t.UserId).ToList();
|
||||
}
|
||||
|
||||
public class VisitTaskSimpleView
|
||||
|
@ -99,8 +100,12 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
public String TrialSiteCode { get; set; } = String.Empty;
|
||||
public string SubjectCode { get; set; } = String.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
public List<UserSimpleInfo> RelationDoctorUserList { get; set; } = new List<UserSimpleInfo>();
|
||||
|
||||
|
||||
public List<VisitTaskSimpleView> GlobalVisitTaskList { get; set; }
|
||||
|
||||
//[JsonIgnore]
|
||||
//public List<UserSimpleInfo> RelationDoctorUserList { get; set; } = new List<UserSimpleInfo>();
|
||||
|
||||
[JsonIgnore]
|
||||
public Guid? DoctorUserId { get; set; }
|
||||
|
@ -118,7 +123,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
{
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public bool IsSelfAnalysis { get; set; }
|
||||
//public bool IsSelfAnalysis { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
@ -132,7 +137,6 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
public int PlanSubjectCount { get; set; }
|
||||
public int PlanVisitCount { get; set; }
|
||||
public int IntervalWeeks { get; set; }
|
||||
public Guid? CompareDoctorUserId { get; set; }
|
||||
public bool IsHaveReadingPeriod { get; set; }
|
||||
public bool IsGenerateGlobalTask { get; set; }
|
||||
public Guid AnalysisDoctorUserId { get; set; }
|
||||
|
@ -140,6 +144,12 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
}
|
||||
|
||||
|
||||
public class TaskConsistentRuleBatchAddOrEdit : TaskConsistentRuleAddOrEdit
|
||||
{
|
||||
|
||||
public bool IsBatchAdd { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
/// <summary> TaskMedicalReviewView 列表视图模型 </summary>
|
||||
public class TaskMedicalReviewView : VisitTaskViewBasic
|
||||
{
|
||||
public string MedicalNo { get; set; } = string.Empty;
|
||||
|
||||
public int AuditState { get; set; }
|
||||
public DateTime? AuditSignTime { get; set; }
|
||||
|
@ -39,6 +40,8 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
//开始读片时间
|
||||
public DateTime? FirstReadingTime { get; set; }
|
||||
|
||||
public string MedicalNo { get; set; } = string.Empty;
|
||||
|
||||
//读片时间差
|
||||
public TimeSpan? ReadingDurationTimeSpan { get; set; }
|
||||
|
||||
|
@ -47,7 +50,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
{
|
||||
get
|
||||
{
|
||||
if (!ReadingDurationTimeSpan.HasValue )
|
||||
if (!ReadingDurationTimeSpan.HasValue)
|
||||
return "";
|
||||
else return /*string.Format("{0}天{1}小时{2}分钟", (SignTime - FirstReadingTime)?.Days, (SignTime - FirstReadingTime)?.Hours, (SignTime - FirstReadingTime)?.Minutes)*/
|
||||
string.Format("{0}分钟", (ReadingDurationTimeSpan)?.TotalMinutes);
|
||||
|
@ -87,6 +90,15 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
}
|
||||
|
||||
//public class GenerateMedicalReviewTaskQuery : TaskMedicalReviewQuery
|
||||
//{
|
||||
// public bool? IsGeneratedJudge { get; set; }
|
||||
|
||||
// public bool? IsGlobalHaveUpdate { get; set; }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
public class GenerateMedicalReviewTaskCommand
|
||||
{
|
||||
public Guid TrialId { get; set; }
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace IRaCIS.Core.Application.Interfaces
|
|||
{
|
||||
|
||||
|
||||
Task<List<TaskConsistentRuleView>> GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery);
|
||||
//Task<List<TaskConsistentRuleView>> GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery);
|
||||
|
||||
Task<IResponseOutput> AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ using IRaCIS.Core.Application.ViewModel;
|
|||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System.Linq.Expressions;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
|
@ -26,7 +27,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
private readonly IRepository<SubjectUser> _subjectUserRepository;
|
||||
private readonly IRepository<Subject> _subjectRepository;
|
||||
|
||||
public TaskConsistentRuleService(IRepository<VisitTask> visitTaskRepository, IRepository<TaskConsistentRule> taskConsistentRuleRepository, IRepository<SubjectUser> subjectUserRepository ,IRepository<Subject> subjectRepository)
|
||||
public TaskConsistentRuleService(IRepository<VisitTask> visitTaskRepository, IRepository<TaskConsistentRule> taskConsistentRuleRepository, IRepository<SubjectUser> subjectUserRepository, IRepository<Subject> subjectRepository)
|
||||
{
|
||||
_taskConsistentRuleRepository = taskConsistentRuleRepository;
|
||||
_visitTaskRepository = visitTaskRepository;
|
||||
|
@ -68,16 +69,16 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
/// <summary>
|
||||
/// 为一致性分析医生,选择Subejct 列表
|
||||
/// 为自身一致性分析医生,选择Subejct 列表
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<PageOutput<DoctorConsistentRuleSubjectView>> GetDoctorConsistentRuleSubjectList(ConsistentQuery inQuery)
|
||||
public async Task<PageOutput<DoctorConsistentRuleSubjectView>> GetDoctorSelfConsistentRuleSubjectList(ConsistentQuery inQuery)
|
||||
{
|
||||
var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inQuery.TaskConsistentRuleId);
|
||||
|
||||
var(group, query) = GetIQueryableDoctorConsistentRuleSubjectView(filterObj);
|
||||
var (group, query) = GetIQueryableDoctorSelfConsistentRuleSubjectView(filterObj);
|
||||
|
||||
var count = group.Count();
|
||||
|
||||
|
@ -98,32 +99,33 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确认生成一致性分析任务
|
||||
/// 确认生成自身一致性分析任务
|
||||
/// </summary>
|
||||
/// <param name="inCommand"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> ConfirmGenerateConsistentTask(ConsistentConfirmGenerateCommand inCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
|
||||
public async Task<IResponseOutput> ConfirmGenerateSelfConsistentTask(ConsistentConfirmGenerateCommand inCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
|
||||
{
|
||||
var filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inCommand.TaskConsistentRuleId);
|
||||
|
||||
var doctorUserId = filterObj.CompareDoctorUserId == null ? filterObj.AnalysisDoctorUserId : filterObj.CompareDoctorUserId;
|
||||
|
||||
var (group, query) = GetIQueryableDoctorConsistentRuleSubjectView(filterObj, inCommand.SubejctIdList);
|
||||
var (group, query) = GetIQueryableDoctorSelfConsistentRuleSubjectView(filterObj, inCommand.SubejctIdList);
|
||||
|
||||
var list = query.OrderByDescending(t=>t.IsHaveGeneratedTask).ToList();
|
||||
var list = query.OrderByDescending(t => t.IsHaveGeneratedTask).ToList();
|
||||
|
||||
foreach (var subject in list)
|
||||
{
|
||||
subject.VisitTaskList.Take(filterObj.PlanVisitCount).ForEach(t => { t.DoctorUserId = doctorUserId; t.TaskConsistentRuleId = filterObj.Id; });
|
||||
subject.VisitTaskList.Take(filterObj.PlanVisitCount).ForEach(t => { t.DoctorUserId = filterObj.AnalysisDoctorUserId; t.TaskConsistentRuleId = filterObj.Id; });
|
||||
|
||||
|
||||
await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
|
||||
{
|
||||
TrialId = filterObj.TrialId,
|
||||
|
||||
ReadingCategory = ReadingCategory.Consistent,
|
||||
|
||||
//产生的过滤掉已经生成的
|
||||
GenerataConsistentTaskList = subject.VisitTaskList.Where(t=>t.IsHaveGeneratedTask==false).ToList()
|
||||
GenerataConsistentTaskList = subject.VisitTaskList.Where(t => t.IsHaveGeneratedTask == false).ToList()
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -137,39 +139,39 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
|
||||
private (IQueryable<IGrouping<Guid,VisitTask>>, IQueryable<DoctorConsistentRuleSubjectView>) GetIQueryableDoctorConsistentRuleSubjectView(TaskConsistentRule filterObj, List<Guid>? subejctIdList=null)
|
||||
private (IQueryable<IGrouping<Guid, VisitTask>>, IQueryable<DoctorConsistentRuleSubjectView>) GetIQueryableDoctorSelfConsistentRuleSubjectView(TaskConsistentRule filterObj, List<Guid>? subejctIdList = null)
|
||||
{
|
||||
|
||||
bool isSelfAnalysis = filterObj.CompareDoctorUserId == null;
|
||||
|
||||
IQueryable<Guid> subjectfilter = default;
|
||||
//IQueryable<Guid> subjectfilter = default;
|
||||
|
||||
if (isSelfAnalysis == false)
|
||||
{
|
||||
//过滤不满足的Subject
|
||||
//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);
|
||||
}
|
||||
// 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 doctorUserId = filterObj.AnalysisDoctorUserId;
|
||||
|
||||
|
||||
|
||||
var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId && t.IsAnalysisCreate == false)
|
||||
var group = _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId && t.IsAnalysisCreate == false && t.ReadingCategory == ReadingCategory.Visit && t.DoctorUserId == doctorUserId)
|
||||
|
||||
|
||||
.WhereIf(subejctIdList!=null && subejctIdList?.Count>0, t => subejctIdList.Contains(t.SubjectId))
|
||||
// 自身一致性分析
|
||||
.WhereIf(isSelfAnalysis, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId)
|
||||
// 组内一致性分析
|
||||
.WhereIf(isSelfAnalysis == false && subjectfilter != null, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId && subjectfilter.Contains(t.SubjectId))
|
||||
//.WhereIf(isSelfAnalysis, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId)
|
||||
//// 组内一致性分析
|
||||
//.WhereIf(isSelfAnalysis == false && subjectfilter != null, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId && subjectfilter.Contains(t.SubjectId))
|
||||
//.WhereIf(subejctIdList != null && subejctIdList?.Count > 0, t => subejctIdList.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.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < 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)
|
||||
.WhereIf(filterObj.IsHaveReadingPeriod == true, t => t.SameSubjectVisiTaskList.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))
|
||||
.GroupBy(t => t.SubjectId)
|
||||
.Where(g => g.Count() >= filterObj.PlanVisitCount);
|
||||
|
||||
|
@ -178,7 +180,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
SubjectId = g.Key,
|
||||
|
||||
IsHaveGeneratedTask = g.Any(c => c.Subject.SubjectVisitTaskList.Any(t => t.IsAnalysisCreate && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id)),
|
||||
IsHaveGeneratedTask = g.Any(c => c.SameSubjectVisiTaskList.Any(t => t.IsAnalysisCreate && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id)),
|
||||
|
||||
VisitTaskList = g.OrderBy(t => t.VisitTaskNum)
|
||||
|
||||
|
@ -198,49 +200,138 @@ namespace IRaCIS.Core.Application.Service
|
|||
SubjectCode = c.Subject.Code,
|
||||
TrialSiteCode = c.Subject.TrialSite.TrialSiteCode,
|
||||
|
||||
RelationDoctorUserList = c.SourceSubjectVisit.VisitTaskList/*Where(t=>t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect)*/.Select(c => new UserSimpleInfo()
|
||||
GlobalVisitTaskList = c.SameSubjectVisiTaskList.Where(t => t.VisitTaskNum == c.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global] && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned).Select(t => new VisitTaskSimpleView()
|
||||
{
|
||||
FullName = c.DoctorUser.FullName,
|
||||
UserCode = c.DoctorUser.UserCode,
|
||||
UserId = c.DoctorUser.Id,
|
||||
UserName = c.DoctorUser.UserName
|
||||
Id = t.Id,
|
||||
ReadingCategory = t.ReadingCategory,
|
||||
ReadingTaskState = t.ReadingTaskState,
|
||||
TaskBlindName = t.TaskBlindName,
|
||||
TaskCode = t.TaskCode,
|
||||
TaskName = t.TaskName,
|
||||
TaskState = t.TaskState,
|
||||
ArmEnum = t.ArmEnum,
|
||||
SubjectId = t.SubjectId,
|
||||
TrialId = t.TrialId,
|
||||
SiteId = t.Subject.SiteId,
|
||||
SubjectCode = t.Subject.Code,
|
||||
TrialSiteCode = t.Subject.TrialSite.TrialSiteCode,
|
||||
}).ToList(),
|
||||
|
||||
IsHaveGeneratedTask = c.Subject.SubjectVisitTaskList.Any(t => t.IsAnalysisCreate && t.DoctorUserId == doctorUserId && t.TaskConsistentRuleId == filterObj.Id),
|
||||
//RelationDoctorUserList = c.SourceSubjectVisit.VisitTaskList/*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.SameSubjectVisiTaskList.Any(t => t.ConsistentAnalysisOriginalTaskId == c.Id),
|
||||
|
||||
}).ToList(),
|
||||
|
||||
ValidTaskCount = g.Count()
|
||||
|
||||
});
|
||||
}); ;
|
||||
|
||||
return (group, query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 一致性分配 配置+ 统计已经生成数量统计表
|
||||
/// 自身一致性分配 配置+ 统计已经生成数量统计表
|
||||
/// </summary>
|
||||
/// <param name="inQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<TaskConsistentRuleView>> GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery)
|
||||
public async Task<List<TaskConsistentRuleView>> GetSelfConsistentRuleList(TaskConsistentRuleQuery inQuery)
|
||||
{
|
||||
|
||||
#region 是否有新的医生加入 自动加入配置
|
||||
|
||||
|
||||
if (await _taskConsistentRuleRepository.AnyAsync(t => t.TrialId == inQuery.TrialId))
|
||||
{
|
||||
var rule = await _taskConsistentRuleRepository.Where(t => t.TrialId == inQuery.TrialId).ProjectTo<TaskConsistentRuleBatchAddOrEdit>(_mapper.ConfigurationProvider).FirstAsync();
|
||||
|
||||
rule.IsBatchAdd = true;
|
||||
|
||||
await BatchAddOrUpdateTaskConsistentRule(rule);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
var taskConsistentRuleQueryable = _taskConsistentRuleRepository.Where(t => t.TrialId == inQuery.TrialId)
|
||||
.WhereIf(inQuery.IsSelfAnalysis, t => t.CompareDoctorUserId == null)
|
||||
.WhereIf(inQuery.IsSelfAnalysis == false, t => t.CompareDoctorUserId != null)
|
||||
.ProjectTo<TaskConsistentRuleView>(_mapper.ConfigurationProvider);
|
||||
|
||||
return await taskConsistentRuleQueryable.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<IResponseOutput> BatchAddOrUpdateTaskConsistentRule(TaskConsistentRuleBatchAddOrEdit addOrEdit)
|
||||
{
|
||||
var trialId = addOrEdit.TrialId;
|
||||
|
||||
|
||||
|
||||
if (addOrEdit.IsBatchAdd)
|
||||
{
|
||||
var query = from enroll in _repository.Where<Enroll>(t => t.TrialId == trialId)
|
||||
join user in _repository.Where<User>() on enroll.DoctorId equals user.DoctorId
|
||||
join taskConsistentRule in _repository.Where<TaskConsistentRule>() on user.Id equals taskConsistentRule.AnalysisDoctorUserId into c
|
||||
from taskConsistentRule in c.DefaultIfEmpty()
|
||||
select new
|
||||
{
|
||||
TrialId = enroll.TrialId,
|
||||
|
||||
DoctorUserId = user.Id,
|
||||
//FullName = user.FullName,
|
||||
//UserCode = user.UserCode,
|
||||
//UserName = user.UserName,
|
||||
|
||||
IsHaveConfig = taskConsistentRule != null
|
||||
};
|
||||
|
||||
var doctorList = await query.ToListAsync();
|
||||
|
||||
|
||||
foreach (var doctor in doctorList)
|
||||
{
|
||||
if (!doctor.IsHaveConfig)
|
||||
{
|
||||
var verifyExp1 = new EntityVerifyExp<TaskConsistentRule>()
|
||||
{
|
||||
VerifyExp = t => t.AnalysisDoctorUserId == addOrEdit.AnalysisDoctorUserId && t.TrialId == addOrEdit.TrialId,
|
||||
VerifyMsg = "已有该医生配置,不允许继续增加"
|
||||
};
|
||||
|
||||
var entity = await _taskConsistentRuleRepository.InsertOrUpdateAsync(addOrEdit, true, verifyExp1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await _taskConsistentRuleRepository.UpdatePartialFromQueryAsync(t => t.TrialId == addOrEdit.TrialId, c => new TaskConsistentRule()
|
||||
{
|
||||
PlanSubjectCount = c.PlanSubjectCount,
|
||||
PlanVisitCount = c.PlanVisitCount,
|
||||
IntervalWeeks = c.IntervalWeeks,
|
||||
IsGenerateGlobalTask = c.IsGenerateGlobalTask,
|
||||
IsHaveReadingPeriod = c.IsHaveReadingPeriod
|
||||
|
||||
}, true);
|
||||
}
|
||||
|
||||
await _taskConsistentRuleRepository.SaveChangesAsync();
|
||||
|
||||
return ResponseOutput.Ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<IResponseOutput> AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule)
|
||||
{
|
||||
|
||||
var verifyExp1 = new EntityVerifyExp<TaskConsistentRule>()
|
||||
{
|
||||
VerifyExp = t => t.AnalysisDoctorUserId == addOrEditTaskConsistentRule.AnalysisDoctorUserId && t.CompareDoctorUserId == addOrEditTaskConsistentRule.CompareDoctorUserId && t.TrialId == addOrEditTaskConsistentRule.TrialId,
|
||||
VerifyExp = t => t.AnalysisDoctorUserId == addOrEditTaskConsistentRule.AnalysisDoctorUserId && t.TrialId == addOrEditTaskConsistentRule.TrialId,
|
||||
VerifyMsg = "已有该医生配置,不允许继续增加"
|
||||
};
|
||||
|
||||
|
@ -256,22 +347,12 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
var config = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == taskConsistentRuleId);
|
||||
|
||||
//自身一致性分析
|
||||
if (config.CompareDoctorUserId == null)
|
||||
{
|
||||
|
||||
if (await _visitTaskRepository.AnyAsync(t => t.IsAnalysisCreate && t.DoctorUserId == config.AnalysisDoctorUserId && t.TrialId == config.TrialId))
|
||||
{
|
||||
throw new BusinessValidationFailedException("已产生一致性分析任务,不允许删除");
|
||||
}
|
||||
}
|
||||
//组内一致性分析
|
||||
else
|
||||
{
|
||||
if (await _visitTaskRepository.AnyAsync(t => t.IsAnalysisCreate && t.DoctorUserId == config.CompareDoctorUserId && t.TrialId == config.TrialId))
|
||||
{
|
||||
throw new BusinessValidationFailedException("已产生一致性分析任务,不允许删除");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var success = await _taskConsistentRuleRepository.DeleteFromQueryAsync(t => t.Id == taskConsistentRuleId, true);
|
||||
|
|
|
@ -90,8 +90,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
CreateMap<VisitTask, ReadingTaskView>().IncludeBase<VisitTask, VisitTaskView>();
|
||||
|
||||
CreateMap<VisitTask, AnalysisTaskView>().IncludeBase<VisitTask, VisitTaskView>()
|
||||
.ForMember(o => o.IsSelfAnalysis, t => t.MapFrom(u => u.TaskConsistentRule.CompareDoctorUserId == null));
|
||||
CreateMap<VisitTask, AnalysisTaskView>().IncludeBase<VisitTask, VisitTaskView>();
|
||||
|
||||
|
||||
|
||||
|
@ -147,6 +146,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
.ForMember(o => o.FullName, t => t.MapFrom(u => u.FullName));
|
||||
|
||||
CreateMap<TaskMedicalReview, TaskMedicalReviewView>().IncludeMembers(t => t.VisitTask)
|
||||
.ForMember(o => o.MedicalNo, t => t.MapFrom(u => u.VisitTask.Subject.MedicalNo))
|
||||
.ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.VisitTask.DoctorUser))
|
||||
.ForMember(o => o.MedicalManagerUser, t => t.MapFrom(u => u.MedicalManagerUser));
|
||||
CreateMap<VisitTask, TaskMedicalReviewView>()
|
||||
|
@ -157,6 +157,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
.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.GeneratedMedicalReviewCount, t => t.MapFrom(u => u.TaskMedicalReviewList.Count()))
|
||||
.ForMember(o => o.MedicalNo, t => t.MapFrom(u => u.Subject.MedicalNo ))
|
||||
.ForMember(o => o.IsGeneratedJudge, t => t.MapFrom(u => u.JudgeVisitTaskId !=null))
|
||||
.ForMember(o => o.ReadingDurationTimeSpan, t => t.MapFrom(u => u.SignTime - u.FirstReadingTime))
|
||||
;
|
||||
|
@ -204,6 +205,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
CreateMap<TaskConsistentRuleAddOrEdit, TaskConsistentRule>();
|
||||
|
||||
CreateMap<TaskConsistentRuleBatchAddOrEdit, TaskConsistentRule>().ForMember(t=>t.Id,u=>u.Ignore()).ReverseMap();
|
||||
|
||||
|
||||
CreateMap<VisitTask, VisitTaskSimpleView>()
|
||||
|
|
|
@ -72,11 +72,13 @@ namespace IRaCIS.Application.Services
|
|||
//return _localizer["test{0}", "测试"];
|
||||
|
||||
|
||||
var list = _repository.Where<SubjectVisit>(t => t.Id == Guid.NewGuid()).SelectMany(t => t.VisitTaskList).ToList();
|
||||
//var list = _repository.Where<SubjectVisit>(t => t.Id == Guid.NewGuid()).SelectMany(t => t.VisitTaskList).ToList();
|
||||
|
||||
var list2 = _repository.Where<VisitTask>(t => t.Id == Guid.NewGuid()).Select(t => t.SourceSubjectVisit).ToList();
|
||||
//var list2 = _repository.Where<VisitTask>(t => t.Id == Guid.NewGuid()).Select(t => t.SourceSubjectVisit).ToList();
|
||||
|
||||
var list3 = _repository.Where<VisitTask>(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SourceSubjectVisit.VisitTaskList).ToList();
|
||||
//var list3 = _repository.Where<VisitTask>(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SourceSubjectVisit.VisitTaskList).ToList();
|
||||
var list2 = _repository.Where<Subject>(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SubjectVisitTaskList).ToList();
|
||||
var list3 = _repository.Where<VisitTask>(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SameSubjectVisiTaskList).ToList();
|
||||
return _userInfo.LocalIp;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace IRaCIS.Core.Domain.Models
|
|||
public int IntervalWeeks { get; set; }
|
||||
|
||||
|
||||
public Guid? CompareDoctorUserId { get; set; }
|
||||
//public Guid? CompareDoctorUserId { get; set; }
|
||||
|
||||
|
||||
public bool IsHaveReadingPeriod { get; set; }
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace IRaCIS.Core.Domain.Models
|
|||
//排除一致性分析 因为souceVisitId 没值
|
||||
//public List<VisitTask> SameVisitTaskList { get; set; }
|
||||
|
||||
|
||||
public List<VisitTask> SameSubjectVisiTaskList { get; set; }
|
||||
|
||||
public TaskConsistentRule TaskConsistentRule { get; set; }
|
||||
|
||||
|
@ -159,6 +159,8 @@ namespace IRaCIS.Core.Domain.Models
|
|||
/// </summary>
|
||||
public bool IsAnalysisCreate { get; set; }
|
||||
|
||||
public bool? IsSelfAnalysis { get; set; }
|
||||
|
||||
public string BlindSubjectCode { get; set; } = string.Empty;
|
||||
public string BlindTrialSiteCode { get; set; } = string.Empty;
|
||||
|
||||
|
|
|
@ -88,20 +88,23 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
|
||||
//modelBuilder.HasDbFunction(typeof(DbContext).GetMethod(nameof(GetTableList)));
|
||||
|
||||
modelBuilder.Entity<TaskAllocationRule>().HasMany(t => t.DoctorVisitTaskList).WithOne(t => t.DoctorTaskAllocationRule).HasForeignKey(t=> new { t.DoctorUserId,t.TrialId } ).HasPrincipalKey(u=> new { u.DoctorUserId,u.TrialId });
|
||||
modelBuilder.Entity<TaskAllocationRule>().HasMany(t => t.DoctorVisitTaskList).WithOne(t => t.DoctorTaskAllocationRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId });
|
||||
|
||||
modelBuilder.Entity<TaskMedicalReviewRule>().HasMany(t => t.DoctorVisitTaskList).WithOne(t => t.DoctorTaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId });
|
||||
|
||||
modelBuilder.Entity<TaskMedicalReviewRule>().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.TaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId });
|
||||
|
||||
modelBuilder.Entity<SubjectUser>().HasMany(t => t.SubjectArmVisitTaskList).WithOne(t=>t.SujectArm).HasForeignKey(t => new { t.SubjectId,t.ArmEnum}).HasPrincipalKey(u => new { u.SubjectId,u.ArmEnum });
|
||||
modelBuilder.Entity<VisitTask>().HasMany(t => t.JudgeVisitList).WithOne(t=>t.JudgeVisitTask);
|
||||
modelBuilder.Entity<SubjectUser>().HasMany(t => t.SubjectArmVisitTaskList).WithOne(t => t.SujectArm).HasForeignKey(t => new { t.SubjectId, t.ArmEnum }).HasPrincipalKey(u => new { u.SubjectId, u.ArmEnum });
|
||||
modelBuilder.Entity<VisitTask>().HasMany(t => t.JudgeVisitList).WithOne(t => t.JudgeVisitTask);
|
||||
|
||||
//modelBuilder.Entity<SubjectVisit>().HasMany(t => t.VisitTaskList).WithOne(t => t.SourceSubjectVisit).HasForeignKey(t=>t.SourceSubjectVisitId).HasPrincipalKey(t=>t.Id);
|
||||
|
||||
//modelBuilder.Entity<VisitTask>().HasMany(t => t.AnalysisVisitTaskList).WithOne().HasForeignKey(t => t.TaskConsistentRuleId).HasPrincipalKey(u => u.SourceSubjectVisitId);
|
||||
|
||||
modelBuilder.Entity<VisitTask>().HasMany(t => t.TaskMedicalReviewList).WithOne(t=>t.VisitTask).HasForeignKey(t => t.VisitTaskId);
|
||||
modelBuilder.Entity<VisitTask>().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId);
|
||||
|
||||
modelBuilder.Entity<VisitTask>().HasMany(t => t.SameSubjectVisiTaskList).WithOne().HasForeignKey(t => t.SubjectId).HasPrincipalKey(u=>u.SubjectId);
|
||||
modelBuilder.Entity<VisitTask>().HasOne(t => t.Subject).WithMany(s=>s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId);
|
||||
|
||||
|
||||
modelBuilder.Entity<Dictionary>().HasMany(t => t.ChildList).WithOne(t => t.Parent);
|
||||
|
|
Loading…
Reference in New Issue