Search in sources :

Example 6 with EpiWeek

use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.

the class ReportsView method updateEpiWeeks.

private void updateEpiWeeks(int year, int week) {
    List<EpiWeek> epiWeekList = DateHelper.createEpiWeekList(year);
    for (EpiWeek epiWeek : epiWeekList) {
        epiWeekFilter.addItem(epiWeek.getWeek());
        epiWeekFilter.setItemCaption(epiWeek.getWeek(), epiWeek.toString());
    }
    epiWeekFilter.select(week);
}
Also used : EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 7 with EpiWeek

use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportOfficersGrid method reload.

public void reload(RegionReferenceDto region, int year, int week) {
    this.region = region;
    this.week = week;
    this.year = year;
    getContainer().removeAllItems();
    EpiWeek epiWeek = new EpiWeek(year, week);
    List<WeeklyReportOfficerSummaryDto> summaryDtos = FacadeProvider.getWeeklyReportFacade().getSummariesPerOfficer(region, epiWeek);
    summaryDtos.forEach(s -> getContainer().addItem(s));
}
Also used : WeeklyReportOfficerSummaryDto(de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 8 with EpiWeek

use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportOfficersGrid method itemClick.

@Override
public void itemClick(ItemClickEvent event) {
    if (event.getPropertyId().equals(VIEW_DETAILS_BTN_ID)) {
        WeeklyReportOfficerSummaryDto summaryDto = (WeeklyReportOfficerSummaryDto) event.getItemId();
        if (summaryDto.getInformants() > 0) {
            VerticalLayout layout = new VerticalLayout();
            layout.setSizeUndefined();
            layout.setMargin(true);
            Window window = VaadinUiUtil.showPopupWindow(layout);
            WeeklyReportInformantsGrid grid = new WeeklyReportInformantsGrid(summaryDto.getOfficer(), new EpiWeek(year, week));
            grid.setWidth(960, Unit.PIXELS);
            grid.setHeightMode(HeightMode.ROW);
            grid.setHeightUndefined();
            layout.addComponent(grid);
            window.setCaption(String.format(I18nProperties.getCaption(Captions.weeklyReportsInDistrict), summaryDto.getDistrict().toString()) + " - " + I18nProperties.getString(Strings.epiWeek) + " " + week + "/" + year);
        }
    }
}
Also used : Window(com.vaadin.ui.Window) WeeklyReportOfficerSummaryDto(de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto) VerticalLayout(com.vaadin.ui.VerticalLayout) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 9 with EpiWeek

use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.

the class StatisticsHelper method getTimeGroupingKeys.

/**
 * @param attribute
 * @param subAttribute
 * @param caseFacade Needed for StatisticsCaseAttribute.ONSET_TIME, REPORT_TIME, OUTCOME_TIME
 * @return
 */
public static List<StatisticsGroupingKey> getTimeGroupingKeys(StatisticsCaseAttribute attribute, StatisticsCaseSubAttribute subAttribute, CaseFacade caseFacade) {
    Date oldestCaseDate = null;
    switch(attribute) {
        case ONSET_TIME:
            oldestCaseDate = caseFacade.getOldestCaseOnsetDate();
            break;
        case REPORT_TIME:
            oldestCaseDate = caseFacade.getOldestCaseReportDate();
            break;
        case OUTCOME_TIME:
            oldestCaseDate = caseFacade.getOldestCaseOutcomeDate();
            break;
        default:
            return new ArrayList<>();
    }
    LocalDate earliest = oldestCaseDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
    LocalDate now = LocalDate.now();
    switch(subAttribute) {
        case YEAR:
            List<StatisticsGroupingKey> years = new ArrayList<>();
            for (int i = earliest.getYear(); i <= now.getYear(); i++) {
                years.add(new Year(i));
            }
            return years;
        case QUARTER:
            List<StatisticsGroupingKey> quarters = new ArrayList<>();
            for (int i = 1; i <= 4; i++) {
                quarters.add(new Quarter(i));
            }
            return quarters;
        case MONTH:
            return toGroupingKeys(Month.values());
        case EPI_WEEK:
            List<StatisticsGroupingKey> epiWeeks = new ArrayList<>();
            for (int i = 1; i <= DateHelper.getMaximumEpiWeekNumber(); i++) {
                epiWeeks.add(new EpiWeek(null, i));
            }
            return epiWeeks;
        case QUARTER_OF_YEAR:
            List<StatisticsGroupingKey> quarterOfYearList = new ArrayList<>();
            QuarterOfYear earliestQuarter = new QuarterOfYear(new Quarter(1), new Year(earliest.getYear()));
            QuarterOfYear latestQuarter = new QuarterOfYear(new Quarter(4), new Year(now.getYear()));
            while (earliestQuarter.getYear().getValue() <= latestQuarter.getYear().getValue()) {
                quarterOfYearList.add(new QuarterOfYear(earliestQuarter.getQuarter(), earliestQuarter.getYear()));
                earliestQuarter.increaseQuarter();
            }
            return quarterOfYearList;
        case MONTH_OF_YEAR:
            List<StatisticsGroupingKey> monthOfYearList = new ArrayList<>();
            for (int year = earliest.getYear(); year <= now.getYear(); year++) {
                for (Month month : Month.values()) {
                    monthOfYearList.add(new MonthOfYear(month, year));
                }
            }
            return monthOfYearList;
        case EPI_WEEK_OF_YEAR:
            List<StatisticsGroupingKey> epiWeekOfYearList = new ArrayList<>();
            for (int year = earliest.getYear(); year <= now.getYear(); year++) {
                epiWeekOfYearList.addAll(DateHelper.createEpiWeekList(year));
            }
            return epiWeekOfYearList;
        default:
            return new ArrayList<>();
    }
}
Also used : Quarter(de.symeda.sormas.api.Quarter) Month(de.symeda.sormas.api.Month) QuarterOfYear(de.symeda.sormas.api.QuarterOfYear) Year(de.symeda.sormas.api.Year) MonthOfYear(de.symeda.sormas.api.MonthOfYear) MonthOfYear(de.symeda.sormas.api.MonthOfYear) QuarterOfYear(de.symeda.sormas.api.QuarterOfYear) ArrayList(java.util.ArrayList) LocalDate(java.time.LocalDate) Date(java.util.Date) LocalDate(java.time.LocalDate) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 10 with EpiWeek

use of de.symeda.sormas.api.utils.EpiWeek in project SORMAS-Project by hzi-braunschweig.

the class DashboardFilterLayout method createCustomDateFilterLayout.

private HorizontalLayout createCustomDateFilterLayout() {
    // Custom filter
    customDateFilterLayout = new HorizontalLayout();
    customDateFilterLayout.setSpacing(true);
    customDateFilterLayout.setVisible(false);
    // 'Apply custom filter' button
    Button applyButton = ButtonHelper.createButton(Captions.dashboardApplyCustomFilter, null, CssStyles.FORCE_CAPTION, CssStyles.BUTTON_FILTER_LIGHT);
    // Date & Epi Week filter
    EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = new EpiWeekAndDateFilterComponent<>(true, true, I18nProperties.getString(Strings.infoCaseDate), null);
    customDateFilterLayout.addComponents(weekAndDateFilter, applyButton);
    // Apply button listener
    applyButton.addClickListener(e -> {
        currentDateFilterType = DateFilterType.CUSTOM;
        DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue();
        Date fromDate = null;
        Date toDate = null;
        EpiWeek fromWeek = null;
        EpiWeek toWeek = null;
        if (dateFilterOption == DateFilterOption.DATE) {
            fromDate = weekAndDateFilter.getDateFromFilter().getValue();
            toDate = weekAndDateFilter.getDateToFilter().getValue();
            setDateFilter(DateHelper.getStartOfDay(fromDate), DateHelper.getEndOfDay(toDate));
        } else {
            fromWeek = (EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue();
            toWeek = (EpiWeek) weekAndDateFilter.getWeekToFilter().getValue();
            setDateFilter(DateHelper.getEpiWeekStart(fromWeek), DateHelper.getEpiWeekEnd(toWeek));
        }
        if ((fromDate != null && toDate != null) || (fromWeek != null && toWeek != null)) {
            if (dateFilterOption == DateFilterOption.DATE) {
                btnCurrentPeriod.setCaption(DateFormatHelper.buildPeriodString(fromDate, toDate));
                int activePeriodLength = DateHelper.getDaysBetween(fromDate, toDate);
                btnPeriodBefore.setCaption(String.format(I18nProperties.getCaption(Captions.dashboardPeriodBefore), DateFormatHelper.buildPeriodString(DateHelper.subtractDays(fromDate, activePeriodLength), DateHelper.subtractDays(toDate, activePeriodLength))));
                btnPeriodLastYear.setCaption(String.format(I18nProperties.getCaption(Captions.dashboardSamePeriodLastYear), DateFormatHelper.buildPeriodString(DateHelper.subtractYears(fromDate, 1), DateHelper.subtractYears(toDate, 1))));
            } else {
                btnCurrentPeriod.setCaption(fromWeek.toShortString() + " - " + toWeek.toShortString());
                Date firstEpiWeekStart = DateHelper.getEpiWeekStart(fromWeek);
                Date lastEpiWeekStart = DateHelper.getEpiWeekStart(toWeek);
                int epiWeeksBetween = DateHelper.getWeeksBetween(firstEpiWeekStart, lastEpiWeekStart);
                btnPeriodBefore.setCaption(String.format(I18nProperties.getCaption(Captions.dashboardPeriodBefore), DateHelper.getEpiWeek(DateHelper.subtractWeeks(firstEpiWeekStart, epiWeeksBetween)).toShortString() + " - " + DateHelper.getEpiWeek(DateHelper.subtractWeeks(lastEpiWeekStart, epiWeeksBetween)).toShortString()));
                btnPeriodLastYear.setCaption(String.format(I18nProperties.getCaption(Captions.dashboardSamePeriodLastYear), DateHelper.getEpiWeekYearBefore(fromWeek).toShortString() + " - " + DateHelper.getEpiWeekYearBefore(toWeek).toShortString()));
            }
            updateComparisonButtons(DateFilterType.CUSTOM, null, null, true);
        } else {
            if (dateFilterOption == DateFilterOption.DATE) {
                new Notification(I18nProperties.getString(Strings.headingMissingDateFilter), I18nProperties.getString(Strings.messageMissingDateFilter), Type.ERROR_MESSAGE, false).show(Page.getCurrent());
            } else {
                new Notification(I18nProperties.getString(Strings.headingMissingEpiWeekFilter), I18nProperties.getString(Strings.messageMissingEpiWeekFilter), Type.ERROR_MESSAGE, false).show(Page.getCurrent());
            }
        }
    });
    return customDateFilterLayout;
}
Also used : NewCaseDateType(de.symeda.sormas.api.caze.NewCaseDateType) PopupButton(org.vaadin.hene.popupbutton.PopupButton) Button(com.vaadin.ui.Button) DateFilterOption(de.symeda.sormas.api.utils.DateFilterOption) Date(java.util.Date) Notification(com.vaadin.ui.Notification) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EpiWeekAndDateFilterComponent(de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Aggregations

EpiWeek (de.symeda.sormas.api.utils.EpiWeek)34 Date (java.util.Date)24 DateFilterOption (de.symeda.sormas.api.utils.DateFilterOption)9 WeeklyReportOfficerSummaryDto (de.symeda.sormas.api.report.WeeklyReportOfficerSummaryDto)4 Test (org.junit.Test)4 Button (com.vaadin.ui.Button)3 HorizontalLayout (com.vaadin.ui.HorizontalLayout)3 MonthOfYear (de.symeda.sormas.api.MonthOfYear)3 QuarterOfYear (de.symeda.sormas.api.QuarterOfYear)3 WeeklyReportDto (de.symeda.sormas.api.report.WeeklyReportDto)3 WeeklyReportRegionSummaryDto (de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto)3 TaskCriteria (de.symeda.sormas.api.task.TaskCriteria)3 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)3 LocalDate (java.time.LocalDate)3 ArrayList (java.util.ArrayList)3 RolesAllowed (javax.annotation.security.RolesAllowed)3 Month (de.symeda.sormas.api.Month)2 Quarter (de.symeda.sormas.api.Quarter)2 Year (de.symeda.sormas.api.Year)2 EventCriteria (de.symeda.sormas.api.event.EventCriteria)2