WeeklyReportFacadeEjb implements WeeklyReportFacade { @Override public List<WeeklyReportRegionSummaryDto> getSummariesPerRegion(EpiWeek epiWeek) { if (userService.getCurrentUser().getJurisdictionLevel() != JurisdictionLevel.NATION) { return new ArrayList<>(); } List<WeeklyReportRegionSummaryDto> summaryDtos = new ArrayList<>(); WeeklyReportCriteria regionReportCriteria = new WeeklyReportCriteria().epiWeek(epiWeek); List<Region> regions = regionService.getAll(Region.NAME, true); for (Region region : regions) { WeeklyReportRegionSummaryDto summaryDto = new WeeklyReportRegionSummaryDto(); summaryDto.setRegion(RegionFacadeEjb.toReferenceDto(region)); Long officers = userService.countByRegion(region, UserRole.SURVEILLANCE_OFFICER); if (officers.intValue() == 0) { continue; } summaryDto.setOfficers(officers.intValue()); Long informants = userService.countByRegion(region, UserRole.HOSPITAL_INFORMANT, UserRole.COMMUNITY_INFORMANT); summaryDto.setInformants(informants.intValue()); regionReportCriteria.reportingUserRegion(summaryDto.getRegion()); regionReportCriteria.officerReport(true); regionReportCriteria.zeroReport(false); Long officerCaseReports = weeklyReportService.countByCriteria(regionReportCriteria, null); summaryDto.setOfficerCaseReports(officerCaseReports.intValue()); regionReportCriteria.zeroReport(true); Long officerZeroReports = weeklyReportService.countByCriteria(regionReportCriteria, null); summaryDto.setOfficerZeroReports(officerZeroReports.intValue()); regionReportCriteria.officerReport(false); regionReportCriteria.zeroReport(false); Long informantCaseReports = weeklyReportService.countByCriteria(regionReportCriteria, null); summaryDto.setInformantCaseReports(informantCaseReports.intValue()); regionReportCriteria.zeroReport(true); Long informantZeroReports = weeklyReportService.countByCriteria(regionReportCriteria, null); summaryDto.setInformantZeroReports(informantZeroReports.intValue()); summaryDtos.add(summaryDto); } return summaryDtos; }  @Override List<WeeklyReportDto> getAllWeeklyReportsAfter(Date date); @Override List<WeeklyReportDto> getByUuids(List<String> uuids); @Override WeeklyReportDto getByUuid(String uuid); @Override WeeklyReportDto saveWeeklyReport(WeeklyReportDto dto); @Override List<String> getAllUuids(); @Override List<WeeklyReportRegionSummaryDto> getSummariesPerRegion(EpiWeek epiWeek); @Override List<WeeklyReportOfficerSummaryDto> getSummariesPerOfficer(RegionReferenceDto regionRef, EpiWeek epiWeek); @Override WeeklyReportDto getByEpiWeekAndUser(EpiWeek epiWeek, UserReferenceDto userRef); WeeklyReport fromDto(@NotNull WeeklyReportDto source); WeeklyReportEntry fromDto(WeeklyReportEntryDto source); static WeeklyReportReferenceDto toReferenceDto(WeeklyReport entity); static WeeklyReportDto toDto(WeeklyReport source); static WeeklyReportEntryDto toDto(WeeklyReportEntry source); @RolesAllowed(UserRole._SYSTEM) @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) void generateSubmitWeeklyReportTasks();  }
@Test public void testGetSummariesPerRegion() { EpiWeek previousEpiWeek = DateHelper.getPreviousEpiWeek(new Date()); createFacilityInformantReport(informant1, new Date(), previousEpiWeek.getWeek(), previousEpiWeek.getYear(), 1); createCommunityInformantReport(informant3, new Date(), previousEpiWeek.getWeek(), previousEpiWeek.getYear(), 1); createFacilityInformantReport(informant4, new Date(), previousEpiWeek.getWeek(), previousEpiWeek.getYear(), 0); List<WeeklyReportRegionSummaryDto> summariesPerRegion = getWeeklyReportFacade().getSummariesPerRegion(previousEpiWeek); assertEquals(1, summariesPerRegion.size()); WeeklyReportRegionSummaryDto summary = summariesPerRegion.get(0); assertEquals(1, summary.getOfficers()); assertEquals(1, summary.getOfficerMissingReports()); assertEquals(0, summary.getOfficerCaseReports()); assertEquals(0, summary.getOfficerZeroReports()); assertEquals(4, summary.getInformants()); assertEquals(2, summary.getInformantCaseReports()); assertEquals(1, summary.getInformantZeroReports()); assertEquals(1, summary.getInformantMissingReports()); createOfficerReport(officer, new Date(), previousEpiWeek.getWeek(), previousEpiWeek.getYear(), 1); summariesPerRegion = getWeeklyReportFacade().getSummariesPerRegion(previousEpiWeek); assertEquals(1, summariesPerRegion.size()); summary = summariesPerRegion.get(0); assertEquals(1, summary.getOfficers()); assertEquals(0, summary.getOfficerMissingReports()); assertEquals(1, summary.getOfficerCaseReports()); assertEquals(0, summary.getOfficerZeroReports()); }