Search in sources :

Example 96 with Disease

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

the class ContactController method getContactCreateComponent.

public CommitDiscardWrapperComponent<ContactCreateForm> getContactCreateComponent(EventParticipantDto eventParticipant) {
    final ContactCreateForm createForm;
    final Disease disease;
    if (eventParticipant.getResultingCase() != null) {
        disease = FacadeProvider.getCaseFacade().getCaseDataByUuid(eventParticipant.getResultingCase().getUuid()).getDisease();
    } else {
        disease = FacadeProvider.getEventFacade().getEventByUuid(eventParticipant.getEvent().getUuid(), false).getDisease();
    }
    createForm = new ContactCreateForm(disease, false, false);
    createForm.setValue(createNewContact(eventParticipant, disease));
    createForm.setPerson(eventParticipant.getPerson());
    createForm.setPersonDetailsReadOnly();
    createForm.setDiseaseReadOnly();
    final CommitDiscardWrapperComponent<ContactCreateForm> createComponent = new CommitDiscardWrapperComponent<>(createForm, UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_CREATE), createForm.getFieldGroup());
    createComponent.addCommitListener(() -> {
        if (!createForm.getFieldGroup().isModified()) {
            final ContactDto dto = createForm.getValue();
            PersonDto personDto = FacadeProvider.getPersonFacade().getPersonByUuid(dto.getPerson().getUuid());
            fillPersonAddressIfEmpty(dto, () -> personDto);
            selectOrCreateContact(dto, personDto, selectedContactUuid -> {
                if (selectedContactUuid != null) {
                    editData(selectedContactUuid);
                }
            });
        }
    });
    return createComponent;
}
Also used : Disease(de.symeda.sormas.api.Disease) PersonDto(de.symeda.sormas.api.person.PersonDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)

Example 97 with Disease

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

the class LineListingConfigurationView method buildView.

