Search in sources :

Example 1 with RegionReferenceDto

use of de.symeda.sormas.api.infrastructure.region.RegionReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class EventGroupMemberList method drawDisplayedEntries.

@Override
protected void drawDisplayedEntries() {
    List<EventIndexDto> displayedEntries = getDisplayedEntries();
    for (int i = 0, displayedEntriesSize = displayedEntries.size(); i < displayedEntriesSize; i++) {
        EventIndexDto event = displayedEntries.get(i);
        EventGroupMemberListEntry listEntry = new EventGroupMemberListEntry(event);
        UserProvider user = UserProvider.getCurrent();
        if (user.hasUserRight(UserRight.EVENTGROUP_LINK)) {
            listEntry.addUnlinkEventListener(i, (ClickListener) clickEvent -> {
                if (!user.hasNationalJurisdictionLevel() && !user.hasRegion(new RegionReferenceDto(event.getRegionUuid()))) {
                    new Notification(I18nProperties.getString(Strings.headingEventGroupUnlinkEventIssue), I18nProperties.getString(Strings.errorEventFromAnotherJurisdiction), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
                    return;
                }
                ControllerProvider.getEventGroupController().unlinkEventGroup(event.toReference(), eventGroupReference);
                reload();
            });
        }
        if (user.hasUserRight(UserRight.EVENTGROUP_EDIT)) {
            listEntry.addEditListener(i, (ClickListener) clickEvent -> ControllerProvider.getEventController().navigateToData(listEntry.getEvent().getUuid()));
        }
        listLayout.addComponent(listEntry);
    }
}
Also used : EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) PaginationList(de.symeda.sormas.ui.utils.PaginationList) ClickListener(com.vaadin.ui.Button.ClickListener) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) EventGroupReferenceDto(de.symeda.sormas.api.event.EventGroupReferenceDto) Captions(de.symeda.sormas.api.i18n.Captions) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) List(java.util.List) EventCriteria(de.symeda.sormas.api.event.EventCriteria) Notification(com.vaadin.ui.Notification) Page(com.vaadin.server.Page) Label(com.vaadin.ui.Label) Strings(de.symeda.sormas.api.i18n.Strings) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) UserProvider(de.symeda.sormas.ui.UserProvider) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) UserProvider(de.symeda.sormas.ui.UserProvider) EventIndexDto(de.symeda.sormas.api.event.EventIndexDto) Notification(com.vaadin.ui.Notification)

Example 2 with RegionReferenceDto

use of de.symeda.sormas.api.infrastructure.region.RegionReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class EventsFilterForm method applyDependenciesOnNewValue.

@Override
protected void applyDependenciesOnNewValue(EventCriteria criteria) {
    applyDateDependencyOnNewValue(EVENT_WEEK_AND_DATE_FILTER, criteria.getDateFilterOption(), criteria.getEventDateFrom(), criteria.getEventDateTo());
    applyDateDependencyOnNewValue(EVENT_SIGNAL_EVOLUTION_WEEK_AND_DATE_FILTER, criteria.getEvolutionDateFilterOption(), criteria.getEventEvolutionDateFrom(), criteria.getEventEvolutionDateTo());
    applyDateDependencyOnNewValue(ACTION_CHANGE_WEEK_AND_DATE_FILTER, criteria.getActionChangeDateFilterOption(), criteria.getActionChangeDateFrom(), criteria.getActionChangeDateTo());
    applyDateDependencyOnNewValue(ACTION_WEEK_AND_DATE_FILTER, criteria.getActionDateFilterOption(), criteria.getActionDateFrom(), criteria.getActionDateTo());
    RegionReferenceDto region = criteria.getRegion();
    DistrictReferenceDto district = criteria.getDistrict();
    applyRegionAndDistrictFilterDependency(region, LocationDto.DISTRICT, district, LocationDto.COMMUNITY);
    applyFacilityFieldsDependencies(criteria.getTypeOfPlace(), criteria.getDistrict(), criteria.getCommunity());
    updateResponsibleUserFieldItems(criteria.getDistrict(), criteria.getRegion());
    ComboBox diseaseField = getField(CaseDataDto.DISEASE);
    Disease disease = (Disease) diseaseField.getValue();
    applyDiseaseFilterDependency(disease);
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) Disease(de.symeda.sormas.api.Disease) ComboBox(com.vaadin.v7.ui.ComboBox) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Example 3 with RegionReferenceDto

use of de.symeda.sormas.api.infrastructure.region.RegionReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationFilterForm method applyDependenciesOnFieldChange.

