Search in sources :

Example 1 with YesNoUnknown

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

the class CaseEditHospitalizationFragment method onLayoutBinding.

@Override
public void onLayoutBinding(final FragmentCaseEditHospitalizationLayoutBinding contentBinding) {
    setUpControlListeners();
    CaseValidator.initializeHospitalizationValidation(contentBinding, caze);
    List<Item> hospitalizationReasons = DataUtils.getEnumItems(HospitalizationReasonType.class, true);
    contentBinding.setData(record);
    contentBinding.setCaze(caze);
    contentBinding.setPreviousHospitalizationList(getPreviousHospitalizations());
    contentBinding.setPrevHosItemClickCallback(onPrevHosItemClickListener);
    getContentBinding().setPreviousHospitalizationBindCallback(this::setFieldVisibilitiesAndAccesses);
    contentBinding.caseHospitalizationHospitalizationReason.initializeSpinner(hospitalizationReasons);
    contentBinding.caseHospitalizationHospitalizedPreviously.addValueChangedListener(field -> {
        YesNoUnknown value = (YesNoUnknown) field.getValue();
        contentBinding.prevHospitalizationsLayout.setVisibility(value == YesNoUnknown.YES ? View.VISIBLE : View.GONE);
        if (value != YesNoUnknown.YES) {
            clearPreviousHospitalizations();
        }
        verifyPrevHospitalizationStatus();
    });
}
Also used : Item(de.symeda.sormas.app.component.Item) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown)

Example 2 with YesNoUnknown

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

the class HospitalizationForm method updatePrevHospHint.

private void updatePrevHospHint(NullableOptionGroup hospitalizedPreviouslyField, PreviousHospitalizationsField previousHospitalizationsField) {
    YesNoUnknown value = (YesNoUnknown) hospitalizedPreviouslyField.getNullableValue();
    Collection<PreviousHospitalizationDto> previousHospitalizations = previousHospitalizationsField.getValue();
    if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_EDIT) && value == YesNoUnknown.YES && (previousHospitalizations == null || previousHospitalizations.size() == 0)) {
        hospitalizedPreviouslyField.setComponentError(new UserError(I18nProperties.getValidationError(Validations.softAddEntryToList)));
    } else {
        hospitalizedPreviouslyField.setComponentError(null);
    }
    if (Objects.nonNull(previousHospitalizationsField.getValue())) {
        hospitalizedPreviouslyField.setEnabled(previousHospitalizationsField.isEmpty());
    } else {
        hospitalizedPreviouslyField.setEnabled(true);
    }
}
Also used : UserError(com.vaadin.server.UserError) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) PreviousHospitalizationDto(de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto)

Example 3 with YesNoUnknown

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

the class ControlSwitchField method createRadioButton.

private RadioButton createRadioButton(int index, int lastIndex, Item item) {
    RadioButton button = new RadioButton(getContext());
    button.setId(index);
    LayoutParams params = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1);
    int borderSize = getResources().getDimensionPixelSize(R.dimen.defaultControlStrokeWidth);
    if (index == 0) {
        params.setMargins(borderSize, borderSize, 0, borderSize);
    } else if (index == lastIndex) {
        params.setMargins(0, borderSize, borderSize, borderSize);
    } else {
        params.setMargins(0, borderSize, 0, borderSize);
    }
    float textSize;
    int heightInPixel;
    if (isSlim()) {
        textSize = getContext().getResources().getDimension(R.dimen.slimControlTextSize);
        heightInPixel = getContext().getResources().getDimensionPixelSize(R.dimen.slimControlHeight);
    } else {
        textSize = getContext().getResources().getDimension(R.dimen.switchControlTextSize);
        heightInPixel = getContext().getResources().getDimensionPixelSize(R.dimen.maxSwitchButtonHeight);
    }
    button.setHeight(heightInPixel);
    button.setMinHeight(heightInPixel);
    button.setMaxHeight(heightInPixel);
    button.setPadding(0, 0, 0, 0);
    button.setBackground(getButtonDrawable(index == lastIndex, hasError));
    button.setButtonDrawable(null);
    button.setGravity(Gravity.CENTER);
    button.setTypeface(Typeface.create(RADIO_BUTTON_FONT_FAMILY, Typeface.NORMAL));
    button.setTextColor(textColor);
    button.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    button.setIncludeFontPadding(false);
    button.setLayoutParams(params);
    Object btnValue = item.getValue();
    String btnKey = item.getKey();
    if (useAbbreviations) {
        if (btnValue instanceof YesNoUnknown && btnKey.equals(YesNoUnknown.UNKNOWN.toString())) {
            btnKey = btnKey.substring(0, 3);
        }
        if (btnValue instanceof SymptomState && btnKey.equals(SymptomState.UNKNOWN.toString())) {
            btnKey = btnKey.substring(0, 3);
        }
    }
    if (btnKey != null) {
        button.setText(btnKey);
    }
    setUpOnClickListener(button, this);
    return button;
}
Also used : SymptomState(de.symeda.sormas.api.symptoms.SymptomState) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) RadioButton(android.widget.RadioButton)

Example 4 with YesNoUnknown

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

the class EpidemiologicalDataEditFragment method setUpControlListeners.

private void setUpControlListeners(final FragmentEditEpidLayoutBinding contentBinding) {
    onExposureItemClickListener = (v, item) -> {
        final Exposure exposure = (Exposure) item;
        final Exposure exposureClone = (Exposure) exposure.clone();
        final ExposureDialog dialog = new ExposureDialog(CaseEditActivity.getActiveActivity(), exposureClone, getActivityRootData(), false);
        dialog.setPositiveCallback(() -> {
            record.getExposures().set(record.getExposures().indexOf(exposure), exposureClone);
            updateExposures();
        });
        dialog.setDeleteCallback(() -> {
            removeExposure(exposure);
            dialog.dismiss();
        });
        dialog.show();
    };
    contentBinding.btnAddExposure.setOnClickListener(v -> {
        final Exposure exposure = DatabaseHelper.getExposureDao().build();
        final ExposureDialog dialog = new ExposureDialog(CaseEditActivity.getActiveActivity(), exposure, getActivityRootData(), true);
        dialog.setPositiveCallback(() -> addExposure(exposure));
        dialog.show();
    });
    contentBinding.epiDataExposureDetailsKnown.addValueChangedListener(field -> {
        YesNoUnknown value = (YesNoUnknown) field.getValue();
        contentBinding.exposuresLayout.setVisibility(value == YesNoUnknown.YES ? VISIBLE : GONE);
        if (value != YesNoUnknown.YES) {
            clearExposures();
        }
        getContentBinding().epiDataExposureDetailsKnown.setEnabled(getExposureList().isEmpty());
    });
    onActivityAsCaseItemClickListener = (v, item) -> {
        final ActivityAsCase activityAsCase = (ActivityAsCase) item;
        final ActivityAsCase activityAsCaseClone = (ActivityAsCase) activityAsCase.clone();
        final ActivityAsCaseDialog dialog = new ActivityAsCaseDialog(CaseEditActivity.getActiveActivity(), activityAsCaseClone, getActivityRootData(), false);
        dialog.setPositiveCallback(() -> {
            record.getActivitiesAsCase().set(record.getActivitiesAsCase().indexOf(activityAsCase), activityAsCaseClone);
            updateActivitiesAsCase();
        });
        dialog.setDeleteCallback(() -> {
            removeActivityAsCase(activityAsCase);
            dialog.dismiss();
        });
        dialog.show();
    };
    contentBinding.btnAddActivityascase.setOnClickListener(v -> {
        final ActivityAsCase activityAsCase = DatabaseHelper.getActivityAsCaseDao().build();
        final ActivityAsCaseDialog dialog = new ActivityAsCaseDialog(CaseEditActivity.getActiveActivity(), activityAsCase, getActivityRootData(), true);
        dialog.setPositiveCallback(() -> addActivityAsCase(activityAsCase));
        dialog.show();
    });
    contentBinding.epiDataActivityAsCaseDetailsKnown.addValueChangedListener(field -> {
        YesNoUnknown value = (YesNoUnknown) field.getValue();
        contentBinding.activityascaseLayout.setVisibility(value == YesNoUnknown.YES ? VISIBLE : GONE);
        if (value != YesNoUnknown.YES) {
            clearActivitiesAsCase();
        }
        getContentBinding().epiDataActivityAsCaseDetailsKnown.setEnabled(getActivityAsCaseList().isEmpty());
    });
}
Also used : YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) Exposure(de.symeda.sormas.app.backend.exposure.Exposure) ActivityAsCase(de.symeda.sormas.app.backend.activityascase.ActivityAsCase)

Example 5 with YesNoUnknown

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

the class CaseController method saveCaseWithFacilityChangedPrompt.

public void saveCaseWithFacilityChangedPrompt(CaseDataDto caze, CaseDataDto oldCase) {
    if (FacilityType.HOSPITAL == caze.getFacilityType() && oldCase.getFacilityType() != FacilityType.HOSPITAL) {
        CurrentHospitalizationForm currentHospitalizationForm = new CurrentHospitalizationForm();
        currentHospitalizationForm.setValue(caze.getHospitalization());
        VaadinUiUtil.showThreeOptionsPopup(I18nProperties.getString(Strings.headingCurrentHospitalization), currentHospitalizationForm, I18nProperties.getCaption(Captions.actionSaveAndOpenHospitalization), I18nProperties.getCaption(Captions.actionSave), I18nProperties.getCaption(Captions.actionDiscard), 700, option -> {
            final NullableOptionGroup admittedToHealthFacilityField = currentHospitalizationForm.getField(HospitalizationDto.ADMITTED_TO_HEALTH_FACILITY);
            switch(option) {
                case OPTION1:
                    {
                        caze.getHospitalization().setAdmittedToHealthFacility((YesNoUnknown) admittedToHealthFacilityField.getNullableValue());
                        saveCase(caze);
                        ControllerProvider.getCaseController().navigateToView(HospitalizationView.VIEW_NAME, caze.getUuid(), null);
                    }
                    break;
                case OPTION2:
                    {
                        caze.getHospitalization().setAdmittedToHealthFacility((YesNoUnknown) admittedToHealthFacilityField.getNullableValue());
                        saveCase(caze);
                        ControllerProvider.getCaseController().navigateToView(CaseDataView.VIEW_NAME, caze.getUuid(), null);
                    }
                    break;
                case OPTION3:
                    SormasUI.refreshView();
                    break;
            }
        });
    } else if (oldCase.getFacilityType() == FacilityType.HOSPITAL && caze.getHealthFacility() != null && !caze.getHealthFacility().getUuid().equals(oldCase.getHealthFacility().getUuid())) {
        VaadinUiUtil.showChooseOptionPopup(I18nProperties.getCaption(Captions.caseInfrastructureDataChanged), new Label(I18nProperties.getString(Strings.messageFacilityChanged)), I18nProperties.getCaption(Captions.caseTransferCase), I18nProperties.getCaption(Captions.caseEditData), 500, e -> {
            CaseLogic.handleHospitalization(caze, oldCase, e.booleanValue());
            saveCase(caze);
            SormasUI.refreshView();
        });
    } else {
        saveCase(caze);
    }
}
Also used : NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) Alignment(com.vaadin.ui.Alignment) CaseSimilarityCriteria(de.symeda.sormas.api.caze.CaseSimilarityCriteria) StringUtils(org.apache.commons.lang3.StringUtils) PersonDto(de.symeda.sormas.api.person.PersonDto) ClinicalCourseForm(de.symeda.sormas.ui.clinicalcourse.ClinicalCourseForm) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) MaternalHistoryView(de.symeda.sormas.ui.caze.maternalhistory.MaternalHistoryView) CssStyles(de.symeda.sormas.ui.utils.CssStyles) Page(com.vaadin.server.Page) PortHealthInfoView(de.symeda.sormas.ui.caze.porthealthinfo.PortHealthInfoView) TextArea(com.vaadin.ui.TextArea) ValoTheme(com.vaadin.ui.themes.ValoTheme) DiseaseHelper(de.symeda.sormas.api.DiseaseHelper) Link(com.vaadin.ui.Link) HtmlHelper(de.symeda.sormas.api.utils.HtmlHelper) EpiDataForm(de.symeda.sormas.ui.epidata.EpiDataForm) Type(com.vaadin.ui.Notification.Type) CaseLogic(de.symeda.sormas.api.caze.CaseLogic) DateHelper8(de.symeda.sormas.ui.utils.DateHelper8) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) MaternalHistoryForm(de.symeda.sormas.ui.caze.maternalhistory.MaternalHistoryForm) CloseEvent(com.vaadin.ui.Window.CloseEvent) ExternalSurveillanceToolException(de.symeda.sormas.api.externalsurveillancetool.ExternalSurveillanceToolException) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) VerticalLayout(com.vaadin.ui.VerticalLayout) EventParticipantCriteria(de.symeda.sormas.api.event.EventParticipantCriteria) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) SymptomsContext(de.symeda.sormas.api.symptoms.SymptomsContext) ArrayList(java.util.ArrayList) ClassificationHtmlRenderer(de.symeda.sormas.api.caze.classification.ClassificationHtmlRenderer) ExternalSurveillanceServiceGateway(de.symeda.sormas.ui.externalsurveillanceservice.ExternalSurveillanceServiceGateway) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) CountryHelper(de.symeda.sormas.api.CountryHelper) SimilarEventParticipantDto(de.symeda.sormas.api.event.SimilarEventParticipantDto) TitleLayout(de.symeda.sormas.ui.utils.components.page.title.TitleLayout) ContactSimilarityCriteria(de.symeda.sormas.api.contact.ContactSimilarityCriteria) ContentMode(com.vaadin.shared.ui.ContentMode) MessageType(de.symeda.sormas.api.messaging.MessageType) DataHelper(de.symeda.sormas.api.utils.DataHelper) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) CaseFacade(de.symeda.sormas.api.caze.CaseFacade) ContactLogic(de.symeda.sormas.api.contact.ContactLogic) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) SymptomsHelper(de.symeda.sormas.api.symptoms.SymptomsHelper) Captions(de.symeda.sormas.api.i18n.Captions) LineListingLayout(de.symeda.sormas.ui.caze.components.linelisting.LineListingLayout) AutomaticDeletionInfoDto(de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto) Button(com.vaadin.ui.Button) CaseBulkEditData(de.symeda.sormas.api.caze.CaseBulkEditData) Disease(de.symeda.sormas.api.Disease) VisitDto(de.symeda.sormas.api.visit.VisitDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout) DiseaseClassificationCriteriaDto(de.symeda.sormas.api.caze.classification.DiseaseClassificationCriteriaDto) FeatureType(de.symeda.sormas.api.feature.FeatureType) CaseSelectionDto(de.symeda.sormas.api.caze.CaseSelectionDto) AutomaticDeletionLabel(de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) UI(com.vaadin.ui.UI) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) Window(com.vaadin.ui.Window) SymptomsForm(de.symeda.sormas.ui.symptoms.SymptomsForm) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) SmsComponent(de.symeda.sormas.ui.caze.messaging.SmsComponent) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CaseEpiDataView(de.symeda.sormas.ui.epidata.CaseEpiDataView) UserRole(de.symeda.sormas.api.user.UserRole) UserProvider(de.symeda.sormas.ui.UserProvider) PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto) CloseListener(com.vaadin.ui.Window.CloseListener) ViewMode(de.symeda.sormas.ui.utils.ViewMode) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) Collection(java.util.Collection) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) EventDto(de.symeda.sormas.api.event.EventDto) Collectors(java.util.stream.Collectors) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) Objects(java.util.Objects) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) List(java.util.List) ExternalResource(com.vaadin.server.ExternalResource) TherapyView(de.symeda.sormas.ui.therapy.TherapyView) ContactDto(de.symeda.sormas.api.contact.ContactDto) Optional(java.util.Optional) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) DateHelper(de.symeda.sormas.api.utils.DateHelper) CollectionUtils(org.apache.commons.collections.CollectionUtils) Notification(com.vaadin.ui.Notification) SormasUI(de.symeda.sormas.ui.SormasUI) Label(com.vaadin.ui.Label) TitleLayoutHelper(de.symeda.sormas.ui.utils.components.page.title.TitleLayoutHelper) HospitalizationForm(de.symeda.sormas.ui.hospitalization.HospitalizationForm) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) AbstractView(de.symeda.sormas.ui.utils.AbstractView) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) PortHealthInfoForm(de.symeda.sormas.ui.caze.porthealthinfo.PortHealthInfoForm) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) UserDto(de.symeda.sormas.api.user.UserDto) HospitalizationView(de.symeda.sormas.ui.hospitalization.HospitalizationView) Sizeable(com.vaadin.server.Sizeable) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) Consumer(java.util.function.Consumer) Navigator(com.vaadin.navigator.Navigator) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) ClinicalCourseView(de.symeda.sormas.ui.clinicalcourse.ClinicalCourseView) HospitalizationDto(de.symeda.sormas.api.hospitalization.HospitalizationDto) Unit(com.vaadin.server.Sizeable.Unit) Strings(de.symeda.sormas.api.i18n.Strings) Component(com.vaadin.ui.Component) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) AutomaticDeletionLabel(de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel) Label(com.vaadin.ui.Label)

Aggregations

YesNoUnknown (de.symeda.sormas.api.utils.YesNoUnknown)8 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)2 RadioButton (android.widget.RadioButton)1 Navigator (com.vaadin.navigator.Navigator)1 ExternalResource (com.vaadin.server.ExternalResource)1 Page (com.vaadin.server.Page)1 Sizeable (com.vaadin.server.Sizeable)1 Unit (com.vaadin.server.Sizeable.Unit)1 UserError (com.vaadin.server.UserError)1 ContentMode (com.vaadin.shared.ui.ContentMode)1 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1 Component (com.vaadin.ui.Component)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 Link (com.vaadin.ui.Link)1 Notification (com.vaadin.ui.Notification)1 Type (com.vaadin.ui.Notification.Type)1 TextArea (com.vaadin.ui.TextArea)1 UI (com.vaadin.ui.UI)1