| Title: | R Client for the 'OMOPHub' Medical Vocabulary API |
|---|---|
| Description: | Provides an R interface to the 'OMOPHub' API for accessing 'OHDSI ATHENA' standardized medical vocabularies. Supports concept search, semantic search using neural embeddings, concept similarity, vocabulary exploration, hierarchy navigation, relationship queries, concept mappings, and FHIR-to-OMOP concept resolution with automatic pagination. |
| Authors: | Alex Chen [aut, cre, cph], Observational Health Data Science and Informatics [cph] |
| Maintainer: | Alex Chen <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.8.1 |
| Built: | 2026-06-03 11:29:16 UTC |
| Source: | https://github.com/omophub/omophub-r |
Standalone wrapper for client$fhir$resolve(). See
FhirResource for full parameter documentation.
fhir_resolve(client, ...)fhir_resolve(client, ...)
client |
An OMOPHubClient instance. |
... |
Arguments passed to |
A list with input and resolution.
FhirResource, fhir_resolve_batch(),
fhir_resolve_codeable_concept()
## Not run: client <- OMOPHubClient$new(api_key = Sys.getenv("OMOPHUB_API_KEY")) fhir_resolve( client, system = "http://snomed.info/sct", code = "44054006", resource_type = "Condition" ) ## End(Not run)## Not run: client <- OMOPHubClient$new(api_key = Sys.getenv("OMOPHUB_API_KEY")) fhir_resolve( client, system = "http://snomed.info/sct", code = "44054006", resource_type = "Condition" ) ## End(Not run)
Standalone wrapper for client$fhir$resolve_batch(). When
as_tibble = TRUE, the result is a flat tibble suitable for
dplyr/tidyr pipelines.
fhir_resolve_batch(client, ...)fhir_resolve_batch(client, ...)
client |
An OMOPHubClient instance. |
... |
Arguments passed to |
See FhirResource$resolve_batch().
FhirResource, fhir_resolve(),
fhir_resolve_codeable_concept()
## Not run: client <- OMOPHubClient$new(api_key = Sys.getenv("OMOPHUB_API_KEY")) tbl <- fhir_resolve_batch( client, codings = list( list(system = "http://snomed.info/sct", code = "44054006"), list(system = "http://loinc.org", code = "2339-0") ), as_tibble = TRUE ) dplyr::filter(tbl, status == "resolved") ## End(Not run)## Not run: client <- OMOPHubClient$new(api_key = Sys.getenv("OMOPHUB_API_KEY")) tbl <- fhir_resolve_batch( client, codings = list( list(system = "http://snomed.info/sct", code = "44054006"), list(system = "http://loinc.org", code = "2339-0") ), as_tibble = TRUE ) dplyr::filter(tbl, status == "resolved") ## End(Not run)
Standalone wrapper for client$fhir$resolve_codeable_concept().
fhir_resolve_codeable_concept(client, ...)fhir_resolve_codeable_concept(client, ...)
client |
An OMOPHubClient instance. |
... |
Arguments passed to |
See FhirResource$resolve_codeable_concept().
FhirResource, fhir_resolve(), fhir_resolve_batch()
## Not run: client <- OMOPHubClient$new(api_key = Sys.getenv("OMOPHUB_API_KEY")) fhir_resolve_codeable_concept( client, coding = list( list(system = "http://snomed.info/sct", code = "44054006"), list(system = "http://hl7.org/fhir/sid/icd-10-cm", code = "E11.9") ), resource_type = "Condition" ) ## End(Not run)## Not run: client <- OMOPHubClient$new(api_key = Sys.getenv("OMOPHUB_API_KEY")) fhir_resolve_codeable_concept( client, coding = list( list(system = "http://snomed.info/sct", code = "44054006"), list(system = "http://hl7.org/fhir/sid/icd-10-cm", code = "E11.9") ), resource_type = "Condition" ) ## End(Not run)
Retrieves the OMOPHub API key from multiple sources in priority order:
Explicit argument
OMOPHUB_API_KEY environment variable
System keyring (if keyring package is installed)
get_api_key(key = NULL)get_api_key(key = NULL)
key |
Optional explicit API key. If provided, this takes precedence. |
A character string containing the API key.
## Not run: # From environment variable Sys.setenv(OMOPHUB_API_KEY = "your_api_key") key <- get_api_key() # Explicit key key <- get_api_key("your_api_key") ## End(Not run)## Not run: # From environment variable Sys.setenv(OMOPHUB_API_KEY = "your_api_key") key <- get_api_key() # Explicit key key <- get_api_key("your_api_key") ## End(Not run)
Checks whether an OMOPHub API key is available without throwing an error.
has_api_key()has_api_key()
TRUE if an API key is available, FALSE otherwise.
Convenience helper for constructing the OMOPHub FHIR Terminology
Service base URL for a given FHIR version. Use it when configuring
an external FHIR client library (httr2, fhircrackr, etc.) to
talk to OMOPHub's FHIR endpoint directly.
omophub_fhir_url(version = c("r4", "r4b", "r5", "r6"))omophub_fhir_url(version = c("r4", "r4b", "r5", "r6"))
version |
FHIR version prefix. One of |
A character scalar with the full FHIR base URL, e.g.
"https://fhir.omophub.com/fhir/r4".
omophub_fhir_url() omophub_fhir_url("r5") ## Not run: # Use with httr2 to call the $lookup operation directly library(httr2) req <- request(omophub_fhir_url()) |> req_url_path_append("CodeSystem/$lookup") |> req_url_query( system = "http://snomed.info/sct", code = "44054006" ) |> req_headers(Authorization = paste("Bearer", Sys.getenv("OMOPHUB_API_KEY"))) resp <- req_perform(req) ## End(Not run)omophub_fhir_url() omophub_fhir_url("r5") ## Not run: # Use with httr2 to call the $lookup operation directly library(httr2) req <- request(omophub_fhir_url()) |> req_url_path_append("CodeSystem/$lookup") |> req_url_query( system = "http://snomed.info/sct", code = "44054006" ) |> req_headers(Authorization = paste("Bearer", Sys.getenv("OMOPHUB_API_KEY"))) resp <- req_perform(req) ## End(Not run)
R6 class for interacting with the OMOPHub vocabulary service. Provides access to OHDSI ATHENA standardized medical vocabularies.
The client provides access to these resources:
concepts: Concept lookup and batch operations
search: Basic and advanced concept search
vocabularies: Vocabulary listing and details
domains: Domain listing and concept filtering
hierarchy: Ancestor and descendant navigation
relationships: Concept relationships
mappings: Concept mappings between vocabularies
A new OMOPHubClient object.
conceptsAccess to concept operations.
searchAccess to search operations.
vocabulariesAccess to vocabulary operations.
domainsAccess to domain operations.
hierarchyAccess to hierarchy operations.
relationshipsAccess to relationship operations.
mappingsAccess to mapping operations.
fhirAccess to FHIR-to-OMOP Concept Resolver operations.
new()
Create a new OMOPHub client.
OMOPHubClient$new( api_key = NULL, base_url = NULL, timeout = 30, max_retries = 3, vocab_version = NULL )
api_keyAPI key for authentication. If not provided, reads from
OMOPHUB_API_KEY environment variable or system keyring.
base_urlAPI base URL. Defaults to https://api.omophub.com/v1.
timeoutRequest timeout in seconds. Defaults to 30.
max_retriesMaximum retry attempts for failed requests. Defaults to 3.
vocab_versionOptional vocabulary version (e.g., "2025.1"). If not specified, uses the latest version.
print()
Print client information.
OMOPHubClient$print()
clone()
The objects of this class are cloneable with this method.
OMOPHubClient$clone(deep = FALSE)
deepWhether to make a deep clone.
## Not run: # Create client (uses OMOPHUB_API_KEY env var) client <- OMOPHubClient$new() # Or with explicit API key client <- OMOPHubClient$new(api_key = "your_api_key") # Search for concepts results <- client$search$basic("diabetes") # Get a specific concept concept <- client$concepts$get(201826) # Use specific vocabulary version client <- OMOPHubClient$new(vocab_version = "2025.1") ## End(Not run)## Not run: # Create client (uses OMOPHUB_API_KEY env var) client <- OMOPHubClient$new() # Or with explicit API key client <- OMOPHubClient$new(api_key = "your_api_key") # Search for concepts results <- client$search$basic("diabetes") # Get a specific concept concept <- client$concepts$get(201826) # Use specific vocabulary version client <- OMOPHubClient$new(vocab_version = "2025.1") ## End(Not run)
Stores the OMOPHub API key in the specified location.
set_api_key(key, store = c("env", "keyring"))set_api_key(key, store = c("env", "keyring"))
key |
The API key to store. |
store |
Where to store the key. One of:
|
Invisibly returns TRUE on success.
## Not run: # Store in environment (current session only) set_api_key("your_api_key") # Store securely in keyring (persistent) set_api_key("your_api_key", store = "keyring") ## End(Not run)## Not run: # Store in environment (current session only) set_api_key("your_api_key") # Store securely in keyring (persistent) set_api_key("your_api_key", store = "keyring") ## End(Not run)