Search in sources :

Example 1 with ImmunizationDto

use of de.symeda.sormas.api.immunization.ImmunizationDto 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 ImmunizationDto

use of de.symeda.sormas.api.immunization.ImmunizationDto 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)

Example 3 with ImmunizationDto

use of de.symeda.sormas.api.immunization.ImmunizationDto in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationController method getImmunizationDataEditComponent.

public CommitDiscardWrapperComponent<ImmunizationDataForm> getImmunizationDataEditComponent(ImmunizationDto immunizationDto) {
    ImmunizationDataForm immunizationDataForm = new ImmunizationDataForm(immunizationDto.isPseudonymized(), immunizationDto.getRelatedCase());
    immunizationDataForm.setValue(immunizationDto);
    UserProvider currentUserProvider = UserProvider.getCurrent();
    CommitDiscardWrapperComponent<ImmunizationDataForm> editComponent = new CommitDiscardWrapperComponent<ImmunizationDataForm>(immunizationDataForm, currentUserProvider != null && currentUserProvider.hasUserRight(UserRight.IMMUNIZATION_EDIT), immunizationDataForm.getFieldGroup()) {

        @Override
        public void discard() {
            immunizationDataForm.discard();
            super.discard();
        }
    };
    AutomaticDeletionInfoDto automaticDeletionInfoDto = FacadeProvider.getImmunizationFacade().getAutomaticDeletionInfo(immunizationDto.getUuid());
    if (automaticDeletionInfoDto != null) {
        editComponent.getButtonsPanel().addComponentAsFirst(new AutomaticDeletionLabel(automaticDeletionInfoDto));
    }
    editComponent.addCommitListener(() -> {
        if (!immunizationDataForm.getFieldGroup().isModified()) {
            ImmunizationDto immunizationDtoValue = immunizationDataForm.getValue();
            List<ImmunizationDto> similarImmunizations = findSimilarImmunizations(immunizationDtoValue);
            if (similarImmunizations.isEmpty()) {
                FacadeProvider.getImmunizationFacade().save(immunizationDtoValue);
                if (immunizationDtoValue.getImmunizationStatus() == ImmunizationStatus.ACQUIRED) {
                    NotificationHelper.showNotification(I18nProperties.getString(Strings.messageImmunizationSavedVaccinationStatusUpdated), Notification.Type.WARNING_MESSAGE, -1);
                } else {
                    Notification.show(I18nProperties.getString(Strings.messageImmunizationSaved), Notification.Type.WARNING_MESSAGE);
                }
                SormasUI.refreshView();
            } else {
                showSimilarImmunizationPopup(immunizationDtoValue, similarImmunizations.get(0), this::saveImmunization);
            }
        }
    });
    // Initialize 'Delete' button
    if (UserProvider.getCurrent().hasUserRight(UserRight.IMMUNIZATION_DELETE)) {
        editComponent.addDeleteListener(() -> {
            FacadeProvider.getImmunizationFacade().deleteImmunization(immunizationDto.getUuid());
            UI.getCurrent().getNavigator().navigateTo(ImmunizationsView.VIEW_NAME);
        }, I18nProperties.getString(Strings.entityImmunization));
    }
    // Initialize 'Archive' button
    if (UserProvider.getCurrent().hasUserRight(UserRight.IMMUNIZATION_ARCHIVE)) {
        boolean archived = FacadeProvider.getImmunizationFacade().isArchived(immunizationDto.getUuid());
        Button archiveButton = ButtonHelper.createButton(archived ? Captions.actionDearchive : Captions.actionArchive, e -> {
            if (editComponent.isModified()) {
                editComponent.commit();
            }
            if (archived) {
                ControllerProvider.getArchiveController().dearchiveEntity(immunizationDto, FacadeProvider.getImmunizationFacade(), Strings.headingDearchiveImmunization, Strings.confirmationDearchiveImmunization, Strings.entityImmunization, Strings.messageImmunizationDearchived, () -> navigateToImmunization(immunizationDto.getUuid()));
            } else {
                ControllerProvider.getArchiveController().archiveEntity(immunizationDto, FacadeProvider.getImmunizationFacade(), Strings.headingArchiveImmunization, Strings.confirmationArchiveImmunization, Strings.entityImmunization, Strings.messageImmunizationArchived, () -> navigateToImmunization(immunizationDto.getUuid()));
            }
        }, ValoTheme.BUTTON_LINK);
        editComponent.getButtonsPanel().addComponentAsFirst(archiveButton);
        editComponent.getButtonsPanel().setComponentAlignment(archiveButton, Alignment.BOTTOM_LEFT);
    }
    return editComponent;
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) UserProvider(de.symeda.sormas.ui.UserProvider) Button(com.vaadin.ui.Button) ImmunizationDataForm(de.symeda.sormas.ui.immunization.components.form.ImmunizationDataForm) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) AutomaticDeletionInfoDto(de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto) AutomaticDeletionLabel(de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel)

