use of de.symeda.sormas.api.Disease in project SORMAS-Project by hzi-braunschweig.
the class DashboardMapComponent method loadMapData.
private void loadMapData(Date fromDate, Date toDate) {
RegionReferenceDto region = dashboardDataProvider.getRegion();
DistrictReferenceDto district = dashboardDataProvider.getDistrict();
Disease disease = dashboardDataProvider.getDisease();
if (showCases) {
showCaseMarkers(FacadeProvider.getCaseFacade().getCasesForMap(region, district, disease, fromDate, toDate, showCurrentEpiSituation ? null : dashboardDataProvider.getNewCaseDateType()));
}
if (showContacts) {
showContactMarkers(FacadeProvider.getContactFacade().getContactsForMap(region, district, disease, fromDate, toDate));
}
if (showEvents) {
showEventMarkers(dashboardDataProvider.getEvents());
}
// Re-create the map key layout to only show the keys for the selected layers
legendDropdown.setContent(createLegend());
}
use of de.symeda.sormas.api.Disease in project SORMAS-Project by hzi-braunschweig.
the class EventParticipantFacadeEjb method getMatchingEventParticipants.
@Override
public List<SimilarEventParticipantDto> getMatchingEventParticipants(EventParticipantCriteria criteria) {
final CriteriaBuilder cb = em.getCriteriaBuilder();
final CriteriaQuery<SimilarEventParticipantDto> cq = cb.createQuery(SimilarEventParticipantDto.class);
final Root<EventParticipant> eventParticipantRoot = cq.from(EventParticipant.class);
cq.distinct(true);
Join<Object, Object> personJoin = eventParticipantRoot.join(EventParticipant.PERSON, JoinType.LEFT);
Join<Object, Object> eventJoin = eventParticipantRoot.join(EventParticipant.EVENT, JoinType.LEFT);
Expression<Object> jurisdictionSelector = JurisdictionHelper.booleanSelector(cb, service.inJurisdictionOrOwned(new EventParticipantQueryContext(cb, cq, eventParticipantRoot)));
cq.multiselect(eventParticipantRoot.get(EventParticipant.UUID), personJoin.get(Person.FIRST_NAME), personJoin.get(Person.LAST_NAME), eventParticipantRoot.get(EventParticipant.INVOLVEMENT_DESCRIPTION), eventJoin.get(Event.UUID), eventJoin.get(Event.EVENT_STATUS), eventJoin.get(Event.EVENT_TITLE), eventJoin.get(Event.START_DATE), jurisdictionSelector);
cq.groupBy(eventParticipantRoot.get(EventParticipant.UUID), personJoin.get(Person.FIRST_NAME), personJoin.get(Person.LAST_NAME), eventParticipantRoot.get(EventParticipant.INVOLVEMENT_DESCRIPTION), eventJoin.get(Event.UUID), eventJoin.get(Event.EVENT_STATUS), eventJoin.get(Event.EVENT_TITLE), eventJoin.get(Event.START_DATE), jurisdictionSelector);
final Predicate defaultFilter = service.createDefaultFilter(cb, eventParticipantRoot);
final Predicate userFilter = service.createUserFilter(cb, cq, eventParticipantRoot);
final PersonReferenceDto person = criteria.getPerson();
final Predicate samePersonFilter = person != null ? cb.equal(personJoin.get(Person.UUID), person.getUuid()) : null;
final Disease disease = criteria.getDisease();
final Predicate diseaseFilter = disease != null ? cb.equal(eventJoin.get(Event.DISEASE), disease) : null;
final Date relevantDate = criteria.getRelevantDate();
final Predicate relevantDateFilter = CriteriaBuilderHelper.or(cb, contactService.recentDateFilter(cb, relevantDate, eventJoin.get(Event.START_DATE), 30), contactService.recentDateFilter(cb, relevantDate, eventJoin.get(Event.END_DATE), 30), contactService.recentDateFilter(cb, relevantDate, eventJoin.get(Event.REPORT_DATE_TIME), 30));
final Predicate noResulingCaseFilter = Boolean.TRUE.equals(criteria.getNoResultingCase()) ? cb.isNull(eventParticipantRoot.get(EventParticipant.RESULTING_CASE)) : null;
cq.where(CriteriaBuilderHelper.and(cb, defaultFilter, userFilter, samePersonFilter, diseaseFilter, relevantDateFilter, noResulingCaseFilter));
List<SimilarEventParticipantDto> participants = em.createQuery(cq).getResultList();
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight);
pseudonymizer.pseudonymizeDtoCollection(SimilarEventParticipantDto.class, participants, p -> p.getInJurisdiction(), null);
if (Boolean.TRUE.equals(criteria.getExcludePseudonymized())) {
participants = participants.stream().filter(e -> !e.isPseudonymized()).collect(Collectors.toList());
}
return participants;
}
use of de.symeda.sormas.api.Disease in project SORMAS-Project by hzi-braunschweig.
the class OutbreakFacadeEjbTest method testOutbreakCreationAndDeletion.
@Test
public void testOutbreakCreationAndDeletion() {
DistrictReferenceDto district = new DistrictReferenceDto(rdcf.district.getUuid(), null, null);
Disease disease = Disease.EVD;
getOutbreakFacade().startOutbreak(district, disease);
// outbreak should be active
assertNotNull(getOutbreakFacade().getActiveByDistrictAndDisease(district, disease));
getOutbreakFacade().endOutbreak(district, disease);
// Database should contain no outbreak
assertNull(getOutbreakFacade().getActiveByDistrictAndDisease(district, disease));
}
use of de.symeda.sormas.api.Disease in project SORMAS-Project by hzi-braunschweig.
the class ContactsDashboardStatisticsComponent method updateFirstComponent.
@Override
protected void updateFirstComponent(int visibleDiseasesCount) {
List<DashboardContactDto> contacts = dashboardDataProvider.getContacts();
List<DashboardContactDto> previousContacts = dashboardDataProvider.getPreviousContacts();
int contactsCount = contacts.size();
firstComponent.updateCountLabel(contactsCount);
int newContactsCount = (int) contacts.stream().filter(c -> c.getReportDate().after(dashboardDataProvider.getFromDate()) || c.getReportDate().equals(dashboardDataProvider.getFromDate())).count();
int newContactsPercentage = contactsCount == 0 ? 0 : (int) ((newContactsCount * 100.0f) / contactsCount);
int symptomaticContactsCount = (int) contacts.stream().filter(c -> Boolean.TRUE.equals(c.getSymptomatic())).count();
int symptomaticContactsPercentage = contactsCount == 0 ? 0 : (int) ((symptomaticContactsCount * 100.0f) / contactsCount);
int contactClassificationUnconfirmedCount = (int) contacts.stream().filter(c -> c.getContactClassification() == ContactClassification.UNCONFIRMED).count();
int contactClassificationUnconfirmedPercentage = contactsCount == 0 ? 0 : (int) ((contactClassificationUnconfirmedCount * 100.0f) / contactsCount);
int contactClassificationConfirmedCount = (int) contacts.stream().filter(c -> c.getContactClassification() == ContactClassification.CONFIRMED).count();
int contactClassificationConfirmedPercentage = contactsCount == 0 ? 0 : (int) ((contactClassificationConfirmedCount * 100.0f) / contactsCount);
int contactClassificationNotAContactCount = (int) contacts.stream().filter(c -> c.getContactClassification() == ContactClassification.NO_CONTACT).count();
int contactClassificationNotAContactPercentage = contactsCount == 0 ? 0 : (int) ((contactClassificationNotAContactCount * 100.0f) / contactsCount);
// Remove and re-create content layout if the disease filter has been applied or set to null
if (currentDisease == null && previousDisease != null) {
firstComponent.removeAllComponentsFromContent();
firstComponent.addComponentToContent(allContactsCountLayout);
} else if (currentDisease != null && previousDisease == null) {
firstComponent.removeAllComponentsFromContent();
firstComponent.addComponentToContent(contactClassificationUnconfirmedLarge);
firstComponent.addComponentToContent(contactClassificationConfirmedLarge);
firstComponent.addComponentToContent(contactClassificationNotAContactLarge);
firstComponent.addComponentToContent(newContactsLarge);
firstComponent.addComponentToContent(symptomaticContactsLarge);
}
if (currentDisease == null) {
// Remove all children of the content layout
firstComponent.removeAllComponentsFromContent();
firstComponent.addComponentToContent(allContactsCountLayout);
contactClassificationUnconfirmed.updateCountLabel(contactClassificationUnconfirmedCount + " (" + contactClassificationUnconfirmedPercentage + " %)");
contactClassificationConfirmed.updateCountLabel(contactClassificationConfirmedCount + " (" + contactClassificationConfirmedPercentage + " %)");
contactClassificationNotAContact.updateCountLabel(contactClassificationNotAContactCount + " (" + contactClassificationNotAContactPercentage + " %)");
newContacts.updateCountLabel(newContactsCount);
symptomaticContacts.updateCountLabel(symptomaticContactsCount + " (" + symptomaticContactsPercentage + " %)");
// Create a map with all diseases as keys and their respective case counts as values
Map<Disease, Integer> diseaseMap = new TreeMap<>();
for (Disease disease : FacadeProvider.getDiseaseConfigurationFacade().getAllDiseasesWithFollowUp()) {
diseaseMap.put(disease, (int) contacts.stream().filter(c -> c.getDisease() == disease).count());
}
// Create a list from this map that sorts the entries by case counts
List<Map.Entry<Disease, Integer>> sortedDiseaseList = createSortedDiseaseList(diseaseMap);
// Create a new StatisticsDiseaseElement for every disease, automatically sorting them by case count
for (int i = 0; i < (Math.min(visibleDiseasesCount, sortedDiseaseList.size())); i++) {
Map.Entry<Disease, Integer> mapEntry = sortedDiseaseList.get(i);
int previousDiseaseCount = (int) previousContacts.stream().filter(c -> c.getDisease() == mapEntry.getKey()).count();
DashboardStatisticsDiseaseElement diseaseElement = new DashboardStatisticsDiseaseElement(mapEntry.getKey().toString(), mapEntry.getValue(), previousDiseaseCount);
firstComponent.addComponentToContent(diseaseElement);
}
} else {
contactClassificationUnconfirmedLarge.updatePercentageValueWithCount(contactClassificationUnconfirmedCount, contactClassificationUnconfirmedPercentage);
contactClassificationConfirmedLarge.updatePercentageValueWithCount(contactClassificationConfirmedCount, contactClassificationConfirmedPercentage);
contactClassificationNotAContactLarge.updatePercentageValueWithCount(contactClassificationNotAContactCount, contactClassificationNotAContactPercentage);
newContactsLarge.updatePercentageValueWithCount(newContactsCount, newContactsPercentage);
symptomaticContactsLarge.updatePercentageValueWithCount(symptomaticContactsCount, symptomaticContactsPercentage);
}
}
use of de.symeda.sormas.api.Disease in project SORMAS-Project by hzi-braunschweig.
the class ContactsFilterForm method applyDependenciesOnNewValue.
@Override
protected void applyDependenciesOnNewValue(ContactCriteria newValue) {
final RegionReferenceDto region = newValue.getRegion();
final DistrictReferenceDto district = newValue.getDistrict();
applyRegionAndDistrictFilterDependency(region, ContactCriteria.DISTRICT, district, ContactCriteria.COMMUNITY);
final UserDto user = currentUserDto();
ComboBox officerField = getField(ContactCriteria.CONTACT_OFFICER);
if (user.getRegion() != null) {
officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(user.getRegion(), UserRole.CONTACT_OFFICER));
} else if (region != null) {
officerField.addItems(FacadeProvider.getUserFacade().getUsersByRegionAndRoles(region, UserRole.CONTACT_OFFICER));
} else {
officerField.removeAllItems();
}
ComboBox birthDateDD = getField(ContactCriteria.BIRTHDATE_DD);
if (getField(ContactCriteria.BIRTHDATE_YYYY).getValue() != null && getField(ContactCriteria.BIRTHDATE_MM).getValue() != null) {
birthDateDD.addItems(DateHelper.getDaysInMonth((Integer) getField(ContactCriteria.BIRTHDATE_MM).getValue(), (Integer) getField(ContactCriteria.BIRTHDATE_YYYY).getValue()));
birthDateDD.setEnabled(true);
} else {
birthDateDD.clear();
birthDateDD.setEnabled(false);
}
// Date/Epi week filter
HorizontalLayout dateFilterLayout = (HorizontalLayout) getMoreFiltersContainer().getComponent(WEEK_AND_DATE_FILTER);
@SuppressWarnings("unchecked") EpiWeekAndDateFilterComponent<NewCaseDateType> weekAndDateFilter = (EpiWeekAndDateFilterComponent<NewCaseDateType>) dateFilterLayout.getComponent(0);
ContactDateType contactDateType = newValue.getReportDateFrom() != null ? ContactDateType.REPORT_DATE : newValue.getLastContactDateFrom() != null ? ContactDateType.LAST_CONTACT_DATE : null;
weekAndDateFilter.getDateTypeSelector().setValue(contactDateType);
weekAndDateFilter.getDateFilterOptionFilter().setValue(newValue.getDateFilterOption());
Date dateFrom = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateFrom() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateFrom() : null;
Date dateTo = contactDateType == ContactDateType.REPORT_DATE ? newValue.getReportDateTo() : contactDateType == ContactDateType.LAST_CONTACT_DATE ? newValue.getLastContactDateTo() : null;
if (DateFilterOption.EPI_WEEK.equals(newValue.getDateFilterOption())) {
weekAndDateFilter.getWeekFromFilter().setValue(dateFrom == null ? null : DateHelper.getEpiWeek(dateFrom));
weekAndDateFilter.getWeekToFilter().setValue(dateTo == null ? null : DateHelper.getEpiWeek(dateTo));
} else {
weekAndDateFilter.getDateFromFilter().setValue(dateFrom);
weekAndDateFilter.getDateToFilter().setValue(dateTo);
}
if (StringUtils.isBlank(newValue.getEventLike())) {
clearAndDisableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
} else {
enableFields(ContactCriteria.ONLY_CONTACTS_SHARING_EVENT_WITH_SOURCE_CASE);
}
ComboBox diseaseField = getField(ContactIndexDto.DISEASE);
ComboBox diseaseVariantField = getField(ContactCriteria.DISEASE_VARIANT);
Disease disease = (Disease) diseaseField.getValue();
if (disease == null) {
FieldHelper.updateItems(diseaseVariantField, Collections.emptyList());
FieldHelper.setEnabled(false, diseaseVariantField);
} else {
List<DiseaseVariant> diseaseVariants = FacadeProvider.getCustomizableEnumFacade().getEnumValues(CustomizableEnumType.DISEASE_VARIANT, disease);
FieldHelper.updateItems(diseaseVariantField, diseaseVariants);
FieldHelper.setEnabled(CollectionUtils.isNotEmpty(diseaseVariants), diseaseVariantField);
}
}
Aggregations