Search in sources :

Example 11 with EpiWeek

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

the class ReportFragment method showReportData.

protected void showReportData() {
    User user = ConfigProvider.getUser();
    EpiWeek epiWeek = getEpiWeek();
    EpiWeekFilterOption filterOption = getEpiWeekFilterOption();
    if (epiWeek == null || !ConfigProvider.hasUserRight(UserRight.WEEKLYREPORT_CREATE)) {
        setVisibilityForNoData();
    } else {
        WeeklyReport weeklyReport = DatabaseHelper.getWeeklyReportDao().queryByEpiWeekAndUser(epiWeek, user);
        if (EpiWeekFilterOption.THIS_WEEK.equals(filterOption)) {
            // table is shown if the report for the last week has been confirmed; no buttons
            reportDate = getResources().getString(R.string.hint_report_not_submitted);
            setVisibilityForTable(false);
            showPendingReport();
        } else if (EpiWeekFilterOption.LAST_WEEK.equals(filterOption)) {
            // table is shown, buttons are shown if the report has not been confirmed yet
            if (weeklyReport == null) {
                setVisibilityForTable(true);
                reportDate = getResources().getString(R.string.hint_report_not_submitted);
                showPendingReport();
            } else {
                setVisibilityForTable(false);
                reportDate = DateFormatHelper.formatLocalDate(weeklyReport.getReportDateTime());
                showWeeklyReport(weeklyReport);
            }
        } else {
            // any other week;
            if (weeklyReport == null) {
                if (DateHelper.isEpiWeekAfter(DateHelper.getEpiWeek(new Date()), epiWeek)) {
                    // 'no data' hint is shown for dates in the future
                    setVisibilityForNoData();
                    reportDate = "";
                    showNoReport();
                } else {
                    // table is shown for dates in the past
                    setVisibilityForTable(true);
                    reportDate = getResources().getString(R.string.hint_report_not_submitted);
                    showPendingReport();
                }
            } else {
                setVisibilityForTable(false);
                reportDate = DateFormatHelper.formatLocalDate(weeklyReport.getReportDateTime());
                showWeeklyReport(weeklyReport);
            }
        }
    }
}
Also used : User(de.symeda.sormas.app.backend.user.User) WeeklyReport(de.symeda.sormas.app.backend.report.WeeklyReport) Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 12 with EpiWeek

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

the class ReportFragment method updateByEpiWeek.

private void updateByEpiWeek() {
    EpiWeek epiWeek = getEpiWeek();
    // TODO this is only necessary because the field value changes are triggered multiple times
    if (DataHelper.equal(epiWeek, lastUpdateEpiWeek)) {
        return;
    }
    lastUpdateEpiWeek = epiWeek;
    EpiWeekFilterOption filterOption;
    if (epiWeek == null) {
        filterOption = EpiWeekFilterOption.SPECIFY_WEEK;
    } else if (epiWeek.equals(DateHelper.getPreviousEpiWeek(new Date()))) {
        filterOption = EpiWeekFilterOption.LAST_WEEK;
    } else if (epiWeek.equals(DateHelper.getEpiWeek(new Date()))) {
        filterOption = EpiWeekFilterOption.THIS_WEEK;
    } else {
        filterOption = EpiWeekFilterOption.SPECIFY_WEEK;
    }
    if (!DataHelper.equal(contentBinding.reportSelector.getValue(), filterOption)) {
        contentBinding.reportSelector.setValue(filterOption);
    }
    showReportData();
    getSubHeadingHandler().updateSubHeadingTitle(getSubHeadingTitle());
}
Also used : Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 13 with EpiWeek

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

the class AggregateReportsFragment method updateByEpiWeek.

