diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs index 8e349d3af..d272aef84 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs @@ -259,7 +259,7 @@ namespace IRaCIS.Core.Application.Service .ProjectTo(_mapper.ConfigurationProvider); - var defalutSortArray = new string[] { nameof(TaskMedicalReviewView.AuditState), nameof(TaskMedicalReviewView.SubjectId), nameof(TaskMedicalReviewView.ArmEnum), nameof(TaskMedicalReviewView.VisitTaskNum) }; + var defalutSortArray = new string[] { nameof(TaskMedicalReviewView.SubjectId), nameof(TaskMedicalReviewView.ArmEnum), nameof(TaskMedicalReviewView.VisitTaskNum) }; var pageList = await taskMedicalReviewQueryable.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); return ResponseOutput.Ok(pageList, new diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index dd47abc68..82c491a75 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -1107,8 +1107,19 @@ namespace IRaCIS.Core.Application.Contracts } + public class GetNextCRCChallengeInDto + { + [NotDefault] + public Guid TrialId { get; set; } - public class ChallengeQuery : PageInput + /// + /// QCChallengeId + /// + public Guid QCChallengeId { get; set; } + } + + + public class ChallengeQuery : PageInput { [NotDefault] public Guid TrialId { get; set; } diff --git a/IRaCIS.Core.Application/Service/QC/QCListService.cs b/IRaCIS.Core.Application/Service/QC/QCListService.cs index 11c4b7e90..4ec4e93bf 100644 --- a/IRaCIS.Core.Application/Service/QC/QCListService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCListService.cs @@ -9,6 +9,7 @@ using IRaCIS.Application.Contracts; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.Service.Reading.Dto; using static Org.BouncyCastle.Math.EC.ECCurve; +using IRaCIS.Core.Infrastructure; namespace IRaCIS.Core.Application.Image.QA { @@ -87,14 +88,69 @@ namespace IRaCIS.Core.Application.Image.QA } - - /// - /// CRC 质疑列表 + /// 获取下一个crc的未关闭的质疑 /// - /// + /// /// + /// [HttpPost] + public async Task GetNextCRCChallenge(GetNextCRCChallengeInDto inDto) + { + var list =await GetCRCChallengeList(new ChallengeQuery() + { + TrialId = inDto.TrialId, + PageIndex = 1, + PageSize = 9999 + }); + + var pageList = list.Item1.CurrentPageData.ToList(); + + + var data = pageList.Where(x=>x.Id==inDto.QCChallengeId||x.IsClosed==false).ToList(); + + if (data.Count > 0) + { + + var index = data.ToList().FindIndex(x => x.Id == inDto.QCChallengeId); + + var result = new QCCRCChallengeViewModel() { }; + + if (index + 1 == data.Count()) // 最后一个 + { + throw new BusinessValidationFailedException(_localizer["QCList_CRCFinishChallenge"]); + } + else if (index == -1 || data.Count == 1) // 第一个或者只有一个 + { + if (data[0].Id == inDto.QCChallengeId) + { + throw new BusinessValidationFailedException(_localizer["QCList_CRCFinishChallenge"]); + } + result = data[0]; + } + else + { + result = data.Skip(index + 1).Take(1).First(); + + } + return result; + + } + else + { + throw new BusinessValidationFailedException(_localizer["QCList_CRCFinishChallenge"]); + } + + } + + + + /// + /// CRC 质疑列表 + /// + /// + /// + [HttpPost] public async Task<(PageOutput, TrialSubjectAndSVConfig)> GetCRCChallengeList(ChallengeQuery challengeQuery) { @@ -117,7 +173,7 @@ namespace IRaCIS.Core.Application.Image.QA .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.SubjectVisit.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) .ProjectTo(_mapper.ConfigurationProvider); - var pageList = await query2.ToPagedListAsync(challengeQuery.PageIndex, challengeQuery.PageSize, challengeQuery.SortField, challengeQuery.Asc, string.IsNullOrWhiteSpace(challengeQuery.SortField), new string[] { "IsUrgent desc", "IsClosed asc" }); + var pageList = await query2.ToPagedListAsync(challengeQuery.PageIndex, challengeQuery.PageSize, challengeQuery.SortField, challengeQuery.Asc, string.IsNullOrWhiteSpace(challengeQuery.SortField), new string[] { "IsUrgent desc", "CreateTime asc" }); var config = await _repository.Where(t => t.Id == challengeQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); return (pageList, config); diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs index b89ece8e1..feebe486e 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs @@ -42,7 +42,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public Guid TrialReadingCriterionId { get; set; } - public Guid SubjectId { get; set; } + public Guid TaskMedicalReviewId { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicalReviewService.cs index 3a16532c3..c0dcd1578 100644 --- a/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicalReviewService.cs +++ b/IRaCIS.Core.Application/Service/Reading/MedicalAudit/ReadingMedicalReviewService.cs @@ -792,40 +792,33 @@ namespace IRaCIS.Core.Application.Service var list = await GetIRMedicalFeedbackList(new GetIRMedicalFeedbackListInDto() { TrialId=inDto.TrialId, - AuditState= MedicalReviewAuditState.Auditing, TrialReadingCriterionId=inDto.TrialReadingCriterionId, - SubjectId=inDto.SubjectId, PageIndex=1, - PageSize=1, + PageSize=99999, }); + var index = list.CurrentPageData.ToList().FindIndex(x => x.Id == inDto.TaskMedicalReviewId); - if (list.CurrentPageData.Count() == 0) + var result = new GetIRMedicalFeedbackListOutDto() { }; + + if (index + 1 == list.CurrentPageData.Count()) // 最后一个 { - list = await GetIRMedicalFeedbackList(new GetIRMedicalFeedbackListInDto() - { - TrialId = inDto.TrialId, - AuditState = MedicalReviewAuditState.Auditing, - TrialReadingCriterionId = inDto.TrialReadingCriterionId, - PageIndex = 1, - PageSize = 1, - }); - } - - - if (list.CurrentPageData.Count() > 0) - { - return list.CurrentPageData[0]; - } - else - { throw new BusinessValidationFailedException(_localizer["MedicalReview_IRFinish"], ApiResponseCodeEnum.CloseCurrentWindows); } + else if (index == -1 || list.CurrentPageData.Count == 1) // 第一个或者只有一个 + { + if (list.CurrentPageData[0].Id == inDto.TaskMedicalReviewId) + { + throw new BusinessValidationFailedException(_localizer["MedicalReview_IRFinish"], ApiResponseCodeEnum.CloseCurrentWindows); + } + result = list.CurrentPageData[0]; + } + else + { + result = list.CurrentPageData.Skip(index + 1).Take(1).First(); - - - - + } + return result; } ///