Search in sources :

Example 1 with SimilarContactDto

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

the class CaseController method convertSamePersonContactsAndEventparticipants.

private void convertSamePersonContactsAndEventparticipants(CaseDataDto caze, Date relevantDate) {
    ContactSimilarityCriteria contactCriteria = new ContactSimilarityCriteria().withPerson(caze.getPerson()).withDisease(caze.getDisease()).withContactClassification(ContactClassification.CONFIRMED).withExcludePseudonymized(true).withNoResultingCase(true);
    List<SimilarContactDto> matchingContacts = FacadeProvider.getContactFacade().getMatchingContacts(contactCriteria);
    EventParticipantCriteria eventParticipantCriteria = new EventParticipantCriteria().withPerson(caze.getPerson()).withDisease(caze.getDisease()).withExcludePseudonymized(true).withNoResultingCase(true);
    List<SimilarEventParticipantDto> matchingEventParticipants = FacadeProvider.getEventParticipantFacade().getMatchingEventParticipants(eventParticipantCriteria);
    if (matchingContacts.size() > 0 || matchingEventParticipants.size() > 0) {
        String infoText = matchingEventParticipants.isEmpty() ? String.format(I18nProperties.getString(Strings.infoConvertToCaseContacts), matchingContacts.size(), caze.getDisease()) : (matchingContacts.isEmpty() ? String.format(I18nProperties.getString(Strings.infoConvertToCaseEventParticipants), matchingEventParticipants.size(), caze.getDisease()) : String.format(I18nProperties.getString(Strings.infoConvertToCaseContactsAndEventParticipants), matchingContacts.size(), caze.getDisease(), matchingEventParticipants.size(), caze.getDisease()));
        HorizontalLayout infoComponent = VaadinUiUtil.createInfoComponent(infoText);
        infoComponent.setWidth(600, Sizeable.Unit.PIXELS);
        CommitDiscardWrapperComponent<HorizontalLayout> convertToCaseConfirmComponent = new CommitDiscardWrapperComponent<>(infoComponent);
        convertToCaseConfirmComponent.getCommitButton().setCaption(I18nProperties.getCaption(Captions.actionYesForAll));
        convertToCaseConfirmComponent.getDiscardButton().setCaption(I18nProperties.getCaption(Captions.actionNo));
        convertToCaseConfirmComponent.addCommitListener(() -> {
            CaseDataDto refreshedCaze = FacadeProvider.getCaseFacade().getCaseDataByUuid(caze.getUuid());
            refreshedCaze.getEpiData().setContactWithSourceCaseKnown(YesNoUnknown.YES);
            saveCase(refreshedCaze);
            setResultingCase(refreshedCaze, matchingContacts, matchingEventParticipants);
            SormasUI.refreshView();
        });
        Button convertSomeButton = ButtonHelper.createButton("convertSome", I18nProperties.getCaption(Captions.actionYesForSome), (Button.ClickListener) event -> {
            convertToCaseConfirmComponent.discard();
            showConvertToCaseSelection(caze, matchingContacts, matchingEventParticipants);
        }, ValoTheme.BUTTON_PRIMARY);
        HorizontalLayout buttonsPanel = convertToCaseConfirmComponent.getButtonsPanel();
        buttonsPanel.addComponent(convertSomeButton, convertToCaseConfirmComponent.getComponentCount() - 1);
        buttonsPanel.setComponentAlignment(convertSomeButton, Alignment.BOTTOM_RIGHT);
        buttonsPanel.setExpandRatio(convertSomeButton, 0);
        VaadinUiUtil.showModalPopupWindow(convertToCaseConfirmComponent, I18nProperties.getString(Strings.headingCaseConversion));
    }
}
Also used : Alignment(com.vaadin.ui.Alignment) CaseSimilarityCriteria(de.symeda.sormas.api.caze.CaseSimilarityCriteria) StringUtils(org.apache.commons.lang3.StringUtils) PersonDto(de.symeda.sormas.api.person.PersonDto) ClinicalCourseForm(de.symeda.sormas.ui.clinicalcourse.ClinicalCourseForm) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) MaternalHistoryView(de.symeda.sormas.ui.caze.maternalhistory.MaternalHistoryView) CssStyles(de.symeda.sormas.ui.utils.CssStyles) Page(com.vaadin.server.Page) PortHealthInfoView(de.symeda.sormas.ui.caze.porthealthinfo.PortHealthInfoView) TextArea(com.vaadin.ui.TextArea) ValoTheme(com.vaadin.ui.themes.ValoTheme) DiseaseHelper(de.symeda.sormas.api.DiseaseHelper) Link(com.vaadin.ui.Link) HtmlHelper(de.symeda.sormas.api.utils.HtmlHelper) EpiDataForm(de.symeda.sormas.ui.epidata.EpiDataForm) Type(com.vaadin.ui.Notification.Type) CaseLogic(de.symeda.sormas.api.caze.CaseLogic) DateHelper8(de.symeda.sormas.ui.utils.DateHelper8) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) MaternalHistoryForm(de.symeda.sormas.ui.caze.maternalhistory.MaternalHistoryForm) CloseEvent(com.vaadin.ui.Window.CloseEvent) ExternalSurveillanceToolException(de.symeda.sormas.api.externalsurveillancetool.ExternalSurveillanceToolException) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) VerticalLayout(com.vaadin.ui.VerticalLayout) EventParticipantCriteria(de.symeda.sormas.api.event.EventParticipantCriteria) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) SymptomsContext(de.symeda.sormas.api.symptoms.SymptomsContext) ArrayList(java.util.ArrayList) ClassificationHtmlRenderer(de.symeda.sormas.api.caze.classification.ClassificationHtmlRenderer) ExternalSurveillanceServiceGateway(de.symeda.sormas.ui.externalsurveillanceservice.ExternalSurveillanceServiceGateway) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) CountryHelper(de.symeda.sormas.api.CountryHelper) SimilarEventParticipantDto(de.symeda.sormas.api.event.SimilarEventParticipantDto) TitleLayout(de.symeda.sormas.ui.utils.components.page.title.TitleLayout) ContactSimilarityCriteria(de.symeda.sormas.api.contact.ContactSimilarityCriteria) ContentMode(com.vaadin.shared.ui.ContentMode) MessageType(de.symeda.sormas.api.messaging.MessageType) DataHelper(de.symeda.sormas.api.utils.DataHelper) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) CaseFacade(de.symeda.sormas.api.caze.CaseFacade) ContactLogic(de.symeda.sormas.api.contact.ContactLogic) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) SymptomsHelper(de.symeda.sormas.api.symptoms.SymptomsHelper) Captions(de.symeda.sormas.api.i18n.Captions) LineListingLayout(de.symeda.sormas.ui.caze.components.linelisting.LineListingLayout) AutomaticDeletionInfoDto(de.symeda.sormas.api.deletionconfiguration.AutomaticDeletionInfoDto) Button(com.vaadin.ui.Button) CaseBulkEditData(de.symeda.sormas.api.caze.CaseBulkEditData) Disease(de.symeda.sormas.api.Disease) VisitDto(de.symeda.sormas.api.visit.VisitDto) HorizontalLayout(com.vaadin.ui.HorizontalLayout) DiseaseClassificationCriteriaDto(de.symeda.sormas.api.caze.classification.DiseaseClassificationCriteriaDto) FeatureType(de.symeda.sormas.api.feature.FeatureType) CaseSelectionDto(de.symeda.sormas.api.caze.CaseSelectionDto) AutomaticDeletionLabel(de.symeda.sormas.ui.utils.components.automaticdeletion.AutomaticDeletionLabel) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) UI(com.vaadin.ui.UI) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto) Window(com.vaadin.ui.Window) SymptomsForm(de.symeda.sormas.ui.symptoms.SymptomsForm) DetailSubComponentWrapper(de.symeda.sormas.ui.utils.DetailSubComponentWrapper) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) SmsComponent(de.symeda.sormas.ui.caze.messaging.SmsComponent) ViewModelProviders(de.symeda.sormas.ui.ViewModelProviders) CaseEpiDataView(de.symeda.sormas.ui.epidata.CaseEpiDataView) UserRole(de.symeda.sormas.api.user.UserRole) UserProvider(de.symeda.sormas.ui.UserProvider) PointOfEntryDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryDto) CloseListener(com.vaadin.ui.Window.CloseListener) ViewMode(de.symeda.sormas.ui.utils.ViewMode) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) Collection(java.util.Collection) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) EventDto(de.symeda.sormas.api.event.EventDto) Collectors(java.util.stream.Collectors) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) Objects(java.util.Objects) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) List(java.util.List) ExternalResource(com.vaadin.server.ExternalResource) TherapyView(de.symeda.sormas.ui.therapy.TherapyView) ContactDto(de.symeda.sormas.api.contact.ContactDto) Optional(java.util.Optional) UiFieldAccessCheckers(de.symeda.sormas.api.utils.fieldaccess.UiFieldAccessCheckers) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) DateHelper(de.symeda.sormas.api.utils.DateHelper) CollectionUtils(org.apache.commons.collections.CollectionUtils) Notification(com.vaadin.ui.Notification) SormasUI(de.symeda.sormas.ui.SormasUI) Label(com.vaadin.ui.Label) TitleLayoutHelper(de.symeda.sormas.ui.utils.components.page.title.TitleLayoutHelper) HospitalizationForm(de.symeda.sormas.ui.hospitalization.HospitalizationForm) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) NullableOptionGroup(de.symeda.sormas.ui.utils.NullableOptionGroup) AbstractView(de.symeda.sormas.ui.utils.AbstractView) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) PortHealthInfoForm(de.symeda.sormas.ui.caze.porthealthinfo.PortHealthInfoForm) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) UserDto(de.symeda.sormas.api.user.UserDto) HospitalizationView(de.symeda.sormas.ui.hospitalization.HospitalizationView) Sizeable(com.vaadin.server.Sizeable) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) Consumer(java.util.function.Consumer) Navigator(com.vaadin.navigator.Navigator) UserReferenceDto(de.symeda.sormas.api.user.UserReferenceDto) UserRight(de.symeda.sormas.api.user.UserRight) TravelEntryDto(de.symeda.sormas.api.travelentry.TravelEntryDto) PointOfEntryReferenceDto(de.symeda.sormas.api.infrastructure.pointofentry.PointOfEntryReferenceDto) ClinicalCourseView(de.symeda.sormas.ui.clinicalcourse.ClinicalCourseView) HospitalizationDto(de.symeda.sormas.api.hospitalization.HospitalizationDto) Unit(com.vaadin.server.Sizeable.Unit) Strings(de.symeda.sormas.api.i18n.Strings) Component(com.vaadin.ui.Component) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Button(com.vaadin.ui.Button) EventParticipantCriteria(de.symeda.sormas.api.event.EventParticipantCriteria) ContactSimilarityCriteria(de.symeda.sormas.api.contact.ContactSimilarityCriteria) SimilarEventParticipantDto(de.symeda.sormas.api.event.SimilarEventParticipantDto)

