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