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());
}
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;
}
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;
}
}
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);
}
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);
}
}
Aggregations