use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventFacadeEjbTest method testEventCriteriaChangedSinceLastShareWithReportingTool.
@Test
public void testEventCriteriaChangedSinceLastShareWithReportingTool() {
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, UserRole.NATIONAL_USER);
EventDto sharedEvent = creator.createEvent(user.toReference());
ExternalShareInfo shareInfo = new ExternalShareInfo();
shareInfo.setCreationDate(Timestamp.valueOf(LocalDateTime.of(2021, Month.APRIL, 20, 12, 31)));
shareInfo.setEvent(getEventService().getByUuid(sharedEvent.getUuid()));
shareInfo.setSender(getUserService().getByUuid(user.getUuid()));
shareInfo.setStatus(ExternalShareStatus.DELETED);
getExternalShareInfoService().ensurePersisted(shareInfo);
sharedEvent.setEventDesc("Dummy description");
getEventFacade().save(sharedEvent);
creator.createEvent(user.toReference());
creator.createEvent(user.toReference());
EventCriteria eventCriteriaForShared = new EventCriteria();
eventCriteriaForShared.setOnlyEntitiesChangedSinceLastSharedWithExternalSurvTool(true);
List<EventIndexDto> indexList = getEventFacade().getIndexList(eventCriteriaForShared, 0, 100, null);
MatcherAssert.assertThat(indexList, hasSize(1));
MatcherAssert.assertThat(indexList.get(0).getUuid(), is(sharedEvent.getUuid()));
}
use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.
the class DashboardFacadeEjb method getDiseaseBurden.
@Override
public List<DiseaseBurdenDto> getDiseaseBurden(RegionReferenceDto region, DistrictReferenceDto district, Date fromDate, Date toDate, Date previousFromDate, Date previousToDate, CriteriaDateType newCaseDateType) {
// diseases
List<Disease> diseases = diseaseConfigurationFacade.getAllDiseases(true, true, true);
// new cases
DashboardCriteria dashboardCriteria = new DashboardCriteria().region(region).district(district).newCaseDateType(newCaseDateType).dateBetween(fromDate, toDate);
Map<Disease, Long> newCases = dashboardService.getCaseCountByDisease(dashboardCriteria);
// events
Map<Disease, Long> events = eventFacade.getEventCountByDisease(new EventCriteria().region(region).district(district).eventDateType(null).eventDateBetween(fromDate, toDate));
// outbreaks
Map<Disease, Long> outbreakDistrictsCount;
if (featureConfigurationFacade.isFeatureEnabled(FeatureType.OUTBREAKS)) {
outbreakDistrictsCount = outbreakFacade.getOutbreakDistrictCountByDisease(new OutbreakCriteria().region(region).district(district).reportedBetween(fromDate, toDate));
} else {
outbreakDistrictsCount = new HashMap<>();
}
// last report district
Map<Disease, District> lastReportedDistricts = dashboardService.getLastReportedDistrictByDisease(dashboardCriteria);
// case fatalities
Map<Disease, Long> caseFatalities = dashboardService.getDeathCountByDisease(dashboardCriteria);
// previous cases
dashboardCriteria.dateBetween(previousFromDate, previousToDate);
Map<Disease, Long> previousCases = dashboardService.getCaseCountByDisease(dashboardCriteria);
// build diseasesBurden
List<DiseaseBurdenDto> diseasesBurden = diseases.stream().map(disease -> {
Long caseCount = newCases.getOrDefault(disease, 0L);
Long previousCaseCount = previousCases.getOrDefault(disease, 0L);
Long eventCount = events.getOrDefault(disease, 0L);
Long outbreakDistrictCount = outbreakDistrictsCount.getOrDefault(disease, 0L);
Long caseFatalityCount = caseFatalities.getOrDefault(disease, 0L);
District lastReportedDistrict = lastReportedDistricts.getOrDefault(disease, null);
String lastReportedDistrictName = lastReportedDistrict == null ? "" : lastReportedDistrict.getName();
return new DiseaseBurdenDto(disease, caseCount, previousCaseCount, eventCount, outbreakDistrictCount, caseFatalityCount, lastReportedDistrictName);
}).collect(Collectors.toList());
return diseasesBurden;
}
use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventDataView method initView.
@Override
protected void initView(String params) {
EventDto event = FacadeProvider.getEventFacade().getEventByUuid(getEventRef().getUuid(), false);
setHeightUndefined();
String htmlLayout = LayoutUtil.fluidRow(LayoutUtil.fluidColumnLoc(8, 0, 12, 0, EVENT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, TASKS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, ACTIONS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 12, 0, DOCUMENTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, EventDocumentsComponent.DOCGENERATION_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SUPERORDINATE_EVENT_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SUBORDINATE_EVENTS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, EVENT_GROUPS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SORMAS_TO_SORMAS_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, ExternalSurveillanceServiceGateway.EXTERANEL_SURVEILLANCE_TOOL_GATEWAY_LOC), LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SHORTCUT_LINKS_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);
editComponent = ControllerProvider.getEventController().getEventDataEditComponent(getEventRef().getUuid(), this::setExternalSurvToolLayoutVisibility);
editComponent.setMargin(false);
editComponent.setWidth(100, Unit.PERCENTAGE);
editComponent.getWrappedComponent().setWidth(100, Unit.PERCENTAGE);
editComponent.addStyleName(CssStyles.MAIN_COMPONENT);
layout.addComponent(editComponent, EVENT_LOC);
externalSurvToolLayout = ExternalSurveillanceServiceGateway.addComponentToLayout(layout, editComponent, event);
setExternalSurvToolLayoutVisibility(event.getEventStatus());
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.TASK_MANAGEMENT)) {
TaskListComponent taskList = new TaskListComponent(TaskContext.EVENT, getEventRef(), event.getDisease());
taskList.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(taskList, TASKS_LOC);
}
ActionStatsComponent actionList = new ActionStatsComponent(ActionContext.EVENT, getEventRef());
actionList.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(actionList, ACTIONS_LOC);
DocumentListComponent documentList = null;
if (FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.DOCUMENTS)) {
// TODO: user rights?
documentList = new DocumentListComponent(DocumentRelatedEntityType.EVENT, getEventRef(), UserRight.EVENT_EDIT, event.isPseudonymized());
layout.addComponent(new SideComponentLayout(documentList), DOCUMENTS_LOC);
}
EventDocumentsComponent eventDocuments = new EventDocumentsComponent(getEventRef(), documentList);
eventDocuments.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(eventDocuments, EventDocumentsComponent.DOCGENERATION_LOC);
boolean eventHierarchiesFeatureEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_HIERARCHIES);
if (eventHierarchiesFeatureEnabled) {
SuperordinateEventComponent superordinateEventComponent = new SuperordinateEventComponent(event, () -> editComponent.discard());
superordinateEventComponent.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(superordinateEventComponent, SUPERORDINATE_EVENT_LOC);
EventListComponent subordinateEventList = new EventListComponent(event.toReference());
subordinateEventList.addStyleName(CssStyles.SIDE_COMPONENT);
layout.addComponent(subordinateEventList, SUBORDINATE_EVENTS_LOC);
}
boolean eventGroupsFeatureEnabled = FacadeProvider.getFeatureConfigurationFacade().isFeatureEnabled(FeatureType.EVENT_GROUPS);
if (eventGroupsFeatureEnabled) {
EventReferenceDto eventReference = event.toReference();
EventGroupListComponent eventGroupsList = new EventGroupListComponent(eventReference);
eventGroupsList.addSideComponentCreateEventListener(e -> showNavigationConfirmPopupIfDirty(() -> {
EventDto eventByUuid = FacadeProvider.getEventFacade().getEventByUuid(eventReference.getUuid(), false);
UserProvider user = UserProvider.getCurrent();
if (!user.hasNationalJurisdictionLevel() && !user.hasRegion(eventByUuid.getEventLocation().getRegion())) {
new Notification(I18nProperties.getString(Strings.headingEventGroupLinkEventIssue), I18nProperties.getString(Strings.errorEventFromAnotherJurisdiction), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
return;
}
EventGroupCriteria eventGroupCriteria = new EventGroupCriteria();
Set<String> eventGroupUuids = FacadeProvider.getEventGroupFacade().getCommonEventGroupsByEvents(Collections.singletonList(eventByUuid.toReference())).stream().map(EventGroupReferenceDto::getUuid).collect(Collectors.toSet());
eventGroupCriteria.setExcludedUuids(eventGroupUuids);
if (user.hasUserRight(UserRight.EVENTGROUP_CREATE) && user.hasUserRight(UserRight.EVENTGROUP_LINK)) {
long events = FacadeProvider.getEventGroupFacade().count(eventGroupCriteria);
if (events > 0) {
ControllerProvider.getEventGroupController().selectOrCreate(eventReference);
} else {
ControllerProvider.getEventGroupController().create(eventReference);
}
} else if (user.hasUserRight(UserRight.EVENTGROUP_CREATE)) {
ControllerProvider.getEventGroupController().create(eventReference);
} else {
long events = FacadeProvider.getEventGroupFacade().count(eventGroupCriteria);
if (events > 0) {
ControllerProvider.getEventGroupController().select(eventReference);
} else {
new Notification(I18nProperties.getString(Strings.headingEventGroupLinkEventIssue), I18nProperties.getString(Strings.errorNotRequiredRights), Notification.Type.ERROR_MESSAGE, false).show(Page.getCurrent());
}
}
}));
layout.addComponent(new SideComponentLayout(eventGroupsList), EVENT_GROUPS_LOC);
}
boolean sormasToSormasEnabled = FacadeProvider.getSormasToSormasFacade().isSharingEventsEnabledForUser();
if (sormasToSormasEnabled || event.getSormasToSormasOriginInfo() != null) {
VerticalLayout sormasToSormasLocLayout = new VerticalLayout();
sormasToSormasLocLayout.setMargin(false);
sormasToSormasLocLayout.setSpacing(false);
SormasToSormasListComponent sormasToSormasListComponent = new SormasToSormasListComponent(event, sormasToSormasEnabled);
sormasToSormasListComponent.addStyleNames(CssStyles.SIDE_COMPONENT);
sormasToSormasLocLayout.addComponent(sormasToSormasListComponent);
layout.addComponent(sormasToSormasLocLayout, SORMAS_TO_SORMAS_LOC);
}
VerticalLayout shortcutLinksLayout = new VerticalLayout();
shortcutLinksLayout.setMargin(false);
shortcutLinksLayout.setSpacing(true);
if (UserProvider.getCurrent().hasUserRight(UserRight.CASE_VIEW)) {
Button seeEventCasesBtn = ButtonHelper.createButton("eventLinkToCases", I18nProperties.getCaption(Captions.eventLinkToCases), thisEvent -> ControllerProvider.getCaseController().navigateTo(new CaseCriteria().eventLike(getEventRef().getUuid())), ValoTheme.BUTTON_PRIMARY);
shortcutLinksLayout.addComponent(seeEventCasesBtn);
}
if (UserProvider.getCurrent().hasUserRight(UserRight.CONTACT_VIEW)) {
Button seeEventContactsBtn = ButtonHelper.createButton("eventLinkToContacts", I18nProperties.getCaption(Captions.eventLinkToContacts), thisEvent -> ControllerProvider.getContactController().navigateTo(new ContactCriteria().eventUuid(getEventRef().getUuid())), ValoTheme.BUTTON_PRIMARY);
shortcutLinksLayout.addComponent(seeEventContactsBtn);
}
LocationDto eventLocationDto = ((EventDataForm) editComponent.getWrappedComponent()).getValue().getEventLocation();
if (eventLocationDto.getFacility() != null) {
Button seeEventsWithinTheSameFacility = ButtonHelper.createButton("eventLinkToEventsWithinTheSameFacility", I18nProperties.getCaption(Captions.eventLinkToEventsWithinTheSameFacility), thisEvent -> ControllerProvider.getEventController().navigateTo(new EventCriteria().region(eventLocationDto.getRegion()).district(eventLocationDto.getDistrict()).eventCommunity(eventLocationDto.getCommunity()).typeOfPlace(TypeOfPlace.FACILITY).facilityType(eventLocationDto.getFacilityType()).facility(eventLocationDto.getFacility())), ValoTheme.BUTTON_PRIMARY);
shortcutLinksLayout.addComponent(seeEventsWithinTheSameFacility);
}
layout.addComponent(shortcutLinksLayout, SHORTCUT_LINKS_LOC);
setEventEditPermission(container);
}
use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventController method selectOrCreateEvent.
public void selectOrCreateEvent(ContactDto contact) {
EventSelectionField eventSelect = new EventSelectionField(contact.getDisease(), I18nProperties.getString(Strings.infoPickOrCreateEventForContact), null);
eventSelect.setWidth(1100, Sizeable.Unit.PIXELS);
final CommitDiscardWrapperComponent<EventSelectionField> component = new CommitDiscardWrapperComponent<>(eventSelect);
component.addCommitListener(() -> {
EventIndexDto selectedEvent = eventSelect.getValue();
if (selectedEvent != null) {
EventCriteria eventCriteria = new EventCriteria();
eventCriteria.setPerson(contact.getPerson());
eventCriteria.setUserFilterIncluded(false);
List<EventIndexDto> eventIndexDto = FacadeProvider.getEventFacade().getIndexList(eventCriteria, null, null, null);
EventReferenceDto eventReferenceDto = new EventReferenceDto(selectedEvent.getUuid());
if (!eventIndexDto.contains(selectedEvent)) {
createEventParticipantWithContact(eventReferenceDto, contact);
}
} else {
create(contact);
}
SormasUI.refreshView();
});
eventSelect.setSelectionChangeCallback((commitAllowed) -> {
component.getCommitButton().setEnabled(commitAllowed);
});
VaadinUiUtil.showModalPopupWindow(component, I18nProperties.getString(Strings.headingPickOrCreateEvent));
}
use of de.symeda.sormas.api.event.EventCriteria in project SORMAS-Project by hzi-braunschweig.
the class EventsFilterForm method onApplyClick.
private void onApplyClick(EpiWeekAndDateFilterComponent<?> weekAndDateFilter, EventCriteria.DateType dateType) {
EventCriteria criteria = getValue();
DateFilterOption dateFilterOption = (DateFilterOption) weekAndDateFilter.getDateFilterOptionFilter().getValue();
CriteriaDateType eventDateType = (CriteriaDateType) weekAndDateFilter.getDateTypeSelector().getValue();
Date fromDate, toDate;
if (dateFilterOption == DateFilterOption.DATE) {
Date dateFrom = weekAndDateFilter.getDateFromFilter().getValue();
fromDate = dateFrom != null ? DateHelper.getStartOfDay(dateFrom) : null;
Date dateTo = weekAndDateFilter.getDateToFilter().getValue();
toDate = dateTo != null ? DateHelper.getEndOfDay(dateTo) : null;
} else {
fromDate = DateHelper.getEpiWeekStart((EpiWeek) weekAndDateFilter.getWeekFromFilter().getValue());
toDate = DateHelper.getEpiWeekEnd((EpiWeek) weekAndDateFilter.getWeekToFilter().getValue());
}
if ((fromDate != null && toDate != null) || (fromDate == null && toDate == null)) {
criteria.dateBetween(dateType, fromDate, toDate, eventDateType, dateFilterOption);
} else {
weekAndDateFilter.setNotificationsForMissingFilters();
}
}
Aggregations