Converting and creating codelists

Converting and creating codelists

This vignette describes a suggested method for creating and reviewing SNOMED CT codelists. Before using the code in this vignette, please follow the vignette 'Using SNOMED dictionaries and codelists' to download the NHS SNOMED distribution and create a R SNOMED dictionary. If you want to include inactive concept descriptions, ensure that the active_only option is set to FALSE when creating the SNOMED dictionary using loadSNOMED.

Searching for and using inactive concepts in SNOMED CT

As SNOMED CT is maintained over time, some concepts are inactivated because they are duplicates, ambiguous or no longer used. Data in existing database may still be recorded using inactive concepts, so it is important that queries account for this.

Prior to using any codelist to perform a search in a healthcare database, it is important to use the NHS Digital query table (downloadable from NHS Digital TRUD - https://isd.digital.nhs.uk/trud/user/guest/group/0/home) to augment the codelist with inactive concepts. The Query Table contains ancestor - descendant relationships for inactive concepts which correspond to current locations in the SNOMED CT hierarchy. This allows appropriate inactive terms to be included as needed, as per your chosen provenance level.

The available provenance levels are:

The NHS Digital history table contains mappings of inactive SNOMED CT concepts to new/current concepts.

Both the query table and the history table are automatically loaded using the loadSNOMED function if they are included in the folders specified when the function is called. The query table should have a name containing "SNOMEDQueryTable" and the history table should have a name containing "HistorySubstitutionTable_Concepts".

library(Rdiagnosislist)
SNOMED <- sampleSNOMED()

# Create a codelist for right heart failure
rhf <- SNOMEDcodelist('Right heart failure', include_desc = TRUE)

addInactiveConcepts(rhf)

Creating SNOMED CT codelists from scratch

A suggested process is:

When using the data for querying, the process is:

Converting Read codelists to SNOMED CT

A suggested process is:

Example code:

library(data.table)
library(Rdiagnosislist)

oldReadCodelist <- fread('
readcode|readterm
G54z500|Valvular heart disease"                     
G5yyC00|Diastolic dysfunction"                      
G5y3100|Ventricular dilatation"
')

# Get sample dictionaries
data(READMAPS)
SNOMED <- sampleSNOMED()

# Create a mapping table for Read to SNOMED (from NHSD table in READMAPS)
NHSD_READ_TO_SNOMED <- READMAPS[, list(readcode = unlist(read2_code)),
    by = conceptId]
mapped <- SNOMEDcodelist(NHSD_READ_TO_SNOMED[oldReadCodelist, on = 'readcode']$conceptId,
    codelist_name = 'heart_dis_from_read', version = 0, author = 'Me', date = 'Feb 2022')

# Export to HTML
# htmlCodelistHierarchy(mapped, file = paste0(tempdir(), '/test.html'))

# Command to open file in web browser (Linux only)
# system(paste0('google-chrome ', tempdir(), '/test.html &'))

# Reimport edited list
importedlist <- fread('
conceptId,term,include_desc,included,checked,comment
368009,"Heart valve disorder (disorder)",FALSE,TRUE,FALSE,""
3545003,"Diastolic dysfunction (finding)",FALSE,TRUE,FALSE,""
6210001,"Dilatation of cardiac ventricle (disorder)",FALSE,TRUE,FALSE,""
418304008,"Diastolic heart failure (disorder)",FALSE,FALSE,FALSE,""
441530006,"Chronic diastolic heart failure (disorder)",FALSE,FALSE,FALSE,""
443343001,"Acute diastolic heart failure (disorder)",FALSE,FALSE,FALSE,""
443344007,"Acute on chronic diastolic heart failure (disorder)",FALSE,FALSE,FALSE,""
153931000119109,"Acute combined systolic and diastolic heart failure (disorder)",FALSE,FALSE,FALSE,""
153951000119103,"Acute on chronic combined systolic and diastolic heart failure (disorder)",FALSE,FALSE,FALSE,""
153941000119100,"Chronic combined systolic and diastolic heart failure (disorder)",FALSE,FALSE,FALSE,""
120891000119109,"Diastolic heart failure stage C (disorder)",FALSE,FALSE,FALSE,""
120881000119106,"Diastolic heart failure stage D (disorder)",FALSE,FALSE,FALSE,""
')

# Convert to parsimonious (tree format) codelist
treecodelist <- as.SNOMEDcodelist(importedlist, format = 'tree',
    codelist_name = 'heart_dis_from_read', version = 1, author = 'Me', date = 'Feb 2022')

HTML codelist for this example

This HTML document presents a hierarchy of SNOMED CT concepts. In SNOMED CT, each concept has a distinct meaning and can be linked to more general terms (ancestors) and more specific terms (descendants). The buttons allow you to explore the codelist at different levels of the hierarchy, and mark whether or not you agree with the inclusion of individual concepts or concept hierarchies. When you have finished your review, you can download your final selection as a .CSV file by clicking the Export button below.

Key to buttons for each concept

Reviewing tools

to .csv

ExpandSNOMED CT conceptCommentCheckedIncluded
Diastolic dysfunction (finding)...Y
· Diastolic heart failure (disorder)...N
· · Acute diastolic heart failure (disorder)...N
· · · Acute combined systolic and diastolic heart failure (disorder)...N
· · · · Acute on chronic combined systolic and diastolic heart failure (disorder)...N
· · · Acute on chronic diastolic heart failure (disorder)...N
· · Chronic diastolic heart failure (disorder)...N
· · · Chronic combined systolic and diastolic heart failure (disorder)...N
· · · Acute on chronic diastolic heart failure (disorder)...N
· · · · Acute on chronic combined systolic and diastolic heart failure (disorder)...N
· · Diastolic heart failure stage C (disorder)...N
· · Diastolic heart failure stage D (disorder)...N
Dilatation of cardiac ventricle (disorder)...Y
Heart valve disorder (disorder)...Y

More information

For more information about SNOMED CT, visit the SNOMED CT international website: https://www.snomed.org/

SNOMED CT (UK edition) can be downloaded from the NHS Digital site: https://isd.digital.nhs.uk/trud/user/guest/group/0/home

The NHS Digital terminology browser can be used to search for terms interactively: https://termbrowser.nhs.uk/



Try the Rdiagnosislist package in your browser

Any scripts or data that you put into this service are public.

Rdiagnosislist documentation built on April 18, 2023, 5:12 p.m.