VisitFacadeEjb implements VisitFacade { @Override public List<VisitDto> getVisitsByContactAndPeriod(ContactReferenceDto contactRef, Date begin, Date end) { Contact contact = contactService.getByReferenceDto(contactRef); Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight); return contact.getVisits() .stream() .filter(visit -> visit.getVisitDateTime().after(begin) && visit.getVisitDateTime().before(end)) .map(visit -> convertToDto(visit, pseudonymizer)) .collect(Collectors.toList()); }  @Override List<String> getAllActiveUuids(); @Override List<VisitDto> getAllActiveVisitsAfter(Date date); @Override List<VisitDto> getByUuids(List<String> uuids); @Override VisitDto getLastVisitByContact(ContactReferenceDto contactRef); @Override List<VisitDto> getVisitsByContactAndPeriod(ContactReferenceDto contactRef, Date begin, Date end); @Override VisitDto getLastVisitByCase(CaseReferenceDto caseRef); @Override VisitDto getVisitByUuid(String uuid); @Override VisitDto saveVisit(VisitDto dto); @Override ExternalVisitDto saveExternalVisit(final ExternalVisitDto dto); @Override void validate(VisitDto visit); @Override void deleteVisit(String visitUuid); @Override List<VisitIndexDto> getIndexList(VisitCriteria visitCriteria, Integer first, Integer max, List<SortProperty> sortProperties); @Override long count(VisitCriteria visitCriteria); @Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) List<VisitExportDto> getVisitsExportList(
		VisitCriteria visitCriteria,
		VisitExportType exportType,
		int first,
		int max,
		ExportConfigurationDto exportConfiguration); Visit fromDto(@NotNull VisitDto source); VisitDto convertToDto(Visit source, Pseudonymizer pseudonymizer); static VisitReferenceDto toReferenceDto(Visit source); static VisitDto toDto(Visit source);  }
@Test public void testGetVisitsByContactAndPeriod() { UserDto user = creator.createUser(creator.createRDCFEntities(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR); PersonDto person = creator.createPerson(); ContactDto contact = creator.createContact(user.toReference(), person.toReference()); Date reportDate = new Date(); int incubationPeriod = 10; Date begin = DateHelper.subtractDays(reportDate, incubationPeriod); Date end = DateHelper.addDays(reportDate, incubationPeriod); VisitDto visitIn1 = creator.createVisit(Disease.EVD, person.toReference(), DateHelper.subtractDays(reportDate, 1)); VisitDto visitIn2 = creator.createVisit(Disease.EVD, person.toReference(), DateHelper.subtractDays(reportDate, 2)); VisitDto visitIn3 = creator.createVisit(Disease.EVD, person.toReference(), DateHelper.addDays(reportDate, 2)); VisitDto visitOut = creator.createVisit(Disease.EVD, person.toReference(), DateHelper.subtractDays(reportDate, 12)); List<VisitDto> visits = getVisitFacade().getVisitsByContactAndPeriod(contact.toReference(), begin, end); assertTrue(visits.contains(visitIn1)); assertTrue(visits.contains(visitIn2)); assertTrue(visits.contains(visitIn3)); assertFalse(visits.contains(visitOut)); }