--- title: "Converting and creating codelists" author: "Anoop Shah" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Converting and creating codelists} %\VignetteEngine{knitr::rmarkdown} \usepackage[utf8]{inputenc} --- 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: - 0: subsumption is always true (i.e. the descendant is always a subtype of the ancestor) - 1: subsumption is usually true (but there is a theoretical risk of false positives) - 2: both ancestors and descendents are only approximately known - 3: the original concept has at least two distinct meanings, so there is a risk of false positives 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". ```{r} 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: - Browse the SNOMED CT terminology to find ancestor terms that may be relevant. - Create a putative codelist using the ancestor terms and their descendants. - Export the codelist to HTML for clinical review. Reviewers can export/save the results of their review using the functions on the HTML document. - Import the reviewed codelist, and use the as.SNOMEDcodelist function to convert it into a parsimonious form for curation. When using the data for querying, the process is: - Convert the codelist to the 'simple' format (i.e. enumerating all terms). - Add inactive terms using the Query table, as above. Converting Read codelists to SNOMED CT -------------------------------------- A suggested process is: - Map Read terms to SNOMED CT using the NHS Digital mapping. - Export the codelist to HTML for clinical review. Reviewers can export/save the results of their review using the functions on the HTML document. - Import the reviewed codelist, and use the as.SNOMEDcodelist function to convert it into a parsimonious form for curation. Example code: ```{r} 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.
to .csv
Expand | SNOMED CT concept | Comment | Checked | Included | |
---|---|---|---|---|---|
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 |