diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index 1aaa80c99..9a604e791 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -995,6 +995,8 @@ namespace IRaCIS.Core.Application.ViewModel [NotDefault] public Guid TrialReadingCriterionId { get; set; } + + public Guid? VisitTaskId { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 7ed3f4b63..9b015371f 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -1185,7 +1185,7 @@ public class VisitTaskService(IRepository _visitTaskRepository, return ResponseOutput.Ok(result, new { - IsReadingTaskViewInOrder = isReadingTaskViewInOrder==ReadingOrder.InOrder, + IsReadingTaskViewInOrder = isReadingTaskViewInOrder == ReadingOrder.InOrder, RandomReadInfo = iRUnReadOut, ReadingTool = readingTool, IseCRFShowInDicomReading = criterionConfig.IseCRFShowInDicomReading, @@ -1516,53 +1516,77 @@ public class VisitTaskService(IRepository _visitTaskRepository, [UnitOfWork] public async Task AIRReReading(AIRReReadingCommand command, [FromServices] IVisitTaskHelpeService _visitTaskCommonService) { - var baseLineTaskList = await _visitTaskRepository.Where(t => t.TrialId == command.TrialId && t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id - && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SourceSubjectVisit.IsBaseLine == true).ToListAsync(); - - var judegeList = await _visitTaskRepository.Where(t => t.TrialId == command.TrialId && t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id - && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Judge && t.ReadingTaskState == ReadingTaskState.HaveSigned).ToListAsync(); - - foreach (var item in judegeList) + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR) { - if (!baseLineTaskList.Any(t => t.SubjectId == item.SubjectId)) + var baseLineTaskList = await _visitTaskRepository.Where(t => t.TrialId == command.TrialId && t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id + && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Visit && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.SourceSubjectVisit.IsBaseLine == true).ToListAsync(); + + var judegeList = await _visitTaskRepository.Where(t => t.TrialId == command.TrialId && t.TrialReadingCriterionId == command.TrialReadingCriterionId && t.DoctorUserId == _userInfo.Id + && t.TaskState == TaskState.Effect && t.ReadingCategory == ReadingCategory.Judge && t.ReadingTaskState == ReadingTaskState.HaveSigned).ToListAsync(); + + foreach (var item in judegeList) { - baseLineTaskList.Add(item); + if (!baseLineTaskList.Any(t => t.SubjectId == item.SubjectId)) + { + baseLineTaskList.Add(item); + } + } + + + var baseLineTaskIdList = baseLineTaskList.Select(t => t.Id).ToList(); + + if (baseLineTaskIdList.Count == 0) + { + return ResponseOutput.Ok(); + } + + //if (baseLineTaskList == null) + //{ + // return ResponseOutput.NotOk("基线任务未阅完,不允许重阅基线任务"); + //} + + await ApplyReReading(new ApplyReReadingCommand() { IsCopyFollowForms = false, IsCopyOrigenalForms = false, TaskIdList = baseLineTaskIdList, TrialId = command.TrialId, RequestReReadingReason = "AIR自动重阅基线", RequestReReadingType = RequestReReadingType.DocotorApply }); + + + + var requestRecordList = await _visitTaskReReadingRepository.Where(t => baseLineTaskIdList.Contains(t.OriginalReReadingTaskId) && t.RequestReReadingUserId == _userInfo.Id && t.RequestReReadingReason == "AIR自动重阅基线").ToListAsync(); + + if (requestRecordList.Count != baseLineTaskIdList.Count) + { + //---后台数据有错误 + return ResponseOutput.NotOk(_localizer["VisitTask_DoctorConfiguration"]); + } + + await ConfirmReReading(new ConfirmReReadingCommand() + { + TrialId = command.TrialId, + RequestReReadingResultEnum = RequestReReadingResult.Agree, + //ConfirmReReadingList = new List() { new ConfirmReReadingDTO() { Id = requestRecord.Id, OriginalReReadingTaskId = task.Id } } + ConfirmReReadingList = requestRecordList.Select(t => new ConfirmReReadingDTO() { Id = t.Id, OriginalReReadingTaskId = t.OriginalReReadingTaskId }).ToList() + }, _visitTaskCommonService); + } + else + { + if (command.VisitTaskId != null) + { + var visitTaskId = command.VisitTaskId.Value; + var taskIdList = new List(); + + taskIdList.Add(visitTaskId); + + await ApplyReReading(new ApplyReReadingCommand() { IsCopyFollowForms = false, IsCopyOrigenalForms = true, TaskIdList = taskIdList, TrialId = command.TrialId, RequestReReadingReason = "阅片人自动重阅阅片任务", RequestReReadingType = RequestReReadingType.DocotorApply }); + + var requestRecord = await _visitTaskReReadingRepository.Where(t => visitTaskId == t.OriginalReReadingTaskId && t.RequestReReadingUserId == _userInfo.Id && t.RequestReReadingReason == "阅片人自动重阅阅片任务").FirstAsync(); + + await ConfirmReReading(new ConfirmReReadingCommand() + { + TrialId = command.TrialId, + RequestReReadingResultEnum = RequestReReadingResult.Agree, + ConfirmReReadingList = new List() { new ConfirmReReadingDTO() { Id = requestRecord.Id, OriginalReReadingTaskId = visitTaskId } } + }, _visitTaskCommonService); } } - - var baseLineTaskIdList = baseLineTaskList.Select(t => t.Id).ToList(); - - if (baseLineTaskIdList.Count == 0) - { - return ResponseOutput.Ok(); - } - - //if (baseLineTaskList == null) - //{ - // return ResponseOutput.NotOk("基线任务未阅完,不允许重阅基线任务"); - //} - - await ApplyReReading(new ApplyReReadingCommand() { IsCopyFollowForms = false, IsCopyOrigenalForms = false, TaskIdList = baseLineTaskIdList, TrialId = command.TrialId, RequestReReadingReason = "AIR自动重阅基线", RequestReReadingType = RequestReReadingType.DocotorApply }); - - - - var requestRecordList = await _visitTaskReReadingRepository.Where(t => baseLineTaskIdList.Contains(t.OriginalReReadingTaskId) && t.RequestReReadingUserId == _userInfo.Id && t.RequestReReadingReason == "AIR自动重阅基线").ToListAsync(); - - if (requestRecordList.Count != baseLineTaskIdList.Count) - { - //---后台数据有错误 - return ResponseOutput.NotOk(_localizer["VisitTask_DoctorConfiguration"]); - } - - await ConfirmReReading(new ConfirmReReadingCommand() - { - TrialId = command.TrialId, - RequestReReadingResultEnum = RequestReReadingResult.Agree, - //ConfirmReReadingList = new List() { new ConfirmReReadingDTO() { Id = requestRecord.Id, OriginalReReadingTaskId = task.Id } } - ConfirmReReadingList = requestRecordList.Select(t => new ConfirmReReadingDTO() { Id = t.Id, OriginalReReadingTaskId = t.OriginalReReadingTaskId }).ToList() - }, _visitTaskCommonService); - return ResponseOutput.Ok(); } @@ -1599,7 +1623,7 @@ public class VisitTaskService(IRepository _visitTaskRepository, throw new BusinessValidationFailedException(_localizer["VisitTask_BackendData"]); } - _logger.LogError("重阅申请状态"+ (int)task.ReReadingApplyState); + _logger.LogError("重阅申请状态" + (int)task.ReReadingApplyState); if (task.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed || task.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed || task.ReReadingApplyState == ReReadingApplyState.Agree) { @@ -1743,7 +1767,7 @@ public class VisitTaskService(IRepository _visitTaskRepository, } //AIR 不加验证 - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR) + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SR) { task.ReReadingApplyState = ReReadingApplyState.DocotorHaveApplyed; } @@ -1879,7 +1903,7 @@ public class VisitTaskService(IRepository _visitTaskRepository, visitTaskReReadingAppply.RequestReReadingRejectReason = agreeReReadingCommand.RequestReReadingRejectReason; - Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze) && t.TaskAllocationState == TaskAllocationState.Allocated; + Expression> filterExpression = t => t.TrialId == trialId && t.SubjectId == origenalTask.SubjectId && (t.TaskState == TaskState.Effect || t.TaskState == TaskState.Freeze) /*&& t.TaskAllocationState == TaskAllocationState.Allocated*/; //是否是一致性分析任务 正常申请 会影响一致性分析任务 filterExpression = filterExpression.And(t => t.IsAnalysisCreate == origenalTask.IsAnalysisCreate); @@ -2045,7 +2069,10 @@ public class VisitTaskService(IRepository _visitTaskRepository, } //IR申请 PM 审批 注意这里有一致性分析的申请同意 不会回退访视,在此要生成影响的访视任务 - else if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && (IsPMOrAPm() || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR)) + else if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && (IsPMOrAPm() || + _userInfo.UserTypeEnumInt == (int)UserTypeEnum.AIR + || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SR + || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.PI)) { diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs index 3b79c5f20..f0d23f934 100644 --- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs @@ -139,7 +139,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.TrialSiteId, t => t.MapFrom(u => u.Subject.TrialSiteId)) - .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => /*u.IsAnalysisCreate == true ? u.BlindTrialSiteCode :*/ u.Subject.TrialSite.TrialSiteCode)) + //.ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => /*u.IsAnalysisCreate == true ? u.BlindTrialSiteCode :*/ u.Subject.TrialSite.TrialSiteCode)) .ForMember(o => o.SubjectCode, t => t.MapFrom(u => /*u.IsAnalysisCreate == true ? u.BlindSubjectCode :*/ u.Subject.Code)) .ForMember(o => o.MedicalNo, t => t.MapFrom(u => u.Subject.MedicalNo)) diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index 575c66817..c77124cad 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -3163,6 +3163,7 @@ namespace IRaCIS.Core.Application.Service await VerifyTaskIsSign(visitTaskId); await _visitTaskRepository.UpdatePartialFromQueryAsync(visitTaskId, x => new VisitTask() { + DoctorUserId = _userInfo.Id, ReadingTaskState = ReadingTaskState.HaveSigned, SignTime = DateTime.Now, });