自身一致性分析

Uat_Study
hang 2022-07-07 16:03:11 +08:00
parent ac7a97706d
commit 2e4e88e39e
10 changed files with 259 additions and 147 deletions

View File

@ -65,23 +65,23 @@
<param name="queryVisitTask"></param> <param name="queryVisitTask"></param>
<returns></returns> <returns></returns>
</member> </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> <summary>
为一致性分析医生选择Subejct 列表 自身一致性分析医生选择Subejct 列表
</summary> </summary>
<param name="inQuery"></param> <param name="inQuery"></param>
<returns></returns> <returns></returns>
</member> </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>
确认生成一致性分析任务 确认生成自身一致性分析任务
</summary> </summary>
<param name="inCommand"></param> <param name="inCommand"></param>
<returns></returns> <returns></returns>
</member> </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>
一致性分配 配置+ 统计已经生成数量统计表 自身一致性分配 配置+ 统计已经生成数量统计表
</summary> </summary>
<param name="inQuery"></param> <param name="inQuery"></param>
<returns></returns> <returns></returns>

View File

@ -27,6 +27,7 @@ namespace IRaCIS.Core.Application.ViewModel
public int? GeneratedVisitCount { get; set; } public int? GeneratedVisitCount { get; set; }
} }
public class ConsistentQuery : PageInput public class ConsistentQuery : PageInput
@ -70,7 +71,7 @@ namespace IRaCIS.Core.Application.ViewModel
public List<VisitTaskSimpleView> VisitTaskList { get; set; } 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 public class VisitTaskSimpleView
@ -99,8 +100,12 @@ namespace IRaCIS.Core.Application.ViewModel
public String TrialSiteCode { get; set; } = String.Empty; public String TrialSiteCode { get; set; } = String.Empty;
public string SubjectCode { 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] [JsonIgnore]
public Guid? DoctorUserId { get; set; } public Guid? DoctorUserId { get; set; }
@ -118,7 +123,7 @@ namespace IRaCIS.Core.Application.ViewModel
{ {
public Guid TrialId { get; set; } 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 PlanSubjectCount { get; set; }
public int PlanVisitCount { get; set; } public int PlanVisitCount { get; set; }
public int IntervalWeeks { get; set; } public int IntervalWeeks { get; set; }
public Guid? CompareDoctorUserId { get; set; }
public bool IsHaveReadingPeriod { get; set; } public bool IsHaveReadingPeriod { get; set; }
public bool IsGenerateGlobalTask { get; set; } public bool IsGenerateGlobalTask { get; set; }
public Guid AnalysisDoctorUserId { 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; }
}
} }

View File

