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