Search in sources :

Example 1 with ImmunizationCreationForm

use of de.symeda.sormas.ui.immunization.components.form.ImmunizationCreationForm in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationController method getImmunizationCreateComponent.

private CommitDiscardWrapperComponent<ImmunizationCreationForm> getImmunizationCreateComponent() {
    UserProvider currentUserProvider = UserProvider.getCurrent();
    if (currentUserProvider != null) {
        ImmunizationCreationForm createForm = new ImmunizationCreationForm();
        ImmunizationDto immunization = ImmunizationDto.build(null);
        immunization.setReportingUser(currentUserProvider.getUserReference());
        createForm.setValue(immunization);
        final CommitDiscardWrapperComponent<ImmunizationCreationForm> viewComponent = new CommitDiscardWrapperComponent<>(createForm, currentUserProvider.hasUserRight(UserRight.IMMUNIZATION_CREATE), createForm.getFieldGroup());
        viewComponent.addCommitListener(() -> {
            if (!createForm.getFieldGroup().isModified()) {
                final ImmunizationDto dto = createForm.getValue();
                PersonDto searchedPerson = createForm.getSearchedPerson();
                if (searchedPerson != null) {
                    dto.setPerson(searchedPerson.toReference());
                    selectOrCreateimmunizationForPerson(dto, searchedPerson.toReference());
                } else {
                    final PersonDto person = createForm.getPerson();
                    ControllerProvider.getPersonController().selectOrCreatePerson(person, I18nProperties.getString(Strings.infoSelectOrCreatePersonForImmunization), selectedPerson -> {
                        if (selectedPerson != null) {
                            selectOrCreateimmunizationForPerson(dto, selectedPerson);
                        }
                    }, true);
                }
            }
        });
        return viewComponent;
    }
    return null;
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) UserProvider(de.symeda.sormas.ui.UserProvider) ImmunizationCreationForm(de.symeda.sormas.ui.immunization.components.form.ImmunizationCreationForm) PersonDto(de.symeda.sormas.api.person.PersonDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)

Example 2 with ImmunizationCreationForm

use of de.symeda.sormas.ui.immunization.components.form.ImmunizationCreationForm in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationController method getImmunizationCreateComponent.

private CommitDiscardWrapperComponent<ImmunizationCreationForm> getImmunizationCreateComponent(PersonReferenceDto personReferenceDto, Disease disease) {
    UserProvider currentUserProvider = UserProvider.getCurrent();
    if (currentUserProvider != null) {
        ImmunizationCreationForm createForm = new ImmunizationCreationForm(personReferenceDto, disease);
        ImmunizationDto immunization = ImmunizationDto.build(personReferenceDto);
        immunization.setDisease(disease);
        immunization.setReportingUser(currentUserProvider.getUserReference());
        createForm.setValue(immunization);
        final CommitDiscardWrapperComponent<ImmunizationCreationForm> viewComponent = new CommitDiscardWrapperComponent<>(createForm, currentUserProvider.hasUserRight(UserRight.IMMUNIZATION_CREATE), createForm.getFieldGroup());
        viewComponent.addCommitListener(() -> {
            if (!createForm.getFieldGroup().isModified()) {
                final ImmunizationDto dto = createForm.getValue();
                selectOrCreateimmunizationForPerson(dto, personReferenceDto);
            }
        });
        return viewComponent;
    }
    return null;
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) UserProvider(de.symeda.sormas.ui.UserProvider) ImmunizationCreationForm(de.symeda.sormas.ui.immunization.components.form.ImmunizationCreationForm) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)

Aggregations

ImmunizationDto (de.symeda.sormas.api.immunization.ImmunizationDto)2 UserProvider (de.symeda.sormas.ui.UserProvider)2 ImmunizationCreationForm (de.symeda.sormas.ui.immunization.components.form.ImmunizationCreationForm)2 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)2 PersonDto (de.symeda.sormas.api.person.PersonDto)1