Title: R Client for the 'OMOPHub' Medical Vocabulary API
Version: 1.1.0
Description: Provides an R interface to the 'OMOPHub' API for accessing 'OHDSI ATHENA' standardized medical vocabularies. Supports concept search, vocabulary exploration, hierarchy navigation, relationship queries, and concept mappings with automatic pagination and rate limiting.
License: MIT + file LICENSE
URL: https://github.com/omopHub/omophub-R, https://docs.omophub.com, https://omophub.github.io/omophub-R/
BugReports: https://github.com/omopHub/omophub-R/issues
Depends: R (≥ 4.1)
Imports: httr2 (≥ 1.0.0), R6, rlang (≥ 1.0.0), cli, tibble, purrr, glue, checkmate
Suggests: testthat (≥ 3.0.0), httptest2, webmockr, knitr, rmarkdown, keyring, withr
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.3.2
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2025-12-11 10:11:49 UTC; konstantin
Author: Alex Chen [aut, cre, cph], Observational Health Data Science and Informatics [cph]
Maintainer: Alex Chen <alex@omophub.com>
Repository: CRAN
Date/Publication: 2025-12-17 10:10:15 UTC

omophub: 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, vocabulary exploration, hierarchy navigation, relationship queries, and concept mappings with automatic pagination and rate limiting.

Provides an R interface to the OMOPHub API for accessing OHDSI ATHENA standardized medical vocabularies. Supports concept search, vocabulary exploration, hierarchy navigation, relationship queries, and concept mappings with automatic pagination and rate limiting.

Main Client

The main entry point is the OMOPHubClient R6 class which provides access to all API resources:

library(omophub)
client <- OMOPHubClient$new()

# Search for concepts
results <- client$search$basic("diabetes")

# Get a specific concept
concept <- client$concepts$get(201826)

Authentication

Set your API key using one of these methods:

Resources

The client provides access to these resources:

Author(s)

Maintainer: OMOPHub Team support@omophub.com [copyright holder]

See Also

Useful links:


Package Attach Hook

Description

Package Attach Hook

Usage

.onAttach(libname, pkgname)

Arguments

libname

Library name.

pkgname

Package name.


Package Load Hook

Description

Package Load Hook

Usage

.onLoad(libname, pkgname)

Arguments

libname

Library name.

pkgname

Package name.


Concepts Resource

Description

R6 class providing access to concept operations.

Value

A list containing the concept data.

A list containing the concept data with mappings.

A list with concepts and any failures.

A list of suggestions.

Related concepts with scores and analysis.

Relationships with summary.

Methods

Public methods


Method new()

Create a new ConceptsResource.

Usage
ConceptsResource$new(base_req)
Arguments
base_req

Base httr2 request object.


Method get()

Get a concept by ID.

Usage
ConceptsResource$get(
  concept_id,
  include_relationships = FALSE,
  include_synonyms = FALSE
)
Arguments
concept_id

The OMOP concept ID.

include_relationships

Include related concepts. Default FALSE.

include_synonyms

Include concept synonyms. Default FALSE.


Method get_by_code()

Get a concept by vocabulary and code.

Usage
ConceptsResource$get_by_code(vocabulary_id, concept_code)
Arguments
vocabulary_id

The vocabulary ID (e.g., "SNOMED", "ICD10CM").

concept_code

The concept code within the vocabulary.


Method batch()

Get multiple concepts by IDs.

Usage
ConceptsResource$batch(
  concept_ids,
  include_relationships = FALSE,
  include_synonyms = FALSE,
  include_mappings = FALSE,
  vocabulary_filter = NULL,
  standard_only = FALSE
)
Arguments
concept_ids

Vector of concept IDs (max 1000).

include_relationships

Include related concepts. Default FALSE.

include_synonyms

Include concept synonyms. Default FALSE.

include_mappings

Include concept mappings. Default FALSE.

vocabulary_filter

Filter results to specific vocabularies.

standard_only

Only return standard concepts. Default FALSE.


Method suggest()

Get concept suggestions (autocomplete).

Usage
ConceptsResource$suggest(query, vocabulary = NULL, domain = NULL, limit = 10)
Arguments
query

Search query (min 2 characters).

vocabulary

Filter to specific vocabulary.

domain

Filter to specific domain.

limit

Maximum suggestions (default 10, max 50).


Method related()

Get related concepts.