@Override
protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueChangeEvent event) {
    super.applyDependenciesOnFieldChange(propertyId, event);
    final ImmunizationCriteria criteria = getValue();
    final ComboBox districtField = getField(ImmunizationCriteria.DISTRICT);
    final ComboBox communityField = getField(ImmunizationCriteria.COMMUNITY);
    final ComboBox facilityTypeGroupField = getField(ImmunizationCriteria.FACILITY_TYPE_GROUP);
    final ComboBox facilityTypeField = getField(ImmunizationCriteria.FACILITY_TYPE);
    final ComboBox facilityField = getField(ImmunizationCriteria.HEALTH_FACILITY);
    final UserDto user = currentUserDto();
    final DistrictReferenceDto currentDistrict = user.getDistrict() != null ? user.getDistrict() : (DistrictReferenceDto) districtField.getValue();
    switch(propertyId) {
        case ImmunizationCriteria.REGION:
            {
                final RegionReferenceDto region = user.getRegion() != null ? user.getRegion() : (RegionReferenceDto) event.getProperty().getValue();
                if (!DataHelper.equal(region, criteria.getRegion())) {
                    if (region != null) {
                        enableFields(districtField);
                        FieldHelper.updateItems(districtField, FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
                    } else {
                        clearAndDisableFields(districtField);
                    }
                    clearAndDisableFields(communityField, facilityField, facilityTypeField, facilityTypeGroupField);
                }
                break;
            }
        case ImmunizationCriteria.DISTRICT:
            {
                final DistrictReferenceDto newDistrict = (DistrictReferenceDto) event.getProperty().getValue();
                if (!DataHelper.equal(newDistrict, criteria.getDistrict())) {
                    if (newDistrict != null) {
                        enableFields(communityField, facilityTypeGroupField);
                        clearAndDisableFields(facilityField);
                        if (facilityTypeGroupField != null) {
                            if (facilityTypeGroupField.getValue() != null && facilityTypeField.getValue() != null) {
                                FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(newDistrict, (FacilityType) facilityTypeField.getValue(), true, false));
                                enableFields(facilityField);
                            } else {
                                FieldHelper.updateEnumData(facilityTypeGroupField, FacilityTypeGroup.getAccomodationGroups());
                            }
                        }
                        FieldHelper.updateItems(communityField, FacadeProvider.getCommunityFacade().getAllActiveByDistrict(newDistrict.getUuid()));
                    } else {
                        clearAndDisableFields(communityField, facilityField, facilityTypeField, facilityTypeGroupField);
                    }
                }
                break;
            }
        case ImmunizationCriteria.COMMUNITY:
            {
                CommunityReferenceDto community = (CommunityReferenceDto) event.getProperty().getValue();
                if (!DataHelper.equal(community, criteria.getCommunity())) {
                    if (facilityField != null) {
                        facilityField.setValue(null);
                    }
                    final FacilityType facilityType = facilityTypeField != null ? (FacilityType) facilityTypeField.getValue() : null;
                    if (facilityType == null && facilityField != null) {
                        facilityField.removeAllItems();
                    } else if (facilityField != null) {
                        if (community == null) {
                            FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(currentDistrict, facilityType, true, false));
                        } else {
                            FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(community, facilityType, true, false));
                        }
                    }
                }
                break;
            }
        case ImmunizationCriteria.FACILITY_TYPE_GROUP:
            {
                FacilityTypeGroup typeGroup = (FacilityTypeGroup) event.getProperty().getValue();
                if (!DataHelper.equal(typeGroup, criteria.getFacilityTypeGroup())) {
                    if (typeGroup != null) {
                        enableFields(ImmunizationCriteria.FACILITY_TYPE);
                        FieldHelper.updateEnumData(facilityTypeField, FacilityType.getAccommodationTypes(typeGroup));
                        facilityField.setValue(null);
                    } else {
                        clearAndDisableFields(facilityTypeField, facilityField);
                    }
                }
                break;
            }
        case ImmunizationCriteria.FACILITY_TYPE:
            {
                FacilityType facilityType = (FacilityType) event.getProperty().getValue();
                if (!DataHelper.equal(facilityType, criteria.getFacilityType())) {
                    if (facilityType == null) {
                        clearAndDisableFields(facilityField);
                    } else {
                        enableFields(facilityField);
                        facilityField.setValue(null);
                        CommunityReferenceDto community = (CommunityReferenceDto) communityField.getValue();
                        if (community != null) {
                            FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(community, facilityType, true, false));
                        } else if (currentDistrict != null) {
                            FieldHelper.updateItems(facilityField, FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(currentDistrict, facilityType, true, false));
                        }
                    }
                }
                break;
            }
        case ImmunizationCriteria.BIRTHDATE_MM:
            {
                Integer birthMM = (Integer) event.getProperty().getValue();
                ComboBox birthDayDD = getField(ImmunizationCriteria.BIRTHDATE_DD);
                birthDayDD.setEnabled(birthMM != null);
                FieldHelper.updateItems(birthDayDD, DateHelper.getDaysInMonth((Integer) getField(ImmunizationCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ImmunizationCriteria.BIRTHDATE_YYYY).getValue()));
                break;
            }
    }
}
Also used : CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) ImmunizationCriteria(de.symeda.sormas.api.immunization.ImmunizationCriteria) ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType)