private void buildView(Disease enteredDisease) {
    if (region != null && (UserProvider.getCurrent().hasNationalJurisdictionLevel() || UserProvider.getCurrent().hasNoneJurisdictionLevel())) {
        Button btnBackToNationView = ButtonHelper.createIconButton(Captions.actionBackToNationOverview, VaadinIcons.ARROW_BACKWARD, e -> {
            SormasUI.get().getNavigator().navigateTo(LineListingConfigurationView.VIEW_NAME);
        }, ValoTheme.BUTTON_PRIMARY);
        addHeaderComponent(btnBackToNationView);
    }
    if (region != null) {
        getViewSubTitleLabel().setValue(region.toString());
    }
    Label infoTextLabel;
    if (region != null) {
        infoTextLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + I18nProperties.getString(Strings.infoLineListingConfigurationRegion), ContentMode.HTML);
    } else {
        infoTextLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml() + " " + I18nProperties.getString(Strings.infoLineListingConfigurationNation), ContentMode.HTML);
    }
    CssStyles.style(infoTextLabel, CssStyles.LABEL_MEDIUM);
    contentLayout.addComponent(infoTextLabel);
    lineListingConfigurationsLayout = new VerticalLayout();
    lineListingConfigurationsLayout.setWidth(100, Unit.PERCENTAGE);
    lineListingConfigurationsLayout.setSpacing(true);
    lineListingConfigurationsLayout.setMargin(false);
    CssStyles.style(lineListingConfigurationsLayout, CssStyles.VSPACE_TOP_3, CssStyles.VSPACE_3);
    contentLayout.addComponent(lineListingConfigurationsLayout);
    // Retrieve existing line listing configurations from the database
    List<Disease> diseasesWithoutConfigurations = FacadeProvider.getDiseaseConfigurationFacade().getAllDiseases(true, true, true);
    List<FeatureConfigurationIndexDto> lineListingConfigurations = FacadeProvider.getFeatureConfigurationFacade().getFeatureConfigurations(new FeatureConfigurationCriteria().featureType(FeatureType.LINE_LISTING).region(region), false);
    for (FeatureConfigurationIndexDto configuration : lineListingConfigurations) {
        if (!configurationMap.containsKey(configuration.getDisease())) {
            configurationMap.put(configuration.getDisease(), new ArrayList<>());
            diseasesWithoutConfigurations.remove(configuration.getDisease());
        }
        configurationMap.get(configuration.getDisease()).add(configuration);
    }
    configurationMap.keySet().stream().forEach(disease -> {
        lineListingConfigurationsLayout.addComponent(createDiseaseConfigurationLayout(disease, configurationMap.get(disease)));
    });
    if (enteredDisease != null && !configurationMap.containsKey(enteredDisease)) {
        lineListingConfigurationsLayout.addComponent(createDiseaseConfigurationLayout(enteredDisease, null));
    }
    addDiseaseLayout = new LineListingAddDiseaseLayout(diseasesWithoutConfigurations);
    addDiseaseLayout.setWidth(600, Unit.PIXELS);
    addDiseaseLayout.setAddDiseaseCallback(disease -> {
        HorizontalLayout diseaseConfigurationLayout = createDiseaseConfigurationLayout(disease, null);
        lineListingConfigurationsLayout.addComponent(diseaseConfigurationLayout);
        addDiseaseLayout.removeDiseaseFromList(disease);
        if (region != null) {
            openEditWindow(disease);
        }
    });
    contentLayout.addComponent(addDiseaseLayout);
}
Also used : Disease(de.symeda.sormas.api.Disease) Button(com.vaadin.ui.Button) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) FeatureConfigurationCriteria(de.symeda.sormas.api.feature.FeatureConfigurationCriteria) FeatureConfigurationIndexDto(de.symeda.sormas.api.feature.FeatureConfigurationIndexDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 98 with Disease

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

the class LineListingConfigurationView method enter.

@Override
public void enter(ViewChangeEvent event) {
    super.enter(event);
    Disease disease = null;
    String[] params = event.getParameters().split("\\?");
    if (params.length > 0) {
        String regionUuid = params[0].replaceAll("/", "");
        this.region = FacadeProvider.getRegionFacade().getReferenceByUuid(regionUuid);
        if (params.length > 1) {
            disease = Disease.valueOf(params[1].substring(params[1].indexOf("=") + 1));
        }
    } else if (!(UserProvider.getCurrent().hasNationalJurisdictionLevel() || UserProvider.getCurrent().hasNoneJurisdictionLevel())) {
        this.region = UserProvider.getCurrent().getUser().getRegion();
    }
    contentLayout = new VerticalLayout();
    contentLayout.setMargin(true);
    contentLayout.setSpacing(true);
    contentLayout.setWidth(100, Unit.PERCENTAGE);
    contentLayout.setStyleName("crud-main-layout");
    buildView(disease);
    addComponent(contentLayout);
}
Also used : Disease(de.symeda.sormas.api.Disease) VerticalLayout(com.vaadin.ui.VerticalLayout)

Example 99 with Disease

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

the class EventsFilterForm method applyDependenciesOnFieldChange.

@Override
protected void applyDependenciesOnFieldChange(String propertyId, Property.ValueChangeEvent event) {
    switch(propertyId) {
        case LocationDto.REGION:
            RegionReferenceDto region = (RegionReferenceDto) event.getProperty().getValue();
            if (region != null) {
                applyRegionFilterDependency(region, LocationDto.DISTRICT);
                clearAndDisableFields(LocationDto.COMMUNITY);
            } else {
                clearAndDisableFields(LocationDto.DISTRICT, LocationDto.COMMUNITY);
            }
            applyFacilityFieldsDependencies();
            updateResponsibleUserFieldItems();
            break;
        case LocationDto.DISTRICT:
            DistrictReferenceDto district = (DistrictReferenceDto) event.getProperty().getValue();
            if (district != null) {
                applyDistrictDependency(district, LocationDto.COMMUNITY);
            } else {
                clearAndDisableFields(LocationDto.COMMUNITY);
            }
            applyFacilityFieldsDependencies();
            updateResponsibleUserFieldItems();
            break;
        case EventDto.TYPE_OF_PLACE:
            applyFacilityFieldsDependencies();
            break;
        case CaseDataDto.DISEASE:
            Disease disease = (Disease) event.getProperty().getValue();
            applyDiseaseFilterDependency(disease);
    }
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) Disease(de.symeda.sormas.api.Disease) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Example 100 with Disease

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

the class StatisticsView method fillCaseCriteria.

private void fillCaseCriteria(boolean showCaseIncidence) {
    caseCriteria = new StatisticsCaseCriteria();
    for (StatisticsFilterComponent filterComponent : filterComponents) {
        StatisticsFilterElement filterElement = filterComponent.getFilterElement();
        switch(filterComponent.getSelectedAttribute()) {
            case SEX:
                if (filterElement.getSelectedValues() != null) {
                    List<Sex> sexes = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                        if (tokenizableValue.getValue().equals(I18nProperties.getString(Strings.notSpecified))) {
                            caseCriteria.sexUnknown(true);
                        } else {
                            sexes.add((Sex) tokenizableValue.getValue());
                        }
                    }
                    caseCriteria.sexes(sexes);
                }
                break;
            case DISEASE:
                if (filterElement.getSelectedValues() != null) {
                    List<Disease> diseases = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                        diseases.add((Disease) tokenizableValue.getValue());
                    }
                    caseCriteria.diseases(diseases);
                }
                break;
            case CLASSIFICATION:
                if (filterElement.getSelectedValues() != null) {
                    List<CaseClassification> classifications = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                        classifications.add((CaseClassification) tokenizableValue.getValue());
                    }
                    caseCriteria.classifications(classifications);
                }
                break;
            case OUTCOME:
                if (filterElement.getSelectedValues() != null) {
                    List<CaseOutcome> outcomes = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                        outcomes.add((CaseOutcome) tokenizableValue.getValue());
                    }
                    caseCriteria.outcomes(outcomes);
                }
                break;
            case AGE_INTERVAL_1_YEAR:
            case AGE_INTERVAL_5_YEARS:
            case AGE_INTERVAL_CHILDREN_COARSE:
            case AGE_INTERVAL_CHILDREN_FINE:
            case AGE_INTERVAL_CHILDREN_MEDIUM:
            case AGE_INTERVAL_BASIC:
                if (filterElement.getSelectedValues() != null) {
                    List<IntegerRange> ageIntervals = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                        ageIntervals.add((IntegerRange) tokenizableValue.getValue());
                    }
                    caseCriteria.addAgeIntervals(ageIntervals);
                    // Fill age groups if 5 years interval has been selected and case incidence is shown
                    if (showCaseIncidence && filterComponent.getSelectedAttribute() == StatisticsCaseAttribute.AGE_INTERVAL_5_YEARS) {
                        List<AgeGroup> ageGroups = new ArrayList<>();
                        for (IntegerRange ageInterval : ageIntervals) {
                            if (ageInterval.getFrom() != null || ageInterval.getTo() != null) {
                                ageGroups.add(AgeGroup.getAgeGroupFromIntegerRange(ageInterval));
                            }
                        }
                        caseCriteria.addAgeGroups(ageGroups);
                    }
                }
                break;
            case JURISDICTION:
                StatisticsFilterJurisdictionElement jurisdictionElement = (StatisticsFilterJurisdictionElement) filterElement;
                if (jurisdictionElement.getSelectedRegions() != null) {
                    List<RegionReferenceDto> regions = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : jurisdictionElement.getSelectedRegions()) {
                        regions.add((RegionReferenceDto) tokenizableValue.getValue());
                    }
                    caseCriteria.regions(regions);
                }
                if (jurisdictionElement.getSelectedDistricts() != null) {
                    List<DistrictReferenceDto> districts = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : jurisdictionElement.getSelectedDistricts()) {
                        districts.add((DistrictReferenceDto) tokenizableValue.getValue());
                    }
                    caseCriteria.districts(districts);
                }
                if (jurisdictionElement.getSelectedCommunities() != null) {
                    List<CommunityReferenceDto> communities = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : jurisdictionElement.getSelectedCommunities()) {
                        communities.add((CommunityReferenceDto) tokenizableValue.getValue());
                    }
                    caseCriteria.communities(communities);
                }
                if (jurisdictionElement.getSelectedHealthFacilities() != null) {
                    List<FacilityReferenceDto> facilities = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : jurisdictionElement.getSelectedHealthFacilities()) {
                        facilities.add((FacilityReferenceDto) tokenizableValue.getValue());
                    }
                    caseCriteria.healthFacilities(facilities);
                }
                break;
            case PLACE_OF_RESIDENCE:
                StatisticsFilterResidenceElement residenceElement = (StatisticsFilterResidenceElement) filterElement;
                if (residenceElement.getSelectedRegions() != null) {
                    List<RegionReferenceDto> regions = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : residenceElement.getSelectedRegions()) {
                        regions.add((RegionReferenceDto) tokenizableValue.getValue());
                    }
                    caseCriteria.personRegions(regions);
                }
                if (residenceElement.getSelectedDistricts() != null) {
                    List<DistrictReferenceDto> districts = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : residenceElement.getSelectedDistricts()) {
                        districts.add((DistrictReferenceDto) tokenizableValue.getValue());
                    }
                    caseCriteria.personDistricts(districts);
                }
                if (residenceElement.getSelectedCommunities() != null) {
                    List<CommunityReferenceDto> communities = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : residenceElement.getSelectedCommunities()) {
                        communities.add((CommunityReferenceDto) tokenizableValue.getValue());
                    }
                    caseCriteria.personCommunities(communities);
                }
                if (residenceElement.getCity() != null) {
                    caseCriteria.setPersonCity(residenceElement.getCity());
                }
                if (residenceElement.getPostcode() != null) {
                    caseCriteria.setPersonPostcode(residenceElement.getPostcode());
                }
                break;
            case REPORTING_USER_ROLE:
                if (filterElement.getSelectedValues() != null) {
                    List<UserRole> reportingUserRoles = new ArrayList<>();
                    for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                        reportingUserRoles.add((UserRole) tokenizableValue.getValue());
                    }
                    caseCriteria.reportingUserRoles(reportingUserRoles);
                }
                break;
            default:
                switch(filterComponent.getSelectedSubAttribute()) {
                    case YEAR:
                        if (filterElement.getSelectedValues() != null) {
                            List<Year> years = new ArrayList<>();
                            for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                                years.add((Year) tokenizableValue.getValue());
                            }
                            caseCriteria.years(years, filterComponent.getSelectedAttribute());
                        }
                        break;
                    case QUARTER:
                        if (filterElement.getSelectedValues() != null) {
                            List<Quarter> quarters = new ArrayList<>();
                            for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                                quarters.add((Quarter) tokenizableValue.getValue());
                            }
                            caseCriteria.quarters(quarters, filterComponent.getSelectedAttribute());
                        }
                        break;
                    case MONTH:
                        if (filterElement.getSelectedValues() != null) {
                            List<Month> months = new ArrayList<>();
                            for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                                months.add((Month) tokenizableValue.getValue());
                            }
                            caseCriteria.months(months, filterComponent.getSelectedAttribute());
                        }
                        break;
                    case EPI_WEEK:
                        if (filterElement.getSelectedValues() != null) {
                            List<EpiWeek> epiWeeks = new ArrayList<>();
                            for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                                epiWeeks.add((EpiWeek) tokenizableValue.getValue());
                            }
                            caseCriteria.epiWeeks(epiWeeks, filterComponent.getSelectedAttribute());
                        }
                        break;
                    case QUARTER_OF_YEAR:
                        if (filterElement.getSelectedValues() != null) {
                            List<QuarterOfYear> quartersOfYear = new ArrayList<>();
                            for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                                quartersOfYear.add((QuarterOfYear) tokenizableValue.getValue());
                            }
                            caseCriteria.quartersOfYear(quartersOfYear, filterComponent.getSelectedAttribute());
                        }
                        break;
                    case MONTH_OF_YEAR:
                        if (filterElement.getSelectedValues() != null) {
                            List<MonthOfYear> monthsOfYear = new ArrayList<>();
                            for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                                monthsOfYear.add((MonthOfYear) tokenizableValue.getValue());
                            }
                            caseCriteria.monthsOfYear(monthsOfYear, filterComponent.getSelectedAttribute());
                        }
                        break;
                    case EPI_WEEK_OF_YEAR:
                        if (filterElement.getSelectedValues() != null) {
                            List<EpiWeek> epiWeeksOfYear = new ArrayList<>();
                            for (TokenizableValue tokenizableValue : filterElement.getSelectedValues()) {
                                epiWeeksOfYear.add((EpiWeek) tokenizableValue.getValue());
                            }
                            caseCriteria.epiWeeksOfYear(epiWeeksOfYear, filterComponent.getSelectedAttribute());
                        }
                        break;
                    case DATE_RANGE:
                        caseCriteria.dateRange((Date) filterElement.getSelectedValues().get(0).getValue(), (Date) filterElement.getSelectedValues().get(1).getValue(), filterComponent.getSelectedAttribute());
                        break;
                    default:
                        throw new IllegalArgumentException(filterComponent.getSelectedSubAttribute().toString());
                }
        }
    }
}
Also used : Quarter(de.symeda.sormas.api.Quarter) Disease(de.symeda.sormas.api.Disease) MonthOfYear(de.symeda.sormas.api.MonthOfYear) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) Sex(de.symeda.sormas.api.person.Sex) ArrayList(java.util.ArrayList) EpiWeek(de.symeda.sormas.api.utils.EpiWeek) Month(de.symeda.sormas.api.Month) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) QuarterOfYear(de.symeda.sormas.api.QuarterOfYear) TokenizableValue(de.symeda.sormas.ui.statistics.StatisticsFilterElement.TokenizableValue) IntegerRange(de.symeda.sormas.api.IntegerRange) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) CaseOutcome(de.symeda.sormas.api.caze.CaseOutcome) AgeGroup(de.symeda.sormas.api.AgeGroup) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) QuarterOfYear(de.symeda.sormas.api.QuarterOfYear) Year(de.symeda.sormas.api.Year) MonthOfYear(de.symeda.sormas.api.MonthOfYear) UserRole(de.symeda.sormas.api.user.UserRole) StatisticsCaseCriteria(de.symeda.sormas.api.statistics.StatisticsCaseCriteria)

Aggregations

Disease (de.symeda.sormas.api.Disease)106 Date (java.util.Date)46 List (java.util.List)39 ArrayList (java.util.ArrayList)34 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)32 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)32 Collectors (java.util.stream.Collectors)29 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)26 Arrays (java.util.Arrays)25 Collections (java.util.Collections)25 UserRole (de.symeda.sormas.api.user.UserRole)24 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)23 DateHelper (de.symeda.sormas.api.utils.DateHelper)23 Map (java.util.Map)23 Label (com.vaadin.ui.Label)20 Strings (de.symeda.sormas.api.i18n.Strings)20 StringUtils (org.apache.commons.lang3.StringUtils)19 ContactDto (de.symeda.sormas.api.contact.ContactDto)18 District (de.symeda.sormas.backend.infrastructure.district.District)18 CollectionUtils (org.apache.commons.collections.CollectionUtils)18