Example 2 with SimilarContactDto

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

the class CaseController method setResultingCase.

private void setResultingCase(CaseDataDto caze, List<SimilarContactDto> matchingContacts, List<SimilarEventParticipantDto> matchingEventParticipants) {
    if (matchingContacts != null && !matchingContacts.isEmpty()) {
        List<String> contactUuids = matchingContacts.stream().map(SimilarContactDto::getUuid).collect(Collectors.toList());
        List<ContactDto> contacts = FacadeProvider.getContactFacade().getByUuids(contactUuids);
        for (ContactDto contact : contacts) {
            contact.setContactStatus(ContactStatus.CONVERTED);
            contact.setResultingCase(caze.toReference());
            contact.setResultingCaseUser(UserProvider.getCurrent().getUserReference());
            FacadeProvider.getContactFacade().save(contact);
        }
    }
    if (matchingEventParticipants != null && !matchingEventParticipants.isEmpty()) {
        List<String> eventParticipantUuids = matchingEventParticipants.stream().map(SimilarEventParticipantDto::getUuid).collect(Collectors.toList());
        List<EventParticipantDto> eventParticipants = FacadeProvider.getEventParticipantFacade().getByUuids(eventParticipantUuids);
        for (EventParticipantDto eventParticipant : eventParticipants) {
            eventParticipant.setResultingCase(caze.toReference());
            FacadeProvider.getEventParticipantFacade().saveEventParticipant(eventParticipant);
        }
    }
}
Also used : SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) ContactDto(de.symeda.sormas.api.contact.ContactDto) SimilarEventParticipantDto(de.symeda.sormas.api.event.SimilarEventParticipantDto) EventParticipantDto(de.symeda.sormas.api.event.EventParticipantDto)

