Search in sources :

Example 1 with WeeklyReportRegionSummaryDto

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;
}
Also used : JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) ArrayList(java.util.ArrayList) WeeklyReportRegionSummaryDto(de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto) Region(de.symeda.sormas.backend.infrastructure.region.Region) WeeklyReportCriteria(de.symeda.sormas.api.report.WeeklyReportCriteria)

Example 2 with WeeklyReportRegionSummaryDto

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());
}
Also used : WeeklyReportRegionSummaryDto(de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto) Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 3 with WeeklyReportRegionSummaryDto

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));
}
Also used : WeeklyReportRegionSummaryDto(de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 4 with WeeklyReportRegionSummaryDto

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);
    }
}
Also used : Window(com.vaadin.ui.Window) WeeklyReportRegionSummaryDto(de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto) VerticalLayout(com.vaadin.ui.VerticalLayout)

Aggregations

WeeklyReportRegionSummaryDto (de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto)4 EpiWeek (de.symeda.sormas.api.utils.EpiWeek)2 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Window (com.vaadin.ui.Window)1 WeeklyReportCriteria (de.symeda.sormas.api.report.WeeklyReportCriteria)1 JurisdictionLevel (de.symeda.sormas.api.user.JurisdictionLevel)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 Region (de.symeda.sormas.backend.infrastructure.region.Region)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Test (org.junit.Test)1