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$mappings) {
  cat(sprintf("%s: %s\n", mapping$target_vocabulary_id, mapping$target_concept_name))
}

Filter by Target Vocabulary

Get mappings to specific vocabularies only:
result <- client$mappings$get(
  201826,
  target_vocabularies = c("ICD10CM", "ICD9CM")
)
for (mapping in result$mappings) {
  code <- mapping$target_concept_code
  name <- mapping$target_concept_name
  vocab <- mapping$target_vocabulary_id
  cat(sprintf("[%s] %s: %s\n", vocab, code, name))
}

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$mappings) {
  source <- mapping$source_concept_id
  target <- mapping$target_concept_id
  cat(sprintf("%s -> %s\n", source, target))
}

Mapping Options

result <- client$mappings$get(
  201826,
  target_vocabularies = c("ICD10CM", "Read"),
  direction = "outgoing",           # "outgoing", "incoming", or "both"
  include_mapping_quality = TRUE,
  standard_only = TRUE,             # Only standard concepts
  page_size = 50
)

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_vocabularies = "ICD10CM"
)

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

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$mappings, function(m) {
  data.frame(
    source_id = m$source_concept_id,
    target_id = m$target_concept_id,
    target_vocab = m$target_vocabulary_id,
    target_code = m$target_concept_code,
    target_name = m$target_concept_name,
    stringsAsFactors = FALSE
  )
}))

# Filter to specific vocabulary
icd10_mappings <- mapping_df[mapping_df$target_vocab == "ICD10CM", ]