Search in sources :

Example 1 with Region

use of de.symeda.sormas.backend.infrastructure.region.Region in project SORMAS-Project by hzi-braunschweig.

the class ContactFacadeEjb method getContactsForMap.

@Override
public List<MapContactDto> getContactsForMap(RegionReferenceDto regionRef, DistrictReferenceDto districtRef, Disease disease, Date from, Date to) {
    Region region = regionService.getByReferenceDto(regionRef);
    District district = districtService.getByReferenceDto(districtRef);
    return service.getContactsForMap(region, district, disease, from, to);
}
Also used : Region(de.symeda.sormas.backend.infrastructure.region.Region) District(de.symeda.sormas.backend.infrastructure.district.District)

Example 2 with Region

use of de.symeda.sormas.backend.infrastructure.region.Region in project SORMAS-Project by hzi-braunschweig.

the class StartupShutdownService method createDefaultInfrastructureData.

private void createDefaultInfrastructureData() {
    if (!configFacade.isCreateDefaultEntities()) {
        // return if isCreateDefaultEntities() is false
        logger.info("Skipping the creation of default infrastructure data");
        return;
    }
    // Region
    Region region = null;
    if (regionService.count() == 0) {
        region = defaultEntitiesCreator.createDefaultRegion(false);
        regionService.ensurePersisted(region);
    }
    // District
    District district = null;
    if (districtService.count() == 0) {
        if (region == null) {
            region = regionService.getAll().get(0);
        }
        district = defaultEntitiesCreator.createDefaultDistrict(region, false);
        districtService.ensurePersisted(district);
        region.getDistricts().add(district);
    }
    // Community
    Community community = null;
    if (communityService.count() == 0) {
        if (district == null) {
            district = districtService.getAll().get(0);
        }
        community = defaultEntitiesCreator.createDefaultCommunity(district, false);
        communityService.ensurePersisted(community);
        district.getCommunities().add(community);
    }
    // Facility
    Facility facility;
    FacilityCriteria facilityCriteria = new FacilityCriteria();
    if (facilityFacade.count(facilityCriteria) == 0) {
        if (community == null) {
            community = communityService.getAll().get(0);
        }
        if (district == null) {
            district = districtService.getAll().get(0);
        }
        if (region == null) {
            region = regionService.getAll().get(0);
        }
        facility = defaultEntitiesCreator.createDefaultFacility(region, district, community);
        facilityService.ensurePersisted(facility);
    }
    // Laboratory
    Facility laboratory;
    facilityCriteria.type(FacilityType.LABORATORY);
    if (facilityFacade.count(facilityCriteria) == 0) {
        if (community == null) {
            community = communityService.getAll().get(0);
        }
        if (district == null) {
            district = districtService.getAll().get(0);
        }
        if (region == null) {
            region = regionService.getAll().get(0);
        }
        laboratory = defaultEntitiesCreator.createDefaultLaboratory(region, district, community);
        facilityService.ensurePersisted(laboratory);
    }
    // Point of Entry
    PointOfEntry pointOfEntry;
    if (pointOfEntryService.count() == 0) {
        if (district == null) {
            district = districtService.getAll().get(0);
        }
        if (region == null) {
            region = regionService.getAll().get(0);
        }
        pointOfEntry = defaultEntitiesCreator.createDefaultPointOfEntry(region, district);
        pointOfEntryService.ensurePersisted(pointOfEntry);
    }
}
Also used : Region(de.symeda.sormas.backend.infrastructure.region.Region) FacilityCriteria(de.symeda.sormas.api.infrastructure.facility.FacilityCriteria) Facility(de.symeda.sormas.backend.infrastructure.facility.Facility) PointOfEntry(de.symeda.sormas.backend.infrastructure.pointofentry.PointOfEntry) District(de.symeda.sormas.backend.infrastructure.district.District) Community(de.symeda.sormas.backend.infrastructure.community.Community)

Example 3 with Region

