Search in sources :

Example 16 with Disease

use of de.symeda.sormas.api.Disease 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) {
        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) {
        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) {
        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);
    BiConsumer<PathogenTestDto, Runnable> onSavedPathogenTest = (pathogenTestDto, callback) -> callback.run();
    // why? if(sampleDto.getSamplePurpose() !=null && sampleDto.getSamplePurpose().equals(SamplePurpose.EXTERNAL)) {
    Supplier<Boolean> createOrEditAllowedCallback = () -> editComponent.getWrappedComponent().getFieldGroup().isValid();
    SampleReferenceDto sampleReferenceDto = getSampleRef();
    PathogenTestListComponent pathogenTestListComponent = new PathogenTestListComponent(sampleReferenceDto);
    pathogenTestListComponent.addSideComponentCreateEventListener(e -> showNavigationConfirmPopupIfDirty(() -> {
        if (createOrEditAllowedCallback.get()) {
            ControllerProvider.getPathogenTestController().create(sampleReferenceDto, 0, pathogenTestListComponent::reload, onSavedPathogenTest);
        } else {
            Notification.show(null, I18nProperties.getString(Strings.messageFormHasErrorsPathogenTest), Notification.Type.ERROR_MESSAGE);
        }
    }));
    pathogenTestListComponent.addSideComponentEditEventListener(e -> showNavigationConfirmPopupIfDirty(() -> {
        String uuid = e.getUuid();
        if (createOrEditAllowedCallback.get()) {
            ControllerProvider.getPathogenTestController().edit(uuid, pathogenTestListComponent::reload, onSavedPathogenTest);
        } else {
            Notification.show(null, I18nProperties.getString(Strings.messageFormHasErrorsPathogenTest), Notification.Type.ERROR_MESSAGE);
        }
    }));
    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) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) PathogenTestListComponent(de.symeda.sormas.ui.samples.pathogentestlink.PathogenTestListComponent) VerticalLayout(com.vaadin.ui.VerticalLayout) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) Supplier(java.util.function.Supplier) 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) Notification(com.vaadin.ui.Notification) CaseInfoLayout(de.symeda.sormas.ui.caze.CaseInfoLayout) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) BiConsumer(java.util.function.BiConsumer) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) 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) Strings(de.symeda.sormas.api.i18n.Strings) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) ContactInfoLayout(de.symeda.sormas.ui.contact.ContactInfoLayout) Disease(de.symeda.sormas.api.Disease) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) 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 17 with Disease

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

the class PathogenTestController method handleAssociatedCase.

private void handleAssociatedCase(PathogenTestDto dto, BiConsumer<PathogenTestDto, Runnable> onSavedPathogenTest, CaseReferenceDto associatedCase, boolean suppressSampleResultUpdatePopup, boolean suppressNavigateToCase) {
    // Negative test result AND test result verified
    // a) Tested disease == case disease AND test result != sample pathogen test result: Ask user whether to update the sample pathogen test result
    // b) Tested disease != case disease: Do nothing
    // Positive test result AND test result verified
    // a) Tested disease == case disease: Ask user whether to update the sample pathogen test result
    // a.1) Tested disease variant != case disease variant: Ask user to change the case disease variant
    // a.2) Case classification != confirmed: Ask user whether to confirm the case
    // b) Tested disease != case disease: Ask user to create a new case for the tested disease
    CaseDataDto caze = FacadeProvider.getCaseFacade().getCaseDataByUuid(associatedCase.getUuid());
    final boolean equalDisease = dto.getTestedDisease() == caze.getDisease();
    Runnable callback = () -> {
        if (equalDisease && PathogenTestResultType.NEGATIVE.equals(dto.getTestResult()) && dto.getTestResultVerified() && !suppressSampleResultUpdatePopup) {
            showChangeAssociatedSampleResultDialog(dto, null);
        } else if (PathogenTestResultType.POSITIVE.equals(dto.getTestResult()) && dto.getTestResultVerified()) {
            if (equalDisease && suppressSampleResultUpdatePopup) {
                checkForDiseaseVariantUpdate(dto, caze, suppressNavigateToCase, this::showConfirmCaseDialog);
            } else if (equalDisease) {
                showChangeAssociatedSampleResultDialog(dto, (accepted) -> {
                    if (accepted) {
                        checkForDiseaseVariantUpdate(dto, caze, suppressNavigateToCase, this::showConfirmCaseDialog);
                    }
                });
            } else {
                showCaseCloningWithNewDiseaseDialog(caze, dto.getTestedDisease(), dto.getTestedDiseaseDetails(), dto.getTestedDiseaseVariant(), dto.getTestedDiseaseVariantDetails());
            }
        }
    };
    if (onSavedPathogenTest != null) {
        onSavedPathogenTest.accept(dto, callback);
    } else {
        callback.run();
    }
}
Also used : TRAY_NOTIFICATION(com.vaadin.ui.Notification.Type.TRAY_NOTIFICATION) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) UI(com.vaadin.ui.UI) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) Window(com.vaadin.ui.Window) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) SampleReferenceDto(de.symeda.sormas.api.sample.SampleReferenceDto) Notification(com.vaadin.ui.Notification) SormasUI(de.symeda.sormas.ui.SormasUI) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) Label(com.vaadin.ui.Label) BiConsumer(java.util.function.BiConsumer) CountryHelper(de.symeda.sormas.api.CountryHelper) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) UserProvider(de.symeda.sormas.ui.UserProvider) DataHelper(de.symeda.sormas.api.utils.DataHelper) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) EventDto(de.symeda.sormas.api.event.EventDto) Captions(de.symeda.sormas.api.i18n.Captions) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) Consumer(java.util.function.Consumer) UserRight(de.symeda.sormas.api.user.UserRight) List(java.util.List) Disease(de.symeda.sormas.api.Disease) PathogenTestFacade(de.symeda.sormas.api.sample.PathogenTestFacade) PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) SampleDto(de.symeda.sormas.api.sample.SampleDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) Strings(de.symeda.sormas.api.i18n.Strings) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto)

Example 18 with Disease

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

the class PathogenTestController method handleAssociatedEventParticipant.

private void handleAssociatedEventParticipant(PathogenTestDto dto, BiConsumer<PathogenTestDto, Runnable> onSavedPathogenTest, EventParticipantReferenceDto associatedEventParticipant, boolean suppressSampleResultUpdatePopup) {
    // Negative test result AND test result verified
    // a) Tested disease == event disease AND test result != sample pathogen test result: Ask user whether to update the sample pathogen test result
    // b) Tested disease != event disease: Do nothing
    // Positive test result AND test result verified
    // a) Tested disease == event disease: Ask user to create a case linked to the event participant
    // a.1) If a case is created, update the sample pathogen test result
    // a.2) If no case is created (or there already is an existing case), ask user whether to update the sample pathogen test result
    // b) Tested disease != event disease: Ask user to create a case for the event participant person
    // b.1) If the event has no disease and a case is created, update the sample pathogen test result
    // b.2) If the event has no disease and no case is created, ask user whether to update the sample pathogen test result
    final EventParticipantDto eventParticipant = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(associatedEventParticipant.getUuid());
    final Disease eventDisease = FacadeProvider.getEventFacade().getEventByUuid(eventParticipant.getEvent().getUuid(), false).getDisease();
    final boolean equalDisease = eventDisease != null && eventDisease.equals(dto.getTestedDisease());
    Runnable callback = () -> {
        if (equalDisease && PathogenTestResultType.NEGATIVE.equals(dto.getTestResult()) && dto.getTestResultVerified() && !suppressSampleResultUpdatePopup) {
            showChangeAssociatedSampleResultDialog(dto, null);
        } else if (PathogenTestResultType.POSITIVE.equals(dto.getTestResult()) && dto.getTestResultVerified()) {
            if (equalDisease) {
                if (eventParticipant.getResultingCase() == null) {
                    showConvertEventParticipantToCaseDialog(eventParticipant, dto.getTestedDisease(), caseCreated -> {
                        handleCaseCreationFromContactOrEventParticipant(caseCreated, dto);
                    });
                } else if (!suppressSampleResultUpdatePopup) {
                    showChangeAssociatedSampleResultDialog(dto, null);
                }
            } else {
                showConvertEventParticipantToCaseDialog(eventParticipant, dto.getTestedDisease(), caseCreated -> {
                    if (eventDisease == null) {
                        handleCaseCreationFromContactOrEventParticipant(caseCreated, dto);
                    }
                });
            }
        }
    };
    if (onSavedPathogenTest != null) {
        onSavedPathogenTest.accept(dto, callback);
    } else {
        callback.run();
    }
}
Also used : Disease(de.symeda.sormas.api.Disease) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto)

Example 19 with Disease

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

the class FeatureConfigurationDao method getDiseasesWithLineListing.

public List<Disease> getDiseasesWithLineListing() {
    StringBuilder queryBuilder = new StringBuilder();
    queryBuilder.append("SELECT ").append(FeatureConfiguration.DISEASE).append(" FROM ").append(getTableName()).append(" WHERE ").append(FeatureConfiguration.FEATURE_TYPE).append(" = '").append(FeatureType.LINE_LISTING).append("'").append(" AND ").append(FeatureConfiguration.END_DATE).append(" <= '").append(DateHelper.getStartOfDay(new Date())).append("'");
    GenericRawResults<Object[]> rawResult = queryRaw(queryBuilder.toString(), new DataType[] { DataType.ENUM_STRING });
    List<Disease> diseases = new ArrayList<>();
    for (Object[] result : rawResult) {
        diseases.add(Disease.valueOf((String) result[0]));
    }
    return diseases;
}
Also used : Disease(de.symeda.sormas.api.Disease) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 20 with Disease

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

the class EventDao method build.

@Override
public Event build() {
    Event event = super.build();
    event.setReportDateTime(new Date());
    event.setReportingUser(ConfigProvider.getUser());
    event.getEventLocation().setRegion(ConfigProvider.getUser().getRegion());
    event.getEventLocation().setDistrict(ConfigProvider.getUser().getDistrict());
    event.setEventStatus(EventStatus.SIGNAL);
    event.setEventInvestigationStatus(EventInvestigationStatus.PENDING);
    Disease defaultDisease = DiseaseConfigurationCache.getInstance().getDefaultDisease();
    if (defaultDisease != null) {
        event.setDisease(defaultDisease);
    }
    return event;
}
Also used : Disease(de.symeda.sormas.api.Disease) Date(java.util.Date)

Aggregations

Disease (de.symeda.sormas.api.Disease)106 Date (java.util.Date)46 List (java.util.List)39 ArrayList (java.util.ArrayList)34 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)32 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)32 Collectors (java.util.stream.Collectors)29 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)26 Arrays (java.util.Arrays)25 Collections (java.util.Collections)25 UserRole (de.symeda.sormas.api.user.UserRole)24 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)23 DateHelper (de.symeda.sormas.api.utils.DateHelper)23 Map (java.util.Map)23 Label (com.vaadin.ui.Label)20 Strings (de.symeda.sormas.api.i18n.Strings)20 StringUtils (org.apache.commons.lang3.StringUtils)19 ContactDto (de.symeda.sormas.api.contact.ContactDto)18 District (de.symeda.sormas.backend.infrastructure.district.District)18 CollectionUtils (org.apache.commons.collections.CollectionUtils)18