From f5f38936e6ce6352b26814255248bceccb377720 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 24 Jun 2022 15:03:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=8D=E9=98=85=E7=94=B3?= =?UTF-8?q?=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/Program.cs | 2 +- .../DTO/TaskAllocationRuleViewModel.cs | 11 +- .../Allocation/DTO/VisitTaskViewModel.cs | 35 +++-- .../Allocation/VisitTaskHelpeService.cs | 81 +++++++--- .../Service/Allocation/VisitTaskService.cs | 140 ++++++++++-------- .../Service/Allocation/_MapConfig.cs | 20 ++- .../Allocation/AllocationRelation.cs | 19 ++- IRaCIS.Core.Domain/Allocation/VisitTask.cs | 46 ++---- .../Allocation/VisitTaskReReading.cs | 67 +++++++++ .../Context/IRaCISDBContext.cs | 2 + IRaCIS.Core.Test/DbHelper.ttinclude | 2 +- .../TT_Template/IRaCIS.Core.Dto.cs | 7 - .../TT_Template/IRaCIS.Core.Entity.cs | 2 - 13 files changed, 289 insertions(+), 145 deletions(-) create mode 100644 IRaCIS.Core.Domain/Allocation/VisitTaskReReading.cs diff --git a/IRaCIS.Core.API/Program.cs b/IRaCIS.Core.API/Program.cs index 866d33353..63c08ae0b 100644 --- a/IRaCIS.Core.API/Program.cs +++ b/IRaCIS.Core.API/Program.cs @@ -138,7 +138,7 @@ namespace IRaCIS.Core.API { var _mediator = host.Services.GetService(typeof(IMediator)) as IMediator; - await _mediator.Send(new AnonymizeCacheRequest()); + //await _mediator.Send(new AnonymizeCacheRequest()); await _mediator.Send(new TrialStateCacheRequest()); } diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs index 0b652b716..f16472897 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskAllocationRuleViewModel.cs @@ -145,7 +145,16 @@ namespace IRaCIS.Core.Application.ViewModel public List ReadingGenerataTaskList= new List(); - //重阅 产生任务 + //重阅 产生任务 + public ReReadingApplyGenerateTaskCommand ReReadingApplyGenerateTaskCommand { get; set; } = new ReReadingApplyGenerateTaskCommand(); + + } + + public class ReReadingApplyGenerateTaskCommand + { + public RequestReReadingType RequestReReadingType { get; set; } + + public string RequestReReadingReason { get; set; } public List ReReadingTaskList = new List(); } diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index 3ca8213fd..1915c5b31 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -82,7 +82,7 @@ namespace IRaCIS.Core.Application.ViewModel //是否回退过 public bool IsReturned { get; set; } - + public RequestReReadingResult RequestReReadingResultEnum { get; set; } //是否 重阅 public bool IsReReading { get; set; } @@ -98,11 +98,6 @@ namespace IRaCIS.Core.Application.ViewModel public DateTime? SignTime { get; set; } - - //重阅原始编号 - public string ReReadingOriginalTaskCode { get; set; } - - public RequestReReadingType RequestReReadingType { get; set; } public DateTime? RequestReReadingTime { get; set; } @@ -113,9 +108,18 @@ namespace IRaCIS.Core.Application.ViewModel public RequestReReadingResult RequestReReadingResultEnum { get; set; } + //重阅原始任务Id 重阅会产生新的任务 + public Guid OriginalReReadingTaskId { get; set; } + + //重阅申请 产生的新任务Id + public Guid NewReReadingTaskId { get; set; } + //产生重阅的根任务Id + public Guid RootReReadingTaskId { get; set; } + //重阅原始编号 + public string ReReadingOriginalTaskCode { get; set; } } @@ -196,7 +200,7 @@ namespace IRaCIS.Core.Application.ViewModel public DateTime? EndAllocateDate { get; set; } - public Guid? OriginalReReadingId { get; set; } + public Guid? RootReReadingTaskId { get; set; } } public class IRUnReadSubjectQuery : PageInput @@ -431,13 +435,26 @@ namespace IRaCIS.Core.Application.ViewModel public class ConfirmReReadingCommand { - public List TaskIdList { get; set; } - public Guid TrialId { get; set; } + public List ConfirmReReadingList { get; set; } + + public RequestReReadingResult RequestReReadingResultEnum { get; set; } } + public class ConfirmReReadingDTO + { + public Guid Id { get; set; } + + //重阅原始任务Id 重阅会产生新的任务 + public Guid OriginalReReadingTaskId { get; set; } + + //重阅申请 产生的新任务Id + public Guid NewReReadingTaskId { get; set; } + + } + public enum TaskOptType { diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index bf2ead207..9d5cb35e3 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -31,10 +31,12 @@ namespace IRaCIS.Core.Application.Service private readonly IRepository _subjectUserRepository; private readonly IMapper _mapper; + private readonly IUserInfo _userInfo; + private readonly IRepository _visitTaskReReadingRepository; public VisitTaskHelpeService(IRepository visitTaskRepository, IRepository subjectUserRepository, IRepository trialRepository, IEasyCachingProvider provider, - IRepository subjectVisitRepository, IRepository taskAllocationRuleRepository, IMapper mapper) + IRepository subjectVisitRepository, IRepository taskAllocationRuleRepository, IMapper mapper, IUserInfo userInfo, IRepository visitTaskReReadingRepository) { _visitTaskRepository = visitTaskRepository; _trialRepository = trialRepository; @@ -43,6 +45,8 @@ namespace IRaCIS.Core.Application.Service _taskAllocationRuleRepository = taskAllocationRuleRepository; _subjectUserRepository = subjectUserRepository; _mapper = mapper; + _userInfo = userInfo; + _visitTaskReReadingRepository = visitTaskReReadingRepository; } //查询列表的时候,一致性核查通过未产生任务的 自动产生任务 如果是一致性核查,那么还会自动分配 @@ -57,7 +61,7 @@ namespace IRaCIS.Core.Application.Service var subjectVisitList = _subjectVisitRepository.Where(t => subjectVisitIdList.Contains(t.Id)).ProjectTo(_mapper.ConfigurationProvider).Distinct().ToList(); - await AddTaskAsync(new GenerateTaskCommand() { TrialId = trialId, IsAssignSubjectToDoctor = isAssignSubjectToDoctor, VisitGenerataTaskList = subjectVisitList, ReadingCategory= ReadingCategory.Visit }); + await AddTaskAsync(new GenerateTaskCommand() { TrialId = trialId, IsAssignSubjectToDoctor = isAssignSubjectToDoctor, VisitGenerataTaskList = subjectVisitList, ReadingCategory = ReadingCategory.Visit }); } @@ -74,7 +78,7 @@ namespace IRaCIS.Core.Application.Service var dbMaxCode = _visitTaskRepository.Where(t => t.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max(); - var cacheMaxCodeInt = _provider.Get($"{trialId }_{ StaticData.CacheKey.TaskMaxCode}").Value; + var cacheMaxCodeInt = _provider.Get($"{trialId}_{StaticData.CacheKey.TaskMaxCode}").Value; int currentMaxCodeInt = cacheMaxCodeInt > dbMaxCode ? cacheMaxCodeInt : dbMaxCode; @@ -83,7 +87,7 @@ namespace IRaCIS.Core.Application.Service case ReadingCategory.Visit: foreach (var subjectVisit in generateTaskCommand.VisitGenerataTaskList) { - var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.OrignalSubjectUserId== null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync(); + var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.SubjectId == subjectVisit.SubjectId && t.OrignalSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync(); if (trialConfig.ReadingType == ReadingMethod.Double) @@ -121,7 +125,7 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 2; - _provider.Set($"{trialId }_{ StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 2, TimeSpan.FromMinutes(30)); + _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 2, TimeSpan.FromMinutes(30)); #region 分配 @@ -222,7 +226,7 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 1; - _provider.Set($"{trialId }_{ StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 1, TimeSpan.FromMinutes(30)); + _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 1, TimeSpan.FromMinutes(30)); #region 分配 @@ -284,32 +288,67 @@ namespace IRaCIS.Core.Application.Service break; case ReadingCategory.ReReading: - foreach (var reReadingVisitTask in generateTaskCommand.ReReadingTaskList) + foreach (var reReadingVisitTask in generateTaskCommand.ReReadingApplyGenerateTaskCommand.ReReadingTaskList) { //reReadingVisitTask.OriginalReReadingId = reReadingVisitTask.Id; //reReadingVisitTask.Id = Guid.Empty; - //reReadingVisitTask. Code = currentMaxCodeInt + 1; + //reReadingVisitTask.SignTime = null; + //reReadingVisitTask.AllocateTime = null; + + //reReadingVisitTask.RequestReReadingReason = generateTaskCommand.ReReadingApplyGenerateTaskCommand.RequestReReadingReason; + //reReadingVisitTask.RequestReReadingType = generateTaskCommand.ReReadingApplyGenerateTaskCommand.RequestReReadingType; + //reReadingVisitTask.RequestReReadingUserId = _userInfo.Id; + + //reReadingVisitTask.Code = currentMaxCodeInt + 1; //reReadingVisitTask.TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)); - await _visitTaskRepository.AddAsync(new VisitTask() + // await _visitTaskRepository.AddAsync(reReadingVisitTask); + + + + var newTask = await _visitTaskRepository.AddAsync(new VisitTask() { - OriginalReReadingId = reReadingVisitTask.Id, + TrialId = reReadingVisitTask.TrialId, SubjectId = reReadingVisitTask.SubjectId, - ArmEnum= reReadingVisitTask.ArmEnum, - TaskName= reReadingVisitTask.TaskName, + ArmEnum = reReadingVisitTask.ArmEnum, + TaskName = reReadingVisitTask.TaskName, TaskBlindName = reReadingVisitTask.TaskBlindName, - TaskAllocationState= reReadingVisitTask.TaskAllocationState, + TaskAllocationState = reReadingVisitTask.TaskAllocationState, ReadingCategory = reReadingVisitTask.ReadingCategory, SourceSubjectVisitId = reReadingVisitTask.SourceSubjectVisitId, + + IsReReadingCreate = true, + TaskState = TaskState.NotEffect, Code = currentMaxCodeInt + 1, TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), - AllocateTime=DateTime.Now, - DoctorUserId= reReadingVisitTask.DoctorUserId + AllocateTime = DateTime.Now, + DoctorUserId = reReadingVisitTask.DoctorUserId, + }); + var rootReReadingTaskId = await _visitTaskReReadingRepository.Where(t => t.OriginalReReadingTaskId == reReadingVisitTask.Id).Select(u => u.RootReReadingTaskId).FirstOrDefaultAsync(); + + + + var visitTaskReReading = await _visitTaskReReadingRepository.AddAsync(new VisitTaskReReading() + { + RootReReadingTaskId = rootReReadingTaskId == Guid.Empty ? reReadingVisitTask.Id : rootReReadingTaskId, + OriginalReReadingTaskId = reReadingVisitTask.Id, + + + NewReReadingTaskId = newTask.Id, + + RequestReReadingTime = DateTime.Now, + RequestReReadingUserId = _userInfo.Id, + RequestReReadingReason = generateTaskCommand.ReReadingApplyGenerateTaskCommand.RequestReReadingReason, + RequestReReadingType = generateTaskCommand.ReReadingApplyGenerateTaskCommand.RequestReReadingType, + }); + + + //是否增加任务类别 @@ -333,15 +372,15 @@ namespace IRaCIS.Core.Application.Service ReadingCategory = ReadingCategory.Judge, TrialId = firstTask.TrialId, Code = currentMaxCodeInt + 1, - SourceSubjectVisitId= firstTask.SourceSubjectVisitId, - SouceReadModuleId=firstTask.SouceReadModuleId, + SourceSubjectVisitId = firstTask.SourceSubjectVisitId, + SouceReadModuleId = firstTask.SouceReadModuleId, TaskCode = AppSettings.GetCodeStr(currentMaxCodeInt + 1, nameof(VisitTask)), }; await _visitTaskRepository.AddAsync(visitTask); currentMaxCodeInt = currentMaxCodeInt + 1; - _provider.Set($"{trialId }_{ StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 1, TimeSpan.FromMinutes(30)); + _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 1, TimeSpan.FromMinutes(30)); await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => generateTaskCommand.JudgeVisitTaskIdList.Contains(x.Id), x => new VisitTask() { @@ -384,7 +423,7 @@ namespace IRaCIS.Core.Application.Service ReadingCategory = item.ReadingCategory }); currentMaxCodeInt = currentMaxCodeInt + 2; - _provider.Set($"{trialId }_{ StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 2, TimeSpan.FromMinutes(30)); + _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 2, TimeSpan.FromMinutes(30)); } } else @@ -409,13 +448,13 @@ namespace IRaCIS.Core.Application.Service currentMaxCodeInt = currentMaxCodeInt + 1; - _provider.Set($"{trialId }_{ StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 1, TimeSpan.FromMinutes(30)); + _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt + 1, TimeSpan.FromMinutes(30)); } } break; } - + await _visitTaskRepository.SaveChangesAsync(); } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 84362a681..6eccad028 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -30,9 +30,12 @@ namespace IRaCIS.Core.Application.Service private readonly IRepository _readModuleRepository; + private readonly IRepository _visitTaskReReadingRepository; + public VisitTaskService(IRepository visitTaskRepository, IRepository trialRepository, IRepository subjectVisitRepository, - IRepository subjectRepository, IRepository subjectUserRepository, IRepository taskAllocationRuleRepository, IRepository readModuleRepository + IRepository subjectRepository, IRepository subjectUserRepository, IRepository taskAllocationRuleRepository, + IRepository readModuleRepository, IRepository visitTaskReReadingRepository ) { _taskAllocationRuleRepository = taskAllocationRuleRepository; @@ -42,6 +45,7 @@ namespace IRaCIS.Core.Application.Service _subjectRepository = subjectRepository; _subjectUserRepository = subjectUserRepository; _readModuleRepository = readModuleRepository; + _visitTaskReReadingRepository = visitTaskReReadingRepository; } @@ -167,7 +171,7 @@ namespace IRaCIS.Core.Application.Service public async Task<(PageOutput, object)> GetReadingTaskList(VisitTaskQuery queryVisitTask) { var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == queryVisitTask.TrialId) - .Where(t => t.OriginalReReadingId == null && t.DoctorUserId != null) + .Where(t => t.IsReReadingCreate == false && t.DoctorUserId != null) .WhereIf(queryVisitTask.SiteId != null, t => t.Subject.SiteId == queryVisitTask.SiteId) .WhereIf(queryVisitTask.SubjectId != null, t => t.SubjectId == queryVisitTask.SubjectId) @@ -201,20 +205,20 @@ namespace IRaCIS.Core.Application.Service { - var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == queryVisitTask.TrialId) - .WhereIf(queryVisitTask.OriginalReReadingId != null, t => t.OriginalReReadingId == queryVisitTask.OriginalReReadingId) - .WhereIf(queryVisitTask.OriginalReReadingId == null, t => t.OriginalReReadingId != null) + var visitTaskQueryable = _visitTaskReReadingRepository + .Where(t => t.NewReReadingTask.TrialId == queryVisitTask.TrialId) + .WhereIf(queryVisitTask.RootReReadingTaskId != null, t => t.RootReReadingTaskId == queryVisitTask.RootReReadingTaskId) - .WhereIf(queryVisitTask.SiteId != null, t => t.Subject.SiteId == queryVisitTask.SiteId) - .WhereIf(queryVisitTask.SubjectId != null, t => t.SubjectId == queryVisitTask.SubjectId) - .WhereIf(queryVisitTask.IsUrgent != null, t => t.IsUrgent == queryVisitTask.IsUrgent) - .WhereIf(queryVisitTask.DoctorUserId != null, t => t.DoctorUserId == queryVisitTask.DoctorUserId) - .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.ReadingTaskState == queryVisitTask.ReadingTaskState) - .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.TaskAllocationState == queryVisitTask.TaskAllocationState) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.TaskName.Contains(queryVisitTask.TaskName) || t.TaskBlindName.Contains(queryVisitTask.TaskName)) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.Subject.Code.Contains(queryVisitTask.SubjectCode)) - .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.AllocateTime > queryVisitTask.BeginAllocateDate) - .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.AllocateTime < queryVisitTask.EndAllocateDate.Value.AddDays(1)) + .WhereIf(queryVisitTask.SiteId != null, t => t.NewReReadingTask.Subject.SiteId == queryVisitTask.SiteId) + .WhereIf(queryVisitTask.SubjectId != null, t => t.NewReReadingTask.SubjectId == queryVisitTask.SubjectId) + .WhereIf(queryVisitTask.IsUrgent != null, t => t.NewReReadingTask.IsUrgent == queryVisitTask.IsUrgent) + .WhereIf(queryVisitTask.DoctorUserId != null, t => t.NewReReadingTask.DoctorUserId == queryVisitTask.DoctorUserId) + .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.NewReReadingTask.ReadingTaskState == queryVisitTask.ReadingTaskState) + .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.NewReReadingTask.TaskAllocationState == queryVisitTask.TaskAllocationState) + .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.NewReReadingTask.TaskName.Contains(queryVisitTask.TaskName) || t.NewReReadingTask.TaskBlindName.Contains(queryVisitTask.TaskName)) + .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.NewReReadingTask.Subject.Code.Contains(queryVisitTask.SubjectCode)) + .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.NewReReadingTask.AllocateTime > queryVisitTask.BeginAllocateDate) + .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.NewReReadingTask.AllocateTime < queryVisitTask.EndAllocateDate.Value.AddDays(1)) .ProjectTo(_mapper.ConfigurationProvider); var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId) }; @@ -347,24 +351,24 @@ namespace IRaCIS.Core.Application.Service public async Task> GetIRReReadingTaskList(VisitTaskQuery queryVisitTask) { - - var visitTaskQueryable = _visitTaskRepository.Where(t => t.TrialId == queryVisitTask.TrialId) - .Where(t => t.DoctorUserId == _userInfo.Id) - .WhereIf(queryVisitTask.OriginalReReadingId != null, t => t.OriginalReReadingId == queryVisitTask.OriginalReReadingId) - .WhereIf(queryVisitTask.OriginalReReadingId == null, t => t.OriginalReReadingId != null) - - .WhereIf(queryVisitTask.SiteId != null, t => t.Subject.SiteId == queryVisitTask.SiteId) - .WhereIf(queryVisitTask.SubjectId != null, t => t.SubjectId == queryVisitTask.SubjectId) - .WhereIf(queryVisitTask.IsUrgent != null, t => t.IsUrgent == queryVisitTask.IsUrgent) - - .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.ReadingTaskState == queryVisitTask.ReadingTaskState) - .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.TaskAllocationState == queryVisitTask.TaskAllocationState) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.TaskName.Contains(queryVisitTask.TaskName) || t.TaskBlindName.Contains(queryVisitTask.TaskName)) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.Subject.Code.Contains(queryVisitTask.SubjectCode)) - .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.AllocateTime > queryVisitTask.BeginAllocateDate) - .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.AllocateTime < queryVisitTask.EndAllocateDate.Value.AddDays(1)) + var visitTaskQueryable = _visitTaskReReadingRepository + .Where(t => t.NewReReadingTask.DoctorUserId == _userInfo.Id) + .Where(t => t.NewReReadingTask.TrialId == queryVisitTask.TrialId) + .WhereIf(queryVisitTask.RootReReadingTaskId != null, t => t.RootReReadingTaskId == queryVisitTask.RootReReadingTaskId) + .WhereIf(queryVisitTask.SiteId != null, t => t.NewReReadingTask.Subject.SiteId == queryVisitTask.SiteId) + .WhereIf(queryVisitTask.SubjectId != null, t => t.NewReReadingTask.SubjectId == queryVisitTask.SubjectId) + .WhereIf(queryVisitTask.IsUrgent != null, t => t.NewReReadingTask.IsUrgent == queryVisitTask.IsUrgent) + .WhereIf(queryVisitTask.DoctorUserId != null, t => t.NewReReadingTask.DoctorUserId == queryVisitTask.DoctorUserId) + .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.NewReReadingTask.ReadingTaskState == queryVisitTask.ReadingTaskState) + .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.NewReReadingTask.TaskAllocationState == queryVisitTask.TaskAllocationState) + .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.NewReReadingTask.TaskName.Contains(queryVisitTask.TaskName) || t.NewReReadingTask.TaskBlindName.Contains(queryVisitTask.TaskName)) + .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.NewReReadingTask.Subject.Code.Contains(queryVisitTask.SubjectCode)) + .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.NewReReadingTask.AllocateTime > queryVisitTask.BeginAllocateDate) + .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.NewReReadingTask.AllocateTime < queryVisitTask.EndAllocateDate.Value.AddDays(1)) .ProjectTo(_mapper.ConfigurationProvider); + + var defalutSortArray = new string[] { nameof(VisitTask.IsUrgent) + " desc", nameof(VisitTask.SubjectId) }; var pageList = await visitTaskQueryable.ToPagedListAsync(queryVisitTask.PageIndex, queryVisitTask.PageSize, queryVisitTask.SortField, queryVisitTask.Asc, string.IsNullOrWhiteSpace(queryVisitTask.SortField), defalutSortArray); @@ -430,12 +434,12 @@ namespace IRaCIS.Core.Application.Service var armEnum = assginSubjectDoctorCommand.DoctorUserIdArmList.Where(t => t.DoctorUserId == doctorUserId).First().ArmEnum; - if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum != armEnum && t.OrignalSubjectUserId==null)) + if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum != armEnum && t.OrignalSubjectUserId == null)) { throw new BusinessValidationFailedException("有Subject 在其他Arm组已有该医生,不允许在新的组添加该医生"); } - if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum == armEnum && t.OrignalSubjectUserId == null)) + if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum == armEnum && t.OrignalSubjectUserId == null)) { throw new BusinessValidationFailedException("有Subject 已有该Arm组的医生,不允许继续分配,请刷新页面,确认页面数据是否过期"); } @@ -466,7 +470,7 @@ namespace IRaCIS.Core.Application.Service { foreach (var subjectId in cancelSubjectAssignCommand.SubjectIdList) { - if (await _visitTaskRepository.AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId != null && t.ArmEnum == Arm.JudgeArm )) + if (await _visitTaskRepository.AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId != null && t.ArmEnum == Arm.JudgeArm)) { throw new BusinessValidationFailedException("有Subject任务已应用,不允许取消分配"); } @@ -540,7 +544,7 @@ namespace IRaCIS.Core.Application.Service if (assignConfirmCommand.SubjectDoctorUserList.Count == 0) { - subjectDoctorIdArmList = _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.OrignalSubjectUserId == null).Select(t => new DoctorArm() { DoctorUserId = t.DoctorUserId, ArmEnum = t.ArmEnum }).ToList(); + subjectDoctorIdArmList = _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.OrignalSubjectUserId == null).Select(t => new DoctorArm() { DoctorUserId = t.DoctorUserId, ArmEnum = t.ArmEnum }).ToList(); } @@ -617,8 +621,8 @@ namespace IRaCIS.Core.Application.Service SubjectId = t.Id, //给Subject分配医生的时候, 未确认绑定关系的 - DoctorUserList = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t=> t.OrignalSubjectUserId==null).Select(t => new { t.DoctorUserId, t.ArmEnum }), - IsApplyed = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).SelectMany(t => t.SubjectArmVisitTaskList).Any(c => c.DoctorUserId != null) + DoctorUserList = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).Select(t => new { t.DoctorUserId, t.ArmEnum }), + IsApplyed = t.SubjectDoctorList.Where(t => isJudge ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.OrignalSubjectUserId == null).SelectMany(t => t.SubjectArmVisitTaskList).Any(c => c.DoctorUserId != null) }).ToList(); //已产生任务的Subject数量(裁判情况下,就是产生裁判任务Subject 的数量) @@ -889,27 +893,22 @@ namespace IRaCIS.Core.Application.Service { var taskList = await _visitTaskRepository.Where(t => applyReReadingCommand.TaskIdList.Contains(t.Id), true).Include(t => t.JudgeVisitTask).ToListAsync(); - var reReadingTaskList = taskList.Clone(); + foreach (var task in taskList) { - if(await _visitTaskRepository.AnyAsync(t=>t.OriginalReReadingId==task.Id)) + if (task.ReReadingApplyState == ReReadingApplyState.HaveApplyed || task.ReReadingApplyState == ReReadingApplyState.Agree) { - throw new BusinessValidationFailedException("已产生重阅任务,不允许再次申请"); + throw new BusinessValidationFailedException("已申请,或者同意状态不允许再次申请重阅"); } - task.RequestReReadingReason = applyReReadingCommand.RequestReReadingReason; - task.RequestReReadingType = applyReReadingCommand.RequestReReadingType; - task.RequestReReadingTime = DateTime.Now; - task.RequestReReadingUserId = _userInfo.Id; - //产生了裁判 if (task.JudgeVisitTaskId != null) { if (task.ReadingTaskState == ReadingTaskState.WaitReading || task.ReadingTaskState == ReadingTaskState.Reading) { - task.JudgeVisitTask.TaskState = TaskState.HaveCanceled; + task.JudgeVisitTask.TaskState = TaskState.Adbandon; } else { @@ -921,11 +920,21 @@ namespace IRaCIS.Core.Application.Service } } + //产生的新任务,状态保持很申请的一直 + var reReadingTaskList = taskList.Clone(); + await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() { TrialId = applyReReadingCommand.TrialId, ReadingCategory = ReadingCategory.ReReading, - ReReadingTaskList = reReadingTaskList + + + ReReadingApplyGenerateTaskCommand = new ReReadingApplyGenerateTaskCommand() + { + RequestReReadingReason = applyReReadingCommand.RequestReReadingReason, + RequestReReadingType = applyReReadingCommand.RequestReReadingType, + ReReadingTaskList = reReadingTaskList + } }); //产生新的任务 @@ -945,22 +954,33 @@ namespace IRaCIS.Core.Application.Service [UnitOfWork] public async Task ConfirmReReading(ConfirmReReadingCommand agreeReReadingCommand) { - //var taskList = await _visitTaskRepository.Where(t => agreeReReadingCommand.TaskIdList.Contains(t.Id), true).ToListAsync(); - - //foreach (var task in taskList) - //{ - // task.RequestReReadingResultEnum = agreeReReadingCommand.RequestReReadingResultEnum; - // task.RequestReReadingConfirmUserId = _userInfo.Id; - //} - //await _visitTaskRepository.SaveChangesAsync(); - await _visitTaskRepository.UpdatePartialFromQueryAsync(t => agreeReReadingCommand.TaskIdList.Contains(t.Id), u => new VisitTask() + foreach (var item in agreeReReadingCommand.ConfirmReReadingList) { - IsReReading = true, - RequestReReadingResultEnum = agreeReReadingCommand.RequestReReadingResultEnum, - RequestReReadingConfirmUserId = _userInfo.Id - }, true); + await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.Id == item.OriginalReReadingTaskId, u => new VisitTask() + { + ReReadingApplyState = (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree ? ReReadingApplyState.Agree : ReReadingApplyState.Reject), + IsReReading=true + }); + + await _visitTaskReReadingRepository.UpdatePartialFromQueryAsync(t => t.Id == item.Id, u => new VisitTaskReReading() + { + RequestReReadingConfirmUserId=_userInfo.Id, + RequestReReadingResultEnum= agreeReReadingCommand.RequestReReadingResultEnum, + }); + + await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.Id == item.NewReReadingTaskId, u => new VisitTask() + { + TaskState = TaskState.Effect + }); + + } + + + await _visitTaskRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 539e836e7..b3df35a3b 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -107,16 +107,20 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.FullName, t => t.MapFrom(u => u.DoctorUser.FullName)) .ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.DoctorUser.UserTypeRole.UserTypeShortName)); - CreateMap() + CreateMap().IncludeMembers(t=>t.NewReReadingTask) .ForMember(o => o.ReReadingOriginalTaskCode, t => t.MapFrom(u => u.OriginalReReadingTask.TaskCode)) + .ForMember(o => o.Id, t => t.MapFrom(u => u.Id)) - .ForMember(o => o.SiteId, t => t.MapFrom(u => u.Subject.SiteId)) - .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.Subject.TrialSite.TrialSiteCode)) - .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.Subject.Code)) - .ForMember(o => o.UserCode, t => t.MapFrom(u => u.DoctorUser.UserCode)) - .ForMember(o => o.UserName, t => t.MapFrom(u => u.DoctorUser.UserName)) - .ForMember(o => o.FullName, t => t.MapFrom(u => u.DoctorUser.FullName)) - .ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.DoctorUser.UserTypeRole.UserTypeShortName)); + .ForMember(o => o.SiteId, t => t.MapFrom(u => u.NewReReadingTask.Subject.SiteId)) + .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.NewReReadingTask.Subject.TrialSite.TrialSiteCode)) + .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.NewReReadingTask.Subject.Code)) + .ForMember(o => o.UserCode, t => t.MapFrom(u => u.NewReReadingTask.DoctorUser.UserCode)) + .ForMember(o => o.UserName, t => t.MapFrom(u => u.NewReReadingTask.DoctorUser.UserName)) + .ForMember(o => o.FullName, t => t.MapFrom(u => u.NewReReadingTask.DoctorUser.FullName)) + .ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.NewReReadingTask.DoctorUser.UserTypeRole.UserTypeShortName)); + + CreateMap() + .ForMember(o => o.Id, t => t.Ignore()); CreateMap() .ForMember(o => o.SiteId, t => t.MapFrom(u => u.Subject.SiteId)) diff --git a/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs b/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs index 4f64c6c8e..e5eaaaccf 100644 --- a/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs +++ b/IRaCIS.Core.Domain.Share/Allocation/AllocationRelation.cs @@ -95,9 +95,15 @@ namespace IRaCIS.Core.Domain.Share public enum TaskState { - // 裁判任务,没做,或者做了没签名 已取消 - HaveCanceled = 3, + //有效 + Effect=0, + NotEffect=1, + + // 裁判任务,没做,或者做了没签名 废弃 + Adbandon = 3, + + //重置 裁判任务做了,签名了 算工作量 HaveReturned = 4 } @@ -136,7 +142,16 @@ namespace IRaCIS.Core.Domain.Share Reject = 2 } + public enum ReReadingApplyState + { + Default = 0, + HaveApplyed=1, + + Agree = 2, + + Reject = 3 + } } diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs index c3971c30c..a6a46fd7d 100644 --- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs +++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs @@ -126,6 +126,16 @@ namespace IRaCIS.Core.Domain.Models public TaskState TaskState { get; set; } + + public ReReadingApplyState ReReadingApplyState { get; set; } + + + + + + //是否 重阅 + public bool IsReReading { get; set; } + /// /// DoctorUserId /// @@ -137,10 +147,6 @@ namespace IRaCIS.Core.Domain.Models public TaskAllocationRule DoctorTaskAllocationRule { get; set; } - //裁判任务已读,但是回退了 暂时废弃 - public bool IsJudgeTaskReturn { get; set; } - - //是否回退过 public bool IsReturned { get; set; } @@ -154,7 +160,6 @@ namespace IRaCIS.Core.Domain.Models public List JudgeVisitList { get; set; } - //任务阅片状态 public ReadingTaskState ReadingTaskState { get; set; } @@ -163,36 +168,14 @@ namespace IRaCIS.Core.Domain.Models - //是否 重阅 - public bool IsReReading { get; set; } public DateTime? SuggesteFinishedTime { get; set; } - //重阅原始任务Id 重阅会产生新的任务 - public Guid? OriginalReReadingId { get; set; } - [ForeignKey("OriginalReReadingId")] - public VisitTask OriginalReReadingTask { get; set; } - - //申请回退类型 - public RequestReReadingType RequestReReadingType { get; set; } - - public DateTime? RequestReReadingTime { get; set; } - - public string RequestReReadingReason { get; set; } = string.Empty; - - public Guid? RequestReReadingUserId { get; set; } - - public User RequestReReadingUser { get; set; } - - public Guid? RequestReReadingConfirmUserId { get; set; } - - public User RequestReReadingConfirmUser { get; set; } - - public RequestReReadingResult RequestReReadingResultEnum { get; set; } - - public SubjectUser SujectArm { get; set; } + public bool IsReReadingCreate { get; set; } + + /// /// 裁判结果的任务ID /// @@ -204,9 +187,6 @@ namespace IRaCIS.Core.Domain.Models public string JudgeResultRemark { get; set; } = string.Empty; - - //建议完成时间 - //public int SuggesteDays { get; set; } } } diff --git a/IRaCIS.Core.Domain/Allocation/VisitTaskReReading.cs b/IRaCIS.Core.Domain/Allocation/VisitTaskReReading.cs new file mode 100644 index 000000000..efb1322bb --- /dev/null +++ b/IRaCIS.Core.Domain/Allocation/VisitTaskReReading.cs @@ -0,0 +1,67 @@ + +//-------------------------------------------------------------------- +// 此代码由T4模板自动生成 byzhouhang 20210918 +// 生成时间 2022-06-07 14:09:29 +// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 +using System; +using IRaCIS.Core.Domain.Share; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Collections.Generic; + +namespace IRaCIS.Core.Domain.Models +{ + /// + ///VisitTask + /// + [Table("VisitTaskReReading")] + public class VisitTaskReReading : Entity, IAuditUpdate, IAuditAdd + { + + + //重阅原始任务Id 重阅会产生新的任务 + public Guid OriginalReReadingTaskId { get; set; } + + + //产生重阅的根任务Id + public Guid RootReReadingTaskId { get; set; } + + //重阅申请 产生的新任务Id + public Guid NewReReadingTaskId { get; set; } + + public Guid RequestReReadingUserId { get; set; } + + public User RequestReReadingUser { get; set; } + + public DateTime RequestReReadingTime { get; set; } + + public VisitTask NewReReadingTask { get; set; } + + public VisitTask OriginalReReadingTask { get; set; } + + //申请回退类型 + public RequestReReadingType RequestReReadingType { get; set; } + + + public string RequestReReadingReason { get; set; } = string.Empty; + public RequestReReadingResult RequestReReadingResultEnum { get; set; } + + + + public Guid? RequestReReadingConfirmUserId { get; set; } + + public User RequestReReadingConfirmUser { get; set; } + + + public Guid CreateUserId { get; set; } + + + public DateTime CreateTime { get; set; } + + + public DateTime UpdateTime { get; set; } + + public Guid UpdateUserId { get; set; } + } + +} diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 908a1bc50..afbffeab4 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -573,6 +573,8 @@ namespace IRaCIS.Core.Infra.EFCore public virtual DbSet SubjectUser { get; set; } + public virtual DbSet VisitTaskReReading { get; set; } + } diff --git a/IRaCIS.Core.Test/DbHelper.ttinclude b/IRaCIS.Core.Test/DbHelper.ttinclude index ad577b233..03a50a02f 100644 --- a/IRaCIS.Core.Test/DbHelper.ttinclude +++ b/IRaCIS.Core.Test/DbHelper.ttinclude @@ -4,7 +4,7 @@ public static readonly string ConnectionString = "Server=123.56.94.154,1433\\MSSQLSERVER;Database=IRaCIS_New_Tet;User ID=sa;Password=dev123456DEV;TrustServerCertificate=true"; public static readonly string DbDatabase = "IRaCIS_New_Tet"; //ַ,ƴ - public static readonly string TableName = "SubjectUser"; + public static readonly string TableName = "VisitTaskReReading"; //ļ service Ƿҳ } #> diff --git a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Dto.cs b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Dto.cs index cb03b0051..e02abfc9b 100644 --- a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Dto.cs +++ b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Dto.cs @@ -1,8 +1 @@  - - - - - - - diff --git a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.cs b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.cs index 171fad3cb..e02abfc9b 100644 --- a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.cs +++ b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.cs @@ -1,3 +1 @@  - -