Search in sources :

Example 1 with MapContactDto

use of de.symeda.sormas.api.contact.MapContactDto in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjbTest method testMapContactListCreation.

@Test
public void testMapContactListCreation() {
    TestDataCreator.RDCF rdcf = creator.createRDCF("Region", "District", "Community", "Facility");
    UserDto user = useSurveillanceOfficerLogin(rdcf);
    PersonDto cazePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    PersonDto contactPerson = creator.createPerson("Contact", "Person", p -> {
        p.getAddress().setLatitude(0.0);
        p.getAddress().setLongitude(0.0);
    });
    creator.createContact(user.toReference(), user.toReference(), contactPerson.toReference(), caze, new Date(), new Date(), caze.getDisease(), rdcf);
    Long count = getContactFacade().countContactsForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1));
    List<MapContactDto> mapContactDtos = getContactFacade().getContactsForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1));
    // List should have one entry
    assertEquals((long) count, mapContactDtos.size());
    assertEquals((long) 1, mapContactDtos.size());
}
Also used : CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) RDCF(de.symeda.sormas.backend.TestDataCreator.RDCF) TestDataCreator(de.symeda.sormas.backend.TestDataCreator) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 2 with MapContactDto

use of de.symeda.sormas.api.contact.MapContactDto in project SORMAS-Project by hzi-braunschweig.

the class DashboardMapComponent method onMarkerClicked.

private void onMarkerClicked(String groupId, int markerIndex) {
    switch(groupId) {
        case CASES_GROUP_ID:
            if (markerIndex < markerCaseFacilities.size()) {
                FacilityReferenceDto facility = markerCaseFacilities.get(markerIndex);
                VerticalLayout layout = new VerticalLayout();
                Window window = VaadinUiUtil.showPopupWindow(layout);
                CasePopupGrid caseGrid = new CasePopupGrid(window, facility, DashboardMapComponent.this);
                caseGrid.setHeightMode(HeightMode.ROW);
                layout.addComponent(caseGrid);
                layout.setMargin(true);
                FacilityDto facilityDto = FacadeProvider.getFacilityFacade().getByUuid(facility.getUuid());
                window.setCaption(I18nProperties.getCaption(Captions.dashboardCasesIn) + " " + facilityDto.toString());
            } else {
                markerIndex -= markerCaseFacilities.size();
                MapCaseDto caze = mapCaseDtos.get(markerIndex);
                ControllerProvider.getCaseController().navigateToCase(caze.getUuid(), true);
            }
            break;
        case CONTACTS_GROUP_ID:
            MapContactDto contact = markerContacts.get(markerIndex);
            ControllerProvider.getContactController().navigateToData(contact.getUuid(), true);
            break;
        case EVENTS_GROUP_ID:
            DashboardEventDto event = markerEvents.get(markerIndex);
            ControllerProvider.getEventController().navigateToData(event.getUuid(), true);
            break;
    }
}
Also used : Window(com.vaadin.ui.Window) MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) VerticalLayout(com.vaadin.ui.VerticalLayout) DashboardEventDto(de.symeda.sormas.api.dashboard.DashboardEventDto) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto)

Example 3 with MapContactDto

use of de.symeda.sormas.api.contact.MapContactDto in project SORMAS-Project by hzi-braunschweig.

the class ContactService method getContactsForMap.

public List<MapContactDto> getContactsForMap(Region region, District district, Disease disease, Date from, Date to) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<MapContactDto> cq = cb.createQuery(MapContactDto.class);
    Root<Contact> contact = cq.from(getElementClass());
    Join<Contact, Person> person = contact.join(Contact.PERSON, JoinType.LEFT);
    Join<Person, Location> contactPersonAddress = person.join(Person.ADDRESS, JoinType.LEFT);
    Join<Contact, Case> caze = contact.join(Contact.CAZE, JoinType.LEFT);
    Join<Case, Person> casePerson = caze.join(Case.PERSON, JoinType.LEFT);
    Join<Case, Symptoms> symptoms = caze.join(Case.SYMPTOMS, JoinType.LEFT);
    Predicate filter = createMapContactsFilter(cb, cq, contact, caze, contactPersonAddress, region, district, disease, from, to);
    List<MapContactDto> result;
    if (filter != null) {
        cq.where(filter);
        cq.multiselect(contact.get(Contact.UUID), contact.get(Contact.CONTACT_CLASSIFICATION), contact.get(Contact.REPORT_LAT), contact.get(Contact.REPORT_LON), contactPersonAddress.get(Location.LATITUDE), contactPersonAddress.get(Location.LONGITUDE), symptoms.get(Symptoms.ONSET_DATE), caze.get(Case.REPORT_DATE), contact.get(Contact.REPORT_DATE_TIME), person.get(Person.FIRST_NAME), person.get(Person.LAST_NAME), casePerson.get(Person.FIRST_NAME), casePerson.get(Person.LAST_NAME));
        result = em.createQuery(cq).getResultList();
    // #1274 Temporarily disabled because it severely impacts the performance of the
    // Dashboard
    // for (MapContactDto mapContactDto : result) {
    // Visit lastVisit =
    // visitService.getLastVisitByContact(getByUuid(mapContactDto.getUuid()),
    // VisitStatus.COOPERATIVE);
    // if (lastVisit != null) {
    // mapContactDto.setLastVisitDateTime(lastVisit.getVisitDateTime());
    // }
    // }
    } else {
        result = Collections.emptyList();
    }
    return result;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Case(de.symeda.sormas.backend.caze.Case) Predicate(javax.persistence.criteria.Predicate) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) Person(de.symeda.sormas.backend.person.Person) Symptoms(de.symeda.sormas.backend.symptoms.Symptoms) Location(de.symeda.sormas.backend.location.Location)

