The omophub package provides an R interface to the OMOPHub API for accessing OHDSI ATHENA standardized medical vocabularies. This vignette demonstrates basic usage patterns.
Install from GitHub:
The package requires an API key from OMOPHub.
Set your API key as an environment variable:
Or add it to your .Renviron file for persistence:
OMOPHUB_API_KEY=your_api_key_here
library(omophub)
# Create client (reads API key from environment)
client <- OMOPHubClient$new()
# Or provide API key explicitly
client <- OMOPHubClient$new(api_key = "your_api_key")
# With additional options
client <- OMOPHubClient$new(
api_key = "your_api_key",
timeout = 30,
max_retries = 3,
vocab_version = "2025.1"
)Retrieve a concept by its OMOP concept ID:
Get a concept by vocabulary-specific code:
Retrieve multiple concepts in a single request:
Basic search:
results <- client$search$basic("diabetes mellitus", page_size = 10)
for (concept in results$data) {
cat(sprintf("%s: %s\n", concept$concept_id, concept$concept_name))
}Search with filters:
Get suggestions for autocomplete:
# First page
results <- client$search$basic("diabetes", page = 1, page_size = 50)
# Check pagination info
print(results$meta$total_items)
print(results$meta$has_next)
# Get next page if available
if (isTRUE(results$meta$has_next)) {
page2 <- client$search$basic("diabetes", page = 2, page_size = 50)
}Find how a concept maps to other vocabularies:
result <- client$mappings$get(201826)
for (mapping in result$mappings) {
cat(sprintf("%s: %s\n",
mapping$target_vocabulary_id,
mapping$target_concept_name))
}Map to specific vocabularies:
Use tryCatch to handle errors: