Search in sources :

Example 1 with NewCaseDateType

use of de.symeda.sormas.api.caze.NewCaseDateType in project SORMAS-Project by hzi-braunschweig.

the class CaseFilterForm method streamFieldsForEmptyCheck.

@SuppressWarnings("rawtypes")
@Override
protected Stream<Field> streamFieldsForEmptyCheck(CustomLayout layout) {
    HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
    @SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
    return super.streamFieldsForEmptyCheck(layout).filter(f -> f != weekAndDateFilter.getDateFilterOptionFilter());
}
Also used : NewCaseDateType(de.symeda.sormas.api.caze.NewCaseDateType) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EpiWeekAndDateFilterComponent(de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent)

Example 2 with NewCaseDateType

use of de.symeda.sormas.api.caze.NewCaseDateType 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)

Example 3 with NewCaseDateType

use of de.symeda.sormas.api.caze.NewCaseDateType in project SORMAS-Project by hzi-braunschweig.

the class ContactsFilterForm method applyDependenciesOnNewValue.

@Override
protected void applyDependenciesOnNewValue(ContactCriteria newValue) {
    final RegionReferenceDto region = newValue.getRegion();
    final DistrictReferenceDto district = newValue.getDistrict();
    applyRegionAndDistrictFilterDependency(region, ContactCriteria.DISTRICT, district, ContactCriteria.COMMUNITY);
    final UserDto user = currentUserDto();
    ComboBox officerField = getField(ContactCriteria.CONTACT_OFFICER);
    if (user.getRegion() != null) {
        officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(user.getRegion(), UserRole.CONTACT_OFFICER));
    } else if (region != null) {
        officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(region, UserRole.CONTACT_OFFICER));
    } else {
        officerField.removeAllItems();
    }
    ComboBox birthDateDD = getField(ContactCriteria.BIRTHDATE_DD);
    if (getField(ContactCriteria.BIRTHDATE_YYYY).getValue() != null && getField(ContactCriteria.BIRTHDATE_MM).getValue() != null) {
        birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(ContactCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ContactCriteria.BIRTHDATE_YYYY).getValue()));
        birthDateDD.setEnabled(true);
    } else {
        birthDateDD.clear();
        birthDateDD.setEnabled(false);
    }
    // Date/Epi week filter
    HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
    @SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
    ContactDateType contactDateType = newValue.getReportDateFrom() != null ? ContactDateType.REPORT_DATE : newValue.getLastContactDateFrom() != null ? ContactDateType.LAST_CONTACT_DATE : null;
    weekAndDateFilter.getDateTypeSelector().setValue(contactDateType);
    weekAndDateFilter.getDateFilterOptionFilter().setValue(newValue.getDateFilterOption());
    Date dateFrom = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateFrom() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateFrom() : null;
    Date dateTo = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateTo() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateTo() : null;
    if (DateFilterOption.EPI_WEEK.equals(newValue.getDateFilterOption())) {
        weekAndDateFilter.getWeekFromFilter().setValue(dateFrom == null ? null : DateHelper.getEpiWeek(dateFrom));
        weekAndDateFilter.getWeekToFilter().setValue(dateTo == null ? null : DateHelper.getEpiWeek(dateTo));
    } else {
        weekAndDateFilter.getDateFromFilter().setValue(dateFrom);
        weekAndDateFilter.getDateToFilter().setValue(dateTo);
    }
    if (StringUtils.isBlank(newValue.getEventLike())) {
        clearAndDisableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
    } else {
        enableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
    }
    ComboBox diseaseField = getField(ContactIndexDto.DISEASE);
    ComboBox diseaseVariantField = getField(ContactCriteria.DISEASE_VARIANT);
    Disease disease = (Disease) diseaseField.getValue();
    if (disease == null) {
        FieldHelper.updateItems(diseaseVariantField, Collections.emptyList());
        FieldHelper.setEnabled(false, diseaseVariantField);
    } else {
        List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
        FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
        FieldHelper.setEnabled(CollectionUtils.isNotEmpty(diseaseVariants), diseaseVariantField);
    }
}
Also used : ContactDateType(de.symeda.sormas.api.contact.ContactDateType) NewCaseDateType(de.symeda.sormas.api.caze.NewCaseDateType) Disease(de.symeda.sormas.api.Disease) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Date(java.util.Date) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EpiWeekAndDateFilterComponent(de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)