Example 4 with ImmunizationDto

use of de.symeda.sormas.api.immunization.ImmunizationDto in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationController method getImmunizationViewTitleLayout.

public TitleLayout getImmunizationViewTitleLayout(String uuid) {
    ImmunizationDto immunizationDto = findImmunization(uuid);
    TitleLayout titleLayout = new TitleLayout();
    String shortUuid = DataHelper.getShortUuid(immunizationDto.getUuid());
    PersonDto person = FacadeProvider.getPersonFacade().getPersonByUuid(immunizationDto.getPerson().getUuid());
    StringBuilder mainRowText = TitleLayoutHelper.buildPersonString(person);
    mainRowText.append(mainRowText.length() > 0 ? " (" + shortUuid + ")" : shortUuid);
    titleLayout.addMainRow(mainRowText.toString());
    return titleLayout;
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto) TitleLayout(de.symeda.sormas.ui.utils.components.page.title.TitleLayout) PersonDto(de.symeda.sormas.api.person.PersonDto)

Example 5 with ImmunizationDto

use of de.symeda.sormas.api.immunization.ImmunizationDto in project SORMAS-Project by hzi-braunschweig.

the class ImmunizationCreationForm method getValue.

@Override
public ImmunizationDto getValue() {
    ImmunizationDto immunizationDto = super.getValue();
    immunizationDto.setImmunizationManagementStatus((ImmunizationManagementStatus) getField(ImmunizationDto.IMMUNIZATION_MANAGEMENT_STATUS).getValue());
    immunizationDto.setImmunizationStatus((ImmunizationStatus) getField(ImmunizationDto.IMMUNIZATION_STATUS).getValue());
    return immunizationDto;
}
Also used : ImmunizationDto(de.symeda.sormas.api.immunization.ImmunizationDto)

Aggregations

ImmunizationDto (de.symeda.sormas.api.immunization.ImmunizationDto)44 PersonDto (de.symeda.sormas.api.person.PersonDto)22 Test (org.junit.Test)22 Date (java.util.Date)21 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)18 VaccinationDto (de.symeda.sormas.api.vaccination.VaccinationDto)11 HealthConditionsDto (de.symeda.sormas.api.clinicalcourse.HealthConditionsDto)6 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)6 UserReferenceDto (de.symeda.sormas.api.user.UserReferenceDto)6 DateTime (org.joda.time.DateTime)6 Immunization (de.symeda.sormas.backend.immunization.entity.Immunization)5 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)4 ImmunizationCriteria (de.symeda.sormas.api.immunization.ImmunizationCriteria)4 ImmunizationIndexDto (de.symeda.sormas.api.immunization.ImmunizationIndexDto)4 ImmunizationReferenceDto (de.symeda.sormas.api.immunization.ImmunizationReferenceDto)4 ImmunizationSimilarityCriteria (de.symeda.sormas.api.immunization.ImmunizationSimilarityCriteria)4 MeansOfImmunization (de.symeda.sormas.api.immunization.MeansOfImmunization)4 SormasToSormasTest (de.symeda.sormas.backend.sormastosormas.SormasToSormasTest)4 Vaccination (de.symeda.sormas.backend.vaccination.Vaccination)4 Disease (de.symeda.sormas.api.Disease)3