@ -13,6 +13,7 @@ namespace IRaCIS.Core.Application.ViewModel
/// <summary> TaskMedicalReviewView 列表视图模型 </summary> /// <summary> TaskMedicalReviewView 列表视图模型 </summary>
public class TaskMedicalReviewView : VisitTaskViewBasic public class TaskMedicalReviewView : VisitTaskViewBasic
{ {
public string MedicalNo { get; set; } = string.Empty;
public int AuditState { get; set; } public int AuditState { get; set; }
public DateTime? AuditSignTime { get; set; } public DateTime? AuditSignTime { get; set; }
@ -39,6 +40,8 @@ namespace IRaCIS.Core.Application.ViewModel
//开始读片时间 //开始读片时间
public DateTime? FirstReadingTime { get; set; } public DateTime? FirstReadingTime { get; set; }
public string MedicalNo { get; set; } = string.Empty;
//读片时间差 //读片时间差
public TimeSpan? ReadingDurationTimeSpan { get; set; } public TimeSpan? ReadingDurationTimeSpan { get; set; }
@ -47,15 +50,15 @@ namespace IRaCIS.Core.Application.ViewModel
{ {
get get
{ {
if (!ReadingDurationTimeSpan.HasValue ) if (!ReadingDurationTimeSpan.HasValue)
return ""; return "";
else return /*string.Format("{0}天{1}小时{2}分钟", (SignTime - FirstReadingTime)?.Days, (SignTime - FirstReadingTime)?.Hours, (SignTime - FirstReadingTime)?.Minutes)*/ else return /*string.Format("{0}天{1}小时{2}分钟", (SignTime - FirstReadingTime)?.Days, (SignTime - FirstReadingTime)?.Hours, (SignTime - FirstReadingTime)?.Minutes)*/
string.Format("{0}分钟", (ReadingDurationTimeSpan)?.TotalMinutes); string.Format("{0}分钟", (ReadingDurationTimeSpan)?.TotalMinutes);
} }
} }
//是否产生裁判 //是否产生裁判
public bool IsGeneratedJudge { get; set; } public bool IsGeneratedJudge { get; set; }
//审核次数 //审核次数
public int? GeneratedMedicalReviewCount { get; set; } public int? GeneratedMedicalReviewCount { get; set; }
@ -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 class GenerateMedicalReviewTaskCommand
{ {
public Guid TrialId { get; set; } public Guid TrialId { get; set; }

View File

@ -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); Task<IResponseOutput> AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule);

View File

@ -11,6 +11,7 @@ using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Infrastructure;
using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Domain.Share;
using System.Linq.Expressions; using System.Linq.Expressions;
using IRaCIS.Core.Infra.EFCore.Common;
namespace IRaCIS.Core.Application.Service namespace IRaCIS.Core.Application.Service
{ {
@ -26,7 +27,7 @@ namespace IRaCIS.Core.Application.Service
private readonly IRepository<SubjectUser> _subjectUserRepository; private readonly IRepository<SubjectUser> _subjectUserRepository;
private readonly IRepository<Subject> _subjectRepository; 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; _taskConsistentRuleRepository = taskConsistentRuleRepository;
_visitTaskRepository = visitTaskRepository; _visitTaskRepository = visitTaskRepository;
@ -68,16 +69,16 @@ namespace IRaCIS.Core.Application.Service
/// <summary> /// <summary>
/// 为一致性分析医生选择Subejct 列表 /// 为自身一致性分析医生选择Subejct 列表
/// </summary> /// </summary>
/// <param name="inQuery"></param> /// <param name="inQuery"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [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 filterObj = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == inQuery.TaskConsistentRuleId);
var(group, query) = GetIQueryableDoctorConsistentRuleSubjectView(filterObj); var (group, query) = GetIQueryableDoctorSelfConsistentRuleSubjectView(filterObj);
var count = group.Count(); var count = group.Count();
@ -98,32 +99,33 @@ namespace IRaCIS.Core.Application.Service
} }
/// <summary> /// <summary>
/// 确认生成一致性分析任务 /// 确认生成自身一致性分析任务
/// </summary> /// </summary>
/// <param name="inCommand"></param> /// <param name="inCommand"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [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 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) 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() await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand()
{ {
TrialId = filterObj.TrialId, TrialId = filterObj.TrialId,
ReadingCategory = ReadingCategory.Consistent, 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) //if (isSelfAnalysis == false)
{ //{
//过滤不满足的Subject // //过滤不满足的Subject
subjectfilter = _subjectUserRepository.Where(t => t.TrialId == filterObj.TrialId).GroupBy(t => t.SubjectId) // 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); // .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, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId)
// 组内一致性分析 //// 组内一致性分析
.WhereIf(isSelfAnalysis == false && subjectfilter != null, t => t.DoctorUserId == filterObj.AnalysisDoctorUserId && subjectfilter.Contains(t.SubjectId)) //.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.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) .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.SameSubjectVisiTaskList.Any(u => u.VisitTaskNum == t.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Global]
.WhereIf(filterObj.IsHaveReadingPeriod == true, t => t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Global) && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SignTime!.Value.AddDays(filterObj.IntervalWeeks * 7) < DateTime.Now))
.GroupBy(t => t.SubjectId) .GroupBy(t => t.SubjectId)
.Where(g => g.Count() >= filterObj.PlanVisitCount); .Where(g => g.Count() >= filterObj.PlanVisitCount);
@ -178,7 +180,7 @@ namespace IRaCIS.Core.Application.Service
{ {
SubjectId = g.Key, 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) VisitTaskList = g.OrderBy(t => t.VisitTaskNum)
@ -198,49 +200,138 @@ namespace IRaCIS.Core.Application.Service
SubjectCode = c.Subject.Code, SubjectCode = c.Subject.Code,
TrialSiteCode = c.Subject.TrialSite.TrialSiteCode, 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, Id = t.Id,
UserCode = c.DoctorUser.UserCode, ReadingCategory = t.ReadingCategory,
UserId = c.DoctorUser.Id, ReadingTaskState = t.ReadingTaskState,
UserName = c.DoctorUser.UserName 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(), }).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(), }).ToList(),
ValidTaskCount = g.Count() ValidTaskCount = g.Count()
}); }); ;
return (group, query); return (group, query);
} }
/// <summary> /// <summary>
/// 一致性分配 配置+ 统计已经生成数量统计表 /// 自身一致性分配 配置+ 统计已经生成数量统计表
/// </summary> /// </summary>
/// <param name="inQuery"></param> /// <param name="inQuery"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [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) var taskConsistentRuleQueryable = _taskConsistentRuleRepository.Where(t => t.TrialId == inQuery.TrialId)
.WhereIf(inQuery.IsSelfAnalysis, t => t.CompareDoctorUserId == null) .ProjectTo<TaskConsistentRuleView>(_mapper.ConfigurationProvider);
.WhereIf(inQuery.IsSelfAnalysis == false, t => t.CompareDoctorUserId != null)
.ProjectTo<TaskConsistentRuleView>(_mapper.ConfigurationProvider);
return await taskConsistentRuleQueryable.ToListAsync(); 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) public async Task<IResponseOutput> AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule)
{ {
var verifyExp1 = new EntityVerifyExp<TaskConsistentRule>() 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 = "已有该医生配置,不允许继续增加" VerifyMsg = "已有该医生配置,不允许继续增加"
}; };
@ -256,24 +347,14 @@ namespace IRaCIS.Core.Application.Service
{ {
var config = await _taskConsistentRuleRepository.FirstOrDefaultAsync(t => t.Id == taskConsistentRuleId); 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))
{ {
if (await _visitTaskRepository.AnyAsync(t => t.IsAnalysisCreate && t.DoctorUserId == config.AnalysisDoctorUserId && t.TrialId == config.TrialId)) throw new BusinessValidationFailedException("已产生一致性分析任务,不允许删除");
{
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); var success = await _taskConsistentRuleRepository.DeleteFromQueryAsync(t => t.Id == taskConsistentRuleId, true);
return ResponseOutput.Ok(); return ResponseOutput.Ok();
} }

