Skip to content

Commit 18f622e

Browse files
author
alex-omophub
committed
Enhance get_by_code() with include_synonyms and include_relationships parameters; update User-Agent header to OMOPHub-SDK-R/1.0.0; add rate limit delay in integration tests.
1 parent aba500f commit 18f622e

4 files changed

Lines changed: 29 additions & 4 deletions

File tree

NEWS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# omophub 1.1.0
2+
3+
## New Features
4+
5+
* Added `include_synonyms` and `include_relationships` parameters to `get_by_code()` for retrieving concept synonyms and relationships in a single request.
6+
7+
## Changes
8+
9+
* User-Agent header updated to `OMOPHub-SDK-R/{version}`.
10+
111
# omophub 1.0.0
212

313
## Initial CRAN Release

R/concepts.R

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,29 @@ ConceptsResource <- R6::R6Class(
4747
#'
4848
#' @param vocabulary_id The vocabulary ID (e.g., "SNOMED", "ICD10CM").
4949
#' @param concept_code The concept code within the vocabulary.
50+
#' @param include_relationships Include related concepts. Default `FALSE`.
51+
#' @param include_synonyms Include concept synonyms. Default `FALSE`.
5052
#'
51-
#' @returns A list containing the concept data with mappings.
52-
get_by_code = function(vocabulary_id, concept_code) {
53+
#' @returns A list containing the concept data with optional relationships and synonyms.
54+
get_by_code = function(vocabulary_id,
55+
concept_code,
56+
include_relationships = FALSE,
57+
include_synonyms = FALSE) {
5358
checkmate::assert_string(vocabulary_id, min.chars = 1)
5459
checkmate::assert_string(concept_code, min.chars = 1)
5560

61+
query <- list()
62+
if (isTRUE(include_relationships)) {
63+
query$include_relationships <- "true"
64+
}
65+
if (isTRUE(include_synonyms)) {
66+
query$include_synonyms <- "true"
67+
}
68+
5669
perform_get(
5770
private$.base_req,
58-
paste0("concepts/by-code/", vocabulary_id, "/", concept_code)
71+
paste0("concepts/by-code/", vocabulary_id, "/", concept_code),
72+
query = if (length(query) > 0) query else NULL
5973
)
6074
},
6175

R/request.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ build_request <- function(base_url, api_key, timeout = 30, max_retries = 3,
2020
"Content-Type" = "application/json",
2121
"Accept" = "application/json"
2222
) |>
23-
httr2::req_user_agent("omophub-R/1.0.0 (https://github.com/omopHub/omophub-R)") |>
23+
httr2::req_user_agent("OMOPHub-SDK-R/1.0.0") |>
2424
httr2::req_timeout(timeout) |>
2525
httr2::req_throttle(
2626
rate = .omophub_env$rate_limit_capacity / .omophub_env$rate_limit_fill_time

tests/testthat/helper-integration.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ get_integration_api_key <- function() {
5151
integration_client <- function() {
5252
skip_if_no_integration_key()
5353
key <- get_integration_api_key()
54+
Sys.sleep(1) # Rate limit delay between tests
5455
OMOPHubClient$new(api_key = key)
5556
}
5657

0 commit comments

Comments
 (0)