use of de.symeda.sormas.backend.infrastructure.region.Region in project SORMAS-Project by hzi-braunschweig.

the class DefaultEntitiesCreator method createDefaultRegion.

public Region createDefaultRegion(boolean randomUuid) {
    Region region = new Region();
    region.setUuid(createUuid(randomUuid, DefaultEntityHelper.DefaultInfrastructureUuidSeed.REGION));
    region.setName(I18nProperties.getCaption(Captions.defaultRegion, "Default Region"));
    region.setEpidCode("DEF-REG");
    region.setDistricts(new ArrayList<>());
    return region;
}
Also used : Region(de.symeda.sormas.backend.infrastructure.region.Region)

Example 4 with Region

use of de.symeda.sormas.backend.infrastructure.region.Region in project SORMAS-Project by hzi-braunschweig.

the class WeeklyReportFacadeEjb method getSummariesPerRegion.

@Override
public List<WeeklyReportRegionSummaryDto> getSummariesPerRegion(EpiWeek epiWeek) {
    if (userService.getCurrentUser().getCalculatedJurisdictionLevel() != JurisdictionLevel.NATION) {
        return new ArrayList<>();
    }
    List<WeeklyReportRegionSummaryDto> summaryDtos = new ArrayList<>();
    WeeklyReportCriteria regionReportCriteria = new WeeklyReportCriteria().epiWeek(epiWeek);
    List<Region> regions = regionService.getAll(Region.NAME, true);
    for (Region region : regions) {
        WeeklyReportRegionSummaryDto summaryDto = new WeeklyReportRegionSummaryDto();
        summaryDto.setRegion(RegionFacadeEjb.toReferenceDto(region));
        Long officers = userService.countByRegion(region, UserRole.SURVEILLANCE_OFFICER);
        if (officers.intValue() == 0) {
            // summarize only regions that do have officers
            continue;
        }
        summaryDto.setOfficers(officers.intValue());
        Long informants = userService.countByRegion(region, UserRole.HOSPITAL_INFORMANT, UserRole.COMMUNITY_INFORMANT);
        summaryDto.setInformants(informants.intValue());
        regionReportCriteria.reportingUserRegion(summaryDto.getRegion());
        regionReportCriteria.officerReport(true);
        regionReportCriteria.zeroReport(false);
        Long officerCaseReports = weeklyReportService.countByCriteria(regionReportCriteria, null);
        summaryDto.setOfficerCaseReports(officerCaseReports.intValue());
        regionReportCriteria.zeroReport(true);
        Long officerZeroReports = weeklyReportService.countByCriteria(regionReportCriteria, null);
        summaryDto.setOfficerZeroReports(officerZeroReports.intValue());
        regionReportCriteria.officerReport(false);
        regionReportCriteria.zeroReport(false);
        Long informantCaseReports = weeklyReportService.countByCriteria(regionReportCriteria, null);
        summaryDto.setInformantCaseReports(informantCaseReports.intValue());
        regionReportCriteria.zeroReport(true);
        Long informantZeroReports = weeklyReportService.countByCriteria(regionReportCriteria, null);
        summaryDto.setInformantZeroReports(informantZeroReports.intValue());
        summaryDtos.add(summaryDto);
    }
    return summaryDtos;
}
Also used : ArrayList(java.util.ArrayList) WeeklyReportRegionSummaryDto(de.symeda.sormas.api.report.WeeklyReportRegionSummaryDto) Region(de.symeda.sormas.backend.infrastructure.region.Region) WeeklyReportCriteria(de.symeda.sormas.api.report.WeeklyReportCriteria)

Example 5 with Region

use of de.symeda.sormas.backend.infrastructure.region.Region in project SORMAS-Project by hzi-braunschweig.

the class PathogenTestFacadeEjb method onPathogenTestChanged.

