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