Search in sources :

Example 1 with FhirSyncLevel

use of net.geoprism.registry.etl.FhirSyncLevel in project geoprism-registry by terraframe.

the class FhirExportSynchronizationManager method synchronize.

public void synchronize() {
    final FhirExternalSystem system = (FhirExternalSystem) this.config.getSystem();
    try (FhirConnection connection = FhirConnectionFactory.get(system)) {
        SortedSet<FhirSyncLevel> levels = this.config.getLevels();
        int expectedLevel = 0;
        long exportCount = 0;
        for (FhirSyncLevel level : levels) {
            if (level.getLevel() != expectedLevel) {
                throw new ProgrammingErrorException("Unexpected level number [" + level.getLevel() + "].");
            }
            history.appLock();
            history.setWorkProgress((long) expectedLevel);
            history.setExportedRecords(exportCount);
            history.apply();
            ListTypeVersion version = ListTypeVersion.get(level.getVersionId());
            FhirDataPopulator populator = FhirFactory.getPopulator(level.getImplementation());
            ListTypeFhirExporter exporter = new ListTypeFhirExporter(version, connection, populator, true);
            long results = exporter.export();
            exportCount += results;
            expectedLevel++;
        }
        history.appLock();
        history.setWorkTotal((long) expectedLevel);
        history.setWorkProgress((long) expectedLevel);
        history.setExportedRecords(exportCount);
        history.clearStage();
        history.addStage(ExportStage.COMPLETE);
        history.apply();
        NotificationFacade.queue(new GlobalNotificationMessage(MessageType.DATA_EXPORT_JOB_CHANGE, null));
        handleExportErrors();
    } catch (Exception e) {
        throw new HttpError(e);
    }
}
Also used : FhirSyncLevel(net.geoprism.registry.etl.FhirSyncLevel) ListTypeVersion(net.geoprism.registry.ListTypeVersion) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) DataFormatException(ca.uhn.fhir.parser.DataFormatException) IOException(java.io.IOException) HttpError(net.geoprism.registry.etl.export.HttpError) GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage)

Example 2 with FhirSyncLevel

use of net.geoprism.registry.etl.FhirSyncLevel in project geoprism-registry by terraframe.

the class FhirExportSynchronizationManager method generateBundle.

public Bundle generateBundle(FhirConnection connection) {
    SortedSet<FhirSyncLevel> levels = this.config.getLevels();
    int expectedLevel = 0;
    Bundle bundle = new Bundle();
    for (FhirSyncLevel level : levels) {
        if (level.getLevel() != expectedLevel) {
            throw new ProgrammingErrorException("Unexpected level number [" + level.getLevel() + "].");
        }
        ListTypeVersion version = ListTypeVersion.get(level.getVersionId());
        FhirDataPopulator populator = FhirFactory.getPopulator(level.getImplementation());
        ListTypeFhirExporter exporter = new ListTypeFhirExporter(version, connection, populator, false);
        exporter.populateBundle(bundle);
        expectedLevel++;
    }
    return bundle;
}
Also used : FhirSyncLevel(net.geoprism.registry.etl.FhirSyncLevel) Bundle(org.hl7.fhir.r4.model.Bundle) ListTypeVersion(net.geoprism.registry.ListTypeVersion) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Aggregations

ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)2 ListTypeVersion (net.geoprism.registry.ListTypeVersion)2 FhirSyncLevel (net.geoprism.registry.etl.FhirSyncLevel)2 DataFormatException (ca.uhn.fhir.parser.DataFormatException)1 IOException (java.io.IOException)1 HttpError (net.geoprism.registry.etl.export.HttpError)1 FhirExternalSystem (net.geoprism.registry.graph.FhirExternalSystem)1 GlobalNotificationMessage (net.geoprism.registry.ws.GlobalNotificationMessage)1 Bundle (org.hl7.fhir.r4.model.Bundle)1