private void onPathogenTestChanged(PathogenTestDto existingPathogenTest, PathogenTest newPathogenTest) {
    // Send an email to all responsible supervisors when a new non-pending sample test is created or the status of
    // a formerly pending test result has changed
    final String sampleUuid = newPathogenTest.getSample().getUuid();
    final Sample sample = sampleService.getByUuid(sampleUuid);
    final Case caze = sample.getAssociatedCase();
    final Contact contact = sample.getAssociatedContact();
    final EventParticipant eventParticipant = sample.getAssociatedEventParticipant();
    Disease disease = null;
    Set<NotificationType> notificationTypes = new HashSet<>();
    List<Region> regions = new ArrayList<>();
    if (caze != null) {
        disease = caze.getDisease();
        notificationTypes.add(NotificationType.CASE_LAB_RESULT_ARRIVED);
        regions.addAll(JurisdictionHelper.getCaseRegions(caze));
    }
    if (contact != null) {
        disease = contact.getDisease() != null ? contact.getDisease() : contact.getCaze().getDisease();
        notificationTypes.add(NotificationType.CONTACT_LAB_RESULT_ARRIVED);
        regions.addAll(JurisdictionHelper.getContactRegions(contact));
    }
    if (eventParticipant != null) {
        disease = eventParticipant.getEvent().getDisease();
        notificationTypes.add(NotificationType.EVENT_PARTICIPANT_LAB_RESULT_ARRIVED);
        regions.add(eventParticipant.getEvent().getEventLocation().getRegion());
        if (disease == null) {
            sendMessageOnPathogenTestChanged(existingPathogenTest, newPathogenTest, null, notificationTypes, regions, MessageContents.CONTENT_LAB_RESULT_ARRIVED_EVENT_PARTICIPANT_NO_DISEASE, DataHelper.getShortUuid(eventParticipant.getUuid()));
        }
    }
    if (disease != null) {
        final String contentLabResultArrived = caze != null ? MessageContents.CONTENT_LAB_RESULT_ARRIVED : contact != null ? MessageContents.CONTENT_LAB_RESULT_ARRIVED_CONTACT : MessageContents.CONTENT_LAB_RESULT_ARRIVED_EVENT_PARTICIPANT;
        final String shortUuid = DataHelper.getShortUuid(caze != null ? caze.getUuid() : contact != null ? contact.getUuid() : eventParticipant.getUuid());
        sendMessageOnPathogenTestChanged(existingPathogenTest, newPathogenTest, disease, notificationTypes, regions, contentLabResultArrived, shortUuid);
    }
}
Also used : Disease(de.symeda.sormas.api.Disease) NotificationType(de.symeda.sormas.api.user.NotificationType) ArrayList(java.util.ArrayList) Region(de.symeda.sormas.backend.infrastructure.region.Region) EventParticipant(de.symeda.sormas.backend.event.EventParticipant) Case(de.symeda.sormas.backend.caze.Case) Contact(de.symeda.sormas.backend.contact.Contact) HashSet(java.util.HashSet)

Aggregations

Region (de.symeda.sormas.backend.infrastructure.region.Region)84 District (de.symeda.sormas.backend.infrastructure.district.District)58 Community (de.symeda.sormas.backend.infrastructure.community.Community)30 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)29 Predicate (javax.persistence.criteria.Predicate)28 Test (org.junit.Test)25 ArrayList (java.util.ArrayList)22 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)21 User (de.symeda.sormas.backend.user.User)21 Facility (de.symeda.sormas.backend.infrastructure.facility.Facility)17 RegionReferenceDto (de.symeda.sormas.api.infrastructure.region.RegionReferenceDto)14 Date (java.util.Date)14 SortProperty (de.symeda.sormas.api.utils.SortProperty)13 DistrictReferenceDto (de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto)12 List (java.util.List)12 Order (javax.persistence.criteria.Order)12 EJB (javax.ejb.EJB)11 LocalBean (javax.ejb.LocalBean)11 Stateless (javax.ejb.Stateless)11 Join (javax.persistence.criteria.Join)11