Example 4 with RegionReferenceDto

use of de.symeda.sormas.api.infrastructure.region.RegionReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationFilterForm method applyDependenciesOnNewValue.

@Override
protected void applyDependenciesOnNewValue(ImmunizationCriteria criteria) {
    final UserDto user = currentUserDto();
    UserProvider currentUserProvider = UserProvider.getCurrent();
    final JurisdictionLevel userJurisdictionLevel = currentUserProvider != null ? UserRole.getJurisdictionLevel(currentUserProvider.getUserRoles()) : null;
    final ComboBox districtField = getField(ImmunizationCriteria.DISTRICT);
    final ComboBox communityField = getField(ImmunizationCriteria.COMMUNITY);
    final ComboBox facilityTypeGroupField = getField(ImmunizationCriteria.FACILITY_TYPE_GROUP);
    final ComboBox facilityTypeField = getField(ImmunizationCriteria.FACILITY_TYPE);
    final ComboBox facilityField = getField(ImmunizationCriteria.HEALTH_FACILITY);
    // Disable all fields
    clearAndDisableFields(districtField, communityField, facilityTypeGroupField, facilityTypeField, facilityField);
    // Get initial field values according to user and criteria
    final RegionReferenceDto region = user.getRegion() == null ? criteria.getRegion() : user.getRegion();
    final DistrictReferenceDto district = user.getDistrict() == null ? criteria.getDistrict() : user.getDistrict();
    final CommunityReferenceDto community = user.getCommunity() == null ? criteria.getCommunity() : user.getCommunity();
    final FacilityTypeGroup facilityTypeGroup = criteria.getFacilityTypeGroup();
    final FacilityType facilityType = criteria.getFacilityType();
    // district
    if (region != null) {
        enableFields(districtField);
        districtField.addItems(FacadeProvider.getDistrictFacade().getAllActiveByRegion(region.getUuid()));
        // community
        if (district != null) {
            districtField.setValue(district);
            communityField.addItems(FacadeProvider.getCommunityFacade().getAllActiveByDistrict(district.getUuid()));
            enableFields(communityField);
            if (community != null) {
                communityField.setValue(community);
            }
        } else {
            clearAndDisableFields(communityField);
        }
    } else {
        clearAndDisableFields(districtField, communityField);
    }
    // facility
    if (userJurisdictionLevel == JurisdictionLevel.HEALTH_FACILITY) {
        facilityField.setValue(user.getHealthFacility());
        disableFields(facilityTypeGroupField, facilityTypeField, facilityField);
    } else if (facilityTypeGroupField != null && district != null) {
        enableFields(facilityTypeGroupField);
        FieldHelper.updateEnumData(facilityTypeGroupField, FacilityTypeGroup.getAccomodationGroups());
        if (facilityTypeGroup != null) {
            facilityTypeGroupField.setValue(facilityTypeGroup);
            enableFields(facilityTypeField);
            FieldHelper.updateEnumData(facilityTypeField, FacilityType.getAccommodationTypes(facilityTypeGroup));
            if (facilityType != null) {
                facilityTypeField.setValue(facilityType);
                enableFields(facilityField);
                if (community != null) {
                    facilityField.addItems(FacadeProvider.getFacilityFacade().getActiveFacilitiesByCommunityAndType(community, facilityType, true, false));
                } else {
                    facilityField.addItems(FacadeProvider.getFacilityFacade().getActiveFacilitiesByDistrictAndType(district, facilityType, true, false));
                }
            } else {
                disableFields(facilityField);
            }
        } else {
            disableFields(facilityTypeField);
        }
    }
    // Disable fields according to user & jurisdiction
    if (userJurisdictionLevel == JurisdictionLevel.DISTRICT) {
        clearAndDisableFields(districtField);
    } else if (userJurisdictionLevel == JurisdictionLevel.COMMUNITY) {
        clearAndDisableFields(districtField, communityField);
    } else if (userJurisdictionLevel == JurisdictionLevel.HEALTH_FACILITY) {
        clearAndDisableFields(districtField, communityField, facilityTypeGroupField, facilityTypeField, facilityField);
    }
    ComboBox birthDateDD = getField(ImmunizationCriteria.BIRTHDATE_DD);
    if (getField(ImmunizationCriteria.BIRTHDATE_YYYY).getValue() != null && getField(ImmunizationCriteria.BIRTHDATE_MM).getValue() != null) {
        birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(ImmunizationCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ImmunizationCriteria.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<ImmunizationDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<ImmunizationDateType>) dateFilterLayout.getComponent(0);
    ImmunizationDateType immunizationDateType = criteria.getImmunizationDateType();
    weekAndDateFilter.getDateTypeSelector().setValue(immunizationDateType);
    weekAndDateFilter.getDateFilterOptionFilter().setValue(criteria.getDateFilterOption());
    Date dateFrom = criteria.getFromDate();
    Date dateTo = criteria.getToDate();
    if (DateFilterOption.EPI_WEEK.equals(criteria.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 : ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) JurisdictionLevel(de.symeda.sormas.api.user.JurisdictionLevel) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Date(java.util.Date) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EpiWeekAndDateFilterComponent(de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) UserProvider(de.symeda.sormas.ui.UserProvider) FacilityTypeGroup(de.symeda.sormas.api.infrastructure.facility.FacilityTypeGroup) ImmunizationDateType(de.symeda.sormas.api.immunization.ImmunizationDateType) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType)

Example 5 with RegionReferenceDto

use of de.symeda.sormas.api.infrastructure.region.RegionReferenceDto in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testSetResponsibleSurveillanceOfficer.

@Test
public void testSetResponsibleSurveillanceOfficer() {
    RDCF rdcf = creator.createRDCF();
    RDCF rdcf2 = creator.createRDCF("Region2", "District2", "Community2", "Facility2");
    RDCF rdcf3 = creator.createRDCF("Region3", "District3", "Community3", "Facility3");
    creator.createUser(rdcf, "First", "User", UserRole.SURVEILLANCE_OFFICER).toReference();
    UserReferenceDto survOff2 = creator.createUser(rdcf, "Second", "User", UserRole.SURVEILLANCE_OFFICER).toReference();
    UserReferenceDto survOff3 = creator.createUser(rdcf2, "Third", "User", UserRole.SURVEILLANCE_OFFICER).toReference();
    UserDto informant = creator.createUser(rdcf, UserRole.HOSPITAL_INFORMANT);
    informant.setAssociatedOfficer(survOff3);
    getUserFacade().saveUser(informant);
    // Reporting user is set as surveillance officer
    CaseDataDto caze = creator.createCase(survOff2, creator.createPerson().toReference(), rdcf);
    assertThat(caze.getSurveillanceOfficer(), is(survOff2));
    // Surveillance officer is removed if the responsible district changes
    caze.setResponsibleRegion(new RegionReferenceDto(rdcf3.region.getUuid(), null, null));
    caze.setResponsibleDistrict(new DistrictReferenceDto(rdcf3.district.getUuid(), null, null));
    caze.setResponsibleCommunity(new CommunityReferenceDto(rdcf3.community.getUuid(), null, null));
    caze.setHealthFacility(new FacilityReferenceDto(rdcf3.facility.getUuid(), null, null));
    caze = getCaseFacade().save(caze);
    assertNull(caze.getSurveillanceOfficer());
    // Surveillance officer is set to the associated officer of an informant if available
    caze.setRegion(new RegionReferenceDto(rdcf2.region.getUuid(), null, null));
    caze.setDistrict(new DistrictReferenceDto(rdcf2.district.getUuid(), null, null));
    caze.setCommunity(new CommunityReferenceDto(rdcf2.community.getUuid(), null, null));
    caze.setHealthFacility(new FacilityReferenceDto(rdcf2.facility.getUuid(), null, null));
    caze = getCaseFacade().save(caze);
    assertThat(caze.getSurveillanceOfficer(), is(survOff3));
}
Also used : UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) UserDto(de.symeda.sormas.api.user.UserDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Aggregations

RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)112 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)77 UserDto (de.symeda.sormas.api.user.UserDto)37 ComboBox (com.vaadin.v7.ui.ComboBox)34 CommunityReferenceDto (de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto)27 Label (com.vaadin.ui.Label)26 Date (java.util.Date)25 Disease (de.symeda.sormas.api.Disease)24 HorizontalLayout (com.vaadin.ui.HorizontalLayout)21 Button (com.vaadin.ui.Button)20 Test (org.junit.Test)20 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)19 ArrayList (java.util.ArrayList)18 TextField (com.vaadin.v7.ui.TextField)17 FacadeProvider (de.symeda.sormas.api.FacadeProvider)17 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)17 Strings (de.symeda.sormas.api.i18n.Strings)17 FacilityReferenceDto (de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto)17 UserProvider (de.symeda.sormas.ui.UserProvider)17 List (java.util.List)17