CaseFacadeEjb implements CaseFacade { @Override public List<DashboardCaseDto> getCasesForDashboard(CaseCriteria caseCriteria) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<DashboardCaseDto> cq = cb.createQuery(DashboardCaseDto.class); Root<Case> caze = cq.from(Case.class); CaseJoins<Case> joins = new CaseJoins<>(caze); Join<Case, Symptoms> symptoms = joins.getSymptoms(); Join<Case, Person> person = joins.getPerson(); Predicate filter = caseService.createUserFilter(cb, cq, caze, new CaseUserFilterCriteria().excludeSharedCases(true).excludeCasesFromContacts(true)); Predicate criteriaFilter = caseService.createCriteriaFilter(caseCriteria, cb, cq, caze, joins); filter = AbstractAdoService.and(cb, filter, criteriaFilter); if (filter != null) { cq.where(filter); } List<DashboardCaseDto> result; if (filter != null) { cq.where(filter); cq.multiselect( caze.get(Case.ID), caze.get(Case.UUID), caze.get(Case.REPORT_DATE), symptoms.get(Symptoms.ONSET_DATE), caze.get(Case.CASE_CLASSIFICATION), caze.get(Case.DISEASE), caze.get(Case.INVESTIGATION_STATUS), person.get(Person.PRESENT_CONDITION), person.get(Person.CAUSE_OF_DEATH_DISEASE)); result = em.createQuery(cq).getResultList(); } else { result = Collections.emptyList(); } return result; }  @Override List<CaseDataDto> getAllActiveCasesAfter(Date date); @Override List<CaseDataDto> getAllActiveCasesAfter(Date date, boolean includeExtendedChangeDateFilters); @Override List<CaseDataDto> getByUuids(List<String> uuids); @Override String getUuidByUuidEpidNumberOrExternalId(String searchTerm); @Override long count(CaseCriteria caseCriteria); @Override List<CaseIndexDto> getIndexList(CaseCriteria caseCriteria, Integer first, Integer max, List<SortProperty> sortProperties); @Override List<CaseIndexDetailedDto> getIndexDetailedList(CaseCriteria caseCriteria, Integer first, Integer max, List<SortProperty> sortProperties); @Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) List<CaseExportDto> getExportList(
		CaseCriteria caseCriteria,
		CaseExportType exportType,
		int first,
		int max,
		ExportConfigurationDto exportConfiguration,
		Language userLanguage); @Override List<String> getAllActiveUuids(); @Override List<DashboardCaseDto> getCasesForDashboard(CaseCriteria caseCriteria); List<DashboardQuarantineDataDto> getQuarantineDataForDashBoard(
		RegionReferenceDto regionRef,
		DistrictReferenceDto districtRef,
		Disease disease,
		Date from,
		Date to); long countCasesConvertedFromContacts(CaseCriteria caseCriteria); @Override List<MapCaseDto> getCasesForMap(RegionReferenceDto regionRef, DistrictReferenceDto districtRef, Disease disease, Date from, Date to); @Override List<CaseDataDto> getAllCasesOfPerson(String personUuid); @Override Map<CaseClassification, Long> getCaseCountPerClassification(
		CaseCriteria caseCriteria,
		boolean excludeSharedCases,
		boolean excludeCasesFromContacts); @Override Map<PresentCondition, Long> getCaseCountPerPersonCondition(
		CaseCriteria caseCriteria,
		boolean excludeSharedCases,
		boolean excludeCasesFromContacts); @Override Map<Disease, Long> getCaseCountByDisease(CaseCriteria caseCriteria, boolean excludeSharedCases, boolean excludeCasesFromContacts); @Override List<CaseReferenceDto> getRandomCaseReferences(CaseCriteria criteria, int count); Map<Disease, District> getLastReportedDistrictByDisease(
		CaseCriteria caseCriteria,
		boolean excludeSharedCases,
		boolean excludeCasesFromContacts); @Override List<CaseIndexDto> getSimilarCases(CaseSimilarityCriteria criteria); @Override List<CaseIndexDto[]> getCasesForDuplicateMerging(CaseCriteria criteria, boolean ignoreRegion); void updateCompleteness(String caseUuid); @Override String getLastReportedDistrictName(CaseCriteria caseCriteria, boolean excludeSharedCases, boolean excludeCasesFromContacts); @Override CaseDataDto getCaseDataByUuid(String uuid); @Override CaseReferenceDto getReferenceByUuid(String uuid); @Override CaseDataDto saveCase(CaseDataDto dto); CaseDataDto saveCase(CaseDataDto dto, boolean handleChanges); @Override void setSampleAssociations(ContactReferenceDto sourceContact, CaseReferenceDto cazeRef); @Override void setSampleAssociations(EventParticipantReferenceDto sourceEventParticipant, CaseReferenceDto cazeRef); @Override void setSampleAssociationsUnrelatedDisease(EventParticipantReferenceDto sourceEventParticipant, CaseReferenceDto cazeRef); @Override void validate(CaseDataDto caze); @Override void archiveOrDearchiveCase(String caseUuid, boolean archive); void onCaseChanged(CaseDataDto existingCase, Case newCase); void setResponsibleSurveillanceOfficer(Case caze); void reassignTasks(Case caze); @Override String generateEpidNumber(CaseReferenceDto caze); String generateEpidNumber(Case caze); @Override void deleteCase(String caseUuid); @Override void deleteCaseAsDuplicate(String caseUuid, String duplicateOfCaseUuid); @Override List<String> getArchivedUuidsSince(Date since); @Override List<String> getDeletedUuidsSince(Date since); Case fillOrBuildEntity(@NotNull CaseDataDto source, Case target); CaseDataDto convertToDto(Case source, Pseudonymizer pseudonymizer); CaseReferenceDto convertToReferenceDto(Case source); static CaseReferenceDto toReferenceDto(Case entity); static CaseDataDto toDto(Case source); void updateInvestigationByStatus(CaseDataDto existingCase, Case caze); void updateInvestigationByTask(Case caze); @Override boolean doesEpidNumberExist(String epidNumber, String caseUuid, Disease caseDisease); @Override List<Pair<DistrictDto, BigDecimal>> getCaseMeasurePerDistrict(Date fromDate, Date toDate, Disease disease, CaseMeasure caseMeasure); @Override Date getOldestCaseOnsetDate(); @Override Date getOldestCaseReportDate(); @Override boolean isArchived(String caseUuid); @Override boolean isDeleted(String caseUuid); @Override void mergeCase(String leadUuid, String otherUuid); @Override CaseDataDto cloneCase(CaseDataDto existingCaseDto); @Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) void archiveAllArchivableCases(int daysAfterCaseGetsArchived); @Override void updateArchived(List<String> caseUuids, boolean archived); @Override boolean exists(String uuid); @Override boolean hasPositiveLabResult(String caseUuid); @Override List<CaseFollowUpDto> getCaseFollowUpList(
		CaseCriteria caseCriteria,
		Date referenceDate,
		int interval,
		Integer first,
		Integer max,
		List<SortProperty> sortProperties); Boolean isCaseEditAllowed(String caseUuid);  }
@Test public void testGetCasesForDashboard() { RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility"); RDCFEntities rdcf2 = creator.createRDCFEntities("Region2", "District2", "Community2", "Facility2"); UserDto user = creator .createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR); PersonDto cazePerson = creator.createPerson("Case", "Person"); CaseDataDto caze = creator.createCase( user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf); CaseDataDto caze2 = creator.createCase( user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf2); caze2.setSharedToCountry(true); getCaseFacade().saveCase(caze2); CaseCriteria caseCriteria = new CaseCriteria().region(caze.getRegion()) .district(caze.getDistrict()) .disease(caze.getDisease()) .newCaseDateBetween(DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1), NewCaseDateType.MOST_RELEVANT); List<DashboardCaseDto> dashboardCaseDtos = getCaseFacade().getCasesForDashboard(caseCriteria); assertEquals(1, dashboardCaseDtos.size()); }