private void updateByEpiWeek() {
    EpiWeek epiWeek = (EpiWeek) contentBinding.aggregateReportsWeek.getValue();
    if (DataHelper.equal(epiWeek, lastUpdateEpiWeek)) {
        return;
    }
    lastUpdateEpiWeek = epiWeek;
    EpiWeekFilterOption filterOption;
    if (epiWeek == null) {
        filterOption = EpiWeekFilterOption.SPECIFY_WEEK;
    } else if (epiWeek.equals(DateHelper.getPreviousEpiWeek(new Date()))) {
        filterOption = EpiWeekFilterOption.LAST_WEEK;
    } else if (epiWeek.equals(DateHelper.getEpiWeek(new Date()))) {
        filterOption = EpiWeekFilterOption.THIS_WEEK;
    } else {
        filterOption = EpiWeekFilterOption.SPECIFY_WEEK;
    }
    if (!DataHelper.equal(contentBinding.reportSelector.getValue(), filterOption)) {
        contentBinding.reportSelector.setValue(filterOption);
    }
    if (epiWeek != null) {
        showReportData();
    }
}
Also used : EpiWeekFilterOption(de.symeda.sormas.app.report.EpiWeekFilterOption) Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 14 with EpiWeek

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

the class AggregateReportsFragment method showReportData.

private void showReportData() {
    User user = ConfigProvider.getUser();
    EpiWeek epiWeek = (EpiWeek) contentBinding.aggregateReportsWeek.getValue();
    reports = DatabaseHelper.getAggregateReportDao().getReportsByEpiWeekAndUser(epiWeek, user);
    contentBinding.reportContent.removeAllViews();
    Date latestLocalChangeDate = null;
    for (AggregateReport report : reports) {
        LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        RowReportAggregateLayoutBinding binding = DataBindingUtil.inflate(inflater, R.layout.row_report_aggregate_layout, contentBinding.reportContent, true);
        binding.setData(report);
        if (latestLocalChangeDate == null || (report.getLocalChangeDate() != null && latestLocalChangeDate.before(report.getLocalChangeDate()))) {
            latestLocalChangeDate = report.getLocalChangeDate();
        }
    }
    Resources r = getResources();
    if (latestLocalChangeDate == null) {
        getSubHeadingHandler().updateSubHeadingTitle(r.getString(R.string.hint_case_numbers_not_submitted));
    } else {
        getSubHeadingHandler().updateSubHeadingTitle(String.format(r.getString(R.string.caption_latest_submission), DateFormatHelper.formatLocalDateTime(latestLocalChangeDate)));
    }
}
Also used : User(de.symeda.sormas.app.backend.user.User) LayoutInflater(android.view.LayoutInflater) AggregateReport(de.symeda.sormas.app.backend.report.AggregateReport) RowReportAggregateLayoutBinding(de.symeda.sormas.app.databinding.RowReportAggregateLayoutBinding) Resources(android.content.res.Resources) Date(java.util.Date) EpiWeek(de.symeda.sormas.api.utils.EpiWeek)

Example 15 with EpiWeek

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

the class EventSelectionField method forSuperordinateEvent.

public static EventSelectionField forSuperordinateEvent(EventDto eventDto, Set<String> excludedUuids) {
    EventSelectionField eventSelectionField = new EventSelectionField(eventDto.getDisease(), I18nProperties.getString(Strings.infoPickOrCreateSuperordinateEventForEvent), eventCriteria -> {
        eventCriteria.setExcludedUuids(excludedUuids);
        eventCriteria.eventDateBetween(null, EventHelper.getStartOrEndDate(eventDto.getStartDate(), eventDto.getEndDate()), null, DateFilterOption.DATE);
    });
    eventSelectionField.weekAndDateFilter.getDateToFilter().addValueChangeListener(valueChangeEvent -> {
        Date selectedToDate = eventSelectionField.weekAndDateFilter.getDateToFilter().getValue();
        prepareSuperordinateFilters(eventDto, eventSelectionField, selectedToDate, eventSelectionField.weekAndDateFilter.getDateToFilter());
    });
    eventSelectionField.weekAndDateFilter.getWeekToFilter().addValueChangeListener(valueChangeEvent -> {
        EpiWeek epiWeek = (EpiWeek) eventSelectionField.weekAndDateFilter.getWeekToFilter().getValue();
        Date epiWeekEndDate = DateHelper.getEpiWeekEnd(epiWeek);
        prepareSuperordinateFilters(eventDto, eventSelectionField, epiWeekEndDate, eventSelectionField.weekAndDateFilter.getWeekToFilter());
    });
    return eventSelectionField;
}
Also used : Date(java.util.Date) 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