Usage
ConceptsResource$related(
  concept_id,
  relatedness_types = NULL,
  vocabulary_ids = NULL,
  domain_ids = NULL,
  min_relatedness_score = NULL,
  max_results = 50,
  include_scores = TRUE,
  standard_concepts_only = FALSE
)
Arguments
concept_id

The source concept ID.

relatedness_types

Types of relatedness (hierarchical, semantic, etc.).

vocabulary_ids

Filter to specific vocabularies.

domain_ids

Filter to specific domains.

min_relatedness_score

Minimum relatedness score.

max_results

Maximum results (default 50, max 200).

include_scores

Include score breakdown. Default TRUE.

standard_concepts_only

Only return standard concepts. Default FALSE.


Method relationships()

Get concept relationships.

Usage
ConceptsResource$relationships(
  concept_id,
  relationship_type = NULL,
  target_vocabulary = NULL,
  include_invalid = FALSE,
  page = 1,
  page_size = 20
)
Arguments
concept_id

The concept ID.

relationship_type

Filter by relationship type.

target_vocabulary

Filter by target vocabulary.

include_invalid

Include invalid relationships. Default FALSE.

page

Page number. Default 1.

page_size

Items per page. Default 20.


Method print()

Print resource information.

Usage
ConceptsResource$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
ConceptsResource$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


Domains Resource

Description

R6 class providing access to domain operations.

Value

Domain list with summary.

Paginated concepts.

Methods

Public methods


Method new()

Create a new DomainsResource.

Usage
DomainsResource$new(base_req)
Arguments
base_req

Base httr2 request object.


Method list()

List all domains.

Usage
DomainsResource$list(
  vocabulary_ids = NULL,
  include_concept_counts = TRUE,
  include_statistics = FALSE,
  include_examples = FALSE,
  standard_only = FALSE,
  active_only = TRUE,
  sort_by = "domain_id",
  sort_order = "asc"
)
Arguments
vocabulary_ids

Filter by vocabularies.

include_concept_counts

Include concept counts. Default TRUE.

include_statistics

Include detailed statistics. Default FALSE.

include_examples

Include example concepts. Default FALSE.

standard_only

Only standard concepts. Default FALSE.

active_only

Only active domains. Default TRUE.

sort_by

Sort field. Default "domain_id".

sort_order

Sort order. Default "asc".


Method concepts()

Get concepts in a domain.

Usage
DomainsResource$concepts(
  domain_id,
  vocabulary_ids = NULL,
  concept_class_ids = NULL,
  standard_only = FALSE,
  page = 1,
  page_size = 50
)
Arguments
domain_id

The domain ID.

vocabulary_ids

Filter by vocabularies.

concept_class_ids

Filter by concept classes.

standard_only

Only standard concepts. Default FALSE.

page

Page number. Default 1.

page_size

Results per page. Default 50.


Method print()

Print resource information.

Usage
DomainsResource$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
DomainsResource$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


Hierarchy Resource

Description

R6 class providing access to hierarchy operations (ancestors and descendants).

Value

Ancestors with hierarchy summary.

Descendants with hierarchy summary.

Methods

Public methods


Method new()

Create a new HierarchyResource.

Usage
HierarchyResource$new(base_req)
Arguments
base_req

Base httr2 request object.


Method ancestors()

Get concept ancestors.

Usage
HierarchyResource$ancestors(
  concept_id,
  vocabulary_id = NULL,
  max_levels = NULL,
  relationship_types = NULL,
  include_paths = FALSE,
  include_distance = TRUE,
  standard_only = FALSE,
  include_deprecated = FALSE,
  page = 1,
  page_size = 100
)
Arguments
concept_id

The concept ID.

vocabulary_id

Filter to specific vocabulary.

max_levels

Maximum hierarchy levels to traverse.

relationship_types

Relationship types to follow (default: "Is a").

include_paths

Include path information. Default FALSE.

include_distance

Include distance from source. Default TRUE.

standard_only

Only return standard concepts. Default FALSE.

include_deprecated

Include deprecated concepts. Default FALSE.

page

Page number. Default 1.

page_size

Results per page. Default 100.


Method descendants()

Get concept descendants.

Usage
HierarchyResource$descendants(
  concept_id,
  vocabulary_id = NULL,
  max_levels = 10,
  relationship_types = NULL,
  include_distance = TRUE,
  standard_only = FALSE,
  include_deprecated = FALSE,
  domain_ids = NULL,
  concept_class_ids = NULL,
  include_synonyms = FALSE,
  page = 1,
  page_size = 100
)
Arguments
concept_id

