Search in sources :

Example 1 with CaseInfoLayout

use of de.symeda.sormas.ui.caze.CaseInfoLayout in project SORMAS-Project by hzi-braunschweig.

the class SampleDataView method initView.

@Override
protected void initView(String params) {
    setHeightUndefined();
    String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, EDIT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, CASE_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, CONTACT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, EVENT_PARTICIPANT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, PATHOGEN_TESTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, ADDITIONAL_TESTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SORMAS_TO_SORMAS_LOC));
    DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> editComponent);
    container.setWidth(100, Unit.PERCENTAGE);
    container.setMargin(true);
    setSubComponent(container);
    CustomLayout layout = new CustomLayout();
    layout.addStyleName(CssStyles.ROOT_COMPONENT);
    layout.setTemplateContents(htmlLayout);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setHeightUndefined();
    container.addComponent(layout);
    SampleDto sampleDto = FacadeProvider.getSampleFacade().getSampleByUuid(getSampleRef().getUuid());
    Disease disease = null;
    final CaseReferenceDto associatedCase = sampleDto.getAssociatedCase();
    if (associatedCase != null && UserProvider.getCurrent().hasAllUserRights(UserRight.CASE_VIEW)) {
        final CaseDataDto caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(associatedCase.getUuid());
        disease = caseDto.getDisease();
        final CaseInfoLayout caseInfoLayout = new CaseInfoLayout(caseDto);
        caseInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addComponent(caseInfoLayout, CASE_LOC);
    }
    final ContactReferenceDto associatedContact = sampleDto.getAssociatedContact();
    if (associatedContact != null && UserProvider.getCurrent().hasAllUserRights(UserRight.CONTACT_VIEW)) {
        final ContactDto contactDto = FacadeProvider.getContactFacade().getByUuid(associatedContact.getUuid());
        disease = contactDto.getDisease();
        final ContactInfoLayout contactInfoLayout = new ContactInfoLayout(contactDto, UiFieldAccessCheckers.getDefault(contactDto.isPseudonymized()));
        contactInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addComponent(contactInfoLayout, CONTACT_LOC);
    }
    final EventParticipantReferenceDto associatedEventParticipant = sampleDto.getAssociatedEventParticipant();
    if (associatedEventParticipant != null && UserProvider.getCurrent().hasAllUserRights(UserRight.EVENTPARTICIPANT_VIEW)) {
        final EventParticipantDto eventParticipantDto = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(associatedEventParticipant.getUuid());
        final EventDto eventDto = FacadeProvider.getEventFacade().getEventByUuid(eventParticipantDto.getEvent().getUuid(), false);
        disease = eventDto.getDisease();
        final EventParticipantInfoLayout eventParticipantInfoLayout = new EventParticipantInfoLayout(eventParticipantDto, eventDto, UiFieldAccessCheckers.getDefault(eventParticipantDto.isPseudonymized()));
        eventParticipantInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addComponent(eventParticipantInfoLayout, EVENT_PARTICIPANT_LOC);
    }
    SampleController sampleController = ControllerProvider.getSampleController();
    editComponent = sampleController.getSampleEditComponent(getSampleRef().getUuid(), sampleDto.isPseudonymized(), disease, true);
    Consumer<Disease> createReferral = (relatedDisease) -> {
        // save changes before referral creation
        editComponent.commit();
        SampleDto committedSample = editComponent.getWrappedComponent().getValue();
        sampleController.createReferral(committedSample, relatedDisease);
    };
    Consumer<SampleDto> openReferredSample = referredSample -> sampleController.navigateToData(referredSample.getUuid());
    sampleController.addReferOrLinkToOtherLabButton(editComponent, disease, createReferral, openReferredSample);
    Consumer<SampleDto> navigate = targetSampleDto -> sampleController.navigateToData(targetSampleDto.getUuid());
    sampleController.addReferredFromButton(editComponent, navigate);
    editComponent.setMargin(new MarginInfo(false, false, true, false));
    editComponent.setWidth(100, Unit.PERCENTAGE);
    editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE);
    editComponent.addStyleName(CssStyles.MAIN_COMPONENT);
    layout.addComponent(editComponent, EDIT_LOC);
    SampleReferenceDto sampleReferenceDto = getSampleRef();
    PathogenTestListComponent pathogenTestListComponent = new PathogenTestListComponent(sampleReferenceDto, this::showUnsavedChangesPopup);
    layout.addComponent(new SideComponentLayout(pathogenTestListComponent), PATHOGEN_TESTS_LOC);
    if (UserProvider.getCurrent() != null && UserProvider.getCurrent().hasUserRight(UserRight.ADDITIONAL_TEST_VIEW) && FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.ADDITIONAL_TESTS)) {
        AdditionalTestListComponent additionalTestList = new AdditionalTestListComponent(sampleReferenceDto.getUuid());
        additionalTestList.addStyleName(CssStyles.SIDE_COMPONENT);
        layout.addComponent(additionalTestList, ADDITIONAL_TESTS_LOC);
    }
    boolean sormasToSormasEnabled = FacadeProvider.getSormasToSormasFacade().isSharingCasesContactsAndSamplesEnabledForUser();
    if (sormasToSormasEnabled || sampleDto.getSormasToSormasOriginInfo() != null) {
        VerticalLayout sormasToSormasLocLayout = new VerticalLayout();
        sormasToSormasLocLayout.setMargin(false);
        sormasToSormasLocLayout.setSpacing(false);
        SormasToSormasListComponent sormasToSormasListComponent = new SormasToSormasListComponent(sampleDto);
        sormasToSormasListComponent.addStyleNames(CssStyles.SIDE_COMPONENT);
        sormasToSormasLocLayout.addComponent(sormasToSormasListComponent);
        layout.addComponent(sormasToSormasLocLayout, SORMAS_TO_SORMAS_LOC);
    }
    setSampleEditPermission(container);
}
Also used : FeatureType(de.symeda.sormas.api.feature.FeatureType) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout) FacadeProvider(de.symeda.sormas.api.FacadeProvider) PathogenTestListComponent(de.symeda.sormas.ui.samples.pathogentestlink.PathogenTestListComponent) VerticalLayout(com.vaadin.ui.VerticalLayout) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) CustomLayout(com.vaadin.ui.CustomLayout) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) SampleReferenceDto(de.symeda.sormas.api.sample.SampleReferenceDto) CssStyles(de.symeda.sormas.ui.utils.CssStyles) CaseInfoLayout(de.symeda.sormas.ui.caze.CaseInfoLayout) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) UserProvider(de.symeda.sormas.ui.UserProvider) EventParticipantInfoLayout(de.symeda.sormas.ui.events.EventParticipantInfoLayout) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) EventDto(de.symeda.sormas.api.event.EventDto) MarginInfo(com.vaadin.shared.ui.MarginInfo) SormasToSormasListComponent(de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent) ContactInfoLayout(de.symeda.sormas.ui.contact.ContactInfoLayout) Consumer(java.util.function.Consumer) UserRight(de.symeda.sormas.api.user.UserRight) LayoutUtil(de.symeda.sormas.ui.utils.LayoutUtil) Disease(de.symeda.sormas.api.Disease) SampleDto(de.symeda.sormas.api.sample.SampleDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) ContactInfoLayout(de.symeda.sormas.ui.contact.ContactInfoLayout) Disease(de.symeda.sormas.api.Disease) SideComponentLayout(de.symeda.sormas.ui.utils.components.sidecomponent.SideComponentLayout) PathogenTestListComponent(de.symeda.sormas.ui.samples.pathogentestlink.PathogenTestListComponent) MarginInfo(com.vaadin.shared.ui.MarginInfo) ContactDto(de.symeda.sormas.api.contact.ContactDto) VerticalLayout(com.vaadin.ui.VerticalLayout) EventParticipantInfoLayout(de.symeda.sormas.ui.events.EventParticipantInfoLayout) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) SampleReferenceDto(de.symeda.sormas.api.sample.SampleReferenceDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) SormasToSormasListComponent(de.symeda.sormas.ui.sormastosormas.SormasToSormasListComponent) EventDto(de.symeda.sormas.api.event.EventDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) CaseInfoLayout(de.symeda.sormas.ui.caze.CaseInfoLayout) CustomLayout(com.vaadin.ui.CustomLayout) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) SampleDto(de.symeda.sormas.api.sample.SampleDto) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto)

