CaseFacadeEjb implements CaseFacade { @Override public List<CaseIndexDto> getIndexList(CaseCriteria caseCriteria, Integer first, Integer max, List<SortProperty> sortProperties) { CriteriaQuery<CaseIndexDto> cq = listQueryBuilder.buildIndexCriteria(caseCriteria, sortProperties); List<CaseIndexDto> cases; if (first != null && max != null) { TypedQuery query = em.createQuery(cq); cases = query.setFirstResult(first).setMaxResults(max).getResultList(); } else { cases = em.createQuery(cq).getResultList(); } Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue)); pseudonymizer.pseudonymizeDtoCollection( CaseIndexDto.class, cases, c -> caseJurisdictionChecker.isInJurisdictionOrOwned(c.getJurisdiction()), (c, isInJurisdiction) -> { pseudonymizer.pseudonymizeDto(AgeAndBirthDateDto.class, c.getAgeAndBirthDate(), isInJurisdiction, null); }); return cases; }  @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 testGetIndexList() { String districtName = "District"; RDCF rdcf = creator.createRDCF("Region", districtName, "Community", "Facility"); useSurveillanceOfficerLogin(rdcf); UserDto user = creator .createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR); String lastName = "Person"; PersonDto cazePerson = creator.createPerson("Case", lastName); creator.createCase( user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf); creator.createCase( user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf, c -> c.setHealthFacilityDetails("abc")); creator.createCase( user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf, c -> c.setHealthFacilityDetails("xyz")); List<CaseIndexDto> results = getCaseFacade().getIndexList( null, 0, 100, Arrays.asList( new SortProperty(CaseIndexDto.DISEASE), new SortProperty(CaseIndexDto.PERSON_FIRST_NAME), new SortProperty(CaseIndexDto.DISTRICT_NAME), new SortProperty(CaseIndexDto.HEALTH_FACILITY_NAME, false), new SortProperty(CaseIndexDto.SURVEILLANCE_OFFICER_UUID))); assertEquals(3, results.size()); assertEquals(districtName, results.get(0).getDistrictName()); assertEquals(lastName, results.get(0).getPersonLastName()); assertEquals("Facility - xyz", results.get(0).getHealthFacilityName()); assertEquals("Facility - abc", results.get(1).getHealthFacilityName()); assertEquals("Facility", results.get(2).getHealthFacilityName()); }
@Test public void testGetIndexListByFreeText() { String districtName = "District"; RDCF rdcf = creator.createRDCF("Region", districtName, "Community", "Facility"); useSurveillanceOfficerLogin(rdcf); UserDto user = creator .createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR); PersonDto person1 = creator.createPerson("FirstName1", "LastName1", p -> { p.getAddress().setPostalCode("10115"); p.getAddress().setCity("Berlin"); p.setPhone("+4930-90-1820"); }); creator.createCase( user.toReference(), person1.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf); PersonDto person2 = creator.createPerson("FirstName2", "LastName2", p -> { p.getAddress().setPostalCode("20095"); p.getAddress().setCity("Hamburg"); p.setPhone("+49-30-901822"); }); creator.createCase( user.toReference(), person2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf); PersonDto person3 = creator.createPerson("FirstName3", "LastName3", p -> { p.getAddress().setPostalCode("80331"); p.getAddress().setCity("Munich"); p.setPhone("+49 31 9018 20"); }); creator.createCase( user.toReference(), person3.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf); Assert.assertEquals(3, getCaseFacade().getIndexList(null, 0, 100, null).size()); Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().nameUuidEpidNumberLike("Munich"), 0, 100, null).size()); Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().nameUuidEpidNumberLike("20095"), 0, 100, null).size()); Assert.assertEquals(2, getCaseFacade().getIndexList(new CaseCriteria().nameUuidEpidNumberLike("+49-31-901-820"), 0, 100, null).size()); Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().nameUuidEpidNumberLike("4930901822"), 0, 100, null).size()); }
@Test public void testGetIndexListByEventFreeText() { String districtName = "District"; RDCF rdcf = creator.createRDCF("Region", districtName, "Community", "Facility"); useSurveillanceOfficerLogin(rdcf); UserDto user = creator .createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR); PersonDto person1 = creator.createPerson(); PersonDto person2 = creator.createPerson(); EventDto event1 = creator.createEvent(EventStatus.SIGNAL, "Signal foo", "A long description for this event", user.toReference(), eventDto -> { }); EventParticipantDto event1Participant1 = creator.createEventParticipant(event1.toReference(), person1, user.toReference()); EventParticipantDto event1Participant2 = creator.createEventParticipant(event1.toReference(), person2, user.toReference()); CaseDataDto case1 = creator.createCase( user.toReference(), person1.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf); CaseDataDto case2 = creator.createCase( user.toReference(), person2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf); event1Participant1.setResultingCase(case1.toReference()); getEventParticipantFacade().saveEventParticipant(event1Participant1); Assert.assertEquals(2, getCaseFacade().getIndexList(null, 0, 100, null).size()); Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().eventLike("signal"), 0, 100, null).size()); Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().eventLike(event1.getUuid()), 0, 100, null).size()); Assert.assertEquals(1, getCaseFacade().getIndexList(new CaseCriteria().eventLike("signal description"), 0, 100, null).size()); }