Search in sources :

Example 6 with FhirExternalSystem

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

the class FhirImportTest method testBasicImport.

@Request
@Test
public void testBasicImport() throws InterruptedException {
    try {
        FhirExternalSystem system = createExternalSystem();
        SynchronizationConfig config = createSyncConfig(system);
        FhirSyncImportConfig iConfig = (FhirSyncImportConfig) config.buildConfiguration();
        FhirResourceProcessor processor = FhirFactory.getProcessor(iConfig.getImplementation());
        IParser parser = FhirContext.forR4().newJsonParser();
        Bundle bundle = new Bundle();
        bundle.addEntry(new BundleEntryComponent().setResource((Resource) parser.parseResource(this.getClass().getResourceAsStream("/fhir/organization.json"))));
        bundle.addEntry(new BundleEntryComponent().setResource((Resource) parser.parseResource(this.getClass().getResourceAsStream("/fhir/location.json"))));
        FhirResourceImporter importer = new FhirResourceImporter(new BasicFhirConnection(system), processor, null, null);
        importer.synchronize(bundle);
        ServerGeoObjectIF geoobject = new ServerGeoObjectService().getGeoObjectByCode("USATestDataHsTwo", "USATestDataHealthStop");
        geoobject.setDate(new Date());
        LocalizedValue displayLabel = geoobject.getDisplayLabel();
        Assert.assertEquals("USATestDataHsTwo ZZZZZZZ", displayLabel.getValue());
    } finally {
        TestDataSet.deleteExternalSystems("FHIRImportTest");
    }
}
Also used : FhirResourceImporter(net.geoprism.registry.etl.fhir.FhirResourceImporter) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) Bundle(org.hl7.fhir.r4.model.Bundle) Resource(org.hl7.fhir.r4.model.Resource) BasicFhirResourceProcessor(net.geoprism.registry.etl.fhir.BasicFhirResourceProcessor) FhirResourceProcessor(net.geoprism.registry.etl.fhir.FhirResourceProcessor) BasicFhirConnection(net.geoprism.registry.etl.fhir.BasicFhirConnection) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) Date(java.util.Date) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) IParser(ca.uhn.fhir.parser.IParser) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 7 with FhirExternalSystem

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

the class FhirImportSynchronizationManager method synchronize.

public void synchronize() {
    final FhirExternalSystem system = (FhirExternalSystem) this.details.getSystem();
    try (FhirConnection connection = FhirConnectionFactory.get(system)) {
        FhirResourceProcessor processor = FhirFactory.getProcessor(this.details.getImplementation());
        FhirResourceImporter importer = new FhirResourceImporter(connection, processor, this.history, this.config.getLastSynchDate());
        importer.synchronize();
        history.appLock();
        history.clearStage();
        history.addStage(ExportStage.COMPLETE);
        history.apply();
        config.appLock();
        config.setLastSynchDate(new Date());
        config.apply();
        NotificationFacade.queue(new GlobalNotificationMessage(MessageType.DATA_EXPORT_JOB_CHANGE, null));
        handleExportErrors();
    } catch (ExportJobHasErrors e) {
        throw e;
    } catch (Exception e) {
        throw new HttpError(e);
    }
}
Also used : HttpError(net.geoprism.registry.etl.export.HttpError) GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) ExportJobHasErrors(net.geoprism.registry.etl.ExportJobHasErrors) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) Date(java.util.Date) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

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