use of com.walmartlabs.concord.runtime.v2.model.Location in project geoprism-registry by terraframe.
the class FhirBulkDataImporter method synchronize.
public void synchronize() {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
CloseableHttpClient myClient = builder.build();
FhirContext ctx = FhirContext.forR4();
String statusUrl = initiateBulkExport(myClient, ctx);
if (statusUrl != null) {
final List<String> outputs = getExportResults(myClient, statusUrl);
IGenericClient client = ctx.newRestfulGenericClient(this.system.getUrl());
for (String binaryUrl : outputs) {
Binary binary = client.fetchResourceFromUrl(Binary.class, binaryUrl);
String base64 = binary.getContentAsBase64();
byte[] result = Base64.getDecoder().decode(base64);
IParser parser = ctx.newJsonParser();
String message = new String(result);
try (BufferedReader reader = new BufferedReader(new StringReader(message))) {
String line = null;
while ((line = reader.readLine()) != null) {
IBaseResource resource = parser.parseResource(line);
IIdType id = resource.getIdElement();
String resourceType = id.getResourceType();
if (resourceType.equals(ResourceTypes.LOCATION.toCode())) {
Location location = (Location) resource;
this.processor.process(location);
} else if (resourceType.equals(ResourceTypes.ORGANIZATION.toCode())) {
Organization organization = (Organization) resource;
this.processor.process(organization);
}
}
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
}
}
}
use of com.walmartlabs.concord.runtime.v2.model.Location in project geoprism-registry by terraframe.
the class FhirResourceImporter method process.
private void process(Bundle bundle) {
FhirPathR4 path = new FhirPathR4(FhirContext.forR4());
List<Location> locations = path.evaluate(bundle, "Bundle.entry.resource.ofType(Location)", Location.class);
for (Location location : locations) {
try {
handleLocation(location);
if (this.history != null) {
this.history.appLock();
this.history.setWorkProgress(count++);
this.history.setExportedRecords(exportCount++);
this.history.apply();
}
} catch (Exception e) {
if (this.history != null) {
this.recordExportError(e, this.history, location);
this.history.appLock();
this.history.setWorkProgress(count++);
this.history.apply();
} else {
throw new ProgrammingErrorException(e);
}
}
}
List<Organization> organizations = path.evaluate(bundle, "Bundle.entry.resource.ofType(Organization)", Organization.class);
for (Organization organization : organizations) {
try {
handleOrganization(organization);
if (this.history != null) {
this.history.appLock();
this.history.setWorkProgress(count++);
this.history.setExportedRecords(exportCount++);
this.history.apply();
}
} catch (Exception e) {
if (this.history != null) {
this.recordExportError(e, this.history, organization);
this.history.appLock();
this.history.setWorkProgress(count++);
this.history.apply();
} else {
throw new ProgrammingErrorException(e);
}
}
}
}
use of com.walmartlabs.concord.runtime.v2.model.Location in project geoprism-registry by terraframe.
the class MCSDFhirDataPopulator method populate.
@Override
public void populate(Business row, Facility facility) {
super.populate(row, facility);
ServerGeoObjectType type = this.getList().getGeoObjectType();
String label = type.getLabel().getValue();
String system = this.getContext().getSystem();
CodeableConcept concept = new CodeableConcept().setText(label).addCoding(new Coding(system, type.getCode(), label));
Location location = facility.getLocation();
location.addType(concept);
location.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.Location");
Organization organization = facility.getOrganization();
organization.addType(concept);
organization.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.Organization");
if (type.getGeometryType().equals(GeometryType.MULTIPOINT)) {
location.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.FacilityLocation");
location.addType(new CodeableConcept().addCoding(new Coding("urn:ietf:rfc:3986", "urn:ihe:iti:mcsd:2019:facility", "Facility")));
location.setPhysicalType(new CodeableConcept().setText("Building").addCoding(new Coding("http://terminology.hl7.org/CodeSystem/location-physical-type", "bu", "Building")));
organization.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.FacilityOrganization");
organization.addType(new CodeableConcept().addCoding(new Coding("urn:ietf:rfc:3986", "urn:ihe:iti:mcsd:2019:facility", "Facility")));
} else {
location.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.JurisdictionLocation");
location.addType(new CodeableConcept().addCoding(new Coding("urn:ietf:rfc:3986", "urn:ihe:iti:mcsd:2019:jurisdiction", "Jurisdiction")));
location.setPhysicalType(new CodeableConcept().setText("Jurisdiction").addCoding(new Coding("http://terminology.hl7.org/CodeSystem/location-physical-type", "jdn", "Jurisdiction")));
organization.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.JurisdictionsOrganization");
organization.addType(new CodeableConcept().addCoding(new Coding("urn:ietf:rfc:3986", "urn:ihe:iti:mcsd:2019:jurisdiction", "Jurisdiction")));
}
if (this.hierarchies.size() > 1) {
for (ServerHierarchyType hierarchy : this.hierarchies) {
this.addHierarchyExtension(row, facility, hierarchy);
}
} else if (this.hierarchies.size() == 1) {
this.setPartOf(row, facility, this.hierarchies.get(0));
}
}
use of com.walmartlabs.concord.runtime.v2.model.Location in project geoprism-registry by terraframe.
the class TolkienFhirDataPopulator method populate.
@Override
public void populate(Business row, Facility facility) {
super.populate(row, facility);
ServerGeoObjectType type = this.getList().getGeoObjectType();
String label = type.getLabel().getValue();
String system = this.getContext().getSystem();
CodeableConcept concept = new CodeableConcept().setText(label).addCoding(new Coding(system, type.getCode(), label));
Location location = facility.getLocation();
location.addType(concept);
location.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.Location");
Organization organization = facility.getOrganization();
organization.addType(concept);
organization.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.Organization");
if (type.getGeometryType().equals(GeometryType.MULTIPOINT)) {
location.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.FacilityLocation");
location.addType(new CodeableConcept().addCoding(new Coding("urn:ietf:rfc:3986", "urn:ihe:iti:mcsd:2019:facility", "Facility")));
location.setPhysicalType(new CodeableConcept().setText("Building").addCoding(new Coding("http://terminology.hl7.org/CodeSystem/location-physical-type", "bu", "Building")));
organization.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.FacilityOrganization");
organization.addType(new CodeableConcept().addCoding(new Coding("urn:ietf:rfc:3986", "urn:ihe:iti:mcsd:2019:facility", "Facility")));
} else {
location.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.JurisdictionLocation");
location.addType(new CodeableConcept().addCoding(new Coding("urn:ietf:rfc:3986", "urn:ihe:iti:mcsd:2019:jurisdiction", "Jurisdiction")));
location.setPhysicalType(new CodeableConcept().setText("Jurisdiction").addCoding(new Coding("http://terminology.hl7.org/CodeSystem/location-physical-type", "jdn", "Jurisdiction")));
organization.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE.mCSD.JurisdictionsOrganization");
organization.addType(new CodeableConcept().addCoding(new Coding("urn:ietf:rfc:3986", "urn:ihe:iti:mcsd:2019:jurisdiction", "Jurisdiction")));
}
// if (this.hierarchies.size() > 1)
{
for (ServerHierarchyType hierarchy : this.hierarchies) {
this.addHierarchyExtension(row, facility, hierarchy);
}
}
// else if (this.hierarchies.size() == 1)
// {
// this.setPartOf(row, facility, this.hierarchies.get(0));
// }
}
use of com.walmartlabs.concord.runtime.v2.model.Location in project eCRNow by drajer-health.
the class CdaFhirUtilities method getLocation.
public static Location getLocation(List<BundleEntryComponent> entries, Encounter en) {
EncounterLocationComponent loc = en.getLocationFirstRep();
if (loc != null && loc.getLocation() != null) {
BundleEntryComponent ent = getResourceEntryForId(loc.getLocation().getReference(), "Location", entries);
if (ent != null) {
logger.debug("Found Location for Id {}", loc.getLocation().getReference());
return (Location) ent.getResource();
}
}
logger.debug("Did not find the location resource for encounter");
return null;
}
Aggregations