The concept ID.

vocabulary_id

Filter to specific vocabulary.

max_levels

Maximum hierarchy levels (default 10, max 10).

relationship_types

Relationship types to follow.

include_distance

Include distance from source. Default TRUE.

standard_only

Only return standard concepts. Default FALSE.

include_deprecated

Include deprecated concepts. Default FALSE.

domain_ids

Filter by domains.

concept_class_ids

Filter by concept classes.

include_synonyms

Include synonyms. Default FALSE.

page

Page number. Default 1.

page_size

Results per page. Default 100.


Method print()

Print resource information.

Usage
HierarchyResource$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
HierarchyResource$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


Mappings Resource

Description

R6 class providing access to mapping operations.

Value

Mappings with summary.

Mapping results with summary.

Methods

Public methods


Method new()

Create a new MappingsResource.

Usage
MappingsResource$new(base_req)
Arguments
base_req

Base httr2 request object.


Method get()

Get mappings for a concept.

Usage
MappingsResource$get(
  concept_id,
  target_vocabularies = NULL,
  mapping_types = NULL,
  direction = "both",
  include_indirect = FALSE,
  standard_only = FALSE,
  include_mapping_quality = FALSE,
  include_synonyms = FALSE,
  include_context = FALSE,
  active_only = TRUE,
  sort_by = NULL,
  sort_order = NULL,
  page = 1,
  page_size = 50
)
Arguments
concept_id

The concept ID.

target_vocabularies

Filter by target vocabularies.

mapping_types

Filter by mapping types.

direction

Mapping direction ("outgoing", "incoming", "both"). Default "both".

include_indirect

Include indirect mappings. Default FALSE.

standard_only

Only standard concept mappings. Default FALSE.

include_mapping_quality

Include quality metrics. Default FALSE.

include_synonyms

Include synonyms. Default FALSE.

include_context

Include mapping context. Default FALSE.

active_only

Only active mappings. Default TRUE.

sort_by

Sort field.

sort_order

Sort order.

page

Page number. Default 1.

page_size

Results per page. Default 50.


Method map()

Map concepts to a target vocabulary.

Usage
MappingsResource$map(
  source_concepts,
  target_vocabulary,
  mapping_type = NULL,
  include_invalid = FALSE
)
Arguments
source_concepts

Vector of OMOP concept IDs to map.

target_vocabulary

Target vocabulary ID (e.g., "ICD10CM", "SNOMED").

mapping_type

Mapping type (direct, equivalent, broader, narrower).

include_invalid

Include invalid mappings. Default FALSE.


Method print()

Print resource information.

Usage
MappingsResource$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
MappingsResource$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


OMOPHub API Client

Description

R6 class for interacting with the OMOPHub vocabulary service. Provides access to OHDSI ATHENA standardized medical vocabularies.

Details

The client provides access to these resources:

Value

A new OMOPHubClient object.

Active bindings

concepts

Access to concept operations.

search

Access to search operations.

vocabularies

Access to vocabulary operations.

domains

Access to domain operations.

hierarchy

Access to hierarchy operations.

relationships

Access to relationship operations.

mappings

Access to mapping operations.

Methods

Public methods


Method new()

Create a new OMOPHub client.

Usage
OMOPHubClient$new(
  api_key = NULL,
  base_url = NULL,
  timeout = 30,
  max_retries = 3,
  vocab_version = NULL
)
Arguments
api_key

API key for authentication. If not provided, reads from OMOPHUB_API_KEY environment variable or system keyring.

base_url

API base URL. Defaults to ⁠https://api.omophub.com/v1⁠.

timeout

Request timeout in seconds. Defaults to 30.

max_retries

Maximum retry attempts for failed requests. Defaults to 3.

vocab_version

Optional vocabulary version (e.g., "2025.1"). If not specified, uses the latest version.


Method print()

Print client information.

Usage
OMOPHubClient$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
OMOPHubClient$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

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

Relationships Resource

Description

R6 class providing access to relationship operations.

Value

Relationships with summary.

Relationship types with metadata.

Methods

Public methods


Method new()

Create a new RelationshipsResource.

Usage
RelationshipsResource$new(base_req)
Arguments
base_req

Base httr2 request object.


Method get()

Get relationships for a concept.

Usage
RelationshipsResource$get(
  concept_id,
  relationship_type = NULL,
  target_vocabulary = NULL,
  include_invalid = FALSE,
  page = 1,
  page_size = 50
)
Arguments
concept_id

