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();
}
});
}
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations