Search in sources :

Example 1 with MapCaseDto

use of de.symeda.sormas.api.caze.MapCaseDto in project SORMAS-Project by hzi-braunschweig.

the class CaseFacadeEjbTest method testMapCaseListCreation.

@Test
public void testMapCaseListCreation() {
    RDCFEntities rdcf = creator.createRDCFEntities("Region", "District", "Community", "Facility");
    UserDto user = creator.createUser(rdcf.region.getUuid(), rdcf.district.getUuid(), rdcf.facility.getUuid(), "Surv", "Sup", UserRole.SURVEILLANCE_SUPERVISOR);
    PersonDto cazePerson = creator.createPerson("Case", "Person", p -> {
        p.getAddress().setLatitude(0.0);
        p.getAddress().setLongitude(0.0);
    });
    CaseDataDto caze = creator.createCase(user.toReference(), cazePerson.toReference(), Disease.EVD, CaseClassification.PROBABLE, InvestigationStatus.PENDING, new Date(), rdcf);
    Long count = getCaseFacade().countCasesForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1), null);
    List<MapCaseDto> mapCaseDtos = getCaseFacade().getCasesForMap(caze.getRegion(), caze.getDistrict(), caze.getDisease(), DateHelper.subtractDays(new Date(), 1), DateHelper.addDays(new Date(), 1), null);
    // List should have one entry
    assertEquals((long) count, mapCaseDtos.size());
    assertEquals(1, mapCaseDtos.size());
}
Also used : MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) Date(java.util.Date) LocalDate(java.time.LocalDate) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest) Test(org.junit.Test)

Example 2 with MapCaseDto

use of de.symeda.sormas.api.caze.MapCaseDto in project SORMAS-Project by hzi-braunschweig.

the class DashboardMapComponent method getCasesForFacility.

public List<CaseDataDto> getCasesForFacility(FacilityReferenceDto facility) {
    List<CaseDataDto> casesForFacility = new ArrayList<>();
    CaseFacade caseFacade = FacadeProvider.getCaseFacade();
    for (MapCaseDto mapCaseDto : casesByFacility.get(facility)) {
        casesForFacility.add(caseFacade.getCaseDataByUuid(mapCaseDto.getUuid()));
    }
    return casesForFacility;
}
Also used : MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) CaseFacade(de.symeda.sormas.api.caze.CaseFacade) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ArrayList(java.util.ArrayList)

Example 3 with MapCaseDto

use of de.symeda.sormas.api.caze.MapCaseDto 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 4 with MapCaseDto

use of de.symeda.sormas.api.caze.MapCaseDto in project SORMAS-Project by hzi-braunschweig.

the class DashboardMapComponent method showCaseMarkers.

private void showCaseMarkers(List<MapCaseDto> cases) {
    clearCaseMarkers();
    fillCaseLists(cases);
    List<LeafletMarker> caseMarkers = new ArrayList<LeafletMarker>();
    for (FacilityReferenceDto facilityReference : casesByFacility.keySet()) {
        List<MapCaseDto> casesList = casesByFacility.get(facilityReference);
        // colorize the icon by the "strongest" classification type (order as in enum)
        // and set its size depending
        // on the number of cases
        int numberOfCases = casesList.size();
        Set<CaseClassification> classificationSet = new HashSet<>();
        for (MapCaseDto caze : casesList) {
            classificationSet.add(caze.getCaseClassification());
        }
        MarkerIcon icon;
        if (classificationSet.contains(CaseClassification.CONFIRMED)) {
            icon = MarkerIcon.FACILITY_CONFIRMED;
        } else if (classificationSet.contains(CaseClassification.PROBABLE)) {
            icon = MarkerIcon.FACILITY_PROBABLE;
        } else if (classificationSet.contains(CaseClassification.SUSPECT)) {
            icon = MarkerIcon.FACILITY_SUSPECT;
        } else {
            icon = MarkerIcon.FACILITY_UNCLASSIFIED;
        }
        // create and place the marker
        markerCaseFacilities.add(facilityReference);
        MapCaseDto firstCase = casesList.get(0);
        LeafletMarker leafletMarker = new LeafletMarker();
        leafletMarker.setLatLon(firstCase.getHealthFacilityLat(), firstCase.getHealthFacilityLon());
        leafletMarker.setIcon(icon);
        leafletMarker.setMarkerCount(numberOfCases);
        caseMarkers.add(leafletMarker);
    }
    for (MapCaseDto caze : mapCaseDtos) {
        LeafletMarker marker = new LeafletMarker();
        CaseClassification caseClassification = caze.getCaseClassification();
        if (caseClassification == CaseClassification.CONFIRMED || caseClassification == CaseClassification.CONFIRMED_NO_SYMPTOMS || caseClassification == CaseClassification.CONFIRMED_UNKNOWN_SYMPTOMS) {
            marker.setIcon(MarkerIcon.CASE_CONFIRMED);
        } else if (caseClassification == CaseClassification.PROBABLE) {
            marker.setIcon(MarkerIcon.CASE_PROBABLE);
        } else if (caseClassification == CaseClassification.SUSPECT) {
            marker.setIcon(MarkerIcon.CASE_SUSPECT);
        } else {
            marker.setIcon(MarkerIcon.CASE_UNCLASSIFIED);
        }
        if (caze.getAddressLat() != null && caze.getAddressLon() != null) {
            marker.setLatLon(caze.getAddressLat(), caze.getAddressLon());
        } else {
            marker.setLatLon(caze.getReportLat(), caze.getReportLon());
        }
        caseMarkers.add(marker);
    }
    map.addMarkerGroup("cases", caseMarkers);
}
Also used : MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) LeafletMarker(de.symeda.sormas.ui.map.LeafletMarker) ArrayList(java.util.ArrayList) MarkerIcon(de.symeda.sormas.ui.map.MarkerIcon) HashSet(java.util.HashSet)

Example 5 with MapCaseDto

use of de.symeda.sormas.api.caze.MapCaseDto in project SORMAS-Project by hzi-braunschweig.

the class DashboardMapComponent method fillCaseLists.

private void fillCaseLists(List<MapCaseDto> cases) {
    for (MapCaseDto caze : cases) {
        // these filters need to be used for the count too
        CaseClassification classification = caze.getCaseClassification();
        if (caseClassificationOption == MapCaseClassificationOption.CONFIRMED_CASES_ONLY && classification != CaseClassification.CONFIRMED)
            continue;
        boolean hasCaseGps = (caze.getAddressLat() != null && caze.getAddressLon() != null) || (caze.getReportLat() != null && caze.getReportLon() != null);
        boolean hasFacilityGps = caze.getHealthFacilityLat() != null && caze.getHealthFacilityLon() != null;
        if (mapCaseDisplayMode == MapCaseDisplayMode.CASE_ADDRESS) {
            if (!hasCaseGps) {
                continue;
            }
            mapCaseDtos.add(caze);
        } else {
            if (FacilityDto.NONE_FACILITY_UUID.equals(caze.getHealthFacilityUuid()) || FacilityDto.OTHER_FACILITY_UUID.equals(caze.getHealthFacilityUuid()) || !hasFacilityGps) {
                if (mapCaseDisplayMode == MapCaseDisplayMode.FACILITY_OR_CASE_ADDRESS) {
                    if (!hasCaseGps) {
                        continue;
                    }
                    mapCaseDtos.add(caze);
                } else {
                    continue;
                }
            } else {
                FacilityReferenceDto facility = new FacilityReferenceDto();
                facility.setUuid(caze.getHealthFacilityUuid());
                if (casesByFacility.get(facility) == null) {
                    casesByFacility.put(facility, new ArrayList<MapCaseDto>());
                }
                casesByFacility.get(facility).add(caze);
            }
        }
        mapAndFacilityCases.add(caze);
    }
}
Also used : MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto)

Aggregations

MapCaseDto (de.symeda.sormas.api.caze.MapCaseDto)7 FacilityReferenceDto (de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto)3 CaseClassification (de.symeda.sormas.api.caze.CaseClassification)2 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)2 ArrayList (java.util.ArrayList)2 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Window (com.vaadin.ui.Window)1 CaseFacade (de.symeda.sormas.api.caze.CaseFacade)1 CasePersonDto (de.symeda.sormas.api.caze.CasePersonDto)1 MapContactDto (de.symeda.sormas.api.contact.MapContactDto)1 DashboardEventDto (de.symeda.sormas.api.dashboard.DashboardEventDto)1 FacilityDto (de.symeda.sormas.api.infrastructure.facility.FacilityDto)1 PersonDto (de.symeda.sormas.api.person.PersonDto)1 PersonReferenceDto (de.symeda.sormas.api.person.PersonReferenceDto)1 UserDto (de.symeda.sormas.api.user.UserDto)1 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)1 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)1 District (de.symeda.sormas.backend.infrastructure.district.District)1 Region (de.symeda.sormas.backend.infrastructure.region.Region)1 Pseudonymizer (de.symeda.sormas.backend.util.Pseudonymizer)1