use of de.symeda.sormas.api.event.EventParticipantReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class SampleController method getDiseaseOf.
public Disease getDiseaseOf(SampleDto sample) {
CaseReferenceDto cazeRef = sample.getAssociatedCase();
if (cazeRef != null) {
return FacadeProvider.getCaseFacade().getByUuid(cazeRef.getUuid()).getDisease();
}
ContactReferenceDto contactRef = sample.getAssociatedContact();
if (contactRef != null) {
return FacadeProvider.getContactFacade().getByUuid(contactRef.getUuid()).getDisease();
}
EventParticipantReferenceDto eventPartRef = sample.getAssociatedEventParticipant();
if (eventPartRef != null) {
EventReferenceDto eventRef = FacadeProvider.getEventParticipantFacade().getByUuid(eventPartRef.getUuid()).getEvent();
if (eventRef != null) {
return FacadeProvider.getEventFacade().getEventByUuid(eventRef.getUuid(), false).getDisease();
}
}
return null;
}
use of de.symeda.sormas.api.event.EventParticipantReferenceDto 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);
}
use of de.symeda.sormas.api.event.EventParticipantReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class AbstractSampleView method refreshMenu.
@Override
public void refreshMenu(SubMenu menu, String params) {
if (!findReferenceByParams(params)) {
return;
}
menu.removeAllViews();
menu.addView(SamplesView.VIEW_NAME, I18nProperties.getCaption(Captions.sampleSamplesList));
final SampleDto sampleByUuid = FacadeProvider.getSampleFacade().getSampleByUuid(params);
final CaseReferenceDto caseRef = sampleByUuid.getAssociatedCase();
if (caseRef != null && UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
menu.addView(CaseDataView.VIEW_NAME, I18nProperties.getString(Strings.entityCase), caseRef.getUuid(), true);
}
final ContactReferenceDto contactRef = sampleByUuid.getAssociatedContact();
if (contactRef != null && UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW)) {
menu.addView(ContactDataView.VIEW_NAME, I18nProperties.getString(Strings.entityContact), contactRef.getUuid(), true);
}
EventParticipantReferenceDto eventParticipantRef = sampleByUuid.getAssociatedEventParticipant();
if (eventParticipantRef != null && UserProvider.getCurrent().hasUserRight(UserRight.EVENT_VIEW)) {
menu.addView(EventParticipantDataView.VIEW_NAME, I18nProperties.getString(Strings.entityEventParticipant), eventParticipantRef.getUuid(), true);
}
menu.addView(SampleDataView.VIEW_NAME, I18nProperties.getCaption(SampleDto.I18N_PREFIX), params);
setMainHeaderComponent(ControllerProvider.getSampleController().getSampleViewTitleLayout(sampleByUuid));
}
use of de.symeda.sormas.api.event.EventParticipantReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class EventController method linkCaseToEvent.
/**
* @return true if the person was already an event participant in the event, false if not
*/
public boolean linkCaseToEvent(EventReferenceDto eventReferenceDto, CaseDataDto caseDataDto, CaseReferenceDto caseRef) {
// Check whether Person is already enlisted as EventParticipant in this Event
EventParticipantReferenceDto eventParticipantRef = FacadeProvider.getEventParticipantFacade().getReferenceByEventAndPerson(eventReferenceDto.getUuid(), caseDataDto.getPerson().getUuid());
if (eventParticipantRef != null) {
EventParticipantDto eventParticipant = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(eventParticipantRef.getUuid());
eventParticipant.setResultingCase(caseRef);
FacadeProvider.getEventParticipantFacade().saveEventParticipant(eventParticipant);
Notification notification = new Notification(I18nProperties.getString(Strings.messagePersonAlreadyEventParticipant), "", Type.HUMANIZED_MESSAGE);
notification.setDelayMsec(10000);
notification.show(Page.getCurrent());
NotificationHelper.showNotification(I18nProperties.getString(Strings.messagePersonAlreadyEventParticipant), Type.HUMANIZED_MESSAGE, 10000);
return true;
}
// Create new EventParticipant for this Person
final PersonDto personDto = FacadeProvider.getPersonFacade().getPersonByUuid(caseDataDto.getPerson().getUuid());
final EventParticipantDto eventParticipantDto = new EventParticipantDto().buildFromCase(caseRef, personDto, eventReferenceDto, UserProvider.getCurrent().getUserReference());
ControllerProvider.getEventParticipantController().createEventParticipant(eventReferenceDto, r -> {
}, eventParticipantDto);
return false;
}
use of de.symeda.sormas.api.event.EventParticipantReferenceDto in project SORMAS-Project by hzi-braunschweig.
the class EventController method removeLinkCaseEventParticipant.
public void removeLinkCaseEventParticipant(EventDto event, CaseDataDto caseDataDto, String notificationMessage) {
EventParticipantReferenceDto eventParticipantRef = FacadeProvider.getEventParticipantFacade().getReferenceByEventAndPerson(event.getUuid(), caseDataDto.getPerson().getUuid());
EventParticipantDto eventParticipantDto = FacadeProvider.getEventParticipantFacade().getEventParticipantByUuid(eventParticipantRef.getUuid());
eventParticipantDto.setResultingCase(null);
FacadeProvider.getEventParticipantFacade().saveEventParticipant(eventParticipantDto);
Notification.show(notificationMessage, Type.TRAY_NOTIFICATION);
}
Aggregations