Title: | Manipulate SNOMED CT Diagnosis Lists |
---|---|
Description: | Functions and methods for manipulating 'SNOMED CT' concepts. The package contains functions for loading the 'SNOMED CT' release into a convenient R environment, selecting 'SNOMED CT' concepts using regular expressions, and navigating the 'SNOMED CT' ontology. It provides the 'SNOMEDconcept' S3 class for a vector of 'SNOMED CT' concepts (stored as 64-bit integers) and the 'SNOMEDcodelist' S3 class for a table of concepts IDs with descriptions. For more information about 'SNOMED CT' visit <https://www.snomed.org/>. |
Authors: | Anoop Shah [aut, cre] |
Maintainer: | Anoop Shah <[email protected]> |
License: | GPL-3 |
Version: | 1.3 |
Built: | 2024-11-28 06:54:06 UTC |
Source: | CRAN |
Returns acronyms, if any, expressed within SNOMED CT descriptions in the form 'ABCD - Another Bland Cardiovascular Disease'.
acronyms(conceptIds, SNOMED = getSNOMED())
acronyms(conceptIds, SNOMED = getSNOMED())
conceptIds |
character or integer64 vector |
SNOMED |
environment containing SNOMED dictionary. Defaults to an object named 'SNOMED' in the global environment |
a data.table with the following columns: id, conceptId, type = 'Acronym', term = acronym
SNOMED <- sampleSNOMED() acronyms('Heart failure') # Get all synonyms and acronyms rva <- SNOMEDconcept('Right ventricular abnormality') rbind(description(rva, include_synonyms = TRUE), acronyms(rva))
SNOMED <- sampleSNOMED() acronyms('Heart failure') # Get all synonyms and acronyms rva <- SNOMEDconcept('Right ventricular abnormality') rbind(description(rva, include_synonyms = TRUE), acronyms(rva))
Adds SNOMED concepts linked by the QUERY or HISTORY tables that are mapped to or descendants of concepts in a SNOMEDcodelist or a SNOMEDconcept vector. If a SNOMEDcodelist, it is automatically converted to the 'simple' format (all items enumerated).
addInactiveConcepts(x, provenance = 0:3, SNOMED = getSNOMED())
addInactiveConcepts(x, provenance = 0:3, SNOMED = getSNOMED())
x |
SNOMEDcodelist or SNOMEDconcept object |
provenance |
vector of provenance values to use |
SNOMED |
SNOMED environment containing HISTORY and QUERY tables |
It is recommended to use this function to convert a reference into a codelist for running a query against an electronic health record database which might contain historic SNOMED CT concepts.
SNOMEDcodelist or SNOMEDconcept with linked inactive concepts included
Other SNOMEDcodelist functions:
SNOMEDcodelist()
,
expandSNOMED()
,
export()
,
is.SNOMEDcodelist()
,
print.SNOMEDcodelist()
Adds terms from a WordNet thesaurus to a concept database, matching on term. It is recommended to restrict the wordnet categories to ensure that words with multiple meanings are not linked to the wrong synonym. This function also corrects some known errors in WordNet to avoid them being passed on to the CDB; currently this applies to 'allergy = allergic reaction' and 'cuneiform bone = triquetral' but more corrections can be done if needed.
addWordnet( CDB_TABLE, wn_categories, WN, CHECK_TABLE = NULL, errors_to_remove = list(c("allergy", "allergic reaction"), c("allergic", "allergic reaction"), c("cuneiform bone", "triquetral bone"), c("upset", "disorder"), c("disorderliness", "disorder")) )
addWordnet( CDB_TABLE, wn_categories, WN, CHECK_TABLE = NULL, errors_to_remove = list(c("allergy", "allergic reaction"), c("allergic", "allergic reaction"), c("cuneiform bone", "triquetral bone"), c("upset", "disorder"), c("disorderliness", "disorder")) )
CDB_TABLE |
data.frame or data.table with columns conceptId (integer64) and term (character, with space before and after) containing existing descriptions in the CDB |
wn_categories |
WordNet categories to use |
WN |
WordNet data.table as returned by downloadWordnet |
CHECK_TABLE |
other table in the same format as CDB_TABLE to check for WordNet synonyms that link to another unrelated concept, where this synonym will be excluded because of the risk of errors |
errors_to_remove |
list of character vectors of length two containing synonym pairs to be removed. The first entry of the pair will be removed from the WordNet file before it is used for adding to CDB |
CDB_TABLE with extra rows for Wordnet synonyms
https://wordnet.princeton.edu/
[downloadWordnet()]
WORDNET <- data.table::data.table(cat = c('noun.body', 'noun.state'), wordnetId = bit64::as.integer64('1', '2'), synonyms = list(c('heart', 'pump', 'ticker'), c('infection', 'infectious')), parents = list('cardiovascular system', 'pathologic process'), adj = list('cardiac', 'infectious')) # Add Wordnet synonyms to a concept database table SNOMED <- sampleSNOMED() CDB_TABLE <- description(c('Heart', 'Infection'), include_synonyms = TRUE)[type == 'Synonym', list(conceptId, term = paste0(' ', tolower(term), ' '))] addWordnet(CDB_TABLE, 'noun.state', WORDNET)
WORDNET <- data.table::data.table(cat = c('noun.body', 'noun.state'), wordnetId = bit64::as.integer64('1', '2'), synonyms = list(c('heart', 'pump', 'ticker'), c('infection', 'infectious')), parents = list('cardiovascular system', 'pathologic process'), adj = list('cardiac', 'infectious')) # Add Wordnet synonyms to a concept database table SNOMED <- sampleSNOMED() CDB_TABLE <- description(c('Heart', 'Infection'), include_synonyms = TRUE)[type == 'Synonym', list(conceptId, term = paste0(' ', tolower(term), ' '))] addWordnet(CDB_TABLE, 'noun.state', WORDNET)
Carries out an exact or regular expression match to return the concept ID for a set of search terms, or converts a character, integer or integer64 vector to a SNOMEDconcept object.
## S3 method for class 'SNOMEDconcept' as.data.frame(x, ...) ## S3 method for class 'SNOMEDconcept' as.integer64(x, ...) SNOMEDconcept( x, active_only = TRUE, exact_match = TRUE, unique = TRUE, SNOMED = getSNOMED() ) as.SNOMEDconcept(x, ...)
## S3 method for class 'SNOMEDconcept' as.data.frame(x, ...) ## S3 method for class 'SNOMEDconcept' as.integer64(x, ...) SNOMEDconcept( x, active_only = TRUE, exact_match = TRUE, unique = TRUE, SNOMED = getSNOMED() ) as.SNOMEDconcept(x, ...)
x |
character vector of terms to match, or character vector containing SNOMED CT concept IDs, or 64-bit integer vector containing SNOMED CT concept IDs |
... |
additional arguments to send to grepl if using regular expression matching |
active_only |
whether or not to include inactive concepts |
exact_match |
if TRUE, only an exact (case sensitive) match is performed. If FALSE, a regular expression match is performed. |
unique |
whether to include no more than one instance of each SNOMED CT concept |
SNOMED |
environment containing SNOMED dictionary. Defaults to an object named 'SNOMED' in the global environment |
a SNOMEDconcept object (vector of 64-bit integers) containing unique SNOMED CT concept IDs
Other SNOMEDconcept functions:
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
union.SNOMEDconcept()
,
unique.SNOMEDconcept()
Other SNOMEDconcept functions:
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
union.SNOMEDconcept()
,
unique.SNOMEDconcept()
Other SNOMEDconcept functions:
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
union.SNOMEDconcept()
,
unique.SNOMEDconcept()
SNOMEDconcept('Heart failure', SNOMED = sampleSNOMED()) -> hf is.SNOMEDconcept(hf) SNOMEDconcept('900000000000003001') as.SNOMEDconcept('900000000000003001')
SNOMEDconcept('Heart failure', SNOMED = sampleSNOMED()) -> hf is.SNOMEDconcept(hf) SNOMEDconcept('900000000000003001') as.SNOMEDconcept('900000000000003001')
Returns the portion of the SNOMED CT relationship tables containing relationships where the given concepts are either the source or the destination.
attrConcept( conceptIds, SNOMED = getSNOMED(), tables = c("RELATIONSHIP", "STATEDRELATIONSHIP"), active_only = TRUE )
attrConcept( conceptIds, SNOMED = getSNOMED(), tables = c("RELATIONSHIP", "STATEDRELATIONSHIP"), active_only = TRUE )
conceptIds |
character or integer64 vector of SNOMED concept IDs |
SNOMED |
environment containing a SNOMED dictionary |
tables |
character vector of relationship tables to use |
active_only |
whether to return only active attributes |
a data.table with the following columns: sourceId (concept ID of source for relationship), destinationId (concept ID of source for relationship), typeId (concept ID of relationship type), typeName (description of relationship type)
SNOMED <- sampleSNOMED() attrConcept(as.SNOMEDconcept('Heart failure'))
SNOMED <- sampleSNOMED() attrConcept(as.SNOMEDconcept('Heart failure'))
Creates composition lookup table for a set of SNOMED CT concepts
batchDecompose(conceptIds, CDB, output_filename, SNOMED = getSNOMED(), ...)
batchDecompose(conceptIds, CDB, output_filename, SNOMED = getSNOMED(), ...)
conceptIds |
SNOMED CT concept IDs for creating decompositions |
CDB |
concept database environment, containing a table called FINDINGS |
output_filename |
filename of output file |
SNOMED |
environment containing a SNOMED dictionary |
... |
out |
TRUE if successful
decompose, compose, createComposeLookup
# Load the SNOMED dictionary (for this example we are using the # sample included with the package) SNOMED <- sampleSNOMED() # Create a concept database environment miniCDB <- createCDB(SNOMED = SNOMED) # Create a decomposition D <- decompose('Cor pulmonale', CDB = miniCDB, noisy = TRUE) print(D)
# Load the SNOMED dictionary (for this example we are using the # sample included with the package) SNOMED <- sampleSNOMED() # Create a concept database environment miniCDB <- createCDB(SNOMED = SNOMED) # Create a decomposition D <- decompose('Cor pulmonale', CDB = miniCDB, noisy = TRUE) print(D)
SNOMEDconcept is an S3 class for vectors of SNOMED concept IDs as 64-bit integers. This function concatenates two or more SNOMEDconcept vectors.
## S3 method for class 'SNOMEDconcept' c(...)
## S3 method for class 'SNOMEDconcept' c(...)
... |
SNOMEDconcept vectors |
concatenation of vectors
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
union.SNOMEDconcept()
,
unique.SNOMEDconcept()
hf <- SNOMEDconcept('Heart failure', SNOMED = sampleSNOMED()) hf2 <- c(hf, hf)
hf <- SNOMEDconcept('Heart failure', SNOMED = sampleSNOMED()) hf2 <- c(hf, hf)
Finds the most specific SNOMED CT concepts that matches the combination of a root concept and attributes. Based on a composeLookup table
compose( conceptId, CDB, composeLookup, attributes_conceptIds = bit64::integer64(0), due_to_conceptIds = bit64::integer64(0), without_conceptIds = bit64::integer64(0), with_conceptIds = bit64::integer64(0), SNOMED = getSNOMED(), show_all_matches = FALSE )
compose( conceptId, CDB, composeLookup, attributes_conceptIds = bit64::integer64(0), due_to_conceptIds = bit64::integer64(0), without_conceptIds = bit64::integer64(0), with_conceptIds = bit64::integer64(0), SNOMED = getSNOMED(), show_all_matches = FALSE )
conceptId |
SNOMED CT concept to refine |
CDB |
SNOMED CT concept database, as created by createCDB. An environment containing the following data tables: FINDINGS, QUAL, CAUSES, BODY, FINDINGS, OTHERSUB, OVERLAP, TRANSITIVE |
composeLookup |
lookup table created by createComposeLookup |
attributes_conceptIds |
SNOMED concept Ids of attributes of concept e.g. laterality, severity, acuteness |
due_to_conceptIds |
SNOMED concept Ids of cause |
without_conceptIds |
SNOMED concept Ids of conditions stated to be absent |
with_conceptIds |
SNOMED concept Ids of conditions also present |
SNOMED |
environment containing SNOMED CT tables |
show_all_matches |
whether to stop if an exact match is found, or continue to search for all potential matches |
a refined SNOMED concept Id
decompose, batchDecompose, createComposeLookup
SNOMED <- sampleSNOMED() miniCDB <- createCDB(SNOMED) D <- decompose('Cor pulmonale', CDB = miniCDB) print(D) # -------------------------------------------------------- # 83291003 | Cor pulmonale (disorder) # -------------------------------------------------------- # Root : 128404006 | Right heart failure (disorder) # - Due to : 19829001 | Disorder of lung (disorder) # # -------------------------------------------------------- # 83291003 | Cor pulmonale (disorder) # -------------------------------------------------------- # Root : 367363000 | Right ventricular failure (disorder) # - Due to : 19829001 | Disorder of lung (disorder) # Compile decompositions into a lookup table CL <- createComposeLookup(D, CDB = miniCDB) compose(as.SNOMEDconcept('Right heart failure'), due_to_conceptIds = as.SNOMEDconcept('Disorder of lung'), CDB = miniCDB, composeLookup = CL) # [1] "83291003 | Cor pulmonale (disorder)"
SNOMED <- sampleSNOMED() miniCDB <- createCDB(SNOMED) D <- decompose('Cor pulmonale', CDB = miniCDB) print(D) # -------------------------------------------------------- # 83291003 | Cor pulmonale (disorder) # -------------------------------------------------------- # Root : 128404006 | Right heart failure (disorder) # - Due to : 19829001 | Disorder of lung (disorder) # # -------------------------------------------------------- # 83291003 | Cor pulmonale (disorder) # -------------------------------------------------------- # Root : 367363000 | Right ventricular failure (disorder) # - Due to : 19829001 | Disorder of lung (disorder) # Compile decompositions into a lookup table CL <- createComposeLookup(D, CDB = miniCDB) compose(as.SNOMEDconcept('Right heart failure'), due_to_conceptIds = as.SNOMEDconcept('Disorder of lung'), CDB = miniCDB, composeLookup = CL) # [1] "83291003 | Cor pulmonale (disorder)"
Extracts SNOMED CT concepts from appropriate places in the hierarchy to create a set of CDB files in an environment. Uses WordNet and manual synonyms if available.
createCDB( SNOMED = getSNOMED(), TRANSITIVE = NULL, WN = NULL, MANUAL_SYNONYMS = NULL, noisy = TRUE, stopwords = c("the", "of", "by", "with", "to", "into", "and", "or", "both", "at", "as", "and/or", "in") )
createCDB( SNOMED = getSNOMED(), TRANSITIVE = NULL, WN = NULL, MANUAL_SYNONYMS = NULL, noisy = TRUE, stopwords = c("the", "of", "by", "with", "to", "into", "and", "or", "both", "at", "as", "and/or", "in") )
SNOMED |
environment containing a SNOMED dictionary |
TRANSITIVE |
transitive closure table, generated by createTransitive. It is regenerated if not provided. |
WN |
WordNet data.table as returned by downloadWordnet containing WordNet data from appropriate categories, in the format: cat (character), wordnetId (integer64), synonyms (list), parents (list), adj (list) |
MANUAL_SYNONYMS |
data.table with columns term1 and term2, containing additional exact synonyms or abbreviations |
noisy |
whether to output status messages |
stopwords |
vector of stopwords |
environment containing the following data tables: FINDINGS, QUAL, CAUSES, BODY, OTHERCAUSE, OTHERSEARCH, OVERLAP, TRANSITIVE
# Not run # data(MANUAL_SYNONYMS) # WN <- downloadWordnet() # MANUAL_SYNONYMS <- rbind(MANUAL_SYNONYMS, downloadOrphanet()) # CDBNEW <- createCDB(WN = WN, MANUAL_SYNONYMS = MANUAL_SYNONYMS)
# Not run # data(MANUAL_SYNONYMS) # WN <- downloadWordnet() # MANUAL_SYNONYMS <- rbind(MANUAL_SYNONYMS, downloadOrphanet()) # CDBNEW <- createCDB(WN = WN, MANUAL_SYNONYMS = MANUAL_SYNONYMS)
Creates composition lookup table for a set of SNOMED CT concepts
createComposeLookup( decompositions, CDB, maxcol = 10, SNOMED = getSNOMED(), ... )
createComposeLookup( decompositions, CDB, maxcol = 10, SNOMED = getSNOMED(), ... )
decompositions |
vector of filenames of decompose output (read by fread) or data.frame containing outputs of decompose function |
CDB |
concept database environment, containing a table called FINDINGS |
maxcol |
maximum number of attributes columns. If NULL it is determined from the data. It might be helpful to specify it so that downstream databases and programs know exactly how many columns to expect. We suggest setting it to 10 which should handle all possible SNOMED CT concept decompositions. |
SNOMED |
environment containing a SNOMED CT dictionary |
... |
other arguments to pass to fread |
data.table
decompose, compose, batchDecompose
# Not run # mylookup <- createComposeLookup(D)
# Not run # mylookup <- createComposeLookup(D)
Creates relevant indices for fast searching of SNOMED CT tables
createSNOMEDindices(SNOMED)
createSNOMEDindices(SNOMED)
SNOMED |
environment containing data.table objects: CONCEPT, DESCRIPTION, RELATIONSHIP, STATEDRELATIONSHIP |
The environment with indices added to each table for fast searching
CONCEPT, DESCRIPTION, RELATIONSHIP, STATEDRELATIONSHIP, REFSET, SIMPLEMAP, EXTENDEDMAP, loadSNOMED, sampleSNOMED
Returns a data.table containing ancestor / descendant relationships which can be used in ancestors and descendants functions
createTransitive( conceptIds, SNOMED = getSNOMED(), tables = c("RELATIONSHIP", "STATEDRELATIONSHIP") )
createTransitive( conceptIds, SNOMED = getSNOMED(), tables = c("RELATIONSHIP", "STATEDRELATIONSHIP") )
conceptIds |
character or integer64 vector of SNOMED concept IDs for the subset of concepts to include in the transitive table. |
SNOMED |
environment containing a SNOMED dictionary |
tables |
vector of names of relationship table(s) to use; by default use both RELATIONSHIP and STATEDRELATIONSHIP |
[ancestors()] and [descendants()]
SNOMED <- sampleSNOMED() TRANSITIVE <- createTransitive('Heart failure')
SNOMED <- sampleSNOMED() TRANSITIVE <- createTransitive('Heart failure')
Decomposes a SNOMED CT term into separate components according to the SNOMED CT information model and text parsing. Each term may have a number of possible decompositions. Requires a CDB environment created by createCDB.
decompose( conceptIds, diagnosis_text = NULL, CDB, SNOMED = getSNOMED(), noisy = FALSE, omit_unmatched = TRUE )
decompose( conceptIds, diagnosis_text = NULL, CDB, SNOMED = getSNOMED(), noisy = FALSE, omit_unmatched = TRUE )
conceptIds |
vector of SNOMED CT concepts to decompose |
diagnosis_text |
vector of SNOMED CT terms (or in theory any text that has the same meaning as the SNOMED CT concept). If NULL, decompositions are created for all SNOMED CT synonyms of the concepts. |
CDB |
an environment containing CDB files, as created by createCDB |
SNOMED |
an environment containing the SNOMED CT dictionary |
noisy |
whether to output messages (for debugging) |
omit_unmatched |
whether to omit rows in which some attributes could not be matched to SNOMED CT concepts |
a SNOMEDfinding objects, which is a data.table with
miniCDB <- createCDB(SNOMED = sampleSNOMED()) D <- decompose(as.SNOMEDconcept('Cor pulmonale', SNOMED = sampleSNOMED()), CDB = miniCDB, SNOMED = sampleSNOMED()) # ------------------------------------------------------- # 83291003 | Cor pulmonale (disorder) # ------------------------------------------------------- # Root : 367363000 | Right ventricular failure (disorder) # - Due to : 70995007 | Pulmonary hypertension (disorder)
miniCDB <- createCDB(SNOMED = sampleSNOMED()) D <- decompose(as.SNOMEDconcept('Cor pulmonale', SNOMED = sampleSNOMED()), CDB = miniCDB, SNOMED = sampleSNOMED()) # ------------------------------------------------------- # 83291003 | Cor pulmonale (disorder) # ------------------------------------------------------- # Root : 367363000 | Right ventricular failure (disorder) # - Due to : 70995007 | Pulmonary hypertension (disorder)
Returns the descriptions matching a set of concept IDs from a SNOMED dictionary
description( conceptIds, include_synonyms = FALSE, active_only = TRUE, SNOMED = getSNOMED() )
description( conceptIds, include_synonyms = FALSE, active_only = TRUE, SNOMED = getSNOMED() )
conceptIds |
character or integer64 vector |
include_synonyms |
whether to return all synonyms, or just the Fully Specified Name, ensuring just one row per concept (default) |
active_only |
whether to include only active descriptions |
SNOMED |
environment containing SNOMED dictionary. Defaults to an object named 'SNOMED' in the global environment |
a data.table with the following columns: id, conceptId, type (only if include_synonyms = TRUE), term, active (only if active_only = FALSE)
htmlCodelistHierarchy
hf <- SNOMEDconcept('Heart failure', SNOMED = sampleSNOMED()) description(hf, include_synonyms = FALSE, SNOMED = sampleSNOMED())
hf <- SNOMEDconcept('Heart failure', SNOMED = sampleSNOMED()) description(hf, include_synonyms = FALSE, SNOMED = sampleSNOMED())
Downloads the Orphanet nomenclature pack and converts it into a format to be appended to MANUAL_SYNONYMS and used in concept database creation.
downloadOrphanet( orphanet_url = "https://www.orphadata.com/data/nomenclature/packs/Orphanet_Nomenclature_Pack_EN.zip", masterfile_name = NULL, SNOMED = getSNOMED() )
downloadOrphanet( orphanet_url = "https://www.orphadata.com/data/nomenclature/packs/Orphanet_Nomenclature_Pack_EN.zip", masterfile_name = NULL, SNOMED = getSNOMED() )
orphanet_url |
URL or filepath to Orphanet zip file |
masterfile_name |
name of xls file containing Orphanet synonyms. If omitted, it is assumed to be the only file with 'MasterFile' in its name, and the program will search for it in the Orphanet zip file. |
SNOMED |
environment containing SNOMED CT dictionary |
data.table containing Orphanet synonyms in the format
https://www.orphadata.com/pack-nomenclature/
downloadWordnet
# Not run # ORPHANET <- downloadOrphanet()
# Not run # ORPHANET <- downloadOrphanet()
Downloads the WordNet thesaurus and converts it into a format to be used by addWordNet to add extra synonyms to a concept database.
downloadWordnet( wordnet_url = "https://wordnetcode.princeton.edu/wn3.1.dict.tar.gz", wn_categories = c("noun.body", "noun.state", "noun.process", "noun.animal", "noun.plant", "noun.phenomenon") )
downloadWordnet( wordnet_url = "https://wordnetcode.princeton.edu/wn3.1.dict.tar.gz", wn_categories = c("noun.body", "noun.state", "noun.process", "noun.animal", "noun.plant", "noun.phenomenon") )
wordnet_url |
URL or filepath to WordNet tar.gz file |
wn_categories |
WordNet categories from which to extract data |
data.table containing WordNet data from appropriate categories, in the format: cat (character), wordnetId (integer64), synonyms (list), parents (list), adj (list)
https://wordnet.princeton.edu/
[addWordNet()]
# Not run # WORDNET <- downloadWordnet()
# Not run # WORDNET <- downloadWordnet()
Returns a set of SNOMED concepts (as a SNOMEDconcept vector) which can be used to exclude findings in the MedCAT named entity recognition step, or blacklist (filter out) findings from the final output.
exclude_irrelevant_findings(SNOMED = getSNOMED()) blacklist_vague_findings(SNOMED = getSNOMED()) blacklist_almost_all_except_diseases(SNOMED = getSNOMED())
exclude_irrelevant_findings(SNOMED = getSNOMED()) blacklist_vague_findings(SNOMED = getSNOMED()) blacklist_almost_all_except_diseases(SNOMED = getSNOMED())
SNOMED |
environment containing a SNOMED dictionary |
social history (except housing problems and care needs), administrative statuses (except registered disabled) and for concept detection
vague findings and disorders, intended to be used in the blacklist
almost all findings and vague disorders, intended to be used in the blacklist
SNOMEDconcept vector containing findings to exclude
exportMiADECDB, createCDB
SNOMEDcodelist is an S3 class for sets of SNOMED concepts. In the 'contracted' form, it may contain only parents and not child terms (to create a more succinct list). The 'Expanded' form contains all concepts. The output of 'showCodelistHierarchy' includes all hierarchies contained within the codelist in a format suitable for display.
expandSNOMED(x, SNOMED = getSNOMED(), ...) contractSNOMED(x, SNOMED = getSNOMED(), ...) showCodelistHierarchy( x, SNOMED = getSNOMED(), max_excluded_descendants = 200, ... )
expandSNOMED(x, SNOMED = getSNOMED(), ...) contractSNOMED(x, SNOMED = getSNOMED(), ...) showCodelistHierarchy( x, SNOMED = getSNOMED(), max_excluded_descendants = 200, ... )
x |
SNOMEDcodelist to expand or contract. If x is not a SNOMEDcodelist, it is coerced to one by as.SNOMEDcodelist |
SNOMED |
environment containing a SNOMED dictionary |
... |
other arguments to pass to as.SNOMEDcodelist |
max_excluded_descendants |
(integer) whether to show excluded descendants as long as they do not exceed this number (a limit is suggested to avoid the program crashing if there are too many descendants). If this number is exceeded, the program will initially try to include children only, and if there are still too many, it will ignore all descendants. An 'included' column is added to the codelist showing which terms are included. This can make it easy to see if a codelist is consistent with the SNOMED CT ontology. |
An object of class 'SNOMEDcodelist' with attribute Expanded = TRUE
Other SNOMEDcodelist functions:
SNOMEDcodelist()
,
addInactiveConcepts()
,
export()
,
is.SNOMEDcodelist()
,
print.SNOMEDcodelist()
Other SNOMEDcodelist functions:
SNOMEDcodelist()
,
addInactiveConcepts()
,
export()
,
is.SNOMEDcodelist()
,
print.SNOMEDcodelist()
Other SNOMEDcodelist functions:
SNOMEDcodelist()
,
addInactiveConcepts()
,
export()
,
is.SNOMEDcodelist()
,
print.SNOMEDcodelist()
SNOMED <- sampleSNOMED() my_concepts <- SNOMEDconcept('Heart failure') my_codelist <- SNOMEDcodelist(data.frame(conceptId = my_concepts, include_desc = TRUE)) expanded_codelist <- expandSNOMED(my_codelist) contractSNOMED(expanded_codelist)
SNOMED <- sampleSNOMED() my_concepts <- SNOMEDconcept('Heart failure') my_codelist <- SNOMEDcodelist(data.frame(conceptId = my_concepts, include_desc = TRUE)) expanded_codelist <- expandSNOMED(my_codelist) contractSNOMED(expanded_codelist)
Writes a SNOMEDcodelist to file. If the filename is NULL, a filename is created from the 'codelist_name' attribute.
export(x, ...) ## S3 method for class 'SNOMEDcodelist' export(x, filename = NULL, ...)
export(x, ...) ## S3 method for class 'SNOMEDcodelist' export(x, filename = NULL, ...)
x |
SNOMEDcodelist object to export to file |
... |
not used |
filename |
character vector of length 1 for the file to write to. If NULL, a filename is generated from the codelist filename. |
invisibly returns the exported codelist
Other SNOMEDcodelist functions:
SNOMEDcodelist()
,
addInactiveConcepts()
,
expandSNOMED()
,
is.SNOMEDcodelist()
,
print.SNOMEDcodelist()
Other SNOMEDcodelist functions:
SNOMEDcodelist()
,
addInactiveConcepts()
,
expandSNOMED()
,
is.SNOMEDcodelist()
,
print.SNOMEDcodelist()
Produces a set of files for the findings / problems algorithm of MedCAT and MiADE. Uses the CDB environment created using createCDB which can incorporate additional manual synonyms or synonyms from WordNet.
exportMiADECDB( CDB, export_folderpath, lang_refset_files = NULL, exclude = NULL, include = NULL, exclude_historic = descendants("Disorder", SNOMED = getSNOMED()), blacklist = NULL, SNOMED = getSNOMED() )
exportMiADECDB( CDB, export_folderpath, lang_refset_files = NULL, exclude = NULL, include = NULL, exclude_historic = descendants("Disorder", SNOMED = getSNOMED()), blacklist = NULL, SNOMED = getSNOMED() )
CDB |
concept database environment created by createCDB |
export_folderpath |
folder path to export to |
lang_refset_files |
character vector of file paths to SNOMED CT language refset files, in order to identify the preferred term for each concept. If NULL, the Fully Specified Name minus the semantic type suffix is used as the preferred term (e.g. if the Fully Specified Name is 'Cancer (disorder)', the default preferred term is 'Cancer'. |
exclude |
a SNOMEDconcept or SNOMEDcodelist object specifying concepts to exclude from the concept database. By default, all concepts in the FINDINGS, CAUSES, BODY, LATERALITY, MORPH, SEVERITY, STAGE and QUAL tables will be included. |
include |
a SNOMEDconcept or SNOMEDcodelist object specifying additional concepts to include in the concept database. By default, all findings are included for potential export, but there may additional concepts of other semantic types (e.g. situation concepts) that need to be included. Inclusion takes place after exclusion, i.e. a concept in both the include and exclude lists will be included. |
exclude_historic |
a SNOMEDconcept or SNOMEDcodelist object specifying concepts to be excluded from the 'historic' lookup, i.e. those that should not be converted into historic forms. The default is to not do this conversion for disorders, only for procedures. |
blacklist |
a SNOMEDconcept or SNOMEDcodelist object specifying concepts to filter out of the final output. By default, concepts in the CDB of any semantic type other than 'finding' or 'disorder' are excluded. The blacklist can be used to exclude a subset of findings or disorders that are not useful for the particular application. |
SNOMED |
environment containing a SNOMED dictionary |
The following files are exported:
For MedCAT (named entity recognition and linking):
- CSV file in MedCAT concept database format containing cui (SNOMED CT concept ID), name, name_status ('P' for preferred term, 'N' for terms that must be disambiguated (e.g. acronyms or short terms), 'A' for synonym), ontologies = SNO (for SNOMED CT)
For MiADE postprocessing:
- CSV file with columns findingId (SNOMED CT concept ID of the underlying finding / disorder) and situationId (SNOMED CT concept ID of the pre-coordinated situation concept for negation of the finding / disorder). Sorted by findingId.
- CSV file with columns findingId (SNOMED CT concept ID of the underlying finding / disorder) and situationId (SNOMED CT concept ID of the pre-coordinated situation concept for 'history of' the finding / disorder). Sorted by findingId.
- CSV file with columns findingId (SNOMED CT concept ID of the underlying finding / disorder) and situationId (SNOMED CT concept ID of the pre-coordinated situation concept for 'suspected' finding / disorder). Sorted by findingId.
- CSV file with columns findingId (SNOMED CT concept ID of the underlying finding / disorder) and otherId (SNOMED CT concept ID of a concept with the same description but a different semantic type, typically a morphologic abnormality). Sorted by otherId.
- CSV file without header with one column containing SNOMED CT concept IDs for concepts that may be identified by MedCAT as part of text analysis but should not be included in final MiADE output, Examples include procedure codes which may be used to link to precoordinated 'history of...' concepts. This file can also be used to force MiADE to ignore any specific SNOMED CT concepts in the output. Sorted in ascending order.
For more information about MiADE, visit https://www.ucl.ac.uk/health-informatics/research/miade/miade-software-and-availability
For more information about MedCAT, visit https://github.com/CogStack/MedCAT
TRUE if successful
createCDB, downloadWordnet, downloadOrphanet, MANUAL_SYNONYMS, exclude_irrelevant_findings
# Not run # exportMiADECDB(CDB, export_folderpath = tempdir())
# Not run # exportMiADECDB(CDB, export_folderpath = tempdir())
Creates tab separated files which can be reloaded with relevant indices for fast searching of SNOMED CT tables
exportSNOMEDenvir(SNOMED, folder)
exportSNOMEDenvir(SNOMED, folder)
SNOMED |
environment containing data.table objects: CONCEPT, DESCRIPTION, RELATIONSHIP, STATEDRELATIONSHIP, REFSET, SIMPLEMAP, EXTENDEDMAP |
folder |
path to folder where files will be written |
CONCEPT, DESCRIPTION, RELATIONSHIP, STATEDRELATIONSHIP
Returns concepts mapped to SNOMED CT from either the SIMPLEMAP table in the SNOMED dictionay (Clinical Terms Version 3, CTV3 maps, one per concept), the EXTENDEDMAP table (ICD-10 and OPCS4 maps) or a separate mapping table with Read Clinical Terms Version 2 (Read 2) and CTV3 maps. A sample mapping table (READMAPS) is provided.
getMaps( x, mappingtable = NULL, to = c("read2", "ctv3", "icd10", "opcs4", "ctv3simple"), SNOMED = getSNOMED(), single_row_per_concept = TRUE )
getMaps( x, mappingtable = NULL, to = c("read2", "ctv3", "icd10", "opcs4", "ctv3simple"), SNOMED = getSNOMED(), single_row_per_concept = TRUE )
x |
SNOMEDcodelist or SNOMEDconcept object. If it is a SNOMEDconcept object it is first converted to a SNOMEDcodelist. If it is a SNOMEDcodelist it is first converted to 'simple' format. Columns named 'read2_code' or 'read2_term' (if adding Read 2 maps) or 'ctv3_concept' or ctv3_termid' (if adding CTV3 maps) will be overwritten. |
mappingtable |
data.table containing mapping in the format described in 'Details'. The MAPS dataset in this package provides a sample. It must contain a unique field 'conceptId', and fields named 'read2_code' and 'read2_term' (for mapping to Read 2) or 'ctv3_concept' and 'ctv3_termid' (for mapping to CTV3). |
to |
character vector stating which terminologies to map to. Options are 'icd10', 'opcs4', 'ctv3simple' (use tables included within the SNOMED dictionary), or 'read2' or 'ctv3' (require a separate mapping table such as READMAPS). Beware that including multiple destination terminologies may result in a significant expansion of the number of rows if single_row_per_concept is FALSE. |
SNOMED |
an environment containing the SNOMED CT dictionary. If not supplied, it will be obtained using getSNOMED(). |
single_row_per_concept |
(logical) if TRUE (default), the function returns a single row per concept with Read 2 and CTV3 maps returned as lists (i.e. multiple entries within a single cell). This means the output is a valid SNOMEDcodelist object. If FALSE, returns multiple rows per concept (one for each map). |
The mapping table can be created from the NHS Digital 'Data Migration' pack files which contain 'forward' maps of Read 2 and CTV3 to SNOMED CT. These are intended for converting individual entries in electronic health records to SNOMED CT. The 'forward' map files contain a SNOMED CT map for every Read 2 or CTV3 code, but not all the SNOMED CT concepts are mapped. Future SNOMED CT concepts will also not be mapped.
These maps can be used for converting SNOMED CT codelists into Read 2 or CTV3 format for running queries, such as to characterise patient phenotypes or identify patient populations for research. They cannot be used in the reverse direction (to map a Read 2/CTV3 codelist to SNOMED CT) because some of the SNOMED CT terms will be missed out, and the list will be incomplete.
The mapping table must be a data.table object with columns: conceptId (integer64, unique), read2_code (character list of 7-character Read 2 codes), read2_term (character list of Read 2 terms), ctv3_concept (character list of CTV3 concept codes), ctv3_termid (character list of CTV3 term description codes)
a data.table containing the columns conceptId and either 'read2_code' and 'read2_term' (for mapping to Read 2), 'ctv3_concept' and 'ctv3_termid' (for mapping to CTV3 using the mapping table), 'ctv3_simple' (mapping to CTV3 using SIMPLEMAP within the SNOMED dictionary), 'icd10_code' or 'opcs4_code' (mapped using EXTENDEDMAP within the SNOMED dictionary). If single_row_per_concept is TRUE, the mapped rows are of type 'list' and the output is also a SNOMEDcodelist in 'simple' format, otherwise the output may have multiple rows per conceptId. Note that each Read 2, CTV3, ICD-10 or OPCS4 term may be mapped to multiple SNOMED CT concepts.
READMAPS, loadREADMAPS
# Load sample SNOMED CT dictionary into the global environment # so it is available to the functions in this example SNOMED <- sampleSNOMED() # Use the sample READMAPS table in this package data(READMAPS) # Example: Mapping a single concept getMaps(SNOMEDconcept('Heart failure'), mappingtable = READMAPS, to = 'read2') # Example: Mapping a concept and its descendants getMaps(descendants(SNOMEDconcept('Heart failure')), mappingtable = READMAPS, to = 'read2') # Example: Mapping a codelist getMaps(SNOMEDcodelist(SNOMEDconcept('Heart failure')), mappingtable = READMAPS, to = c('ctv3', 'ctv3simple', 'icd10'))
# Load sample SNOMED CT dictionary into the global environment # so it is available to the functions in this example SNOMED <- sampleSNOMED() # Use the sample READMAPS table in this package data(READMAPS) # Example: Mapping a single concept getMaps(SNOMEDconcept('Heart failure'), mappingtable = READMAPS, to = 'read2') # Example: Mapping a concept and its descendants getMaps(descendants(SNOMEDconcept('Heart failure')), mappingtable = READMAPS, to = 'read2') # Example: Mapping a codelist getMaps(SNOMEDcodelist(SNOMEDconcept('Heart failure')), mappingtable = READMAPS, to = c('ctv3', 'ctv3simple', 'icd10'))
Retrieves a Refset from the REFSET table
getRefset(conceptIds, SNOMED = getSNOMED())
getRefset(conceptIds, SNOMED = getSNOMED())
conceptIds |
character or integer64 vector of Refset SNOMED concept IDs, or something that can be coerced to a SNOMEDconcept |
SNOMED |
environment containing a SNOMED dictionary |
a SNOMEDconcept vector of conceptIds of members of the selected refset(s)
SNOMED <- sampleSNOMED() getRefset(c('Renal clinical finding simple reference set', 'Care planning activities simple reference set'))
SNOMED <- sampleSNOMED() getRefset(c('Renal clinical finding simple reference set', 'Care planning activities simple reference set'))
Returns an object named 'SNOMED' from the global environment. Returns an error if no such object exists, or if it is not an environment containing tables named CONCEPT, RELATIONSHIP, STATEDRELATIONSHIP and DESCRIPTION. There is no attempt to check that these tables are actually valid.
getSNOMED(SNOMEDname = "SNOMED")
getSNOMED(SNOMEDname = "SNOMED")
SNOMEDname |
name of the SNOMED environment to search for |
SNOMED environment from the global environment
CONCEPT, DESCRIPTION, RELATIONSHIP, STATEDRELATIONSHIP, REFSET, SIMPLEMAP, EXTENDEDMAP, loadSNOMED, sampleSNOMED
SNOMED <- sampleSNOMED() SNOMED2 <- getSNOMED() # To display metadata for this SNOMED CT dictionary SNOMED2$metadata
SNOMED <- sampleSNOMED() SNOMED2 <- getSNOMED() # To display metadata for this SNOMED CT dictionary SNOMED2$metadata
For each concept in the first list, whether it has the attribute in the second list. Returns a vector of Booleans.
hasAttributes( sourceIds, destinationIds, typeIds = bit64::as.integer64("116680003"), SNOMED = getSNOMED(), tables = c("RELATIONSHIP", "STATEDRELATIONSHIP"), active_only = TRUE )
hasAttributes( sourceIds, destinationIds, typeIds = bit64::as.integer64("116680003"), SNOMED = getSNOMED(), tables = c("RELATIONSHIP", "STATEDRELATIONSHIP"), active_only = TRUE )
sourceIds |
character or integer64 vector of SNOMED concept IDs for children, recycled if necessary |
destinationIds |
character or integer64 vector of SNOMED concept IDs for parents, recycled if necessary |
typeIds |
character or integer64 vector of SNOMED concept IDs for renationship types, recycled if necessary. Defaults to 116680003 = 'Is a' (child/parent) |
SNOMED |
environment containing a SNOMED dictionary |
tables |
character vector of relationship tables to use |
active_only |
whether only active relationships should be considered, default TRUE |
a vector of Booleans stating whether the attribute exists
SNOMED <- sampleSNOMED() hasAttributes(c('Heart failure', 'Acute heart failure'), c('Heart structure', 'Heart failure'), c('Finding site', 'Is a'))
SNOMED <- sampleSNOMED() hasAttributes(c('Heart failure', 'Acute heart failure'), c('Heart structure', 'Heart failure'), c('Finding site', 'Is a'))
Sample of the SNOMED CT table showing current equivalents for inactive concepts.
data(HISTORY)
data(HISTORY)
An object of class "data.table"
integer64: concept ID of the inactive concepts
integer: status of the old concept
integer64: concept ID of the new concept
integer: status of the new concept
character: path
integer: whether ambiguous
integer: number of iterations
character: old concept Fully Specified Name
integer: number of tags for old concept
integer: new concept Fully Specified Name
integer: new concept Fully Specified Name status
integer: whether TLH identical
integer: whether Fully Specified Names are identical ignoring the tags
integer: whether Fully Specified Names tags are identical
Other SNOMEDsample:
QUERY
,
SNOMED_RELATIONSHIP
# Create a TEST environment and load the sample dictionaries TEST <- new.env() data(CONCEPT, envir = TEST) data(DESCRIPTION, envir = TEST) data(RELATIONSHIP, envir = TEST) data(STATEDRELATIONSHIP, envir = TEST) data(HISTORY, envir = TEST) # Show properties of the history table str(TEST$HISTORY)
# Create a TEST environment and load the sample dictionaries TEST <- new.env() data(CONCEPT, envir = TEST) data(DESCRIPTION, envir = TEST) data(RELATIONSHIP, envir = TEST) data(STATEDRELATIONSHIP, envir = TEST) data(HISTORY, envir = TEST) # Show properties of the history table str(TEST$HISTORY)
Exports a codelist with hierarchy as HTML for easy viewing.
htmlCodelistHierarchy( x, file = NULL, title = NULL, description = NULL, extracols = NULL, SNOMED = getSNOMED(), ... )
htmlCodelistHierarchy( x, file = NULL, title = NULL, description = NULL, extracols = NULL, SNOMED = getSNOMED(), ... )
x |
a SNOMEDcodelist, codelistHierarchy (output of showCodelistHierarchy), or an object which can be coerced to a SNOMEDcodelist (such as a SNOMEDconcept vector). |
file |
filename to export to. If NULL, no file is written |
title |
title of HTML document |
description |
paragraph of description text (excluding <p></p> tags) |
extracols |
character vector of additional columns of codelist_with_hierarchy to include in HTML output |
SNOMED |
environment containing the SNOMED dictionary to use |
... |
extra arguments to pass to as.SNOMEDcodelist |
a character vector containing HTML output
showCodelistHierarchy
SNOMED <- sampleSNOMED() my_concepts <- SNOMEDconcept('Acute heart failure') my_codelist <- SNOMEDcodelist(data.frame(conceptId = my_concepts, include_desc = TRUE)) my_codelist <- getMaps(my_codelist, to = 'icd10') htmlCodelistHierarchy(my_codelist, file = paste0(tempdir(), '/codelist.html'), extracols = 'icd10_code') # The codelist.html file can now be viewed in a web browser # Clean up temporary file file.remove(paste0(tempdir(), '/codelist.html'))
SNOMED <- sampleSNOMED() my_concepts <- SNOMEDconcept('Acute heart failure') my_codelist <- SNOMEDcodelist(data.frame(conceptId = my_concepts, include_desc = TRUE)) my_codelist <- getMaps(my_codelist, to = 'icd10') htmlCodelistHierarchy(my_codelist, file = paste0(tempdir(), '/codelist.html'), extracols = 'icd10_code') # The codelist.html file can now be viewed in a web browser # Clean up temporary file file.remove(paste0(tempdir(), '/codelist.html'))
Checks the active_only flag in the metadata of a SNOMED environment to determine whether inactive terms are included
inactiveIncluded(SNOMED = getSNOMED())
inactiveIncluded(SNOMED = getSNOMED())
SNOMED |
environment containing SNOMED dictionary, defaults to an object named 'SNOMED' in the global environment |
TRUE or FALSE (logical vector of length one)
# Create a TEST environment and load the sample dictionaries TEST <- sampleSNOMED() inactiveIncluded(TEST) assign('metadata', list(active_only = TRUE), envir = TEST) inactiveIncluded(TEST)
# Create a TEST environment and load the sample dictionaries TEST <- sampleSNOMED() inactiveIncluded(TEST) assign('metadata', list(active_only = TRUE), envir = TEST) inactiveIncluded(TEST)
SNOMEDcodelist is an S3 class for lists of SNOMED codes. This function checks whether the object has the class SNOMEDcodelist, and whether the specified attributes are as per the arguments (if the arguments are left as NULL, as per default, they are not checked). The function does not check if the codelist contains valid data.
is.SNOMEDcodelist( x, format = NULL, codelist_name = NULL, version = NULL, author = NULL, date = NULL, SNOMED = NULL )
is.SNOMEDcodelist( x, format = NULL, codelist_name = NULL, version = NULL, author = NULL, date = NULL, SNOMED = NULL )
x |
object to check |
format |
Whether the codelist is expressed as a simple enumeration of concepts ('simple'), as a set of concept hierarchies ('tree') or as a set of hierarchies showing all concepts ('exptree'). Codelists can be converted between the formats, but the result of conversion may depend on the SNOMED CT dictionary being used. |
codelist_name |
Name of the codelist (character vector of length 1) |
version |
Version of the codelist (character vector of length 1) |
author |
Author of the codelist (character vector of length 1) |
date |
Date assigned to the codelist (character vector of length 1) |
SNOMED |
Dummy argument to ensure that this function works with as.SNOMEDcodelist |
a logical vector of length one: TRUE or FALSE
Other SNOMEDcodelist functions:
SNOMEDcodelist()
,
addInactiveConcepts()
,
expandSNOMED()
,
export()
,
print.SNOMEDcodelist()
SNOMEDconcept is an S3 class for vectors of SNOMED concept IDs as 64-bit integers. This function checks whether the object has the class SNOMEDconcept and is a vector of 64-bit integers.
is.SNOMEDconcept(x)
is.SNOMEDconcept(x)
x |
object to check |
a logical vector of length one: TRUE or FALSE
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
print.SNOMEDconcept()
,
union.SNOMEDconcept()
,
unique.SNOMEDconcept()
Creates a mapping table derived from NHS Digital Data Migration distribution. These tables are available from the Technology Reference Update Distribution: https://isd.digital.nhs.uk/trud/user/guest/group/0/pack/9/subpack/9/releases
loadREADMAPS( not_assured_rcsctmap_uk, not_assured_rctermsctmap_uk, assured_ctv3sctmap2_uk )
loadREADMAPS( not_assured_rcsctmap_uk, not_assured_rctermsctmap_uk, assured_ctv3sctmap2_uk )
not_assured_rcsctmap_uk |
File containing Read 2 codes mapped to SNOMED CT, in file: 'Not Clinically Assured/rcsctmap_uk_20200401000001.txt' |
not_assured_rctermsctmap_uk |
File containing Read 2 terms mapped to SNOMED CT, in file: 'Not Clinically Assured/rctermsctmap_uk_20200401000001.txt' |
assured_ctv3sctmap2_uk |
File containing CTV3 concepts and terms mapped to SNOMED CT, in file: 'Clinically Assured/ctv3sctmap2_uk_20200401000001.txt' |
The final release was in April 2020. The mapping tables are intended for converting entires in clinical records from Read Version 2 (Read 2) to SNOMED CT, and Clinical Terms Version 3 (CTV3) to SNOMED CT.
These maps can be used for converting SNOMED CT codelists into Read 2 or CTV3 format for running queries, such as to characterise patient phenotypes or identify patient populations for research. They cannot be used in the reverse direction (to map a Read 2/CTV3 codelist to SNOMED CT) because some of the SNOMED CT terms will be missed out, and the list will be incomplete.
This function uses the following three mapping files:
File containing Read 2 codes mapped to SNOMED CT, in file: 'Not Clinically Assured/rcsctmap_uk_20200401000001.txt'
File containing Read 2 terms mapped to SNOMED CT, in file: 'Not Clinically Assured/rctermsctmap_uk_20200401000001.txt'
File containing CTV3 concepts and terms mapped to SNOMED CT, in file: 'Clinically Assured/ctv3sctmap2_uk_20200401000001.txt'
The output data.table has the following columns:
integer64: SNOMED CT conceptId (primary key)
list: character list of 7-character Read 2 codes
list: character list of Read 2 terms
list: character list of CTV3 concept codes
list: character list of CTV3 term description codes
A data.table with columns conceptId, read2_code, ctv3_concept, ctv3_termid
READMAPS, getMaps, loadSNOMED
Identifies relevant SNOMED CT files from the folder structure of a SNOMED CT distribution. This includes the core 'Snapshot' tables mapping tables from the 'Refset' folder and the history substitution table and query table. The relevant tables are loaded into an R environment, which can be saved and then easily retrieved for future use. Files from two folders (e.g. International and UK versions) can be loaded together, and are automatically appended by the function.
loadSNOMED(folders, active_only = TRUE, version = NULL)
loadSNOMED(folders, active_only = TRUE, version = NULL)
folders |
Vector of folder paths containing SNOMED CT files |
active_only |
Whether to limit to current (active) SNOMED CT concepts |
version |
Version description. If NULL, it is derived from the folder paths and expressed in the form: INT date & UK date |
The SNOMED CT files are available from the NHS Digital Technology Reference Update Distribution: https://isd.digital.nhs.uk/trud/user/guest/group/0/home
An environment containing data.table objects: CONCEPT, DESCRIPTION, RELATIONSHIP, STATEDRELATIONSHIP, REFSET, SIMPLEMAP, EXTENDEDMAP, HISTORY (optional), QUERY (optional)
loadREADMAPS, CONCEPT, DESCRIPTION, RELATIONSHIP, STATEDRELATIONSHIP, REFSET, SIMPLEMAP, EXTENDEDMAP, QUERY, HISTORY sampleSNOMED, getSNOMED, exportSNOMEDenvir
# Create a TEST environment and load the sample dictionaries TEST <- sampleSNOMED() # Export to temporary directory exportSNOMEDenvir(TEST, tempdir()) # Try to import using the loadSNOMED function TEST2 <- loadSNOMED(tempdir(), active_only = FALSE) # Check that reimported SNOMED dictionary is the same as the original all.equal(TEST$CONCEPT, TEST2$CONCEPT) all.equal(TEST$DESCRIPTION, TEST2$DESCRIPTION) all.equal(TEST$RELATIONSHIP, TEST2$RELATIONSHIP) all.equal(TEST$STATEDRELATIONSHIP, TEST2$STATEDRELATIONSHIP) all.equal(TEST$REFSET, TEST2$REFSET) all.equal(TEST$SIMPLEMAP, TEST2$SIMPLEMAP) all.equal(TEST$EXTENDEDMAP, TEST2$EXTENDEDMAP)
# Create a TEST environment and load the sample dictionaries TEST <- sampleSNOMED() # Export to temporary directory exportSNOMEDenvir(TEST, tempdir()) # Try to import using the loadSNOMED function TEST2 <- loadSNOMED(tempdir(), active_only = FALSE) # Check that reimported SNOMED dictionary is the same as the original all.equal(TEST$CONCEPT, TEST2$CONCEPT) all.equal(TEST$DESCRIPTION, TEST2$DESCRIPTION) all.equal(TEST$RELATIONSHIP, TEST2$RELATIONSHIP) all.equal(TEST$STATEDRELATIONSHIP, TEST2$STATEDRELATIONSHIP) all.equal(TEST$REFSET, TEST2$REFSET) all.equal(TEST$SIMPLEMAP, TEST2$SIMPLEMAP) all.equal(TEST$EXTENDEDMAP, TEST2$EXTENDEDMAP)
Sample manual synonym table to assist in creation of concept database
data(MANUAL_SYNONYMS)
data(MANUAL_SYNONYMS)
An object of class "data.table"
character: Synonym, in lower case if case is unimportant
character: SNOMED CT term, in lower case if case is unimportant
boolean: whether synonym can only ever mean snomed. Not to be used for abbreviations or acronyms.
[addManual()]
data(MANUAL_SYNONYMS) str(MANUAL_SYNONYMS)
data(MANUAL_SYNONYMS) str(MANUAL_SYNONYMS)
Returns concepts with 'Is a' or inverse 'Is a' relationship with a set of target concepts. Ancestors include parents and all higher relations. Descendants include children and all lower relations.
parents( conceptIds, include_self = FALSE, SNOMED = getSNOMED(), TRANSITIVE = NULL, ... ) ancestors( conceptIds, include_self = FALSE, SNOMED = getSNOMED(), TRANSITIVE = NULL, ... ) children( conceptIds, include_self = FALSE, SNOMED = getSNOMED(), TRANSITIVE = NULL, ... ) descendants( conceptIds, include_self = FALSE, SNOMED = getSNOMED(), TRANSITIVE = NULL, ... )
parents( conceptIds, include_self = FALSE, SNOMED = getSNOMED(), TRANSITIVE = NULL, ... ) ancestors( conceptIds, include_self = FALSE, SNOMED = getSNOMED(), TRANSITIVE = NULL, ... ) children( conceptIds, include_self = FALSE, SNOMED = getSNOMED(), TRANSITIVE = NULL, ... ) descendants( conceptIds, include_self = FALSE, SNOMED = getSNOMED(), TRANSITIVE = NULL, ... )
conceptIds |
character or integer64 vector of SNOMED concept IDs |
include_self |
whether to include the original concept(s) in the output, default = FALSE |
SNOMED |
environment containing a SNOMED dictionary |
TRANSITIVE |
transitive closure table for ancestors and descendants, containing is-a relationships. This table can be created by createTransitive to speed up the ancestor / descendant functions. If a TRANSITIVE table is provided, the SNOMED environment is not used and relatedConcepts is not called. TRANSITIVE should be a data.table with columns ancestorId and descendantId. |
... |
other arguments to pass to relatedConcepts |
a bit64 vector of SNOMED CT concepts
[createTransitive()] for creation of TRANSITIVE table, and [relatedConcepts()] for the underlying function to extract SNOMED CT relationships.
SNOMED <- sampleSNOMED() parents('Heart failure') children('Heart failure') ancestors('Heart failure') descendants('Heart failure')
SNOMED <- sampleSNOMED() parents('Heart failure') children('Heart failure') ancestors('Heart failure') descendants('Heart failure')
Displays a SNOMEDcodelist on screen, including metadata. Truncates term descriptions in order to fit within the line width.
## S3 method for class 'SNOMEDcodelist' print(x, ...)
## S3 method for class 'SNOMEDcodelist' print(x, ...)
x |
SNOMEDcodelist object to print to screen |
... |
not used |
invisibly returns the codelist
Other SNOMEDcodelist functions:
SNOMEDcodelist()
,
addInactiveConcepts()
,
expandSNOMED()
,
export()
,
is.SNOMEDcodelist()
SNOMEDconcept is an S3 class for vectors of SNOMED concept IDs as 64-bit integers. This function checks whether the object has the class SNOMEDconcept and is a vector of 64-bit integers.
## S3 method for class 'SNOMEDconcept' print(x, ...)
## S3 method for class 'SNOMEDconcept' print(x, ...)
x |
SNOMEDconcept object, or something that can be coerced to one |
... |
not required |
invisibly returns a character vector of the SNOMED CT concepts with descriptions separated by pipe (|)
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
union.SNOMEDconcept()
,
unique.SNOMEDconcept()
Print method for output of 'decompose' function
## S3 method for class 'SNOMEDfindings' print(x, ...)
## S3 method for class 'SNOMEDfindings' print(x, ...)
x |
SNOMEDfindings object to display |
... |
not used |
TRUE
Sample of the SNOMED CT table of ancestor / descendant relationships for inactive concepts.
data(QUERY)
data(QUERY)
An object of class "data.table"
integer64: concept ID of the ancestor (active) concept
integer64: concept ID of the descendant (inactive) concept
integer: provenance of relationship. Provenance = 0 means subsumption is always true. Provenance = 1 means subsumption is usually true (but there is a theoretical risk of false positives). Provenance = 2 means both ancestors and descendents are only approximately known. Provenance = 3 means original code had at least two distinct meanings and all are being returned
Other SNOMEDsample:
HISTORY
,
SNOMED_RELATIONSHIP
# Create a TEST environment and load the sample dictionaries TEST <- new.env() data(CONCEPT, envir = TEST) data(DESCRIPTION, envir = TEST) data(RELATIONSHIP, envir = TEST) data(STATEDRELATIONSHIP, envir = TEST) data(QUERY, envir = TEST) # Show properties of the query table str(TEST$QUERY)
# Create a TEST environment and load the sample dictionaries TEST <- new.env() data(CONCEPT, envir = TEST) data(DESCRIPTION, envir = TEST) data(RELATIONSHIP, envir = TEST) data(STATEDRELATIONSHIP, envir = TEST) data(QUERY, envir = TEST) # Show properties of the query table str(TEST$QUERY)
A sample of a mapping table derived from NHS Digital maps. Contains concepts in Read Clinical Terms Version 2 and Clinical Terms Version 3 that map to a set of SNOMED CT concepts, according to a supplied mapping file. The source data are available from the NHS Digital Technology Reference data Update Distribution https://isd.digital.nhs.uk/trud/user/guest/group/0/pack/9/subpack/9/releases.
data(READMAPS)
data(READMAPS)
An object of class "data.table"
integer64: SNOMED CT conceptId (primary key)
list: character list of 7-character Read V2 codes
list: character list of Read V2 terms
list: character list of CTV3 concept codes
list: character list of CTV3 term description codes
loadREADMAPS, getMaps
# Show properties of the READMAPS table data(READMAPS) str(READMAPS)
# Show properties of the READMAPS table data(READMAPS) str(READMAPS)
Returns an environment containing a selection of SNOMED CT terms, their relationships and descriptions which are provided with the package
sampleSNOMED()
sampleSNOMED()
environment containing four data.table objects: CONCEPT, DESCRIPTION, RELATIONSHIP, STATEDRELATIONSHIP and a list named 'metadata'
CONCEPT, DESCRIPTION, RELATIONSHIP, STATEDRELATIONSHIP, REFSET, SIMPLEMAP, EXTENDEDMAP, HISTORY, QUERY, loadSNOMED, sampleSNOMED
TEST <- sampleSNOMED() inactiveIncluded(TEST) SNOMEDconcept('Heart failure', SNOMED = TEST) # To display metadata for this SNOMED CT dictionary sampleSNOMED()$metadata
TEST <- sampleSNOMED() inactiveIncluded(TEST) SNOMEDconcept('Heart failure', SNOMED = TEST) # To display metadata for this SNOMED CT dictionary sampleSNOMED()$metadata
Uses the fully specified name in the DESCRIPTION table. If there are multiple fully specified names, the name with the most recent effectiveTime will be used.
semanticType(conceptIds, SNOMED = getSNOMED())
semanticType(conceptIds, SNOMED = getSNOMED())
conceptIds |
character or integer64 vector of SNOMED concept IDs |
SNOMED |
environment containing a SNOMED dictionary |
a character vector of semantic tags corresponding to the conceptIDs
SNOMED <- sampleSNOMED() semanticType(as.SNOMEDconcept(c('Heart failure', 'Is a')))
SNOMED <- sampleSNOMED() semanticType(as.SNOMEDconcept(c('Heart failure', 'Is a')))
Returns a vector of SNOMED CT concept IDs for an ancestor of each concept that is within a second list. If multiple ancestors are included in the second list, the concept is not simplified (i.e. the original concept ID is returned). This functionality can be used to translate concepts into simpler forms for display, e.g. 'Heart failure' instead of 'Heart failure with reduced ejection fraction'.
simplify( conceptIds, ancestorIds, SNOMED = getSNOMED(), tables = c("RELATIONSHIP", "STATEDRELATIONSHIP") )
simplify( conceptIds, ancestorIds, SNOMED = getSNOMED(), tables = c("RELATIONSHIP", "STATEDRELATIONSHIP") )
conceptIds |
character or integer64 vector of SNOMED concept IDs for concepts for which an ancestor is sought |
ancestorIds |
character or integer64 vector of SNOMED concept IDs for possible ancestors |
SNOMED |
environment containing a SNOMED dictionary |
tables |
character vector of relationship tables to use |
This function is intended for use with active SNOMED CT concepts only.
a data.table with the following columns: originalId (integer64) = original conceptId, ancestorId (integer64) = closest single ancestor, or original concept ID if no ancestor is included among ancestorIds
SNOMED <- sampleSNOMED() original_terms <- c('Systolic heart failure', 'Is a', 'Heart failure with reduced ejection fraction', 'Acute kidney injury due to circulatory failure (disorder)') # Note in this example 'Is a' has no parents in ancestors, # and acute kidney failure has two parents in ancestors # so neither of the parents will be chosen. # Also test out inclusion of duplicate concepts. ancestors <- simplify(c(as.SNOMEDconcept(original_terms), as.SNOMEDconcept(original_terms)[3:4]), as.SNOMEDconcept(c('Heart failure', 'Acute heart failure', 'Cardiorenal syndrome (disorder)'))) print(cbind(original_terms, description(ancestors$ancestorId)$term))
SNOMED <- sampleSNOMED() original_terms <- c('Systolic heart failure', 'Is a', 'Heart failure with reduced ejection fraction', 'Acute kidney injury due to circulatory failure (disorder)') # Note in this example 'Is a' has no parents in ancestors, # and acute kidney failure has two parents in ancestors # so neither of the parents will be chosen. # Also test out inclusion of duplicate concepts. ancestors <- simplify(c(as.SNOMEDconcept(original_terms), as.SNOMEDconcept(original_terms)[3:4]), as.SNOMEDconcept(c('Heart failure', 'Acute heart failure', 'Cardiorenal syndrome (disorder)'))) print(cbind(original_terms, description(ancestors$ancestorId)$term))
A sample of the SNOMED CT concept table.
data(CONCEPT)
data(CONCEPT)
An object of class "data.table"
integer64: SNOMED CT conceptId (primary key)
integer64: class of SNOMED CT concept (whether it is used for recording information or is a metadata concept)
integer64: 900000000000074008 = primitive concept, 900000000000073002 = defined by conditions
IDate: when the concept became active
logical: whether this concept is currently active
# Show properties of the CONCEPT table data('CONCEPT') str(CONCEPT)
# Show properties of the CONCEPT table data('CONCEPT') str(CONCEPT)
A sample of the SNOMED CT description table. Each concept may has a fully specified name and may have any number of synonyms.
data(DESCRIPTION)
data(DESCRIPTION)
An object of class "data.table"
integer64: description ID
integer64: class of SNOMED CT concept (whether it is used for recording information or is a metadata concept)
integer64: SNOMED CT concept ID
character: 'en' = English
integer64: 900000000000013009 = Synonym, 900000000000003001 = Fully Specified Name
character: term description
integer64: 900000000000020002 = Initial character case sensitive, 900000000000017005 = Whole term case sensitive, 900000000000448009 = Whole term case insensitive
IDate: when the concept became active
logical: whether this concept is currently active
# Show properties of the DESCRIPTION table data('DESCRIPTION') str(DESCRIPTION)
# Show properties of the DESCRIPTION table data('DESCRIPTION') str(DESCRIPTION)
A sample of the SNOMED CT extended map table, containing maps to ICD-10 and OPCS4.
data(EXTENDEDMAP)
data(EXTENDEDMAP)
An object of class "data.table"
integer64: core metadata concept: 449080006 = SNOMED CT to ICD-10 rule-based mapping module, 999000031000000106 = SNOMED CT United Kingdom Edition reference set module
integer64: foundation metadata concept: 447562003 = ICD-10 complex map reference set, 1126441000000105 = Office of Population Censuses and Surveys Classification of Interventions and Procedures Version 4.9 complex map reference set, 999002271000000101 = International Classification of Diseases, Tenth Revision, Fifth Edition, five character code United Kingdom complex map reference set
integer64: SNOMED CT conceptId of the concept mapped
integer: mapping group
integer: priority of alternative maps (1 = highest)
character: advice on mapping rule
character: mapping advice
character: target ICD-10 or OPCS4 code. The optional period between the third and fourth character has been removed for consistency.
integer64: foundation metadata concept describing the quality of the map
IDate: when the concept became active
logical: whether this concept is currently active
# Load the dataset and show its properties data('EXTENDEDMAP') str(EXTENDEDMAP) # This EXTENDEDMAP table is part of the sample SNOMED CT dictionary # Hence this should show the same properties as above str(sampleSNOMED()$EXTENDEDMAP)
# Load the dataset and show its properties data('EXTENDEDMAP') str(EXTENDEDMAP) # This EXTENDEDMAP table is part of the sample SNOMED CT dictionary # Hence this should show the same properties as above str(sampleSNOMED()$EXTENDEDMAP)
A sample of the SNOMED CT refset table. This contains SNOMED CT codelists that are used for partiular operational or clinical purposes, and are curated by SNOMED CT. The id column of the refset table is not included, in order to save spave.
data(REFSET)
data(REFSET)
An object of class "data.table"
integer64: SNOMED CT core metadata concept, stating whether the refset is from the SNOMED CT core module or the UK extension.
integer64: SNOMED CT conceptId of the refset. These concepts have semantic type 'foundation metadata concept'
integer64: SNOMED CT conceptId of the member of the refset
IDate: when the concept became active
logical: whether this concept is currently active
# Load the dataset and show its properties data('REFSET') str(REFSET) # This REFSET table is part of the sample SNOMED CT dictionary # Hence this should show the same properties as above str(sampleSNOMED()$REFSET)
# Load the dataset and show its properties data('REFSET') str(REFSET) # This REFSET table is part of the sample SNOMED CT dictionary # Hence this should show the same properties as above str(sampleSNOMED()$REFSET)
Samples of the SNOMED CT tables of stated relationships (RELATIONSHIP) and inferred relationships (RELATIONSHIP).
data(RELATIONSHIP); data(STATEDRELATIONSHIP) STATEDRELATIONSHIP
data(RELATIONSHIP); data(STATEDRELATIONSHIP) STATEDRELATIONSHIP
An object of class "data.table"
An object of class data.table
(inherits from data.frame
) with 329 rows and 10 columns.
integer64: ID of the relationship record (primary key)
logical: whether this concept is currently active
integer64: class of SNOMED CT concept (whether it is used for recording information or is a metadata concept)
integer64: source SNOMED CT concept for the relationship
integer64: destination SNOMED CT concept for the relationship
integer: group ID for relationships that are grouped
integer64: 900000000000011006 = Inferred relationship
integer64: 900000000000451002 = Existential restriction modifier
IDate: when the concept became active
integer64: type of relationship, e.g. 116680003 = Is a, 42752001 = Due to, 246090004 = Associated finding, 363698007 = Finding site, 363702006 = Has focus
Other SNOMEDsample:
HISTORY
,
QUERY
# Create a TEST environment and load the sample dictionaries TEST <- new.env() data(CONCEPT, envir = TEST) data(DESCRIPTION, envir = TEST) data(RELATIONSHIP, envir = TEST) data(STATEDRELATIONSHIP, envir = TEST) # Show properties of the relationship tables str(TEST$RELATIONSHIP) str(TEST$STATEDRELATIONSHIP)
# Create a TEST environment and load the sample dictionaries TEST <- new.env() data(CONCEPT, envir = TEST) data(DESCRIPTION, envir = TEST) data(RELATIONSHIP, envir = TEST) data(STATEDRELATIONSHIP, envir = TEST) # Show properties of the relationship tables str(TEST$RELATIONSHIP) str(TEST$STATEDRELATIONSHIP)
A sample of the SNOMED CT SIMPLE map table, containing maps to ICD-10 and OPCS4.
data(SIMPLEMAP)
data(SIMPLEMAP)
An object of class "data.table"
integer64: core metadata concept: 900000000000207008 = SNOMED CT core module, 999000021000000109 = SNOMED CT United Kingdom clinical extension reference set module, 999000031000000106 = SNOMED CT United Kingdom Edition reference set module
integer64: foundation metadata concept: 900000000000497000 = CTV3 simple map reference set, 446608001 = ICD-O simple map reference set, 1323081000000108 = Coronavirus disease 19 caused by severe acute respiratory syndrome coronavirus 2 test result communication to general practice concept simple map reference set, 1323091000000105 = Coronavirus disease 19 caused by severe acute respiratory syndrome coronavirus 2 test result communication to general practice description simple map reference set, 82551000000107 = National Health Service England National Genomic Test Directory whole genome sequencing test simple map reference set
integer64: SNOMED CT conceptId of the concept mapped
character: target ICD-O or CTV3 code
IDate: when the concept became active
logical: whether this concept is currently active
# Load the dataset and show its properties data('SIMPLEMAP') str(SIMPLEMAP) # This SIMPLEMAP table is part of the sample SNOMED CT dictionary # Hence this should show the same properties as above str(sampleSNOMED()$SIMPLEMAP)
# Load the dataset and show its properties data('SIMPLEMAP') str(SIMPLEMAP) # This SIMPLEMAP table is part of the sample SNOMED CT dictionary # Hence this should show the same properties as above str(sampleSNOMED()$SIMPLEMAP)
SNOMEDcodelist is an S3 class for lists of SNOMED CT concepts. It consists of conceptId and include_desc columns. The option to include descendants allows the creation of more succinct SNOMED codelists.
SNOMEDcodelist( x, include_desc = FALSE, format = c("simple", "tree", "exptree"), codelist_name = NULL, version = NULL, author = NULL, date = NULL, SNOMED = getSNOMED(), show_excluded_descendants = FALSE ) as.SNOMEDcodelist(x, ...)
SNOMEDcodelist( x, include_desc = FALSE, format = c("simple", "tree", "exptree"), codelist_name = NULL, version = NULL, author = NULL, date = NULL, SNOMED = getSNOMED(), show_excluded_descendants = FALSE ) as.SNOMEDcodelist(x, ...)
x |
vector of SNOMED CT concept IDs, something which can be coerced to a SNOMEDconcept object, or a data.frame with a column 'conceptId' containing SNOMED CT concept concept IDs in integer64 or text format and optional column 'include_desc' (Boolean) stating whether descendants of the term should be included. |
include_desc |
Boolean vector stating whether descendants are included, recycled if necessary. Default = FALSE. Ignored if x contains a column 'include_desc' |
format |
Whether the codelist is expressed as a simple enumeration of concepts ('simple'), as a set of concept hierarchies ('tree'), or concept hierarchies showing all descendant terms ('exptree'). Codelists can be converted between the formats, but the result of conversion may depend on the SNOMED CT dictionary being used. |
codelist_name |
Name of the codelist (character vector of length 1) |
version |
Version of the codelist (character vector of length 1) |
author |
Author of the codelist (character vector of length 1) |
date |
Date attributed to the codelist (character vector of length 1) |
SNOMED |
environment containing a SNOMED dictionary |
show_excluded_descendants |
Whether to show excluded descendants alongside the codes included in the codelist (for a 'tree' or 'exptree' format codelist). |
... |
other arguments to pass to SNOMEDcodelist |
Input is a data.frame or data.table with column names 'conceptId' and optionally 'include_desc', which is FALSE by default, but if TRUE then the codelist automatically includes all active descendants of that concept.
If the codelist is intended to contain inactive concepts, it can only exist in the 'simple' format. Inactive concepts will be lost if the codelist is converted between formats.
as.SNOMEDcodelist converts its argument into a SNOMEDcodelist but leaves it unchanged if it is already a SNOMEDcodelist.
An object of class 'SNOMEDcodelist'
htmlCodelistHierarchy
Other SNOMEDcodelist functions:
addInactiveConcepts()
,
expandSNOMED()
,
export()
,
is.SNOMEDcodelist()
,
print.SNOMEDcodelist()
Other SNOMEDcodelist functions:
addInactiveConcepts()
,
expandSNOMED()
,
export()
,
is.SNOMEDcodelist()
,
print.SNOMEDcodelist()
SNOMED <- sampleSNOMED() my_concepts <- SNOMEDconcept('Heart failure') SNOMEDcodelist(my_concepts) SNOMEDcodelist(data.frame(conceptId = my_concepts)) as.SNOMEDcodelist(data.frame(conceptId = my_concepts, include_desc = TRUE))
SNOMED <- sampleSNOMED() my_concepts <- SNOMEDconcept('Heart failure') SNOMEDcodelist(my_concepts) SNOMEDcodelist(data.frame(conceptId = my_concepts)) as.SNOMEDcodelist(data.frame(conceptId = my_concepts, include_desc = TRUE))
The default set functions in the base package do not handle integer64 vectors correctly, so this package also provides new generic functions for union, intersect and setdiff, which enable the appropriate object-specific function to be called according to the class of the vector. This means that SNOMEDconcept vectors will remain as SNOMEDconcept vectors when these functions are used.
## S3 method for class 'SNOMEDconcept' union(x, y) union(x, y) ## Default S3 method: union(x, y) ## S3 method for class 'SNOMEDconcept' intersect(x, y) intersect(x, y) ## Default S3 method: intersect(x, y) ## S3 method for class 'SNOMEDconcept' setdiff(x, y) setdiff(x, y) ## Default S3 method: setdiff(x, y)
## S3 method for class 'SNOMEDconcept' union(x, y) union(x, y) ## Default S3 method: union(x, y) ## S3 method for class 'SNOMEDconcept' intersect(x, y) intersect(x, y) ## Default S3 method: intersect(x, y) ## S3 method for class 'SNOMEDconcept' setdiff(x, y) setdiff(x, y) ## Default S3 method: setdiff(x, y)
x |
SNOMEDconcept vector |
y |
SNOMEDconcept vector, or an object that can be coerced to SNOMEDconcept by as.SNOMEDconcept |
an integer64 vector of SNOMEDconcept class
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
unique.SNOMEDconcept()
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
unique.SNOMEDconcept()
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
unique.SNOMEDconcept()
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
unique.SNOMEDconcept()
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
unique.SNOMEDconcept()
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
unique.SNOMEDconcept()
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
unique.SNOMEDconcept()
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
unique.SNOMEDconcept()
sys_acute <- SNOMEDconcept(c('Systolic heart failure', 'Acute heart failure'), SNOMED = sampleSNOMED()) acute_left_right <- SNOMEDconcept(c('Acute heart failure', 'Left heart failure', 'Right heart failure'), SNOMED = sampleSNOMED()) union(sys_acute, acute_left_right) intersect(sys_acute, acute_left_right) setdiff(sys_acute, acute_left_right)
sys_acute <- SNOMEDconcept(c('Systolic heart failure', 'Acute heart failure'), SNOMED = sampleSNOMED()) acute_left_right <- SNOMEDconcept(c('Acute heart failure', 'Left heart failure', 'Right heart failure'), SNOMED = sampleSNOMED()) union(sys_acute, acute_left_right) intersect(sys_acute, acute_left_right) setdiff(sys_acute, acute_left_right)
SNOMEDconcept is an S3 class for vectors of SNOMED concept IDs as 64-bit integers. This function returns a vector containing only unique SNOMEDconcept values.
## S3 method for class 'SNOMEDconcept' unique(x, ...)
## S3 method for class 'SNOMEDconcept' unique(x, ...)
x |
SNOMEDconcept vector |
... |
other variables to pass on to the underlying 'unique' function |
SNOMEDconcept vector with duplicates removed
Other SNOMEDconcept functions:
as.data.frame.SNOMEDconcept()
,
c.SNOMEDconcept()
,
is.SNOMEDconcept()
,
print.SNOMEDconcept()
,
union.SNOMEDconcept()
hf <- SNOMEDconcept('Heart failure', SNOMED = sampleSNOMED()) hf2 <- c(hf, hf) unique(hf2)
hf <- SNOMEDconcept('Heart failure', SNOMED = sampleSNOMED()) hf2 <- c(hf, hf) unique(hf2)