CaseFacadeEjb implements CaseFacade { @Override public String generateEpidNumber(CaseReferenceDto caze) { return generateEpidNumber(caseService.getByReferenceDto(caze)); }  @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 testGenerateEpidNumber() { RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility"); UserDto user = creator.createUser( rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR, UserRole.ADMIN); PersonDto cazePerson = creator.createPerson("Case", "Person"); CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), rdcf); Calendar calendar = Calendar.getInstance(); String year = String.valueOf(calendar.get(Calendar.YEAR)).substring(2); assertEquals("COU-REG-DIS-" + year + "-001", caze.getEpidNumber()); CaseDataDto secondCaze = creator.createCase(user.toReference(), cazePerson.toReference(), rdcf); assertEquals("COU-REG-DIS-" + year + "-002", secondCaze.getEpidNumber()); secondCaze.setEpidNumber("COU-REG-DIS-" + year + "-0004"); getCaseFacade().saveCase(secondCaze); CaseDataDto thirdCaze = creator.createCase(user.toReference(), cazePerson.toReference(), rdcf); assertEquals("COU-REG-DIS-" + year + "-005", thirdCaze.getEpidNumber()); thirdCaze.setEpidNumber("COU-REG-DIS-" + year + "-3"); getCaseFacade().saveCase(thirdCaze); CaseDataDto fourthCaze = creator.createCase(user.toReference(), cazePerson.toReference(), rdcf); assertEquals("COU-REG-DIS-" + year + "-005", fourthCaze.getEpidNumber()); fourthCaze.setEpidNumber("COU-REG-DIS-" + year + "-AAA"); getCaseFacade().saveCase(fourthCaze); fourthCaze = getCaseFacade().getCaseDataByUuid(fourthCaze.getUuid()); assertEquals("COU-REG-DIS-" + year + "-005", fourthCaze.getEpidNumber()); getCaseFacade().deleteCase(fourthCaze.getUuid()); CaseDataDto fifthCaze = creator.createCase(user.toReference(), cazePerson.toReference(), rdcf); assertEquals("COU-REG-DIS-" + year + "-005", fifthCaze.getEpidNumber()); }