Search in sources :

Example 1 with LocationPositionComponent

use of org.hl7.fhir.r4.model.Location.LocationPositionComponent in project synthea by synthetichealth.

the class FhirR4 method providerLocation.

/**
 * Map the Provider into a FHIR Location resource, and add it to the given Bundle.
 *
 * @param rand     Source of randomness to use when generating ids etc
 * @param bundle   The Bundle to add to
 * @param provider The Provider
 * @return The added Entry or null if the bundle already contains this provider location
 */
protected static org.hl7.fhir.r4.model.Location providerLocation(RandomNumberGenerator rand, Bundle bundle, Provider provider) {
    org.hl7.fhir.r4.model.Location location = new org.hl7.fhir.r4.model.Location();
    if (USE_US_CORE_IG) {
        Meta meta = new Meta();
        meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-location");
        location.setMeta(meta);
    }
    location.setStatus(LocationStatus.ACTIVE);
    location.setName(provider.name);
    // set telecom
    if (provider.phone != null && !provider.phone.isEmpty()) {
        ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(provider.phone);
        location.addTelecom(contactPoint);
    } else if (USE_US_CORE_IG) {
        ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue("(555) 555-5555");
        location.addTelecom(contactPoint);
    }
    // set address
    Address address = new Address().addLine(provider.address).setCity(provider.city).setPostalCode(provider.zip).setState(provider.state);
    if (COUNTRY_CODE != null) {
        address.setCountry(COUNTRY_CODE);
    }
    location.setAddress(address);
    LocationPositionComponent position = new LocationPositionComponent();
    position.setLatitude(provider.getY());
    position.setLongitude(provider.getX());
    location.setPosition(position);
    location.addIdentifier().setSystem(SYNTHEA_IDENTIFIER).setValue(provider.getResourceLocationID());
    Identifier organizationIdentifier = new Identifier().setSystem(SYNTHEA_IDENTIFIER).setValue(provider.getResourceID());
    location.setManagingOrganization(new Reference().setIdentifier(organizationIdentifier).setDisplay(provider.name));
    return location;
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) Address(org.hl7.fhir.r4.model.Address) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) LocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Identifier(org.hl7.fhir.r4.model.Identifier) Location(org.mitre.synthea.world.geography.Location)

Example 2 with LocationPositionComponent

use of org.hl7.fhir.r4.model.Location.LocationPositionComponent in project geoprism-registry by terraframe.

the class BasicFhirResourceProcessor method getGeometry.

@Override
protected Geometry getGeometry(Location location, ServerGeoObjectType type) {
    if (type.getGeometryType().equals(GeometryType.MULTIPOINT)) {
        LocationPositionComponent position = location.getPosition();
        if (position != null) {
            GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
            BigDecimal latitude = position.getLatitude();
            BigDecimal longitude = position.getLongitude();
            if (latitude != null && longitude != null) {
                Point point = factory.createPoint(new Coordinate(longitude.doubleValue(), latitude.doubleValue()));
                return factory.createMultiPoint(new Point[] { point });
            }
        }
    }
    return super.getGeometry(location, type);
}
Also used : LocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) Coordinate(com.vividsolutions.jts.geom.Coordinate) PrecisionModel(com.vividsolutions.jts.geom.PrecisionModel) Point(com.vividsolutions.jts.geom.Point) BigDecimal(java.math.BigDecimal)

Example 3 with LocationPositionComponent

use of org.hl7.fhir.r4.model.Location.LocationPositionComponent in project geoprism-registry by terraframe.

the class ListTypeFhirExporter method createFacility.

private Facility createFacility(Business row, Identifier identifier) {
    String code = row.getValue(DefaultAttribute.CODE.getName());
    Organization org = new Organization();
    org.setId(new IdType(org.getResourceType().name(), code));
    org.setName(row.getValue(DefaultAttribute.DISPLAY_LABEL.getName() + ListTypeVersion.DEFAULT_LOCALE));
    org.addIdentifier(identifier);
    Location location = new Location();
    location.setId(new IdType(location.getResourceType().name(), code));
    location.setName(row.getValue(DefaultAttribute.DISPLAY_LABEL.getName() + ListTypeVersion.DEFAULT_LOCALE));
    location.setManagingOrganization(new Reference(org.getIdElement()));
    location.addIdentifier(identifier);
    Geometry geometry = row.getObjectValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME);
    if (geometry != null) {
        Point centroid = geometry.getCentroid();
        GeoJsonWriter writer = new GeoJsonWriter();
        String geojson = writer.write(geometry);
        Encoder encoder = Base64.getEncoder();
        // Create a location
        Attachment attachment = new Attachment();
        attachment.setContentType("application/json");
        attachment.setDataElement(new Base64BinaryType(encoder.encodeToString(geojson.getBytes())));
        attachment.setTitle("Geojson");
        Extension extension = new Extension("http://hl7.org/fhir/StructureDefinition/location-boundary-geojson");
        extension.setValue(attachment);
        location.setPosition(new LocationPositionComponent(new DecimalType(centroid.getX()), new DecimalType(centroid.getY())));
        location.addExtension(extension);
    }
    return new Facility(org, location);
}
Also used : GeoJsonWriter(com.vividsolutions.jts.io.geojson.GeoJsonWriter) Organization(org.hl7.fhir.r4.model.Organization) Reference(org.hl7.fhir.r4.model.Reference) Attachment(org.hl7.fhir.r4.model.Attachment) Point(com.vividsolutions.jts.geom.Point) IdType(org.hl7.fhir.r4.model.IdType) Geometry(com.vividsolutions.jts.geom.Geometry) Extension(org.hl7.fhir.r4.model.Extension) LocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent) Encoder(java.util.Base64.Encoder) DecimalType(org.hl7.fhir.r4.model.DecimalType) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) Location(org.hl7.fhir.r4.model.Location)

Aggregations

LocationPositionComponent (org.hl7.fhir.r4.model.Location.LocationPositionComponent)3 Point (com.vividsolutions.jts.geom.Point)2 Reference (org.hl7.fhir.r4.model.Reference)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 PrecisionModel (com.vividsolutions.jts.geom.PrecisionModel)1 GeoJsonWriter (com.vividsolutions.jts.io.geojson.GeoJsonWriter)1 BigDecimal (java.math.BigDecimal)1 Encoder (java.util.Base64.Encoder)1 Address (org.hl7.fhir.r4.model.Address)1 Attachment (org.hl7.fhir.r4.model.Attachment)1 Base64BinaryType (org.hl7.fhir.r4.model.Base64BinaryType)1 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)1 DecimalType (org.hl7.fhir.r4.model.DecimalType)1 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)1 Extension (org.hl7.fhir.r4.model.Extension)1 IdType (org.hl7.fhir.r4.model.IdType)1 Identifier (org.hl7.fhir.r4.model.Identifier)1 Location (org.hl7.fhir.r4.model.Location)1