Example 4 with MapContactDto

use of de.symeda.sormas.api.contact.MapContactDto in project SORMAS-Project by hzi-braunschweig.

the class DashboardMapComponent method showContactMarkers.

private void showContactMarkers(List<MapContactDto> contacts) {
    clearContactMarkers();
    List<LeafletMarker> contactMarkers = new ArrayList<LeafletMarker>();
    for (MapContactDto contact : contacts) {
        // Don't show a marker for contacts that don't have geo coordinates
        if (contact.getAddressLat() == null || contact.getAddressLon() == null) {
            if (contact.getReportLat() == null || contact.getReportLon() == null) {
                continue;
            }
        }
        // Don't show a marker for contacts that are filtered out
        if (!showUnconfirmedContacts && contact.getContactClassification() == ContactClassification.UNCONFIRMED) {
            continue;
        }
        if (!showConfirmedContacts && contact.getContactClassification() != ContactClassification.UNCONFIRMED) {
            continue;
        }
        MarkerIcon icon;
        // }
        switch(contact.getContactClassification()) {
            case CONFIRMED:
                icon = MarkerIcon.CONTACT_LONG_OVERDUE;
                break;
            case UNCONFIRMED:
                icon = MarkerIcon.CONTACT_OVERDUE;
                break;
            case NO_CONTACT:
                icon = MarkerIcon.CONTACT_OK;
                break;
            default:
                icon = MarkerIcon.CONTACT_OK;
                break;
        }
        LeafletMarker marker = new LeafletMarker();
        marker.setIcon(icon);
        if (contact.getAddressLat() != null && contact.getAddressLon() != null) {
            marker.setLatLon(contact.getAddressLat(), contact.getAddressLon());
        } else {
            marker.setLatLon(contact.getReportLat(), contact.getReportLon());
        }
        markerContacts.add(contact);
        contactMarkers.add(marker);
    }
    map.addMarkerGroup(CONTACTS_GROUP_ID, contactMarkers);
}
Also used : MapContactDto(de.symeda.sormas.api.contact.MapContactDto) LeafletMarker(de.symeda.sormas.ui.map.LeafletMarker) ArrayList(java.util.ArrayList) MarkerIcon(de.symeda.sormas.ui.map.MarkerIcon)

Aggregations

MapContactDto (de.symeda.sormas.api.contact.MapContactDto)4 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Window (com.vaadin.ui.Window)1 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)1 MapCaseDto (de.symeda.sormas.api.caze.MapCaseDto)1 DashboardEventDto (de.symeda.sormas.api.dashboard.DashboardEventDto)1 FacilityDto (de.symeda.sormas.api.infrastructure.facility.FacilityDto)1 FacilityReferenceDto (de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto)1 PersonDto (de.symeda.sormas.api.person.PersonDto)1 UserDto (de.symeda.sormas.api.user.UserDto)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 TestDataCreator (de.symeda.sormas.backend.TestDataCreator)1 RDCF (de.symeda.sormas.backend.TestDataCreator.RDCF)1 Case (de.symeda.sormas.backend.caze.Case)1 Location (de.symeda.sormas.backend.location.Location)1 Person (de.symeda.sormas.backend.person.Person)1 Symptoms (de.symeda.sormas.backend.symptoms.Symptoms)1 LeafletMarker (de.symeda.sormas.ui.map.LeafletMarker)1 MarkerIcon (de.symeda.sormas.ui.map.MarkerIcon)1 LocalDate (java.time.LocalDate)1