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