View File

@ -90,8 +90,7 @@ namespace IRaCIS.Core.Application.Service
CreateMap<VisitTask, ReadingTaskView>().IncludeBase<VisitTask, VisitTaskView>(); CreateMap<VisitTask, ReadingTaskView>().IncludeBase<VisitTask, VisitTaskView>();
CreateMap<VisitTask, AnalysisTaskView>().IncludeBase<VisitTask, VisitTaskView>() CreateMap<VisitTask, AnalysisTaskView>().IncludeBase<VisitTask, VisitTaskView>();
.ForMember(o => o.IsSelfAnalysis, t => t.MapFrom(u => u.TaskConsistentRule.CompareDoctorUserId == null));
@ -147,6 +146,7 @@ namespace IRaCIS.Core.Application.Service
.ForMember(o => o.FullName, t => t.MapFrom(u => u.FullName)); .ForMember(o => o.FullName, t => t.MapFrom(u => u.FullName));
CreateMap<TaskMedicalReview, TaskMedicalReviewView>().IncludeMembers(t => t.VisitTask) 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.DoctorUser, t => t.MapFrom(u => u.VisitTask.DoctorUser))
.ForMember(o => o.MedicalManagerUser, t => t.MapFrom(u => u.MedicalManagerUser)); .ForMember(o => o.MedicalManagerUser, t => t.MapFrom(u => u.MedicalManagerUser));
CreateMap<VisitTask, TaskMedicalReviewView>() 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.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.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.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.IsGeneratedJudge, t => t.MapFrom(u => u.JudgeVisitTaskId !=null))
.ForMember(o => o.ReadingDurationTimeSpan, t => t.MapFrom(u => u.SignTime - u.FirstReadingTime)) .ForMember(o => o.ReadingDurationTimeSpan, t => t.MapFrom(u => u.SignTime - u.FirstReadingTime))
; ;
@ -204,7 +205,8 @@ namespace IRaCIS.Core.Application.Service
CreateMap<TaskConsistentRuleAddOrEdit, TaskConsistentRule>(); CreateMap<TaskConsistentRuleAddOrEdit, TaskConsistentRule>();
CreateMap<TaskConsistentRuleBatchAddOrEdit, TaskConsistentRule>().ForMember(t=>t.Id,u=>u.Ignore()).ReverseMap();
CreateMap<VisitTask, VisitTaskSimpleView>() CreateMap<VisitTask, VisitTaskSimpleView>()
//.ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.DoctorUser)) //.ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.DoctorUser))

View File

