Search in sources :

Example 1 with CaseMeasure

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

the class CaseFacadeEjb method getCaseMeasurePerDistrict.

@Override
public List<Pair<DistrictDto, BigDecimal>> getCaseMeasurePerDistrict(Date fromDate, Date toDate, Disease disease, CaseMeasure caseMeasure) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Object[]> cq = cb.createQuery(Object[].class);
    Root<Case> caseRoot = cq.from(Case.class);
    Root<District> districtRoot = cq.from(District.class);
    Predicate filter = service.createDefaultFilter(cb, caseRoot);
    if (fromDate != null || toDate != null) {
        filter = service.createCaseRelevanceFilter(cb, caseRoot, fromDate, toDate);
    }
    if (disease != null) {
        Predicate diseaseFilter = cb.equal(caseRoot.get(Case.DISEASE), disease);
        filter = filter != null ? cb.and(filter, diseaseFilter) : diseaseFilter;
    }
    Predicate districtFilter = cb.or(cb.equal(caseRoot.get(Case.DISTRICT), districtRoot), cb.and(cb.isNull(caseRoot.get(Case.DISTRICT)), cb.equal(caseRoot.get(Case.RESPONSIBLE_DISTRICT), districtRoot)));
    filter = filter != null ? cb.and(filter, districtFilter) : districtFilter;
    cq.where(filter);
    cq.groupBy(districtRoot);
    cq.multiselect(districtRoot, cb.count(caseRoot));
    if (caseMeasure == CaseMeasure.CASE_COUNT) {
        cq.orderBy(cb.asc(cb.count(caseRoot)));
    }
    List<Object[]> results = em.createQuery(cq).getResultList();
    if (caseMeasure == CaseMeasure.CASE_COUNT) {
        List<Pair<DistrictDto, BigDecimal>> resultList = results.stream().map(e -> new Pair<DistrictDto, BigDecimal>(districtFacade.toDto((District) e[0]), new BigDecimal((Long) e[1]))).collect(Collectors.toList());
        return resultList;
    } else {
        List<Pair<DistrictDto, BigDecimal>> resultList = results.stream().map(e -> {
            District district = (District) e[0];
            Integer population = populationDataFacade.getProjectedDistrictPopulation(district.getUuid());
            Long caseCount = (Long) e[1];
            if (population == null || population <= 0) {
                // No or negative population - these entries will be cut off in the UI
                return new Pair<DistrictDto, BigDecimal>(districtFacade.toDto(district), new BigDecimal(0));
            } else {
                return new Pair<DistrictDto, BigDecimal>(districtFacade.toDto(district), InfrastructureHelper.getCaseIncidence(caseCount.intValue(), population, InfrastructureHelper.CASE_INCIDENCE_DIVISOR));
            }
        }).sorted(new Comparator<Pair<DistrictDto, BigDecimal>>() {

            @Override
            public int compare(Pair<DistrictDto, BigDecimal> o1, Pair<DistrictDto, BigDecimal> o2) {
                return o1.getElement1().compareTo(o2.getElement1());
            }
        }).collect(Collectors.toList());
        return resultList;
    }
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) VisitService(de.symeda.sormas.backend.visit.VisitService) PlagueType(de.symeda.sormas.api.caze.PlagueType) VisitStatus(de.symeda.sormas.api.visit.VisitStatus) CaseSimilarityCriteria(de.symeda.sormas.api.caze.CaseSimilarityCriteria) DistrictService(de.symeda.sormas.backend.infrastructure.district.DistrictService) StringUtils(org.apache.commons.lang3.StringUtils) PersonDto(de.symeda.sormas.api.person.PersonDto) TaskHelper(de.symeda.sormas.api.task.TaskHelper) AbstractCoreFacadeEjb(de.symeda.sormas.backend.common.AbstractCoreFacadeEjb) TransactionAttributeType(javax.ejb.TransactionAttributeType) CaseExportDto(de.symeda.sormas.api.caze.CaseExportDto) Duration(java.time.Duration) Map(java.util.Map) TreatmentFacadeEjb(de.symeda.sormas.backend.therapy.TreatmentFacadeEjb) DocumentRelatedEntityType(de.symeda.sormas.api.document.DocumentRelatedEntityType) PrescriptionDto(de.symeda.sormas.api.therapy.PrescriptionDto) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) ParameterExpression(javax.persistence.criteria.ParameterExpression) OutbreakService(de.symeda.sormas.backend.outbreak.OutbreakService) DiseaseHelper(de.symeda.sormas.api.DiseaseHelper) CommunityService(de.symeda.sormas.backend.infrastructure.community.CommunityService) FacilityHelper(de.symeda.sormas.api.infrastructure.facility.FacilityHelper) Resource(javax.annotation.Resource) TaskPriority(de.symeda.sormas.api.task.TaskPriority) NotNull(javax.validation.constraints.NotNull) CaseIndexDetailedDto(de.symeda.sormas.api.caze.CaseIndexDetailedDto) User(de.symeda.sormas.backend.user.User) PathogenTestResultType(de.symeda.sormas.api.sample.PathogenTestResultType) CaseLogic(de.symeda.sormas.api.caze.CaseLogic) EpiDataDto(de.symeda.sormas.api.epidata.EpiDataDto) JurisdictionHelper(de.symeda.sormas.backend.util.JurisdictionHelper) SampleService(de.symeda.sormas.backend.sample.SampleService) ExternalSurveillanceToolException(de.symeda.sormas.api.externalsurveillancetool.ExternalSurveillanceToolException) Sample(de.symeda.sormas.backend.sample.Sample) Hospitalization(de.symeda.sormas.backend.hospitalization.Hospitalization) Community(de.symeda.sormas.backend.infrastructure.community.Community) QueryHelper(de.symeda.sormas.backend.util.QueryHelper) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) ManualMessageLogDto(de.symeda.sormas.api.messaging.ManualMessageLogDto) FacilityFacadeEjb(de.symeda.sormas.backend.infrastructure.facility.FacilityFacadeEjb) TypedQuery(javax.persistence.TypedQuery) VisitFacadeEjbLocal(de.symeda.sormas.backend.visit.VisitFacadeEjb.VisitFacadeEjbLocal) PathogenTestType(de.symeda.sormas.api.sample.PathogenTestType) CaseListEntryDto(de.symeda.sormas.api.caze.CaseListEntryDto) Calendar(java.util.Calendar) PreviousHospitalizationDto(de.symeda.sormas.api.hospitalization.PreviousHospitalizationDto) SampleFacadeEjb(de.symeda.sormas.backend.sample.SampleFacadeEjb) ConfigFacadeEjbLocal(de.symeda.sormas.backend.common.ConfigFacadeEjb.ConfigFacadeEjbLocal) ExportHelper(de.symeda.sormas.backend.importexport.ExportHelper) EJB(javax.ejb.EJB) TaskCriteria(de.symeda.sormas.api.task.TaskCriteria) ManualMessageLogService(de.symeda.sormas.backend.common.messaging.ManualMessageLogService) HospitalizationFacadeEjbLocal(de.symeda.sormas.backend.hospitalization.HospitalizationFacadeEjb.HospitalizationFacadeEjbLocal) DataHelper(de.symeda.sormas.api.utils.DataHelper) Task(de.symeda.sormas.backend.task.Task) PointOfEntry(de.symeda.sormas.backend.infrastructure.pointofentry.PointOfEntry) PersonFacadeEjb(de.symeda.sormas.backend.person.PersonFacadeEjb) CaseOrigin(de.symeda.sormas.api.caze.CaseOrigin) AgeAndBirthDateDto(de.symeda.sormas.api.caze.AgeAndBirthDateDto) PersonService(de.symeda.sormas.backend.person.PersonService) SymptomsHelper(de.symeda.sormas.api.symptoms.SymptomsHelper) SortProperty(de.symeda.sormas.api.utils.SortProperty) Prescription(de.symeda.sormas.backend.therapy.Prescription) TravelEntryService(de.symeda.sormas.backend.travelentry.services.TravelEntryService) PrescriptionFacadeEjb(de.symeda.sormas.backend.therapy.PrescriptionFacadeEjb) AtomicLong(java.util.concurrent.atomic.AtomicLong) ExposureDto(de.symeda.sormas.api.exposure.ExposureDto) Disease(de.symeda.sormas.api.Disease) VisitDto(de.symeda.sormas.api.visit.VisitDto) HealthConditions(de.symeda.sormas.backend.clinicalcourse.HealthConditions) FeatureTypeProperty(de.symeda.sormas.api.feature.FeatureTypeProperty) FieldVisibilityCheckers(de.symeda.sormas.api.utils.fieldvisibility.FieldVisibilityCheckers) PortHealthInfoFacadeEjbLocal(de.symeda.sormas.backend.caze.porthealthinfo.PortHealthInfoFacadeEjb.PortHealthInfoFacadeEjbLocal) VisitFacadeEjb(de.symeda.sormas.backend.visit.VisitFacadeEjb) CaseSelectionDto(de.symeda.sormas.api.caze.CaseSelectionDto) ContactCriteria(de.symeda.sormas.api.contact.ContactCriteria) SurveillanceReportService(de.symeda.sormas.backend.caze.surveillancereport.SurveillanceReportService) ImmunizationEntityHelper(de.symeda.sormas.backend.immunization.ImmunizationEntityHelper) Join(javax.persistence.criteria.Join) Date(java.util.Date) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) PopulationDataFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.PopulationDataFacadeEjb.PopulationDataFacadeEjbLocal) Random(java.util.Random) AccessDeniedException(de.symeda.sormas.api.utils.AccessDeniedException) PortHealthInfoDto(de.symeda.sormas.api.caze.porthealthinfo.PortHealthInfoDto) PrescriptionService(de.symeda.sormas.backend.therapy.PrescriptionService) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) CriteriaBuilderHelper.or(de.symeda.sormas.backend.common.CriteriaBuilderHelper.or) CaseClassificationFacadeEjbLocal(de.symeda.sormas.backend.caze.classification.CaseClassificationFacadeEjb.CaseClassificationFacadeEjbLocal) Vaccination(de.symeda.sormas.backend.vaccination.Vaccination) VisitSummaryExportDetails(de.symeda.sormas.backend.contact.VisitSummaryExportDetails) ManagedScheduledExecutorService(javax.enterprise.concurrent.ManagedScheduledExecutorService) InfrastructureHelper(de.symeda.sormas.api.infrastructure.InfrastructureHelper) DiseaseConfigurationFacadeEjbLocal(de.symeda.sormas.backend.disease.DiseaseConfigurationFacadeEjb.DiseaseConfigurationFacadeEjbLocal) Person(de.symeda.sormas.backend.person.Person) FacilityType(de.symeda.sormas.api.infrastructure.facility.FacilityType) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) InvestigationStatus(de.symeda.sormas.api.caze.InvestigationStatus) PrescriptionFacadeEjbLocal(de.symeda.sormas.backend.therapy.PrescriptionFacadeEjb.PrescriptionFacadeEjbLocal) Instant(java.time.Instant) Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) Collectors(java.util.stream.Collectors) Language(de.symeda.sormas.api.Language) NewCaseDateType(de.symeda.sormas.api.caze.NewCaseDateType) PatchHelper(de.symeda.sormas.backend.util.PatchHelper) Objects(java.util.Objects) CaseIndexDto(de.symeda.sormas.api.caze.CaseIndexDto) SurveillanceReportFacadeEjb(de.symeda.sormas.backend.caze.surveillancereport.SurveillanceReportFacadeEjb) ExportConfigurationDto(de.symeda.sormas.api.importexport.ExportConfigurationDto) ShareTreeCriteria(de.symeda.sormas.api.sormastosormas.ShareTreeCriteria) MessageContents(de.symeda.sormas.backend.common.messaging.MessageContents) BirthDateDto(de.symeda.sormas.api.caze.BirthDateDto) PreviousHospitalization(de.symeda.sormas.backend.hospitalization.PreviousHospitalization) ContactDto(de.symeda.sormas.api.contact.ContactDto) LocalDate(java.time.LocalDate) Order(javax.persistence.criteria.Order) ClinicalCourseDto(de.symeda.sormas.api.clinicalcourse.ClinicalCourseDto) FeatureConfigurationFacadeEjbLocal(de.symeda.sormas.backend.feature.FeatureConfigurationFacadeEjb.FeatureConfigurationFacadeEjbLocal) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) ContactFacadeEjbLocal(de.symeda.sormas.backend.contact.ContactFacadeEjb.ContactFacadeEjbLocal) CaseFollowUpDto(de.symeda.sormas.api.caze.CaseFollowUpDto) DateHelper(de.symeda.sormas.api.utils.DateHelper) AdditionalTestDto(de.symeda.sormas.api.sample.AdditionalTestDto) CoreEntityType(de.symeda.sormas.backend.deletionconfiguration.CoreEntityType) Function(java.util.function.Function) VisitOrigin(de.symeda.sormas.api.VisitOrigin) EventParticipantService(de.symeda.sormas.backend.event.EventParticipantService) AdditionalTestFacadeEjbLocal(de.symeda.sormas.backend.sample.AdditionalTestFacadeEjb.AdditionalTestFacadeEjbLocal) Inject(javax.inject.Inject) ReinfectionDetail(de.symeda.sormas.api.caze.ReinfectionDetail) PreviousCaseDto(de.symeda.sormas.api.caze.PreviousCaseDto) TransactionAttribute(javax.ejb.TransactionAttribute) TaskStatus(de.symeda.sormas.api.task.TaskStatus) TherapyReferenceDto(de.symeda.sormas.api.therapy.TherapyReferenceDto) CriteriaBuilderHelper.and(de.symeda.sormas.backend.common.CriteriaBuilderHelper.and) SymptomsDto(de.symeda.sormas.api.symptoms.SymptomsDto) CriteriaBuilderHelper(de.symeda.sormas.backend.common.CriteriaBuilderHelper) PathogenTestDto(de.symeda.sormas.api.sample.PathogenTestDto) ExternalShareInfoService(de.symeda.sormas.backend.share.ExternalShareInfoService) LocationDto(de.symeda.sormas.api.location.LocationDto) TaskContext(de.symeda.sormas.api.task.TaskContext) Logger(org.slf4j.Logger) HospitalizationFacadeEjb(de.symeda.sormas.backend.hospitalization.HospitalizationFacadeEjb) Document(de.symeda.sormas.backend.document.Document) TherapyFacadeEjbLocal(de.symeda.sormas.backend.therapy.TherapyFacadeEjb.TherapyFacadeEjbLocal) VisitLogic.getVisitResult(de.symeda.sormas.backend.visit.VisitLogic.getVisitResult) DateTime(org.joda.time.DateTime) UserReference(de.symeda.sormas.backend.user.UserReference) RegionFacadeEjb(de.symeda.sormas.backend.infrastructure.region.RegionFacadeEjb) PresentCondition(de.symeda.sormas.api.person.PresentCondition) UserRight(de.symeda.sormas.api.user.UserRight) VisitResultDto(de.symeda.sormas.api.visit.VisitResultDto) ExternalJournalService(de.symeda.sormas.backend.externaljournal.ExternalJournalService) ContactReferenceDto(de.symeda.sormas.api.contact.ContactReferenceDto) ShareInfoHelper(de.symeda.sormas.backend.sormastosormas.share.shareinfo.ShareInfoHelper) Comparator(java.util.Comparator) Arrays(java.util.Arrays) CasePersonDto(de.symeda.sormas.api.caze.CasePersonDto) DtoHelper(de.symeda.sormas.backend.util.DtoHelper) EmbeddedSampleExportDto(de.symeda.sormas.api.caze.EmbeddedSampleExportDto) SymptomsFacadeEjbLocal(de.symeda.sormas.backend.symptoms.SymptomsFacadeEjb.SymptomsFacadeEjbLocal) Immunization(de.symeda.sormas.backend.immunization.entity.Immunization) CommunityFacadeEjb(de.symeda.sormas.backend.infrastructure.community.CommunityFacadeEjb) ExternalDataUpdateException(de.symeda.sormas.api.externaldata.ExternalDataUpdateException) MeansOfImmunization(de.symeda.sormas.api.immunization.MeansOfImmunization) ClinicalVisitCriteria(de.symeda.sormas.api.clinicalcourse.ClinicalVisitCriteria) Valid(javax.validation.Valid) BigDecimal(java.math.BigDecimal) CaseOutcome(de.symeda.sormas.api.caze.CaseOutcome) YesNoUnknown(de.symeda.sormas.api.utils.YesNoUnknown) Page(de.symeda.sormas.api.common.Page) FollowUpDto(de.symeda.sormas.api.followup.FollowUpDto) Predicate(javax.persistence.criteria.Predicate) UserFacadeEjb(de.symeda.sormas.backend.user.UserFacadeEjb) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) JoinType(javax.persistence.criteria.JoinType) JsonNode(com.fasterxml.jackson.databind.JsonNode) Visit(de.symeda.sormas.backend.visit.Visit) EpiData(de.symeda.sormas.backend.epidata.EpiData) SormasToSormasOriginInfoFacadeEjb(de.symeda.sormas.backend.sormastosormas.origin.SormasToSormasOriginInfoFacadeEjb) EventParticipantReferenceDto(de.symeda.sormas.api.event.EventParticipantReferenceDto) FacilityService(de.symeda.sormas.backend.infrastructure.facility.FacilityService) TherapyDto(de.symeda.sormas.api.therapy.TherapyDto) Set(java.util.Set) SampleFacadeEjbLocal(de.symeda.sormas.backend.sample.SampleFacadeEjb.SampleFacadeEjbLocal) DistrictFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.district.DistrictFacadeEjb.DistrictFacadeEjbLocal) PointOfEntryService(de.symeda.sormas.backend.infrastructure.pointofentry.PointOfEntryService) UserService(de.symeda.sormas.backend.user.UserService) MaternalHistoryDto(de.symeda.sormas.api.caze.maternalhistory.MaternalHistoryDto) ExternalDataDto(de.symeda.sormas.api.externaldata.ExternalDataDto) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) SampleCriteria(de.symeda.sormas.api.sample.SampleCriteria) EventParticipant(de.symeda.sormas.backend.event.EventParticipant) HealthConditionsDto(de.symeda.sormas.api.clinicalcourse.HealthConditionsDto) FollowUpPeriodDto(de.symeda.sormas.api.followup.FollowUpPeriodDto) CaseReferenceDefinition(de.symeda.sormas.api.caze.CaseReferenceDefinition) CaseMeasure(de.symeda.sormas.api.CaseMeasure) PersonReferenceDto(de.symeda.sormas.api.person.PersonReferenceDto) PathogenTest(de.symeda.sormas.backend.sample.PathogenTest) ArrayList(java.util.ArrayList) CaseReferenceDto(de.symeda.sormas.api.caze.CaseReferenceDto) ClinicalVisitFacadeEjb(de.symeda.sormas.backend.clinicalcourse.ClinicalVisitFacadeEjb) EpiDataFacadeEjb(de.symeda.sormas.backend.epidata.EpiDataFacadeEjb) TreatmentCriteria(de.symeda.sormas.api.therapy.TreatmentCriteria) LocalBean(javax.ejb.LocalBean) CountryHelper(de.symeda.sormas.api.CountryHelper) Root(javax.persistence.criteria.Root) PersonFacadeEjbLocal(de.symeda.sormas.backend.person.PersonFacadeEjb.PersonFacadeEjbLocal) ClinicalVisitDto(de.symeda.sormas.api.clinicalcourse.ClinicalVisitDto) MessageType(de.symeda.sormas.api.messaging.MessageType) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) MaternalHistoryFacadeEjbLocal(de.symeda.sormas.backend.caze.maternalhistory.MaternalHistoryFacadeEjb.MaternalHistoryFacadeEjbLocal) CaseFacade(de.symeda.sormas.api.caze.CaseFacade) Captions(de.symeda.sormas.api.i18n.Captions) Exposure(de.symeda.sormas.backend.exposure.Exposure) Treatment(de.symeda.sormas.backend.therapy.Treatment) CaseBulkEditData(de.symeda.sormas.api.caze.CaseBulkEditData) PrescriptionCriteria(de.symeda.sormas.api.therapy.PrescriptionCriteria) ContactService(de.symeda.sormas.backend.contact.ContactService) SampleDto(de.symeda.sormas.api.sample.SampleDto) Subquery(javax.persistence.criteria.Subquery) SymptomsFacadeEjb(de.symeda.sormas.backend.symptoms.SymptomsFacadeEjb) TravelEntry(de.symeda.sormas.backend.travelentry.TravelEntry) SurveillanceReport(de.symeda.sormas.backend.caze.surveillancereport.SurveillanceReport) SormasToSormasOriginInfo(de.symeda.sormas.backend.sormastosormas.origin.SormasToSormasOriginInfo) FeatureType(de.symeda.sormas.api.feature.FeatureType) TherapyFacadeEjb(de.symeda.sormas.backend.therapy.TherapyFacadeEjb) EventService(de.symeda.sormas.backend.event.EventService) PointOfEntryFacadeEjb(de.symeda.sormas.backend.infrastructure.pointofentry.PointOfEntryFacadeEjb) ApproximateAgeType(de.symeda.sormas.api.person.ApproximateAgeType) ClinicalVisitService(de.symeda.sormas.backend.clinicalcourse.ClinicalVisitService) AbstractDomainObject(de.symeda.sormas.backend.common.AbstractDomainObject) InfoProvider(de.symeda.sormas.api.utils.InfoProvider) LoggerFactory(org.slf4j.LoggerFactory) ExposureType(de.symeda.sormas.api.exposure.ExposureType) HealthConditionsMapper(de.symeda.sormas.backend.clinicalcourse.HealthConditionsMapper) CauseOfDeath(de.symeda.sormas.api.person.CauseOfDeath) CommunityFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.community.CommunityFacadeEjb.CommunityFacadeEjbLocal) ExposureService(de.symeda.sormas.backend.exposure.ExposureService) ExternalShareInfoCountAndLatestDate(de.symeda.sormas.backend.share.ExternalShareInfoCountAndLatestDate) SormasToSormasCaseFacadeEjbLocal(de.symeda.sormas.backend.sormastosormas.entities.caze.SormasToSormasCaseFacadeEjb.SormasToSormasCaseFacadeEjbLocal) NotificationService(de.symeda.sormas.backend.common.NotificationService) TreatmentFacadeEjbLocal(de.symeda.sormas.backend.therapy.TreatmentFacadeEjb.TreatmentFacadeEjbLocal) UserRole(de.symeda.sormas.api.user.UserRole) Path(javax.persistence.criteria.Path) Contact(de.symeda.sormas.backend.contact.Contact) Stateless(javax.ejb.Stateless) PortHealthInfoFacadeEjb(de.symeda.sormas.backend.caze.porthealthinfo.PortHealthInfoFacadeEjb) DocumentService(de.symeda.sormas.backend.document.DocumentService) NotificationDeliveryFailedException(de.symeda.sormas.backend.common.messaging.NotificationDeliveryFailedException) CaseCriteria(de.symeda.sormas.api.caze.CaseCriteria) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) Region(de.symeda.sormas.backend.infrastructure.region.Region) District(de.symeda.sormas.backend.infrastructure.district.District) AdditionalTest(de.symeda.sormas.backend.sample.AdditionalTest) SormasToSormasFacadeEjbLocal(de.symeda.sormas.backend.sormastosormas.SormasToSormasFacadeEjb.SormasToSormasFacadeEjbLocal) CommunityReferenceDto(de.symeda.sormas.api.infrastructure.community.CommunityReferenceDto) TaskType(de.symeda.sormas.api.task.TaskType) EventSummaryDetails(de.symeda.sormas.backend.event.EventSummaryDetails) List(java.util.List) MaternalHistoryFacadeEjb(de.symeda.sormas.backend.caze.maternalhistory.MaternalHistoryFacadeEjb) DistrictFacadeEjb(de.symeda.sormas.backend.infrastructure.district.DistrictFacadeEjb) DistrictDto(de.symeda.sormas.api.infrastructure.district.DistrictDto) Optional(java.util.Optional) EpiDataHelper(de.symeda.sormas.api.epidata.EpiDataHelper) Location(de.symeda.sormas.backend.location.Location) ValidationRuntimeException(de.symeda.sormas.api.utils.ValidationRuntimeException) ClinicalCourseFacadeEjb(de.symeda.sormas.backend.clinicalcourse.ClinicalCourseFacadeEjb) VaccinationFacadeEjb(de.symeda.sormas.backend.vaccination.VaccinationFacadeEjb) TaskService(de.symeda.sormas.backend.task.TaskService) HashMap(java.util.HashMap) PathogenTestFacadeEjbLocal(de.symeda.sormas.backend.sample.PathogenTestFacadeEjb.PathogenTestFacadeEjbLocal) SurveillanceReportDto(de.symeda.sormas.api.caze.surveillancereport.SurveillanceReportDto) CaseExportType(de.symeda.sormas.api.caze.CaseExportType) CollectionUtils(org.apache.commons.collections.CollectionUtils) IterableHelper(de.symeda.sormas.backend.util.IterableHelper) FacilityFacadeEjbLocal(de.symeda.sormas.backend.infrastructure.facility.FacilityFacadeEjb.FacilityFacadeEjbLocal) Symptoms(de.symeda.sormas.backend.symptoms.Symptoms) TreatmentService(de.symeda.sormas.backend.therapy.TreatmentService) Expression(javax.persistence.criteria.Expression) BurialInfoDto(de.symeda.sormas.api.caze.BurialInfoDto) SormasToSormasOriginInfoFacadeEjbLocal(de.symeda.sormas.backend.sormastosormas.origin.SormasToSormasOriginInfoFacadeEjb.SormasToSormasOriginInfoFacadeEjbLocal) ModelConstants(de.symeda.sormas.backend.util.ModelConstants) EpiDataService(de.symeda.sormas.backend.epidata.EpiDataService) CaseJoins(de.symeda.sormas.utils.CaseJoins) ClinicalVisit(de.symeda.sormas.backend.clinicalcourse.ClinicalVisit) EpiDataFacadeEjbLocal(de.symeda.sormas.backend.epidata.EpiDataFacadeEjb.EpiDataFacadeEjbLocal) Validations(de.symeda.sormas.api.i18n.Validations) ClinicalVisitFacadeEjbLocal(de.symeda.sormas.backend.clinicalcourse.ClinicalVisitFacadeEjb.ClinicalVisitFacadeEjbLocal) MessageSubject(de.symeda.sormas.backend.common.messaging.MessageSubject) Pair(de.symeda.sormas.api.utils.DataHelper.Pair) PathogenTestService(de.symeda.sormas.backend.sample.PathogenTestService) MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) RegionService(de.symeda.sormas.backend.infrastructure.region.RegionService) TimeUnit(java.util.concurrent.TimeUnit) Event(de.symeda.sormas.backend.event.Event) NotificationType(de.symeda.sormas.api.user.NotificationType) MessagingService(de.symeda.sormas.backend.common.messaging.MessagingService) Country(de.symeda.sormas.backend.infrastructure.country.Country) SormasToSormasShareInfo(de.symeda.sormas.backend.sormastosormas.share.shareinfo.SormasToSormasShareInfo) ClinicalCourseFacadeEjbLocal(de.symeda.sormas.backend.clinicalcourse.ClinicalCourseFacadeEjb.ClinicalCourseFacadeEjbLocal) Strings(de.symeda.sormas.api.i18n.Strings) ExternalSurveillanceToolGatewayFacadeEjbLocal(de.symeda.sormas.backend.externalsurveillancetool.ExternalSurveillanceToolGatewayFacadeEjb.ExternalSurveillanceToolGatewayFacadeEjbLocal) Collections(java.util.Collections) ClinicalCourseReferenceDto(de.symeda.sormas.api.clinicalcourse.ClinicalCourseReferenceDto) TreatmentDto(de.symeda.sormas.api.therapy.TreatmentDto) BigDecimal(java.math.BigDecimal) Predicate(javax.persistence.criteria.Predicate) Comparator(java.util.Comparator) DistrictDto(de.symeda.sormas.api.infrastructure.district.DistrictDto) AtomicLong(java.util.concurrent.atomic.AtomicLong) AbstractDomainObject(de.symeda.sormas.backend.common.AbstractDomainObject) District(de.symeda.sormas.backend.infrastructure.district.District) Pair(de.symeda.sormas.api.utils.DataHelper.Pair)

