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