diff --git a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs index f346b1870..944ae2eed 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs @@ -377,7 +377,7 @@ namespace IRaCIS.Application.Services /// public async Task> GetSubjectReadVisitList(GetSubjectReadVisitsInDto inDto) { - var maxReadVisit = await _readModuleRepository.Where(x => x.SubjectId == inDto.SubjectId&&x.ReadingSetType==inDto.ReadingSetType && x.ModuleType != ModuleTypeEnum.Global).OrderByDescending(x=>x.VisitNum).FirstOrDefaultAsync(); + var maxReadVisit = await _readModuleRepository.Where(x => x.SubjectId == inDto.SubjectId&&x.ReadingSetType==inDto.ReadingSetType).OrderByDescending(x=>x.VisitNum).FirstOrDefaultAsync(); var maxReadVisitNum= maxReadVisit==null?0:maxReadVisit.VisitNum; var visitQuery = _subjectVisitRepository.Where(x => x.SubjectId == inDto.SubjectId && x.LatestScanDate != null&&!x.IsLostVisit); var finalVisitNum = await visitQuery.Where(x => x.IsFinalVisit).Select(x => x.VisitNum).FirstOrDefaultAsync(); @@ -385,7 +385,7 @@ namespace IRaCIS.Application.Services var readModulequery = _readModuleRepository.AsQueryable(); var resultlist= await visitQuery.WhereIf(finalVisitNum != null&& finalVisitNum!=0, x => x.VisitNum <= finalVisitNum) - .Where(x=>x.VisitNum>= maxReadVisitNum) + .Where(x=>x.VisitNum> maxReadVisitNum) .Where(x => readModulequery.Where(y => y.SubjectVisitId == x.Id && y.ReadingSetType == inDto.ReadingSetType).Count() == 0).OrderBy(x => finalVisitNum) .Select(x => new GetSubjectReadVisitsOutDto() { @@ -405,7 +405,7 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task AddReadModule(ReadModuleAddDto dto) { - var visitQuery = _subjectVisitRepository.Where(x => x.SubjectId == dto.SubjectId && x.InPlan); + var visitQuery = _subjectVisitRepository.Where(x => x.SubjectId == dto.SubjectId); visitQuery = visitQuery.WhereIf(dto.ExpirationDate != null, x => x.LatestScanDate <= dto.ExpirationDate.Value) .WhereIf(dto.ExpirationVisitNum != null, x => x.VisitNum <= dto.ExpirationVisitNum.Value);