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
)

Arguments

pc

The PathlingContext object.

fhir_endpoint_url

The URL of the FHIR server to export from.

output_dir

The directory to write the output files to.

group_id

Optional group ID for group-level export.

patients

Optional list of patient IDs for patient-level export.

types

List of FHIR resource types to include.

output_format

The format of the output data. Defaults to "application/fhir+ndjson".

since

Only include resources modified after this timestamp.

elements

List of FHIR elements to include.

type_filters

FHIR search queries to filter resources.

include_associated_data

Pre-defined set of FHIR resources to include.

output_extension

File extension for output files. Defaults to "ndjson".

timeout

Optional timeout duration in seconds.

max_concurrent_downloads

Maximum number of concurrent downloads. Defaults to 10.

auth_config

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)

Value

A DataSource object that can be used to run queries against the data.

Examples

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)
} # }