Search in sources :

Example 6 with SymptomState

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

the class SymptomsValidator method initializeSymptomsValidation.

static void initializeSymptomsValidation(final FragmentSymptomsEditLayoutBinding contentBinding, final AbstractDomainObject ado) {
    if (contentBinding.symptomsFever.getVisibility() == View.VISIBLE) {
        contentBinding.symptomsTemperature.addValueChangedListener(field -> toggleFeverComponentError(contentBinding, (Float) field.getValue(), (SymptomState) contentBinding.symptomsFever.getValue()));
        contentBinding.symptomsFever.addValueChangedListener(field -> toggleFeverComponentError(contentBinding, (Float) contentBinding.symptomsTemperature.getValue(), (SymptomState) field.getValue()));
    }
    if (ado instanceof Case) {
        contentBinding.symptomsOnsetDate.addValueChangedListener(field -> {
            Date value = (Date) field.getValue();
            if (((Case) ado).getHospitalization().getAdmissionDate() != null && DateTimeComparator.getDateOnlyInstance().compare(value, ((Case) ado).getHospitalization().getAdmissionDate()) >= 0) {
                contentBinding.symptomsOnsetDate.enableWarningState(I18nProperties.getValidationError(Validations.beforeDateSoft, contentBinding.symptomsOnsetDate.getCaption(), I18nProperties.getPrefixCaption(HospitalizationDto.I18N_PREFIX, HospitalizationDto.ADMISSION_DATE)));
            } else {
                contentBinding.symptomsOnsetDate.disableWarningState();
            }
        });
    }
}
Also used : SymptomState(de.symeda.sormas.api.symptoms.SymptomState) Date(java.util.Date) Case(de.symeda.sormas.app.backend.caze.Case)

Example 7 with SymptomState

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

the class SymptomsForm method toggleFeverComponentError.

private void toggleFeverComponentError(NullableOptionGroup feverField, ComboBox temperatureField) {
    Float temperatureValue = (Float) temperatureField.getValue();
    SymptomState feverValue = (SymptomState) feverField.getNullableValue();
    if (temperatureValue != null && temperatureValue >= 38.0f && feverValue != SymptomState.YES) {
        setFeverComponentError(feverField, true);
    } else if (temperatureValue != null && temperatureValue < 38.0f && feverValue != SymptomState.NO) {
        setFeverComponentError(feverField, false);
    } else {
        feverField.setComponentError(null);
    }
}
Also used : SymptomState(de.symeda.sormas.api.symptoms.SymptomState)

Example 8 with SymptomState

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

the class ClassificationAnyOfSymptomsCriteriaDto method eval.

@Override
public boolean eval(CaseDataDto caze, PersonDto person, List<PathogenTestDto> pathogenTests, List<EventDto> events, Date lastVaccinationDate) {
    for (Field field : SymptomsDto.class.getDeclaredFields()) {
        SymptomsDto symptomsDto = caze.getSymptoms();
        if (field.getType() == SymptomState.class && fieldVisibilityCheckers.isVisible(SymptomsDto.class, field.getName())) {
            field.setAccessible(true);
            try {
                boolean matchedFieldState = field.get(symptomsDto) == symptomState;
                field.setAccessible(false);
                if (matchedFieldState) {
                    return true;
                }
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
        }
    }
    return false;
}
Also used : SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) Field(java.lang.reflect.Field) SymptomState(de.symeda.sormas.api.symptoms.SymptomState)

Example 9 with SymptomState

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

the class SymptomsReadFragment method extractSymptoms.