Example 4 with NewCaseDateType

use of de.symeda.sormas.api.caze.NewCaseDateType in project SORMAS-Project by hzi-braunschweig.

the class ContactsFilterForm method streamFieldsForEmptyCheck.

@Override
@SuppressWarnings("rawtypes")
protected Stream<Field> streamFieldsForEmptyCheck(CustomLayout layout) {
    HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
    @SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
    return super.streamFieldsForEmptyCheck(layout).filter(f -> f != weekAndDateFilter.getDateFilterOptionFilter());
}
Also used : NewCaseDateType(de.symeda.sormas.api.caze.NewCaseDateType) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EpiWeekAndDateFilterComponent(de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent)

Example 5 with NewCaseDateType

use of de.symeda.sormas.api.caze.NewCaseDateType in project SORMAS-Project by hzi-braunschweig.

the class TaskGridFilterForm method applyDependenciesOnNewValue.

@Override
protected void applyDependenciesOnNewValue(TaskCriteria newValue) {
    // Date/Epi week filter
    HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
    @SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
    TaskDateType taskDateType = newValue.getStartDateFrom() != null ? TaskDateType.SUGGESTED_START_DATE : newValue.getDueDateFrom() != null ? TaskDateType.DUE_DATE : null;
    weekAndDateFilter.getDateTypeSelector().setValue(taskDateType);
    weekAndDateFilter.getDateFilterOptionFilter().setValue(newValue.getDateFilterOption());
    Date dateFrom = taskDateType == TaskDateType.SUGGESTED_START_DATE ? newValue.getStartDateFrom() : taskDateType == TaskDateType.DUE_DATE ? newValue.getDueDateFrom() : null;
    Date dateTo = taskDateType == TaskDateType.SUGGESTED_START_DATE ? newValue.getStartDateTo() : taskDateType == TaskDateType.DUE_DATE ? newValue.getDueDateTo() : null;
    if (DateFilterOption.EPI_WEEK.equals(newValue.getDateFilterOption())) {
        weekAndDateFilter.getWeekFromFilter().setValue(dateFrom == null ? null : DateHelper.getEpiWeek(dateFrom));
        weekAndDateFilter.getWeekToFilter().setValue(dateTo == null ? null : DateHelper.getEpiWeek(dateTo));
    } else {
        weekAndDateFilter.getDateFromFilter().setValue(dateFrom);
        weekAndDateFilter.getDateToFilter().setValue(dateTo);
    }
}
Also used : NewCaseDateType(de.symeda.sormas.api.caze.NewCaseDateType) TaskDateType(de.symeda.sormas.api.task.TaskDateType) Date(java.util.Date) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EpiWeekAndDateFilterComponent(de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent)

Aggregations

HorizontalLayout (com.vaadin.ui.HorizontalLayout)7 NewCaseDateType (de.symeda.sormas.api.caze.NewCaseDateType)7 EpiWeekAndDateFilterComponent (de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent)7 Date (java.util.Date)4 ComboBox (com.vaadin.v7.ui.ComboBox)2 Disease (de.symeda.sormas.api.Disease)2 DiseaseVariant (de.symeda.sormas.api.disease.DiseaseVariant)2 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)2 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)2 UserDto (de.symeda.sormas.api.user.UserDto)2 Button (com.vaadin.ui.Button)1 Notification (com.vaadin.ui.Notification)1 ContactDateType (de.symeda.sormas.api.contact.ContactDateType)1 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)1 FacilityType (de.symeda.sormas.api.infrastructure.facility.FacilityType)1 FacilityTypeGroup (de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup)1 TaskDateType (de.symeda.sormas.api.task.TaskDateType)1 JurisdictionLevel (de.symeda.sormas.api.user.JurisdictionLevel)1 DateFilterOption (de.symeda.sormas.api.utils.DateFilterOption)1 EpiWeek (de.symeda.sormas.api.utils.EpiWeek)1