R/datasource.R
pathling_read_bulk.Rd
Creates a data source by downloading data from a FHIR server that implements the FHIR Bulk Data Access API.
pathling_read_bulk(
pc,
fhir_endpoint_url,
output_dir,
group_id = NULL,
patients = NULL,
types = NULL,
output_format = "application/fhir+ndjson",
since = NULL,
elements = NULL,
type_filters = NULL,
include_associated_data = NULL,
output_extension = "ndjson",
timeout = NULL,
max_concurrent_downloads = 10,
auth_config = NULL
)
The PathlingContext object.
The URL of the FHIR server to export from.
The directory to write the output files to.
Optional group ID for group-level export.
Optional list of patient IDs for patient-level export.
List of FHIR resource types to include.
The format of the output data. Defaults to "application/fhir+ndjson".
Only include resources modified after this timestamp.
List of FHIR elements to include.
FHIR search queries to filter resources.
Pre-defined set of FHIR resources to include.
File extension for output files. Defaults to "ndjson".
Optional timeout duration in seconds.
Maximum number of concurrent downloads. Defaults to 10.
Optional authentication configuration list with the following possible elements:
enabled: Whether authentication is enabled (default: FALSE)
client_id: The client ID to use for authentication
private_key_jwk: The private key in JWK format
client_secret: The client secret to use for authentication
token_endpoint: The token endpoint URL
use_smart: Whether to use SMART authentication (default: TRUE)
use_form_for_basic_auth: Whether to use form-based basic auth (default: FALSE)
scope: The scope to request
token_expiry_tolerance: The token expiry tolerance in seconds (default: 120)
A DataSource object that can be used to run queries against the data.
Pathling documentation - Reading from Bulk Data API
Other data source functions:
pathling_read_bundles()
,
pathling_read_datasets()
,
pathling_read_delta()
,
pathling_read_ndjson()
,
pathling_read_parquet()
,
pathling_read_tables()
if (FALSE) { # \dontrun{
pc <- pathling_connect()
# Basic system-level export
data_source <- pc %>% pathling_read_bulk(
fhir_endpoint_url = "https://bulk-data.smarthealthit.org/fhir",
output_dir = "/tmp/bulk_export"
)
# Group-level export with filters
data_source <- pc %>% pathling_read_bulk(
fhir_endpoint_url = "https://bulk-data.smarthealthit.org/fhir",
output_dir = "/tmp/bulk_export",
group_id = "group-1",
types = c("Patient", "Observation"),
elements = c("id", "status"),
since = as.POSIXct("2023-01-01")
)
# Patient-level export with auth
data_source <- pc %>% pathling_read_bulk(
fhir_endpoint_url = "https://bulk-data.smarthealthit.org/fhir",
output_dir = "/tmp/bulk_export",
patients = c(
"123", # Just the ID portion
"456"
),
auth_config = list(
enabled = TRUE,
client_id = "my-client-id",
private_key_jwk = '{ "kty":"RSA", ...}',
scope = "system/*.read"
)
)
pathling_disconnect(pc)
} # }