Search in sources :

Example 1 with FhirPathR4

use of org.hl7.fhir.r4.hapi.fluentpath.FhirPathR4 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)

Aggregations

ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 FhirPathR4 (org.hl7.fhir.r4.hapi.fluentpath.FhirPathR4)1 Location (org.hl7.fhir.r4.model.Location)1 Organization (org.hl7.fhir.r4.model.Organization)1