Skip to main content

Get a Concept

Retrieve a concept by its OMOP concept ID:
concept <- client$concepts$get(201826)
print(concept$concept_name)   # "Type 2 diabetes mellitus"
print(concept$vocabulary_id)  # "SNOMED"
print(concept$domain_id)      # "Condition"

Get by Vocabulary Code

Look up a concept using a vocabulary-specific code:
# Get SNOMED concept by its code
concept <- client$concepts$get_by_code("SNOMED", "44054006")
print(concept$concept_name)  # "Type 2 diabetes mellitus"

# Get ICD-10-CM concept
concept <- client$concepts$get_by_code("ICD10CM", "E11")

Batch Get Concepts

Retrieve multiple concepts in a single request:
result <- client$concepts$batch(c(201826, 4329847, 1112807))
for (concept in result$concepts) {
  cat(sprintf("%s: %s\n", concept$concept_id, concept$concept_name))
}

Autocomplete Suggestions

Get concept suggestions for autocomplete functionality:
suggestions <- client$concepts$suggest("diab", limit = 10)
for (suggestion in suggestions$suggestions) {
  print(suggestion$concept_name)
}

Get Relationships

Get relationships for a concept:
result <- client$concepts$relationships(201826, page_size = 20)
for (rel in result$relationships) {
  cat(sprintf("%s: %s\n", rel$relationship_id, rel$concept_name_2))
}

Get Ancestors

Find parent concepts in the hierarchy:
result <- client$hierarchy$ancestors(201826, max_levels = 3)
for (ancestor in result$ancestors) {
  level <- ancestor$level_of_separation %||% 0
  cat(sprintf("%s%s\n", strrep("  ", level), ancestor$concept_name))
}

Get Descendants

Find child concepts in the hierarchy:
result <- client$hierarchy$descendants(201826, max_levels = 2)
for (descendant in result$descendants) {
  print(descendant$concept_name)
}

With Options

Include synonyms and other metadata:
concept <- client$concepts$get(
  201826,
  include_synonyms = TRUE
)
Find concepts related to a given concept:
result <- client$concepts$related(201826, page_size = 10)
for (related in result$related) {
  cat(sprintf("%s (%s)\n", related$concept_name, related$relationship_id))
}