Example 2 with CaseMeasure

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

the class DashboardMapComponent method createFooter.

private HorizontalLayout createFooter() {
    HorizontalLayout mapFooterLayout = new HorizontalLayout();
    mapFooterLayout.setWidth(100, Unit.PERCENTAGE);
    mapFooterLayout.setSpacing(true);
    CssStyles.style(mapFooterLayout, CssStyles.VSPACE_4, CssStyles.VSPACE_TOP_3);
    // Map key dropdown button
    legendDropdown = ButtonHelper.createPopupButton(Captions.dashboardMapKey, null, CssStyles.BUTTON_SUBTLE);
    legendDropdown.setContent(createLegend());
    mapFooterLayout.addComponent(legendDropdown);
    mapFooterLayout.setComponentAlignment(legendDropdown, Alignment.MIDDLE_RIGHT);
    mapFooterLayout.setExpandRatio(legendDropdown, 1);
    // Layers dropdown button
    VerticalLayout layersLayout = new VerticalLayout();
    {
        layersLayout.setMargin(true);
        layersLayout.setSpacing(false);
        layersLayout.setSizeUndefined();
        // Add check boxes and apply button
        {
            // case classifications
            OptionGroup caseClassificationOptions = new OptionGroup();
            caseClassificationOptions.addItems((Object[]) MapCaseClassificationOption.values());
            caseClassificationOptions.setValue(caseClassificationOption);
            caseClassificationOptions.addValueChangeListener(event -> {
                caseClassificationOption = (MapCaseClassificationOption) event.getProperty().getValue();
                refreshMap(true);
            });
            // Optiongroup to select what property the coordinates should be based on
            OptionGroup mapCaseDisplayModeSelect = new OptionGroup();
            mapCaseDisplayModeSelect.setWidth(100, Unit.PERCENTAGE);
            mapCaseDisplayModeSelect.addItems((Object[]) MapCaseDisplayMode.values());
            mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode);
            mapCaseDisplayModeSelect.addValueChangeListener(event -> {
                mapCaseDisplayMode = (MapCaseDisplayMode) event.getProperty().getValue();
                refreshMap(true);
            });
            HorizontalLayout showCasesLayout = new HorizontalLayout();
            {
                showCasesLayout.setMargin(false);
                showCasesLayout.setSpacing(false);
                CheckBox showCasesCheckBox = new CheckBox();
                showCasesCheckBox.setId(Captions.dashboardShowCases);
                showCasesCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowCases));
                showCasesCheckBox.setValue(showCases);
                showCasesCheckBox.addValueChangeListener(e -> {
                    showCases = (boolean) e.getProperty().getValue();
                    mapCaseDisplayModeSelect.setEnabled(showCases);
                    mapCaseDisplayModeSelect.setValue(mapCaseDisplayMode);
                    caseClassificationOptions.setEnabled(showCases);
                    refreshMap(true);
                });
                showCasesLayout.addComponent(showCasesCheckBox);
                Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
                infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseMap));
                CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY, CssStyles.HSPACE_LEFT_3);
                infoLabel.setHeightUndefined();
                showCasesLayout.addComponent(infoLabel);
                showCasesLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER);
            }
            layersLayout.addComponent(showCasesLayout);
            layersLayout.addComponent(mapCaseDisplayModeSelect);
            mapCaseDisplayModeSelect.setEnabled(showCases);
            layersLayout.addComponent(caseClassificationOptions);
            caseClassificationOptions.setEnabled(showCases);
            CheckBox showConfirmedContactsCheckBox = new CheckBox();
            showConfirmedContactsCheckBox.setId(Captions.dashboardShowConfirmedContacts);
            CheckBox showUnconfirmedContactsCheckBox = new CheckBox();
            showUnconfirmedContactsCheckBox.setId(Captions.dashboardShowUnconfirmedContacts);
            CheckBox showContactsCheckBox = new CheckBox();
            showContactsCheckBox.setId(Captions.dashboardShowContacts);
            showContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowContacts));
            showContactsCheckBox.setValue(showContacts);
            showContactsCheckBox.addValueChangeListener(e -> {
                showContacts = (boolean) e.getProperty().getValue();
                showConfirmedContactsCheckBox.setEnabled(showContacts);
                showConfirmedContactsCheckBox.setValue(true);
                showUnconfirmedContactsCheckBox.setEnabled(showContacts);
                showUnconfirmedContactsCheckBox.setValue(true);
                refreshMap(true);
            });
            layersLayout.addComponent(showContactsCheckBox);
            showConfirmedContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowConfirmedContacts));
            showConfirmedContactsCheckBox.setValue(showConfirmedContacts);
            showConfirmedContactsCheckBox.addValueChangeListener(e -> {
                showConfirmedContacts = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showConfirmedContactsCheckBox);
            CssStyles.style(showUnconfirmedContactsCheckBox, CssStyles.VSPACE_3);
            showUnconfirmedContactsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowUnconfirmedContacts));
            showUnconfirmedContactsCheckBox.setValue(showUnconfirmedContacts);
            showUnconfirmedContactsCheckBox.addValueChangeListener(e -> {
                showUnconfirmedContacts = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showUnconfirmedContactsCheckBox);
            showConfirmedContactsCheckBox.setEnabled(showContacts);
            showUnconfirmedContactsCheckBox.setEnabled(showContacts);
            CheckBox showEventsCheckBox = new CheckBox();
            showEventsCheckBox.setId(Captions.dashboardShowEvents);
            CssStyles.style(showEventsCheckBox, CssStyles.VSPACE_3);
            showEventsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowEvents));
            showEventsCheckBox.setValue(showEvents);
            showEventsCheckBox.addValueChangeListener(e -> {
                showEvents = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showEventsCheckBox);
            if (UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_USER) || UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_CLINICIAN) || UserProvider.getCurrent().hasUserRole(UserRole.NATIONAL_OBSERVER)) {
                OptionGroup regionMapVisualizationSelect = new OptionGroup();
                regionMapVisualizationSelect.setWidth(100, Unit.PERCENTAGE);
                regionMapVisualizationSelect.addItems((Object[]) CaseMeasure.values());
                regionMapVisualizationSelect.setValue(caseMeasure);
                regionMapVisualizationSelect.addValueChangeListener(event -> {
                    caseMeasure = (CaseMeasure) event.getProperty().getValue();
                    refreshMap(true);
                });
                HorizontalLayout showRegionsLayout = new HorizontalLayout();
                {
                    showRegionsLayout.setMargin(false);
                    showRegionsLayout.setSpacing(false);
                    CheckBox showRegionsCheckBox = new CheckBox();
                    showRegionsCheckBox.setId(Captions.dashboardShowRegions);
                    showRegionsCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardShowRegions));
                    showRegionsCheckBox.setValue(showRegions);
                    showRegionsCheckBox.addValueChangeListener(e -> {
                        showRegions = (boolean) e.getProperty().getValue();
                        regionMapVisualizationSelect.setEnabled(showRegions);
                        regionMapVisualizationSelect.setValue(caseMeasure);
                        refreshMap(true);
                    });
                    showRegionsLayout.addComponent(showRegionsCheckBox);
                    Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML);
                    infoLabel.setDescription(I18nProperties.getString(Strings.infoCaseIncidence));
                    CssStyles.style(infoLabel, CssStyles.LABEL_MEDIUM, CssStyles.LABEL_SECONDARY, CssStyles.HSPACE_LEFT_3);
                    infoLabel.setHeightUndefined();
                    showRegionsLayout.addComponent(infoLabel);
                    showRegionsLayout.setComponentAlignment(infoLabel, Alignment.TOP_CENTER);
                }
                layersLayout.addComponent(showRegionsLayout);
                layersLayout.addComponent(regionMapVisualizationSelect);
                regionMapVisualizationSelect.setEnabled(showRegions);
            }
            CheckBox hideOtherCountriesCheckBox = new CheckBox();
            hideOtherCountriesCheckBox.setId(Captions.dashboardHideOtherCountries);
            hideOtherCountriesCheckBox.setCaption(I18nProperties.getCaption(Captions.dashboardHideOtherCountries));
            hideOtherCountriesCheckBox.setValue(hideOtherCountries);
            hideOtherCountriesCheckBox.addValueChangeListener(e -> {
                hideOtherCountries = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            CssStyles.style(hideOtherCountriesCheckBox, CssStyles.VSPACE_3);
            layersLayout.addComponent(hideOtherCountriesCheckBox);
            CheckBox showCurrentEpiSituationCB = new CheckBox();
            showCurrentEpiSituationCB.setId(Captions.dashboardMapShowEpiSituation);
            showCurrentEpiSituationCB.setCaption(I18nProperties.getCaption(Captions.dashboardMapShowEpiSituation));
            showCurrentEpiSituationCB.setValue(false);
            showCurrentEpiSituationCB.addValueChangeListener(e -> {
                showCurrentEpiSituation = (boolean) e.getProperty().getValue();
                refreshMap(true);
            });
            layersLayout.addComponent(showCurrentEpiSituationCB);
        }
    }
    PopupButton layersDropdown = ButtonHelper.createPopupButton(Captions.dashboardMapLayers, layersLayout, CssStyles.BUTTON_SUBTLE);
    mapFooterLayout.addComponent(layersDropdown);
    mapFooterLayout.setComponentAlignment(layersDropdown, Alignment.MIDDLE_RIGHT);
    return mapFooterLayout;
}
Also used : Date(java.util.Date) CheckBox(com.vaadin.v7.ui.CheckBox) DashboardEventDto(de.symeda.sormas.api.dashboard.DashboardEventDto) I18nProperties(de.symeda.sormas.api.i18n.I18nProperties) Alignment(com.vaadin.ui.Alignment) Window(com.vaadin.ui.Window) LeafletMarker(de.symeda.sormas.ui.map.LeafletMarker) ControllerProvider(de.symeda.sormas.ui.ControllerProvider) GeoShapeProvider(de.symeda.sormas.api.geo.GeoShapeProvider) BigDecimal(java.math.BigDecimal) CssStyles(de.symeda.sormas.ui.utils.CssStyles) GeoLatLon(de.symeda.sormas.api.geo.GeoLatLon) VaadinIcons(com.vaadin.icons.VaadinIcons) LeafletMap(de.symeda.sormas.ui.map.LeafletMap) UserRole(de.symeda.sormas.api.user.UserRole) LeafletMapUtil(de.symeda.sormas.ui.map.LeafletMapUtil) UserProvider(de.symeda.sormas.ui.UserProvider) RoundingMode(java.math.RoundingMode) ValoTheme(com.vaadin.ui.themes.ValoTheme) InfrastructureHelper(de.symeda.sormas.api.infrastructure.InfrastructureHelper) Set(java.util.Set) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) DashboardCssStyles(de.symeda.sormas.ui.dashboard.DashboardCssStyles) DashboardType(de.symeda.sormas.ui.dashboard.DashboardType) ContactClassification(de.symeda.sormas.api.contact.ContactClassification) DashboardDataProvider(de.symeda.sormas.ui.dashboard.DashboardDataProvider) List(java.util.List) ExternalResource(com.vaadin.server.ExternalResource) AbstractComponent(com.vaadin.ui.AbstractComponent) DistrictDto(de.symeda.sormas.api.infrastructure.district.DistrictDto) Optional(java.util.Optional) RegionReferenceDto(de.symeda.sormas.api.infrastructure.region.RegionReferenceDto) FacilityDto(de.symeda.sormas.api.infrastructure.facility.FacilityDto) VaadinUiUtil(de.symeda.sormas.ui.utils.VaadinUiUtil) FacadeProvider(de.symeda.sormas.api.FacadeProvider) VerticalLayout(com.vaadin.ui.VerticalLayout) MapContactDto(de.symeda.sormas.api.contact.MapContactDto) CaseMeasure(de.symeda.sormas.api.CaseMeasure) CaseClassification(de.symeda.sormas.api.caze.CaseClassification) HashMap(java.util.HashMap) PopupButton(org.vaadin.hene.popupbutton.PopupButton) CssLayout(com.vaadin.ui.CssLayout) LeafletPolygon(de.symeda.sormas.ui.map.LeafletPolygon) EventStatus(de.symeda.sormas.api.event.EventStatus) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) OptionGroup(com.vaadin.v7.ui.OptionGroup) Image(com.vaadin.ui.Image) Label(com.vaadin.ui.Label) AbstractOrderedLayout(com.vaadin.ui.AbstractOrderedLayout) ButtonHelper(de.symeda.sormas.ui.utils.ButtonHelper) ContentMode(com.vaadin.shared.ui.ContentMode) DataHelper(de.symeda.sormas.api.utils.DataHelper) DistrictReferenceDto(de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto) UserDto(de.symeda.sormas.api.user.UserDto) CaseFacade(de.symeda.sormas.api.caze.CaseFacade) Pair(de.symeda.sormas.api.utils.DataHelper.Pair) MapCaseDto(de.symeda.sormas.api.caze.MapCaseDto) FacilityReferenceDto(de.symeda.sormas.api.infrastructure.facility.FacilityReferenceDto) Captions(de.symeda.sormas.api.i18n.Captions) Consumer(java.util.function.Consumer) Button(com.vaadin.ui.Button) Disease(de.symeda.sormas.api.Disease) MarkerIcon(de.symeda.sormas.ui.map.MarkerIcon) HeightMode(com.vaadin.v7.shared.ui.grid.HeightMode) HorizontalLayout(com.vaadin.ui.HorizontalLayout) Strings(de.symeda.sormas.api.i18n.Strings) OptionGroup(com.vaadin.v7.ui.OptionGroup) PopupButton(org.vaadin.hene.popupbutton.PopupButton) CheckBox(com.vaadin.v7.ui.CheckBox) Label(com.vaadin.ui.Label) VerticalLayout(com.vaadin.ui.VerticalLayout) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

CaseMeasure (de.symeda.sormas.api.CaseMeasure)2 Disease (de.symeda.sormas.api.Disease)2 CaseClassification (de.symeda.sormas.api.caze.CaseClassification)2 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)2 CaseFacade (de.symeda.sormas.api.caze.CaseFacade)2 MapCaseDto (de.symeda.sormas.api.caze.MapCaseDto)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 VaadinIcons (com.vaadin.icons.VaadinIcons)1 ExternalResource (com.vaadin.server.ExternalResource)1 ContentMode (com.vaadin.shared.ui.ContentMode)1 AbstractComponent (com.vaadin.ui.AbstractComponent)1 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)1 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1 CssLayout (com.vaadin.ui.CssLayout)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Image (com.vaadin.ui.Image)1 Label (com.vaadin.ui.Label)1 VerticalLayout (com.vaadin.ui.VerticalLayout)1 Window (com.vaadin.ui.Window)1