Skip to main content

Get Mappings for a Concept

Find how a concept maps to other vocabularies:
result <- client$mappings$get(201826)  # Type 2 diabetes mellitus
for (mapping in result$data$mappings) {
  cat(sprintf("%s: %s\n", mapping$relationship_id, mapping$target_concept_name))
}

Filter by Target Vocabulary

Get mappings to a specific vocabulary only:
result <- client$mappings$get(
  201826,
  target_vocabulary = "ICD10CM"
)
for (mapping in result$data$mappings) {
  cat(sprintf("%s: %s\n", mapping$target_concept_id, mapping$target_concept_name))
}

Include Invalid Mappings

Include deprecated or invalid mappings in results:
result <- client$mappings$get(
  201826,
  target_vocabulary = "ICD10CM",
  include_invalid = TRUE
)

Use Specific Vocabulary Version

Query mappings from a specific vocabulary release:
result <- client$mappings$get(
  201826,
  target_vocabulary = "ICD10CM",
  vocab_release = "2025.1"
)

Map Multiple Concepts

Map a batch of concept IDs to a target vocabulary:
result <- client$mappings$map(
  source_concepts = c(201826, 4329847),  # Diabetes, MI
  target_vocabulary = "ICD10CM"
)
for (mapping in result$data$mappings) {
  source <- mapping$source_concept_id
  target <- mapping$target_concept_id
  cat(sprintf("%s -> %s\n", source, target))
}

Map with Specific Mapping Type

Filter mappings by type:
result <- client$mappings$map(
  source_concepts = c(201826, 192671),
  target_vocabulary = "ICD10CM",
  mapping_type = "direct"  # "direct", "equivalent", "broader", "narrower"
)

Common Use Case: SNOMED to ICD-10

Map SNOMED conditions to ICD-10-CM for billing:
# Get SNOMED concept
concept <- client$concepts$get_by_code("SNOMED", "44054006")

# Find ICD-10-CM mappings
mappings <- client$mappings$get(
  concept$concept_id,
  target_vocabulary = "ICD10CM"
)

cat(sprintf("Mapping %s:\n", concept$concept_name))
for (m in mappings$data$mappings) {
  cat(sprintf("  -> %s (confidence: %s)\n", m$target_concept_name, m$confidence))
}

Working with Mapping Results

Convert mappings to a data frame for analysis:
result <- client$mappings$get(201826)

# Create a data frame from mappings
mapping_df <- do.call(rbind, lapply(result$data$mappings, function(m) {
  data.frame(
    source_id = m$source_concept_id,
    source_name = m$source_concept_name,
    target_id = m$target_concept_id,
    target_name = m$target_concept_name,
    relationship = m$relationship_id,
    confidence = m$confidence,
    stringsAsFactors = FALSE
  )
}))

print(mapping_df)