@ -72,11 +72,13 @@ namespace IRaCIS.Application.Services
//return _localizer["test{0}", "测试"]; //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; return _userInfo.LocalIp;
} }

View File

@ -47,7 +47,7 @@ namespace IRaCIS.Core.Domain.Models
public int IntervalWeeks { get; set; } public int IntervalWeeks { get; set; }
public Guid? CompareDoctorUserId { get; set; } //public Guid? CompareDoctorUserId { get; set; }
public bool IsHaveReadingPeriod { get; set; } public bool IsHaveReadingPeriod { get; set; }

View File

@ -84,7 +84,7 @@ namespace IRaCIS.Core.Domain.Models
//排除一致性分析 因为souceVisitId 没值 //排除一致性分析 因为souceVisitId 没值
//public List<VisitTask> SameVisitTaskList { get; set; } //public List<VisitTask> SameVisitTaskList { get; set; }
public List<VisitTask> SameSubjectVisiTaskList { get; set; }
public TaskConsistentRule TaskConsistentRule { get; set; } public TaskConsistentRule TaskConsistentRule { get; set; }
@ -159,6 +159,8 @@ namespace IRaCIS.Core.Domain.Models
/// </summary> /// </summary>
public bool IsAnalysisCreate { get; set; } public bool IsAnalysisCreate { get; set; }
public bool? IsSelfAnalysis { get; set; }
public string BlindSubjectCode { get; set; } = string.Empty; public string BlindSubjectCode { get; set; } = string.Empty;
public string BlindTrialSiteCode { get; set; } = string.Empty; public string BlindTrialSiteCode { get; set; } = string.Empty;

View File

