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