Search in sources :

Example 61 with Location

use of com.ibm.watson.compare_comply.v1.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);
            }
        }
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) FhirContext(ca.uhn.fhir.context.FhirContext) Organization(org.hl7.fhir.r4.model.Organization) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) HttpClientBuilder(org.apache.http.impl.client.HttpClientBuilder) IOException(java.io.IOException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) PoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager) BufferedReader(java.io.BufferedReader) StringReader(java.io.StringReader) Binary(org.hl7.fhir.r4.model.Binary) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) IParser(ca.uhn.fhir.parser.IParser) IIdType(org.hl7.fhir.instance.model.api.IIdType) Location(org.hl7.fhir.r4.model.Location)

Example 62 with Location

use of com.ibm.watson.compare_comply.v1.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);
            }
        }
    }
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) FhirPathR4(org.hl7.fhir.r4.hapi.fluentpath.FhirPathR4) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Location(org.hl7.fhir.r4.model.Location)

Example 63 with Location

use of com.ibm.watson.compare_comply.v1.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));
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Organization(org.hl7.fhir.r4.model.Organization) Coding(org.hl7.fhir.r4.model.Coding) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Location(org.hl7.fhir.r4.model.Location)

Example 64 with Location

use of com.ibm.watson.compare_comply.v1.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));
// }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Organization(org.hl7.fhir.r4.model.Organization) Coding(org.hl7.fhir.r4.model.Coding) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Location(org.hl7.fhir.r4.model.Location)

Example 65 with Location

use of com.ibm.watson.compare_comply.v1.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;
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) EncounterLocationComponent(org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent) Location(org.hl7.fhir.r4.model.Location)

Aggregations

Test (org.junit.Test)120 Location (org.hl7.fhir.r4.model.Location)93 Location (org.hl7.fhir.dstu3.model.Location)66 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)59 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)42 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)30 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)27 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)21 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)20 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)20 StringParam (ca.uhn.fhir.rest.param.StringParam)20 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)16 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)16 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)16 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)16 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)13 Test (org.junit.jupiter.api.Test)13 ArrayList (java.util.ArrayList)11 HashSet (java.util.HashSet)11 TokenParam (ca.uhn.fhir.rest.param.TokenParam)10