From 2e4e88e39efc95bb2871d8125d10450a42bf5f0c Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Thu, 7 Jul 2022 16:03:11 +0800
Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E8=BA=AB=E4=B8=80=E8=87=B4=E6=80=A7?=
=?UTF-8?q?=E5=88=86=E6=9E=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../IRaCIS.Core.Application.xml | 12 +-
.../DTO/TaskConsistentRuleViewModel.cs | 20 +-
.../DTO/TaskMedicalReviewViewModel.cs | 18 +-
.../Interface/ITaskConsistentRuleService.cs | 2 +-
.../Allocation/TaskConsistentRuleService.cs | 197 ++++++++++++------
.../Service/Allocation/_MapConfig.cs | 8 +-
IRaCIS.Core.Application/TestService.cs | 8 +-
.../Allocation/TaskConsistentRule.cs | 2 +-
IRaCIS.Core.Domain/Allocation/VisitTask.cs | 4 +-
.../Context/IRaCISDBContext.cs | 135 ++++++------
10 files changed, 259 insertions(+), 147 deletions(-)
diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index 21308dfe6..f32435817 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -65,23 +65,23 @@
-
+
- 为一致性分析医生,选择Subejct 列表
+ 为自身一致性分析医生,选择Subejct 列表
-
+
- 确认生成一致性分析任务
+ 确认生成自身一致性分析任务
-
+
- 一致性分配 配置+ 统计已经生成数量统计表
+ 自身一致性分配 配置+ 统计已经生成数量统计表
diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs
index 9f171a534..a7407c4e9 100644
--- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskConsistentRuleViewModel.cs
@@ -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 VisitTaskList { get; set; }
- public List HistoryDoctorUserList => VisitTaskList.SelectMany(t => t.RelationDoctorUserList).DistinctBy(t=>t.UserId).ToList();
+ //public List 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 RelationDoctorUserList { get; set; } = new List();
+
+
+ public List GlobalVisitTaskList { get; set; }
+
+ //[JsonIgnore]
+ //public List RelationDoctorUserList { get; set; } = new List();
[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; }
+ }
+
}
diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewViewModel.cs
index 39977a0b2..460e09aae 100644
--- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewViewModel.cs
@@ -13,6 +13,7 @@ namespace IRaCIS.Core.Application.ViewModel
/// TaskMedicalReviewView 列表视图模型
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,15 +50,15 @@ 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);
+ string.Format("{0}分钟", (ReadingDurationTimeSpan)?.TotalMinutes);
}
}
//是否产生裁判
- public bool IsGeneratedJudge { get; set; }
+ public bool IsGeneratedJudge { 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 Guid TrialId { get; set; }
diff --git a/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskConsistentRuleService.cs
index 61cb8b39b..8e2cc36fc 100644
--- a/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskConsistentRuleService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskConsistentRuleService.cs
@@ -14,7 +14,7 @@ namespace IRaCIS.Core.Application.Interfaces
{
- Task> GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery);
+ //Task> GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery);
Task AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule);
diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs
index 4df1bad94..5be0bf124 100644
--- a/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/TaskConsistentRuleService.cs
@@ -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 _subjectUserRepository;
private readonly IRepository _subjectRepository;
- public TaskConsistentRuleService(IRepository visitTaskRepository, IRepository taskConsistentRuleRepository, IRepository subjectUserRepository ,IRepository subjectRepository)
+ public TaskConsistentRuleService(IRepository visitTaskRepository, IRepository taskConsistentRuleRepository, IRepository subjectUserRepository, IRepository subjectRepository)
{
_taskConsistentRuleRepository = taskConsistentRuleRepository;
_visitTaskRepository = visitTaskRepository;
@@ -68,16 +69,16 @@ namespace IRaCIS.Core.Application.Service
///
- /// 为一致性分析医生,选择Subejct 列表
+ /// 为自身一致性分析医生,选择Subejct 列表
///
///
///
[HttpPost]
- public async Task> GetDoctorConsistentRuleSubjectList(ConsistentQuery inQuery)
+ public async Task> 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
}
///
- /// 确认生成一致性分析任务
+ /// 确认生成自身一致性分析任务
///
///
///
[HttpPost]
- public async Task ConfirmGenerateConsistentTask(ConsistentConfirmGenerateCommand inCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService)
+ public async Task 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>, IQueryable) GetIQueryableDoctorConsistentRuleSubjectView(TaskConsistentRule filterObj, List? subejctIdList=null)
+ private (IQueryable>, IQueryable) GetIQueryableDoctorSelfConsistentRuleSubjectView(TaskConsistentRule filterObj, List? subejctIdList = null)
{
- bool isSelfAnalysis = filterObj.CompareDoctorUserId == null;
- IQueryable subjectfilter = default;
+ //IQueryable 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);
}
///
- /// 一致性分配 配置+ 统计已经生成数量统计表
+ /// 自身一致性分配 配置+ 统计已经生成数量统计表
///
///
///
[HttpPost]
- public async Task> GetTaskConsistentRuleList(TaskConsistentRuleQuery inQuery)
+ public async Task> GetSelfConsistentRuleList(TaskConsistentRuleQuery inQuery)
{
+ #region 是否有新的医生加入 自动加入配置
+
+
+ if (await _taskConsistentRuleRepository.AnyAsync(t => t.TrialId == inQuery.TrialId))
+ {
+ var rule = await _taskConsistentRuleRepository.Where(t => t.TrialId == inQuery.TrialId).ProjectTo(_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(_mapper.ConfigurationProvider);
+ .ProjectTo(_mapper.ConfigurationProvider);
return await taskConsistentRuleQueryable.ToListAsync();
}
+ public async Task BatchAddOrUpdateTaskConsistentRule(TaskConsistentRuleBatchAddOrEdit addOrEdit)
+ {
+ var trialId = addOrEdit.TrialId;
+
+
+
+ if (addOrEdit.IsBatchAdd)
+ {
+ var query = from enroll in _repository.Where(t => t.TrialId == trialId)
+ join user in _repository.Where() on enroll.DoctorId equals user.DoctorId
+ join taskConsistentRule in _repository.Where() 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()
+ {
+ 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 AddOrUpdateTaskConsistentRule(TaskConsistentRuleAddOrEdit addOrEditTaskConsistentRule)
{
var verifyExp1 = new EntityVerifyExp()
{
- 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,24 +347,14 @@ 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))
{
- 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("已产生一致性分析任务,不允许删除");
- }
+ throw new BusinessValidationFailedException("已产生一致性分析任务,不允许删除");
}
+
var success = await _taskConsistentRuleRepository.DeleteFromQueryAsync(t => t.Id == taskConsistentRuleId, true);
return ResponseOutput.Ok();
}
diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs
index 204dcb58b..e2ef659c8 100644
--- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs
@@ -90,8 +90,7 @@ namespace IRaCIS.Core.Application.Service
CreateMap().IncludeBase();
- CreateMap().IncludeBase()
- .ForMember(o => o.IsSelfAnalysis, t => t.MapFrom(u => u.TaskConsistentRule.CompareDoctorUserId == null));
+ CreateMap().IncludeBase();
@@ -147,6 +146,7 @@ namespace IRaCIS.Core.Application.Service
.ForMember(o => o.FullName, t => t.MapFrom(u => u.FullName));
CreateMap().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()
@@ -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,7 +205,8 @@ namespace IRaCIS.Core.Application.Service
CreateMap();
-
+ CreateMap().ForMember(t=>t.Id,u=>u.Ignore()).ReverseMap();
+
CreateMap()
//.ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.DoctorUser))
diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs
index d1eaef945..c31415c2d 100644
--- a/IRaCIS.Core.Application/TestService.cs
+++ b/IRaCIS.Core.Application/TestService.cs
@@ -72,11 +72,13 @@ namespace IRaCIS.Application.Services
//return _localizer["test{0}", "测试"];
- var list = _repository.Where(t => t.Id == Guid.NewGuid()).SelectMany(t => t.VisitTaskList).ToList();
+ //var list = _repository.Where(t => t.Id == Guid.NewGuid()).SelectMany(t => t.VisitTaskList).ToList();
- var list2 = _repository.Where(t => t.Id == Guid.NewGuid()).Select(t => t.SourceSubjectVisit).ToList();
+ //var list2 = _repository.Where(t => t.Id == Guid.NewGuid()).Select(t => t.SourceSubjectVisit).ToList();
- var list3 = _repository.Where(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SourceSubjectVisit.VisitTaskList).ToList();
+ //var list3 = _repository.Where(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SourceSubjectVisit.VisitTaskList).ToList();
+ var list2 = _repository.Where(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SubjectVisitTaskList).ToList();
+ var list3 = _repository.Where(t => t.Id == Guid.NewGuid()).SelectMany(t => t.SameSubjectVisiTaskList).ToList();
return _userInfo.LocalIp;
}
diff --git a/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs b/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs
index 0cd0a8be5..bddce9bae 100644
--- a/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs
+++ b/IRaCIS.Core.Domain/Allocation/TaskConsistentRule.cs
@@ -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; }
diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs
index 31b0dc614..71d423176 100644
--- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs
+++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs
@@ -84,7 +84,7 @@ namespace IRaCIS.Core.Domain.Models
//排除一致性分析 因为souceVisitId 没值
//public List SameVisitTaskList { get; set; }
-
+ public List SameSubjectVisiTaskList { get; set; }
public TaskConsistentRule TaskConsistentRule { get; set; }
@@ -159,6 +159,8 @@ namespace IRaCIS.Core.Domain.Models
///
public bool IsAnalysisCreate { get; set; }
+ public bool? IsSelfAnalysis { get; set; }
+
public string BlindSubjectCode { get; set; } = string.Empty;
public string BlindTrialSiteCode { get; set; } = string.Empty;
diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
index 8faa5fe3e..95f6e65ee 100644
--- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
+++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
@@ -81,28 +81,31 @@ namespace IRaCIS.Core.Infra.EFCore
{
modelBuilder.Entity(builder =>
{
- builder.HasBaseType((Type)null);
- builder.ToView(null);
- builder.HasNoKey();
+ builder.HasBaseType((Type)null);
+ builder.ToView(null);
+ builder.HasNoKey();
});
//modelBuilder.HasDbFunction(typeof(DbContext).GetMethod(nameof(GetTableList)));
- modelBuilder.Entity().HasMany(t => t.DoctorVisitTaskList).WithOne(t => t.DoctorTaskAllocationRule).HasForeignKey(t=> new { t.DoctorUserId,t.TrialId } ).HasPrincipalKey(u=> new { u.DoctorUserId,u.TrialId });
+ modelBuilder.Entity().HasMany(t => t.DoctorVisitTaskList).WithOne(t => t.DoctorTaskAllocationRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId });
modelBuilder.Entity().HasMany(t => t.DoctorVisitTaskList).WithOne(t => t.DoctorTaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId });
modelBuilder.Entity().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.TaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId });
- modelBuilder.Entity().HasMany(t => t.SubjectArmVisitTaskList).WithOne(t=>t.SujectArm).HasForeignKey(t => new { t.SubjectId,t.ArmEnum}).HasPrincipalKey(u => new { u.SubjectId,u.ArmEnum });
- modelBuilder.Entity().HasMany(t => t.JudgeVisitList).WithOne(t=>t.JudgeVisitTask);
+ modelBuilder.Entity().HasMany(t => t.SubjectArmVisitTaskList).WithOne(t => t.SujectArm).HasForeignKey(t => new { t.SubjectId, t.ArmEnum }).HasPrincipalKey(u => new { u.SubjectId, u.ArmEnum });
+ modelBuilder.Entity().HasMany(t => t.JudgeVisitList).WithOne(t => t.JudgeVisitTask);
//modelBuilder.Entity().HasMany(t => t.VisitTaskList).WithOne(t => t.SourceSubjectVisit).HasForeignKey(t=>t.SourceSubjectVisitId).HasPrincipalKey(t=>t.Id);
//modelBuilder.Entity().HasMany(t => t.AnalysisVisitTaskList).WithOne().HasForeignKey(t => t.TaskConsistentRuleId).HasPrincipalKey(u => u.SourceSubjectVisitId);
- modelBuilder.Entity().HasMany(t => t.TaskMedicalReviewList).WithOne(t=>t.VisitTask).HasForeignKey(t => t.VisitTaskId);
-
+ modelBuilder.Entity().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId);
+
+ modelBuilder.Entity().HasMany(t => t.SameSubjectVisiTaskList).WithOne().HasForeignKey(t => t.SubjectId).HasPrincipalKey(u=>u.SubjectId);
+ modelBuilder.Entity().HasOne(t => t.Subject).WithMany(s=>s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId);
+
modelBuilder.Entity().HasMany(t => t.ChildList).WithOne(t => t.Parent);
modelBuilder.Entity().HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser);
@@ -141,7 +144,7 @@ namespace IRaCIS.Core.Infra.EFCore
modelBuilder.Entity(entityType.ClrType).Property(nameof(Entity.Id)).HasValueGenerator();
}
-
+
}
}
@@ -174,7 +177,7 @@ namespace IRaCIS.Core.Infra.EFCore
public virtual DbSet TrialExperienceCriteria { get; set; }
-
+
#endregion
@@ -284,7 +287,7 @@ namespace IRaCIS.Core.Infra.EFCore
#region Trial
public virtual DbSet Trial { get; set; }
-
+
public virtual DbSet TrialDictionary { get; set; }
public virtual DbSet TrialDetail { get; set; }
@@ -425,7 +428,7 @@ namespace IRaCIS.Core.Infra.EFCore
public override int SaveChanges()
{
//UpdateAuditInfo().GetAwaiter();
- AddAudit().GetAwaiter();
+ AddAudit().GetAwaiter();
return base.SaveChanges();
}
@@ -438,7 +441,7 @@ namespace IRaCIS.Core.Infra.EFCore
}
- public async Task AddAudit()
+ public async Task AddAudit()
{
try
{
@@ -449,9 +452,9 @@ namespace IRaCIS.Core.Infra.EFCore
catch (Exception)
{
-
+
}
-
+
}
///
@@ -460,71 +463,71 @@ namespace IRaCIS.Core.Infra.EFCore
//private async Task UpdateAuditInfo()
//{
-
- //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());
+ //ChangeTracker.DetectChanges(); // Important!
- //foreach (var t in entities)
- //{
- // switch (t.State)
- // {
+ //// 获取所有更改,删除,新增的实体,但排除审计实体(避免死循环)
+ //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());
- // case EntityState.Deleted:
+ //foreach (var t in entities)
+ //{
+ // switch (t.State)
+ // {
- // break;
- // case EntityState.Modified:
+ // case EntityState.Deleted:
- // if (t.Entity is IAuditUpdate updateEntity1)
- // {
- // updateEntity1.UpdateTime = DateTime.UtcNow.AddHours(8);
- // updateEntity1.UpdateUserId = _userInfo.Id;
- // }
+ // break;
+ // case EntityState.Modified:
+
+ // if (t.Entity is IAuditUpdate updateEntity1)
+ // {
+ // updateEntity1.UpdateTime = DateTime.UtcNow.AddHours(8);
+ // updateEntity1.UpdateUserId = _userInfo.Id;
+ // }
- // break;
- // //添加的时候,更新审计字段也赋值
- // case EntityState.Added:
+ // break;
+ // //添加的时候,更新审计字段也赋值
+ // case EntityState.Added:
- // ////// 仓储添加时 就有id了
- // //if (t.Entity is Entity entity && entity.Id == Guid.Empty)
- // //{
- // // entity.Id = NewId.NextGuid();
- // //}
+ // ////// 仓储添加时 就有id了
+ // //if (t.Entity is Entity entity && entity.Id == Guid.Empty)
+ // //{
+ // // entity.Id = NewId.NextGuid();
+ // //}
- // if (t.Entity is IAuditAdd addEntity)
- // {
- // if (addEntity.CreateTime == default(DateTime))
- // {
- // addEntity.CreateTime = DateTime.UtcNow.AddHours(8);
- // }
+ // if (t.Entity is IAuditAdd addEntity)
+ // {
+ // if (addEntity.CreateTime == default(DateTime))
+ // {
+ // addEntity.CreateTime = DateTime.UtcNow.AddHours(8);
+ // }
- // addEntity.CreateUserId = _userInfo.Id;
- // }
+ // addEntity.CreateUserId = _userInfo.Id;
+ // }
- // if (t.Entity is IAuditUpdate updateEntity)
- // {
- // updateEntity.UpdateTime = DateTime.UtcNow.AddHours(8);
- // updateEntity.UpdateUserId = _userInfo.Id;
- // }
+ // if (t.Entity is IAuditUpdate updateEntity)
+ // {
+ // updateEntity.UpdateTime = DateTime.UtcNow.AddHours(8);
+ // updateEntity.UpdateUserId = _userInfo.Id;
+ // }
- // if (t.Entity is IAuditAddWithUserName addEntity3)
- // {
- // addEntity3.CreateTime = DateTime.UtcNow.AddHours(8);
- // addEntity3.CreateUserId = _userInfo.Id;
- // addEntity3.CreateUser = _userInfo.RealName;
- // }
- // break;
- // }
- //}
+ // if (t.Entity is IAuditAddWithUserName addEntity3)
+ // {
+ // addEntity3.CreateTime = DateTime.UtcNow.AddHours(8);
+ // addEntity3.CreateUserId = _userInfo.Id;
+ // addEntity3.CreateUser = _userInfo.RealName;
+ // }
+ // break;
+ // }
+ //}
//}
@@ -567,7 +570,7 @@ namespace IRaCIS.Core.Infra.EFCore
break;
}
}
-
+
if (e.Entry.Entity is IAuditAddWithUserName addEntity2)
{
switch (e.Entry.State)