The concept ID.

relationship_type

Filter by relationship type.

target_vocabulary

Filter by target vocabulary.

include_invalid

Include invalid relationships. Default FALSE.

page

Page number. Default 1.

page_size

Results per page. Default 50.


Method types()

Get available relationship types.

Usage
RelationshipsResource$types(
  vocabulary_ids = NULL,
  include_reverse = FALSE,
  include_usage_stats = FALSE,
  include_examples = FALSE,
  category = NULL,
  is_defining = NULL,
  standard_only = FALSE,
  page = 1,
  page_size = 100
)
Arguments
vocabulary_ids

Filter by vocabularies.

include_reverse

Include reverse relationships. Default FALSE.

include_usage_stats

Include usage statistics. Default FALSE.

include_examples

Include example concepts. Default FALSE.

category

Filter by category.

is_defining

Filter by defining status.

standard_only

Only standard relationships. Default FALSE.

page

Page number. Default 1.

page_size

Results per page. Default 100.


Method print()

Print resource information.

Usage
RelationshipsResource$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
RelationshipsResource$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


Search Resource

Description

R6 class providing access to search operations.

Value

Search results with pagination.

A tibble of all matching concepts.

Search results with facets and metadata.

Autocomplete suggestions.

Methods

Public methods


Method new()

Create a new SearchResource.

Usage
SearchResource$new(base_req)
Arguments
base_req

Base httr2 request object.


Method basic()

Basic concept search.

Usage
SearchResource$basic(
  query,
  vocabulary_ids = NULL,
  domain_ids = NULL,
  concept_class_ids = NULL,
  standard_concept = NULL,
  include_synonyms = FALSE,
  include_invalid = FALSE,
  min_score = NULL,
  exact_match = FALSE,
  page = 1,
  page_size = 20,
  sort_by = NULL,
  sort_order = NULL
)
Arguments
query

Search query string.

vocabulary_ids

Filter by vocabulary IDs.

domain_ids

Filter by domain IDs.

concept_class_ids

Filter by concept class IDs.

standard_concept

Filter by standard concept ("S", "C", or NULL).

include_synonyms

Search in synonyms. Default FALSE.

include_invalid

Include invalid concepts. Default FALSE.

min_score

Minimum relevance score.

exact_match

Require exact match. Default FALSE.

page

Page number (1-based). Default 1.

page_size

Results per page. Default 20.

sort_by

Sort field.

sort_order

Sort order ("asc" or "desc").


Method basic_all()

Fetch all search results with automatic pagination.

Usage
SearchResource$basic_all(
  query,
  vocabulary_ids = NULL,
  domain_ids = NULL,
  page_size = 100,
  max_pages = Inf,
  progress = TRUE,
  ...
)
Arguments
query

Search query string.

vocabulary_ids

Filter by vocabulary IDs.

domain_ids

Filter by domain IDs.

page_size

Results per page. Default 100.

max_pages

Maximum pages to fetch. Default Inf.

progress

Show progress bar. Default TRUE.

...

Additional search parameters.


Method advanced()

Advanced concept search with facets.

Usage
SearchResource$advanced(
  query,
  vocabularies = NULL,
  domains = NULL,
  concept_classes = NULL,
  standard_concepts_only = FALSE,
  include_invalid = FALSE,
  relationship_filters = NULL,
  limit = 20,
  offset = 0
)
Arguments
query

Search query string.

vocabularies

Filter by vocabularies.

domains

Filter by domains.

concept_classes

Filter by concept classes.

standard_concepts_only

Only return standard concepts. Default FALSE.

include_invalid

Include invalid concepts. Default FALSE.

relationship_filters

Relationship-based filters.

limit

Maximum results. Default 20.

offset

Result offset. Default 0.


Method autocomplete()

Get autocomplete suggestions.

Usage
SearchResource$autocomplete(
  query,
  vocabulary_ids = NULL,
  domains = NULL,
  max_suggestions = 10
)
Arguments
query

Partial query string.

vocabulary_ids

Filter by vocabulary IDs.

domains

Filter by domains.

max_suggestions

Maximum suggestions. Default 10.


Method print()

Print resource information.

Usage
SearchResource$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
SearchResource$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


Vocabularies Resource

Description

R6 class providing access to vocabulary operations.

Value

Paginated vocabulary list.

Vocabulary details.

Vocabulary statistics.

Domain statistics for vocabularies.

Paginated concepts.

Methods

Public methods