private void extractSymptoms() {
    yesResult = new ArrayList<>();
    unknownResult = new ArrayList<>();
    for (String symptomPropertyId : SymptomsHelper.getSymptomPropertyIds()) {
        // Skip fields that don't belong in this list
        if (SymptomsHelper.isSpecialSymptom(symptomPropertyId)) {
            continue;
        }
        try {
            Method getter = Symptoms.class.getDeclaredMethod("get" + DataHelper.capitalize(symptomPropertyId));
            SymptomState symptomState = (SymptomState) getter.invoke(record);
            if (symptomState != null) {
                switch(symptomState) {
                    case YES:
                        yesResult.add(I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, symptomPropertyId));
                        break;
                    case NO:
                        // ignore this
                        break;
                    case UNKNOWN:
                        unknownResult.add(I18nProperties.getPrefixCaption(SymptomsDto.I18N_PREFIX, symptomPropertyId));
                        break;
                    default:
                        throw new IllegalArgumentException(symptomState.toString());
                }
            }
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    }
    Collections.sort(yesResult, String.CASE_INSENSITIVE_ORDER);
    Collections.sort(unknownResult, String.CASE_INSENSITIVE_ORDER);
}
Also used : SymptomState(de.symeda.sormas.api.symptoms.SymptomState) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 10 with SymptomState

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

the class SymptomsForm method createButtonSetClearedToSymptomState.

public Button createButtonSetClearedToSymptomState(String caption, SymptomState symptomState) {
    Button button = ButtonHelper.createButton(caption, event -> {
        for (Object symptomId : unconditionalSymptomFieldIds) {
            Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId);
            if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) {
                Set<SymptomState> value = (Set<SymptomState>) symptom.getValue();
                value.add(symptomState);
                symptom.setValue(value);
            }
        }
        for (Object symptomId : conditionalBleedingSymptomFieldIds) {
            Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId);
            if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) {
                Set<SymptomState> value = (Set<SymptomState>) symptom.getValue();
                value.add(symptomState);
                symptom.setValue(value);
            }
        }
        for (Object symptomId : lesionsFieldIds) {
            Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId);
            if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) {
                Set<SymptomState> value = (Set<SymptomState>) symptom.getValue();
                value.add(symptomState);
                symptom.setValue(value);
            }
        }
        for (Object symptomId : monkeypoxImageFieldIds) {
            Field<Object> symptom = (Field<Object>) getFieldGroup().getField(symptomId);
            if (symptom.isVisible() && (Set.class.isAssignableFrom(symptom.getValue().getClass()) && ((Set) symptom.getValue()).size() == 0)) {
                Set<SymptomState> value = (Set<SymptomState>) symptom.getValue();
                value.add(symptomState);
                symptom.setValue(value);
            }
        }
    }, ValoTheme.BUTTON_LINK);
    return button;
}
Also used : AbstractField(com.vaadin.v7.ui.AbstractField) Field(com.vaadin.v7.ui.Field) TextField(com.vaadin.v7.ui.TextField) DateField(com.vaadin.v7.ui.DateField) SymptomState(de.symeda.sormas.api.symptoms.SymptomState) Set(java.util.Set) Button(com.vaadin.ui.Button)

Aggregations

SymptomState (de.symeda.sormas.api.symptoms.SymptomState)10 SymptomsDto (de.symeda.sormas.api.symptoms.SymptomsDto)5 Field (java.lang.reflect.Field)4 RadioButton (android.widget.RadioButton)1 Button (com.vaadin.ui.Button)1 AbstractField (com.vaadin.v7.ui.AbstractField)1 DateField (com.vaadin.v7.ui.DateField)1 Field (com.vaadin.v7.ui.Field)1 TextField (com.vaadin.v7.ui.TextField)1 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 ReinfectionDetail (de.symeda.sormas.api.caze.ReinfectionDetail)1 HealthConditionsDto (de.symeda.sormas.api.clinicalcourse.HealthConditionsDto)1 ExposureDto (de.symeda.sormas.api.exposure.ExposureDto)1 PersonDto (de.symeda.sormas.api.person.PersonDto)1 SampleDto (de.symeda.sormas.api.sample.SampleDto)1 UserDto (de.symeda.sormas.api.user.UserDto)1 YesNoUnknown (de.symeda.sormas.api.utils.YesNoUnknown)1 Case (de.symeda.sormas.app.backend.caze.Case)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)1