use of de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportFacadeEjb method getSummariesPerRegion.
@Override
public List<WeeklyReportRegionSummaryDto> getSummariesPerRegion(EpiWeek epiWeek) {
JurisdictionLevel jurisdictionLevel = userService.getCurrentUser().getJurisdictionLevel();
if (jurisdictionLevel != JurisdictionLevel.NONE & jurisdictionLevel != 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.countByDistricts(region.getDistricts(), UserRight.WEEKLYREPORT_CREATE);
if (officers.intValue() == 0) {
// summarize only regions that do have officers
continue;
}
summaryDto.setOfficers(officers.intValue());
Long informants = userService.countByCommunities(region.getDistricts(), UserRight.WEEKLYREPORT_CREATE);
informants += userService.countByHealthFacilities(region.getDistricts(), UserRight.WEEKLYREPORT_CREATE);
informants += userService.countByPointOfEntries(region.getDistricts(), UserRight.WEEKLYREPORT_CREATE);
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;
}
use of de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportFacadeEjbTest method testGetSummariesPerRegion.
@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());
}
use of de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportRegionsGrid method reload.
public void reload(int year, int week) {
this.week = week;
this.year = year;
getContainer().removeAllItems();
EpiWeek epiWeek = new EpiWeek(year, week);
List<WeeklyReportRegionSummaryDto> summaryDtos = FacadeProvider.getWeeklyReportFacade().getSummariesPerRegion(epiWeek);
summaryDtos.forEach(s -> getContainer().addItem(s));
}
use of de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto in project SORMAS-Project by hzi-braunschweig.
the class WeeklyReportRegionsGrid method itemClick.
@Override
public void itemClick(ItemClickEvent event) {
if (event.getPropertyId().equals(VIEW_DETAILS_BTN_ID)) {
WeeklyReportRegionSummaryDto summaryDto = (WeeklyReportRegionSummaryDto) event.getItemId();
VerticalLayout layout = new VerticalLayout();
layout.setSizeUndefined();
layout.setMargin(true);
Window window = VaadinUiUtil.showPopupWindow(layout);
WeeklyReportOfficersGrid grid = new WeeklyReportOfficersGrid();
grid.reload(summaryDto.getRegion(), year, week);
grid.setWidth(1600, Unit.PIXELS);
grid.setHeightMode(HeightMode.ROW);
grid.setHeightUndefined();
layout.addComponent(grid);
window.setCaption(String.format(I18nProperties.getCaption(Captions.weeklyReportsInDistrict), summaryDto.getRegion().toString()) + " - " + I18nProperties.getString(Strings.epiWeek) + " " + week + "/" + year);
}
}
Aggregations