Search in sources :

Example 26 with Disease

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());
}
Also used : RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) Disease(de.symeda.sormas.api.Disease) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)

Example 27 with Disease

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;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) Disease(de.symeda.sormas.api.Disease) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) Date(java.util.Date) Predicate(javax.persistence.criteria.Predicate) AbstractDomainObject(de.symeda.sormas.backend.common.AbstractDomainObject) SimilarEventParticipantDto(de.symeda.sormas.api.event.SimilarEventParticipantDto)

Example 28 with Disease

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));
}
Also used : Disease(de.symeda.sormas.api.Disease) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 29 with 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);
    }
}
Also used : FollowUpStatus(de.symeda.sormas.api.contact.FollowUpStatus) DashboardStatisticsGraphicalGrowthElement(de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsGraphicalGrowthElement) Date(java.util.Date) FacadeProvider(de.symeda.sormas.api.FacadeProvider) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) VisitStatus(de.symeda.sormas.api.visit.VisitStatus) CountElementStyle(de.symeda.sormas.ui.dashboard.statistics.CountElementStyle) DateHelper(de.symeda.sormas.api.utils.DateHelper) HashMap(java.util.HashMap) CssLayout(com.vaadin.ui.CssLayout) ArrayList(java.util.ArrayList) DashboardStatisticsDiseaseElement(de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsDiseaseElement) CssStyles(de.symeda.sormas.ui.utils.CssStyles) Map(java.util.Map) Label(com.vaadin.ui.Label) VaadinIcons(com.vaadin.icons.VaadinIcons) DashboardStatisticsCountElement(de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsCountElement) ContentMode(com.vaadin.shared.ui.ContentMode) EnumMap(java.util.EnumMap) ContactStatus(de.symeda.sormas.api.contact.ContactStatus) AbstractDashboardStatisticsComponent(de.symeda.sormas.ui.dashboard.statistics.AbstractDashboardStatisticsComponent) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) Captions(de.symeda.sormas.api.i18n.Captions) DashboardStatisticsPercentageElement(de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsPercentageElement) DashboardContactDto(de.symeda.sormas.api.dashboard.DashboardContactDto) DashboardDataProvider(de.symeda.sormas.ui.dashboard.DashboardDataProvider) List(java.util.List) Disease(de.symeda.sormas.api.Disease) TreeMap(java.util.TreeMap) DashboardStatisticsSubComponent(de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsSubComponent) Optional(java.util.Optional) Descriptions(de.symeda.sormas.api.i18n.Descriptions) Strings(de.symeda.sormas.api.i18n.Strings) DashboardStatisticsDiseaseElement(de.symeda.sormas.ui.dashboard.statistics.DashboardStatisticsDiseaseElement) Disease(de.symeda.sormas.api.Disease) TreeMap(java.util.TreeMap) DashboardContactDto(de.symeda.sormas.api.dashboard.DashboardContactDto) HashMap(java.util.HashMap) Map(java.util.Map) EnumMap(java.util.EnumMap) TreeMap(java.util.TreeMap)

Example 30 with Disease

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);
    }
}
Also used : ContactDateType(de.symeda.sormas.api.contact.ContactDateType) NewCaseDateType(de.symeda.sormas.api.caze.NewCaseDateType) Disease(de.symeda.sormas.api.Disease) DiseaseVariant(de.symeda.sormas.api.disease.DiseaseVariant) ComboBox(com.vaadin.v7.ui.ComboBox) UserDto(de.symeda.sormas.api.user.UserDto) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) Date(java.util.Date) HorizontalLayout(com.vaadin.ui.HorizontalLayout) EpiWeekAndDateFilterComponent(de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)

Aggregations

Disease (de.symeda.sormas.api.Disease)106 Date (java.util.Date)46 List (java.util.List)39 ArrayList (java.util.ArrayList)34 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)32 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)32 Collectors (java.util.stream.Collectors)29 I18nProperties (de.symeda.sormas.api.i18n.I18nProperties)26 Arrays (java.util.Arrays)25 Collections (java.util.Collections)25 UserRole (de.symeda.sormas.api.user.UserRole)24 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)23 DateHelper (de.symeda.sormas.api.utils.DateHelper)23 Map (java.util.Map)23 Label (com.vaadin.ui.Label)20 Strings (de.symeda.sormas.api.i18n.Strings)20 StringUtils (org.apache.commons.lang3.StringUtils)19 ContactDto (de.symeda.sormas.api.contact.ContactDto)18 District (de.symeda.sormas.backend.infrastructure.district.District)18 CollectionUtils (org.apache.commons.collections.CollectionUtils)18