Search in sources :

Example 1 with FhirExternalSystem

use of net.geoprism.registry.graph.FhirExternalSystem in project geoprism-registry by terraframe.

the class FhirExportJob method execute.

@Override
public void execute(ExecutionContext executionContext) throws Throwable {
    NotificationFacade.queue(new GlobalNotificationMessage(MessageType.PUBLISH_JOB_CHANGE, null));
    FhirExternalSystem system = this.getExternalSystem();
// this.getVersion().exportToFhir(system, this.getImplementation());
}
Also used : GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem)

Example 2 with FhirExternalSystem

use of net.geoprism.registry.graph.FhirExternalSystem in project geoprism-registry by terraframe.

the class DHIS2FeatureService method getSystemCapabilities.

@Request(RequestType.SESSION)
public JsonObject getSystemCapabilities(String sessionId, String systemJSON) {
    JsonObject capabilities = new JsonObject();
    JsonObject jo = JsonParser.parseString(systemJSON).getAsJsonObject();
    ExternalSystem system = ExternalSystem.desieralize(jo);
    if (system instanceof DHIS2ExternalSystem) {
        DHIS2ExternalSystem dhis2System = (DHIS2ExternalSystem) system;
        DHIS2TransportServiceIF dhis2 = getTransportService(dhis2System);
        String version = dhis2.getVersionRemoteServer();
        if (ArrayUtils.contains(DHIS2FeatureService.OAUTH_INCOMPATIBLE_VERSIONS, version)) {
            capabilities.addProperty("oauth", false);
        } else {
            capabilities.addProperty("oauth", true);
        }
    } else if (system instanceof FhirExternalSystem) {
        capabilities.addProperty("oauth", true);
    } else {
        capabilities.addProperty("oauth", false);
    }
    return capabilities;
}
Also used : DHIS2TransportServiceIF(net.geoprism.registry.etl.export.dhis2.DHIS2TransportServiceIF) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) JsonObject(com.google.gson.JsonObject) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) Request(com.runwaysdk.session.Request)

Example 3 with FhirExternalSystem

use of net.geoprism.registry.graph.FhirExternalSystem 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 4 with FhirExternalSystem

use of net.geoprism.registry.graph.FhirExternalSystem in project geoprism-registry by terraframe.

the class FhirExportSynchronizationManager method writeToFile.

public File writeToFile() throws IOException {
    final FhirExternalSystem system = (FhirExternalSystem) this.config.getSystem();
    try (FhirConnection connection = FhirConnectionFactory.get(system)) {
        String name = SessionPredicate.generateId();
        File root = new File(new File(VaultProperties.getPath("vault.default"), "files"), name);
        root.mkdirs();
        Bundle bundle = this.generateBundle(connection);
        FhirContext ctx = FhirContext.forR4();
        IParser parser = ctx.newJsonParser();
        try {
            parser.encodeResourceToWriter(bundle, new FileWriter(new File(root, "bundle.json")));
        } catch (DataFormatException | IOException e) {
            throw new ProgrammingErrorException(e);
        }
        return root;
    } catch (Exception e) {
        throw new HttpError(e);
    }
}
Also used : FhirContext(ca.uhn.fhir.context.FhirContext) Bundle(org.hl7.fhir.r4.model.Bundle) FileWriter(java.io.FileWriter) IOException(java.io.IOException) 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) DataFormatException(ca.uhn.fhir.parser.DataFormatException) HttpError(net.geoprism.registry.etl.export.HttpError) File(java.io.File) IParser(ca.uhn.fhir.parser.IParser)

Example 5 with FhirExternalSystem

use of net.geoprism.registry.graph.FhirExternalSystem in project geoprism-registry by terraframe.

the class FhirImportTest method createExternalSystem.

@Request
private FhirExternalSystem createExternalSystem() {
    FhirExternalSystem system = new FhirExternalSystem();
    system.setId("FHIRImportTest");
    system.setOrganization(USATestData.ORG_NPS.getServerObject());
    system.getEmbeddedComponent(ExternalSystem.LABEL).setValue("defaultLocale", "Test");
    system.getEmbeddedComponent(ExternalSystem.DESCRIPTION).setValue("defaultLocale", "Test");
    system.setUrl("localhost:8080/fhir");
    system.setSystem("localhost");
    system.apply();
    return system;
}
Also used : FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) Request(com.runwaysdk.session.Request)

Aggregations

FhirExternalSystem (net.geoprism.registry.graph.FhirExternalSystem)7 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)3 Request (com.runwaysdk.session.Request)3 HttpError (net.geoprism.registry.etl.export.HttpError)3 GlobalNotificationMessage (net.geoprism.registry.ws.GlobalNotificationMessage)3 DataFormatException (ca.uhn.fhir.parser.DataFormatException)2 IParser (ca.uhn.fhir.parser.IParser)2 IOException (java.io.IOException)2 Date (java.util.Date)2 Bundle (org.hl7.fhir.r4.model.Bundle)2 FhirContext (ca.uhn.fhir.context.FhirContext)1 JsonObject (com.google.gson.JsonObject)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 ListTypeVersion (net.geoprism.registry.ListTypeVersion)1 SynchronizationConfig (net.geoprism.registry.SynchronizationConfig)1 ExportJobHasErrors (net.geoprism.registry.etl.ExportJobHasErrors)1 FhirSyncLevel (net.geoprism.registry.etl.FhirSyncLevel)1 DHIS2TransportServiceIF (net.geoprism.registry.etl.export.dhis2.DHIS2TransportServiceIF)1 BasicFhirConnection (net.geoprism.registry.etl.fhir.BasicFhirConnection)1