Example 2 with CaseInfoLayout

use of de.symeda.sormas.ui.caze.CaseInfoLayout in project SORMAS-Project by hzi-braunschweig.

the class ContactDataView method createCaseInfoLayout.

private CaseInfoLayout createCaseInfoLayout(CaseDataDto caseDto) {
    CaseInfoLayout caseInfoLayout = new CaseInfoLayout(caseDto);
    caseInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
    return caseInfoLayout;
}
Also used : CaseInfoLayout(de.symeda.sormas.ui.caze.CaseInfoLayout)

Example 3 with CaseInfoLayout

use of de.symeda.sormas.ui.caze.CaseInfoLayout in project SORMAS-Project by hzi-braunschweig.

the class TravelEntryDataView method createCaseInfoLayout.

private CaseInfoLayout createCaseInfoLayout(String caseUuid) {
    CaseDataDto caseDto = FacadeProvider.getCaseFacade().getCaseDataByUuid(caseUuid);
    CaseInfoLayout caseInfoLayout = new CaseInfoLayout(caseDto, true);
    caseInfoLayout.addStyleName(CssStyles.SIDE_COMPONENT);
    return caseInfoLayout;
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CaseInfoLayout(de.symeda.sormas.ui.caze.CaseInfoLayout)

Aggregations

CaseInfoLayout (de.symeda.sormas.ui.caze.CaseInfoLayout)3 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)2 MarginInfo (com.vaadin.shared.ui.MarginInfo)1 CustomLayout (com.vaadin.ui.CustomLayout)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Disease (de.symeda.sormas.api.Disease)1 FacadeProvider (de.symeda.sormas.api.FacadeProvider)1 CaseReferenceDto (de.symeda.sormas.api.caze.CaseReferenceDto)1 ContactDto (de.symeda.sormas.api.contact.ContactDto)1 ContactReferenceDto (de.symeda.sormas.api.contact.ContactReferenceDto)1 EventDto (de.symeda.sormas.api.event.EventDto)1 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)1 EventParticipantReferenceDto (de.symeda.sormas.api.event.EventParticipantReferenceDto)1 FeatureType (de.symeda.sormas.api.feature.FeatureType)1 SampleDto (de.symeda.sormas.api.sample.SampleDto)1 SampleReferenceDto (de.symeda.sormas.api.sample.SampleReferenceDto)1 UserRight (de.symeda.sormas.api.user.UserRight)1 UiFieldAccessCheckers (de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers)1 ControllerProvider (de.symeda.sormas.ui.ControllerProvider)1 UserProvider (de.symeda.sormas.ui.UserProvider)1