DiseaseFacadeEjb implements DiseaseFacade { @Override public List<DiseaseBurdenDto> getDiseaseBurdenForDashboard( RegionReferenceDto regionRef, DistrictReferenceDto districtRef, Date from, Date to, Date previousFrom, Date previousTo) { List<Disease> diseases = diseaseConfigurationFacade.getAllDiseases(true, true, true); CaseCriteria caseCriteria = new CaseCriteria().newCaseDateBetween(from, to, null).region(regionRef).district(districtRef); Map<Disease, Long> newCases = caseFacade.getCaseCountByDisease(caseCriteria, true, true); Map<Disease, Long> events = eventFacade.getEventCountByDisease(new EventCriteria().region(regionRef).district(districtRef).reportedBetween(from, to)); Map<Disease, Long> outbreakDistrictsCount = outbreakFacade .getOutbreakDistrictCountByDisease(new OutbreakCriteria().region(regionRef).district(districtRef).reportedBetween(from, to)); Map<Disease, District> lastReportedDistricts = caseFacade.getLastReportedDistrictByDisease(caseCriteria, true, true); Map<Disease, Long> caseFatalities = personFacade.getDeathCountByDisease(caseCriteria, true, true); caseCriteria.newCaseDateBetween(previousFrom, previousTo, null); Map<Disease, Long> previousCases = caseFacade.getCaseCountByDisease(caseCriteria, true, true); List<DiseaseBurdenDto> diseasesBurden = diseases.stream().map(disease -> { Long caseCount = newCases.getOrDefault(disease, 0L); Long previousCaseCount = previousCases.getOrDefault(disease, 0L); Long eventCount = events.getOrDefault(disease, 0L); Long outbreakDistrictCount = outbreakDistrictsCount.getOrDefault(disease, 0L); Long caseFatalityCount = caseFatalities.getOrDefault(disease, 0L); District lastReportedDistrict = lastReportedDistricts.getOrDefault(disease, null); String lastReportedDistrictName = lastReportedDistrict == null ? "" : lastReportedDistrict.getName(); return new DiseaseBurdenDto( disease, caseCount, previousCaseCount, eventCount, outbreakDistrictCount, caseFatalityCount, lastReportedDistrictName); }).collect(Collectors.toList()); return diseasesBurden; }  @Override List<DiseaseBurdenDto> getDiseaseBurdenForDashboard(
		RegionReferenceDto regionRef,
		DistrictReferenceDto districtRef,
		Date from,
		Date to,
		Date previousFrom,
		Date previousTo);  }
@Test public void testDiseaseBurdenForDashboard() { Date referenceDate = new Date(); RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility"); CommunityDto community2 = creator.createCommunity("Community2", rdcf.district); RDCF rdcf2 = new RDCF( rdcf.region, rdcf.district, community2.toReference(), creator.createFacility("Facility2", rdcf.region, rdcf.district, community2.toReference()).toReference()); 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, DateHelper.subtractDays(referenceDate, 2), rdcf); PersonDto cazePerson2 = creator.createPerson("Case", "Person2"); CaseDataDto caze2 = creator.createCase( user.toReference(), cazePerson2.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, DateHelper.addDays(referenceDate, 1), rdcf2); PersonDto cazePerson3 = creator.createPerson("Case", "Person3"); CaseDataDto caze3 = creator.createCase( user.toReference(), cazePerson3.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, DateHelper.addDays(referenceDate, 2), rdcf); PersonDto cazePerson4 = creator.createPerson("Case", "Person4"); CaseDataDto caze4 = creator.createCase( user.toReference(), cazePerson4.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, referenceDate, rdcf2); List<DiseaseBurdenDto> diseaseBurdenForDashboard = getDiseaseFacade().getDiseaseBurdenForDashboard( rdcf.region, rdcf.district, DateHelper.getStartOfDay(referenceDate), DateHelper.getEndOfDay(DateHelper.addDays(referenceDate, 10)), DateHelper.getStartOfDay(DateHelper.subtractDays(referenceDate, 10)), DateHelper.getEndOfDay(DateHelper.subtractDays(referenceDate, 1))); DiseaseBurdenDto evdBurden = diseaseBurdenForDashboard.stream().filter(dto -> dto.getDisease() == Disease.EVD).findFirst().get(); assertEquals(new Long(3), evdBurden.getCaseCount()); assertEquals(new Long(1), evdBurden.getPreviousCaseCount()); assertEquals(rdcf.district.getCaption(), evdBurden.getLastReportedDistrictName()); }