Method new()

Create a new VocabulariesResource.

Usage
VocabulariesResource$new(base_req)
Arguments
base_req

Base httr2 request object.


Method list()

List all vocabularies.

Usage
VocabulariesResource$list(
  include_stats = FALSE,
  include_inactive = FALSE,
  sort_by = "name",
  sort_order = "asc",
  page = 1,
  page_size = 100
)
Arguments
include_stats

Include vocabulary statistics. Default FALSE.

include_inactive

Include inactive vocabularies. Default FALSE.

sort_by

Sort field ("name", "priority", "updated"). Default "name".

sort_order

Sort order ("asc" or "desc"). Default "asc".

page

Page number. Default 1.

page_size

Results per page. Default 100.


Method get()

Get vocabulary details.

Usage
VocabulariesResource$get(
  vocabulary_id,
  include_stats = FALSE,
  include_domains = FALSE
)
Arguments
vocabulary_id

The vocabulary ID.

include_stats

Include statistics. Default FALSE.

include_domains

Include domain breakdown. Default FALSE.


Method stats()

Get vocabulary statistics.

Usage
VocabulariesResource$stats(vocabulary_id)
Arguments
vocabulary_id

The vocabulary ID.


Method domains()

Get vocabulary domains.

Usage
VocabulariesResource$domains(vocabulary_ids = NULL, page = 1, page_size = 50)
Arguments
vocabulary_ids

Filter by vocabulary IDs (optional).

page

Page number. Default 1.

page_size

Results per page. Default 50.


Method concepts()

Get concepts in a vocabulary.

Usage
VocabulariesResource$concepts(
  vocabulary_id,
  domain_id = NULL,
  concept_class_id = NULL,
  standard_only = FALSE,
  page = 1,
  page_size = 50
)
Arguments
vocabulary_id

The vocabulary ID.

domain_id

Filter by domain.

concept_class_id

Filter by concept class.

standard_only

Only standard concepts. Default FALSE.

page

Page number. Default 1.

page_size

Results per page. Default 50.


Method print()

Print resource information.

Usage
VocabulariesResource$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
VocabulariesResource$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


Abort with OMOPHub API Error

Description

Abort with OMOPHub API Error

Usage

abort_api_error(status, message, endpoint, call = rlang::caller_env())

Arguments

status

HTTP status code.

message

Error message.

endpoint

API endpoint that failed.

call

The calling environment.


Abort with Authentication Error

Description

Abort with Authentication Error

Usage

abort_auth_error(message, call = rlang::caller_env())

Arguments

message

Error message.

call

The calling environment.


Abort with Rate Limit Error

Description

Abort with Rate Limit Error

Usage

abort_rate_limit(retry_after = NULL, call = rlang::caller_env())

Arguments

retry_after

Seconds until rate limit resets.

call

The calling environment.


Abort with Validation Error

Description

Abort with Validation Error

Usage

abort_validation(message, arg = NULL, call = rlang::caller_env())

Arguments

message

Error message.

arg

The argument that failed validation.

call

The calling environment.


Convert Boolean to API String

Description

Convert Boolean to API String

Usage

bool_to_str(x)

Arguments

x

A logical value.

Value

"true" or "false" string, or NULL if x is NULL.


Build Base OMOPHub Request

Description

Creates an httr2 request object with authentication, rate limiting, and retry logic configured.

Usage

build_request(
  base_url,
  api_key,
  timeout = 30,
  max_retries = 3,
  vocab_version = NULL
)

Arguments

base_url

API base URL.

api_key

API key for authentication.

timeout

Request timeout in seconds.

max_retries

Maximum retry attempts.

vocab_version

Optional vocabulary version.

Value

An httr2 request object.


Extract Error Message from API Response

Description

Extract Error Message from API Response

Usage

extract_error_message(resp)

Arguments

resp

An httr2 response object.

Value

A character string with the error message.


Extract Pagination Metadata

Description

Extracts pagination metadata from an API response.

Usage

extract_pagination(response)

Arguments

response

API response object.

Value

A list with pagination fields.


Get OMOPHub API Key

Description

Retrieves the OMOPHub API key from multiple sources in priority order:

  1. Explicit argument

  2. OMOPHUB_API_KEY environment variable

  3. System keyring (if keyring package is installed)

Usage

get_api_key(key = NULL)

Arguments

key

Optional explicit API key. If provided, this takes precedence.

Value

A character string containing the API key.

Examples

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

Check if API Key is Available

Description

