Search in sources :

Example 1 with ImmunizationPickOrCreateField

use of de.symeda.sormas.ui.immunization.components.fields.pickorcreate.ImmunizationPickOrCreateField in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationController method selectOrCreateImmunization.

private void selectOrCreateImmunization(ImmunizationDto immunizationDto, Consumer<String> selectedImmunizationUuidConsumer) {
    ImmunizationSimilarityCriteria criteria = new ImmunizationSimilarityCriteria.Builder().withDisease(immunizationDto.getDisease()).withStartDate(immunizationDto.getStartDate()).withEndDate(immunizationDto.getEndDate()).withPerson(immunizationDto.getPerson().getUuid()).withMeansOfImmunization(immunizationDto.getMeansOfImmunization()).build();
    List<ImmunizationDto> similarImmunizations = FacadeProvider.getImmunizationFacade().getSimilarImmunizations(criteria);
    if (!similarImmunizations.isEmpty()) {
        ImmunizationPickOrCreateField pickOrCreateField = new ImmunizationPickOrCreateField(immunizationDto, similarImmunizations);
        pickOrCreateField.setWidth(1280, Sizeable.Unit.PIXELS);
        final CommitDiscardWrapperComponent<ImmunizationPickOrCreateField> component = new CommitDiscardWrapperComponent<>(pickOrCreateField);
        component.getCommitButton().setCaption(I18nProperties.getCaption(Captions.actionConfirm));
        component.getCommitButton().setEnabled(false);
        component.addCommitListener(() -> selectedImmunizationUuidConsumer.accept(pickOrCreateField.getValue()));
        pickOrCreateField.setSelectionChangeCallback((commitAllowed) -> component.getCommitButton().setEnabled(commitAllowed));
        VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateImmunization));
    } else {
        selectedImmunizationUuidConsumer.accept(immunizationDto.getUuid());
    }
}
Also used : ImmunizationSimilarityCriteria(de.symeda.sormas.api.immunization.ImmunizationSimilarityCriteria) ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) ImmunizationPickOrCreateField(de.symeda.sormas.ui.immunization.components.fields.pickorcreate.ImmunizationPickOrCreateField) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)

Aggregations

ImmunizationDto (de.symeda.sormas.api.immunization.ImmunizationDto)1 ImmunizationSimilarityCriteria (de.symeda.sormas.api.immunization.ImmunizationSimilarityCriteria)1 ImmunizationPickOrCreateField (de.symeda.sormas.ui.immunization.components.fields.pickorcreate.ImmunizationPickOrCreateField)1 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)1