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