Example 3 with SimilarContactDto

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

the class LabMessageController method getSimilarContacts.

private List<SimilarContactDto> getSimilarContacts(LabMessageDto labMessage, PersonReferenceDto selectedPerson) {
    ContactSimilarityCriteria contactSimilarityCriteria = new ContactSimilarityCriteria();
    contactSimilarityCriteria.setPerson(selectedPerson);
    contactSimilarityCriteria.setDisease(labMessage.getTestedDisease());
    List<SimilarContactDto> similarContacts = FacadeProvider.getContactFacade().getMatchingContacts(contactSimilarityCriteria);
    return similarContacts;
}
Also used : SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto) ContactSimilarityCriteria(de.symeda.sormas.api.contact.ContactSimilarityCriteria)

Example 4 with SimilarContactDto

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

the class EntrySelectionField method getValue.

@Override
public SimilarEntriesDto getValue() {
    if (caseGrid != null && rbSelectCase.getValue() != null) {
        SimilarEntriesDto value = new SimilarEntriesDto();
        value.setCaze((CaseSelectionDto) caseGrid.getSelectedRow());
        return value;
    } else if (contactGrid != null && rbSelectContact.getValue() != null) {
        SimilarEntriesDto value = new SimilarEntriesDto();
        value.setContact((SimilarContactDto) contactGrid.getSelectedRow());
        return value;
    } else if (eventParticipantGrid != null && rbSelectEventParticipant.getValue() != null) {
        SimilarEntriesDto value = new SimilarEntriesDto();
        value.setEventParticipant((SimilarEventParticipantDto) eventParticipantGrid.getSelectedRow());
        return value;
    } else if (CREATE_CASE.equals(rbCreateEntity.getValue())) {
        SimilarEntriesDto value = new SimilarEntriesDto();
        value.setNewCase(true);
        return value;
    } else if (CREATE_CONTACT.equals(rbCreateEntity.getValue())) {
        SimilarEntriesDto value = new SimilarEntriesDto();
        value.setNewContact(true);
        return value;
    } else if (CREATE_EVENT_PARTICIPANT.equals(rbCreateEntity.getValue())) {
        SimilarEntriesDto value = new SimilarEntriesDto();
        value.setNewEventParticipant(true);
        return value;
    }
    return null;
}
Also used : SimilarEntriesDto(de.symeda.sormas.api.labmessage.SimilarEntriesDto) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto)