@ -81,28 +81,31 @@ namespace IRaCIS.Core.Infra.EFCore
{ {
modelBuilder.Entity<TableList>(builder => modelBuilder.Entity<TableList>(builder =>
{ {
builder.HasBaseType((Type)null); builder.HasBaseType((Type)null);
builder.ToView(null); builder.ToView(null);
builder.HasNoKey(); builder.HasNoKey();
}); });
//modelBuilder.HasDbFunction(typeof(DbContext).GetMethod(nameof(GetTableList))); //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.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<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<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<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<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.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); modelBuilder.Entity<Dictionary>().HasMany(t => t.ChildList).WithOne(t => t.Parent);
modelBuilder.Entity<SubjectUser>().HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser); modelBuilder.Entity<SubjectUser>().HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser);
@ -141,7 +144,7 @@ namespace IRaCIS.Core.Infra.EFCore
modelBuilder.Entity(entityType.ClrType).Property<Guid>(nameof(Entity.Id)).HasValueGenerator<MySequentialGuidValueGenerator>(); modelBuilder.Entity(entityType.ClrType).Property<Guid>(nameof(Entity.Id)).HasValueGenerator<MySequentialGuidValueGenerator>();
} }
} }
} }
@ -174,7 +177,7 @@ namespace IRaCIS.Core.Infra.EFCore
public virtual DbSet<TrialExperienceCriteria> TrialExperienceCriteria { get; set; } public virtual DbSet<TrialExperienceCriteria> TrialExperienceCriteria { get; set; }
#endregion #endregion
@ -284,7 +287,7 @@ namespace IRaCIS.Core.Infra.EFCore
#region Trial #region Trial
public virtual DbSet<Trial> Trial { get; set; } public virtual DbSet<Trial> Trial { get; set; }
public virtual DbSet<TrialDictionary> TrialDictionary { get; set; } public virtual DbSet<TrialDictionary> TrialDictionary { get; set; }
public virtual DbSet<TrialStatusDetail> TrialDetail { get; set; } public virtual DbSet<TrialStatusDetail> TrialDetail { get; set; }
@ -425,7 +428,7 @@ namespace IRaCIS.Core.Infra.EFCore
public override int SaveChanges() public override int SaveChanges()
{ {
//UpdateAuditInfo().GetAwaiter(); //UpdateAuditInfo().GetAwaiter();
AddAudit().GetAwaiter(); AddAudit().GetAwaiter();
return base.SaveChanges(); return base.SaveChanges();
} }
@ -438,7 +441,7 @@ namespace IRaCIS.Core.Infra.EFCore
} }
public async Task AddAudit() public async Task AddAudit()
{ {
try try
{ {
@ -449,9 +452,9 @@ namespace IRaCIS.Core.Infra.EFCore
catch (Exception) catch (Exception)
{ {
} }
} }
/// <summary> /// <summary>
@ -460,71 +463,71 @@ namespace IRaCIS.Core.Infra.EFCore
//private async Task UpdateAuditInfo() //private async Task UpdateAuditInfo()
//{ //{
//ChangeTracker.DetectChanges(); // Important!
//// 获取所有更改,删除,新增的实体,但排除审计实体(避免死循环) //ChangeTracker.DetectChanges(); // Important!
//var entities = ChangeTracker.Entries()
// .Where(u => (u.State == EntityState.Modified || u.State == EntityState.Deleted || u.State == EntityState.Added)).Where(x=>x.Entity.GetType()!=typeof(data)).ToList();
//AuditingData auditingData = new AuditingData(this, _userInfo);
//await auditingData.IncomingEntitys(entities);
//var items = entities.SelectMany(x => x.Entity.GetType().ToString());
//foreach (var t in entities) //// 获取所有更改,删除,新增的实体,但排除审计实体(避免死循环)
//{ //var entities = ChangeTracker.Entries()
// switch (t.State) // .Where(u => (u.State == EntityState.Modified || u.State == EntityState.Deleted || u.State == EntityState.Added)).Where(x=>x.Entity.GetType()!=typeof(data)).ToList();
// { //AuditingData auditingData = new AuditingData(this, _userInfo);
//await auditingData.IncomingEntitys(entities);
//var items = entities.SelectMany(x => x.Entity.GetType().ToString());
// case EntityState.Deleted: //foreach (var t in entities)
//{
// switch (t.State)
// {
// break; // case EntityState.Deleted:
// case EntityState.Modified:
// if (t.Entity is IAuditUpdate updateEntity1) // break;
// { // case EntityState.Modified:
// updateEntity1.UpdateTime = DateTime.UtcNow.AddHours(8);
// updateEntity1.UpdateUserId = _userInfo.Id; // if (t.Entity is IAuditUpdate updateEntity1)
// } // {
// updateEntity1.UpdateTime = DateTime.UtcNow.AddHours(8);
// updateEntity1.UpdateUserId = _userInfo.Id;
// }
// break; // break;
// //添加的时候,更新审计字段也赋值 // //添加的时候,更新审计字段也赋值
// case EntityState.Added: // case EntityState.Added:
// ////// 仓储添加时 就有id了 // ////// 仓储添加时 就有id了
// //if (t.Entity is Entity entity && entity.Id == Guid.Empty) // //if (t.Entity is Entity entity && entity.Id == Guid.Empty)
// //{ // //{
// // entity.Id = NewId.NextGuid(); // // entity.Id = NewId.NextGuid();
// //} // //}
// if (t.Entity is IAuditAdd addEntity) // if (t.Entity is IAuditAdd addEntity)
// { // {
// if (addEntity.CreateTime == default(DateTime)) // if (addEntity.CreateTime == default(DateTime))
// { // {
// addEntity.CreateTime = DateTime.UtcNow.AddHours(8); // addEntity.CreateTime = DateTime.UtcNow.AddHours(8);
// } // }
// addEntity.CreateUserId = _userInfo.Id; // addEntity.CreateUserId = _userInfo.Id;
// } // }
// if (t.Entity is IAuditUpdate updateEntity) // if (t.Entity is IAuditUpdate updateEntity)
// { // {
// updateEntity.UpdateTime = DateTime.UtcNow.AddHours(8); // updateEntity.UpdateTime = DateTime.UtcNow.AddHours(8);
// updateEntity.UpdateUserId = _userInfo.Id; // updateEntity.UpdateUserId = _userInfo.Id;
// } // }
// if (t.Entity is IAuditAddWithUserName addEntity3) // if (t.Entity is IAuditAddWithUserName addEntity3)
// { // {
// addEntity3.CreateTime = DateTime.UtcNow.AddHours(8); // addEntity3.CreateTime = DateTime.UtcNow.AddHours(8);
// addEntity3.CreateUserId = _userInfo.Id; // addEntity3.CreateUserId = _userInfo.Id;
// addEntity3.CreateUser = _userInfo.RealName; // addEntity3.CreateUser = _userInfo.RealName;
// } // }
// break; // break;
// } // }
//} //}
//} //}
@ -567,7 +570,7 @@ namespace IRaCIS.Core.Infra.EFCore
break; break;
} }
} }
if (e.Entry.Entity is IAuditAddWithUserName addEntity2) if (e.Entry.Entity is IAuditAddWithUserName addEntity2)
{ {
switch (e.Entry.State) switch (e.Entry.State)