Checks whether an OMOPHub API key is available without throwing an error.

Usage

has_api_key()

Value

TRUE if an API key is available, FALSE otherwise.


Check if Error is Transient (Retryable)

Description

Check if Error is Transient (Retryable)

Usage

is_transient_error(resp)

Arguments

resp

An httr2 response object.

Value

TRUE if the error is transient and should be retried.


Join List Elements for Query Parameter

Description

Join List Elements for Query Parameter

Usage

join_params(x, sep = ",")

Arguments

x

A character vector.

sep

Separator (default comma).

Value

A single comma-separated string, or NULL if x is NULL/empty.


Create OMOPHub Concepts Result

Description

Creates an S3 object for concept search results.

Usage

new_omophub_concepts(data, meta = list())

Arguments

data

Concept data (list or tibble).

meta

Pagination metadata.

Value

An omophub_concepts S3 object.


Create OMOPHub Hierarchy Result

Description

Create OMOPHub Hierarchy Result

Usage

new_omophub_hierarchy(data, meta = list(), type = "hierarchy")

Arguments

data

Hierarchy data (ancestors or descendants).

meta

Metadata including summary.

type

Type of hierarchy ("ancestors" or "descendants").

Value

An omophub_hierarchy S3 object.


Create OMOPHub Mappings Result

Description

Create OMOPHub Mappings Result

Usage

new_omophub_mappings(data, meta = list())

Arguments

data

Mapping data.

meta

Metadata.

Value

An omophub_mappings S3 object.


Create OMOPHub Relationships Result

Description

Create OMOPHub Relationships Result

Usage

new_omophub_relationships(data, meta = list())

Arguments

data

Relationship data.

meta

Metadata.

Value

An omophub_relationships S3 object.


Create OMOPHub Vocabularies Result

Description

Create OMOPHub Vocabularies Result

Usage

new_omophub_vocabularies(data, meta = list())

Arguments

data

Vocabulary data.

meta

Pagination metadata.

Value

An omophub_vocabularies S3 object.


Fetch All Paginated Results

Description

Fetches all pages of results and combines them into a single tibble.

Usage

paginate_all(fetch_fn, page_size = 100, max_pages = Inf, progress = TRUE)

Arguments

fetch_fn

A function that takes page and size arguments and returns a list with data (the results) and meta (pagination metadata).

page_size

Number of items per page. Default 100.

max_pages

Maximum number of pages to fetch. Default Inf.

progress

Show progress bar. Default TRUE.

Value

A tibble containing all fetched results.


Create Lazy Pagination Iterator

Description

Creates an iterator that fetches pages on demand.

Usage

paginate_lazy(fetch_fn, page_size = 100)

Arguments

fetch_fn

A function that takes page and size arguments.

page_size

Number of items per page. Default 100.

Value

An iterator object with next_page() and has_more() methods.


Perform GET Request

Description

Perform GET Request

Usage

perform_get(base_req, endpoint, query = NULL)

Arguments

base_req

Base request object.

endpoint

API endpoint path.

query

Named list of query parameters.

Value

Parsed JSON response. For paginated endpoints, returns a list with data (the results) and meta (pagination info). For single-item endpoints, returns the unwrapped data directly.


Perform POST Request

Description

Perform POST Request

Usage

perform_post(base_req, endpoint, body = NULL, query = NULL)

Arguments

base_req

Base request object.

endpoint

API endpoint path.

body

Named list for JSON body.

query

Named list of query parameters.

Value

Parsed JSON response (unwrapped from data field if present).


Set OMOPHub API Key

Description

Stores the OMOPHub API key in the specified location.

Usage

set_api_key(key, store = c("env", "keyring"))

Arguments

key

The API key to store.

store

Where to store the key. One of:

  • "env": Set as environment variable for current session (default)

  • "keyring": Store securely in system keyring (requires keyring package)

Value

Invisibly returns TRUE on success.

Examples

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

Validate Concept ID

Description

Validate Concept ID

Usage

validate_concept_id(concept_id, arg = "concept_id", call = rlang::caller_env())

Arguments

concept_id

A concept ID to validate.

arg

Argument name for error messages.

call

The calling environment.


Validate Page Parameters

Description

Validate Page Parameters

Usage

validate_pagination(
  page,
  page_size,
  max_page_size = 1000,
  call = rlang::caller_env()
)

Arguments

page

Page number.

page_size

Page size.

max_page_size

Maximum allowed page size.

call

The calling environment.