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