Example 5 with SimilarContactDto

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

the class ContactController method selectOrCreateContact.

public void selectOrCreateContact(final ContactDto contact, final PersonDto personDto, Consumer<String> resultConsumer) {
    ContactSelectionField contactSelect = new ContactSelectionField(contact, I18nProperties.getString(Strings.infoSelectOrCreateContact), personDto.getFirstName(), personDto.getLastName());
    contactSelect.setWidth(1024, Unit.PIXELS);
    if (contactSelect.hasMatches()) {
        // TODO add user right parameter
        final CommitDiscardWrapperComponent<ContactSelectionField> component = new CommitDiscardWrapperComponent<>(contactSelect);
        component.addCommitListener(() -> {
            final SimilarContactDto selectedContact = contactSelect.getValue();
            if (selectedContact != null) {
                if (resultConsumer != null) {
                    resultConsumer.accept(selectedContact.getUuid());
                }
            } else {
                createNewContact(contact, resultConsumer);
            }
        });
        contactSelect.setSelectionChangeCallback((commitAllowed) -> {
            component.getCommitButton().setEnabled(commitAllowed);
        });
        VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateContact));
        contactSelect.selectBestMatch();
    } else {
        createNewContact(contact, resultConsumer);
    }
}
Also used : CommitDiscardWrapperComponent(de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent) SimilarContactDto(de.symeda.sormas.api.contact.SimilarContactDto)

Aggregations

SimilarContactDto (de.symeda.sormas.api.contact.SimilarContactDto)13 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)5 ContactDto (de.symeda.sormas.api.contact.ContactDto)5 CommitDiscardWrapperComponent (de.symeda.sormas.ui.utils.CommitDiscardWrapperComponent)5 ContactSimilarityCriteria (de.symeda.sormas.api.contact.ContactSimilarityCriteria)4 SimilarEventParticipantDto (de.symeda.sormas.api.event.SimilarEventParticipantDto)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 EventParticipantDto (de.symeda.sormas.api.event.EventParticipantDto)3 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)3 Disease (de.symeda.sormas.api.Disease)2 CaseReferenceDto (de.symeda.sormas.api.caze.CaseReferenceDto)2 ContactClassification (de.symeda.sormas.api.contact.ContactClassification)2 PersonDto (de.symeda.sormas.api.person.PersonDto)2 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)2 Test (org.junit.Test)2 Navigator (com.vaadin.navigator.Navigator)1 ExternalResource (com.vaadin.server.ExternalResource)1 Page (com.vaadin.server.Page)1 Sizeable (com.vaadin.server.Sizeable)1