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");
}
}
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);
}
}
Aggregations