Add SNOMED CT UK Monolith tables to CodeMiner database
Source:R/add_snomed_ct_uk_monolith.R
add_snomed_ct_uk_monolith.RdReads SNOMED CT UK Monolith Edition RF2 files and adds these
tables to the active codeminer database. This is a convenience wrapper
around read_snomed_ct_uk_monolith() that automatically calls
add_lookup_table(), add_mapping_table(), and add_relationship_table()
for each table.
The function processes lookup tables, mapping tables, and relationship tables from the SNOMED CT release and adds them to the database with their associated metadata.
Usage
add_snomed_ct_uk_monolith(
path = get_snomed_ct_uk_monolith(),
tables = c("sct_lookup", "sct_relationship", "sct_icd10", "sct_opcs4"),
version = NULL,
source = "https://isd.digital.nhs.uk/trud/",
.icd10_refset_id = "999002271000000101",
.opcs4_refset_id = "999002321000000109"
)Arguments
- path
Path to the SNOMED CT UK Monolith Edition. This can be either:
A zip file (e.g., from
get_snomed_ct_uk_monolith())An unzipped directory containing the subdirectories
Snapshot/TerminologyandSnapshot/Refset
Default uses
get_snomed_ct_uk_monolith()to download the latest release.- tables
Character vector of table names to read and add. Available tables:
Lookup table:
"sct_lookup"Relationship table:
"sct_relationship"Mapping tables:
"sct_icd10","sct_opcs4"
By default, adds all tables.
- version
Character string specifying the version label for the SNOMED CT release. If not provided, it will be derived from the zip filename or folder name.
- source
Character string specifying the source URL or description. Defaults to the NHS TRUD website.
- .icd10_refset_id
Character string. The SNOMED CT Concept ID identifying the specific Reference Set (Refset) used for ICD-10 mappings. Defaults to
"999002271000000101". This is an advanced parameter.- .opcs4_refset_id
Character string. The SNOMED CT Concept ID identifying the specific Reference Set (Refset) used for OPCS-4 mappings. Defaults to
"999002321000000109". This is an advanced parameter.
Value
Invisibly returns the result from read_snomed_ct_uk_monolith() (a
named list of tables with metadata).
Details
The function performs the following steps:
Calls
read_snomed_ct_uk_monolith()to read the specified tablesIterates through each table and table type (lookup/mapping/relationship)
Adds each table to the database using the appropriate
add_*functionReturns the parsed data invisibly
This function requires an active database connection set up via
build_database() or similar.
See also
read_snomed_ct_uk_monolith()for reading without adding to databaseadd_lookup_table(),add_mapping_table(),add_relationship_table()get_snomed_ct_uk_monolith()for downloading from NHS TRUD
Examples
if (FALSE) { # \dontrun{
# Set up database connection
build_database(db_path = "my_codes.db")
# Download latest release and add all tables
add_snomed_ct_uk_monolith()
# Add specific tables only
add_snomed_ct_uk_monolith(
tables = c("sct_lookup", "sct_icd10")
)
# Use local zip file
snomed_zip <- "~/data/uk_sct2mo_41.3.0_20251217000001Z.zip"
add_snomed_ct_uk_monolith(path = snomed_zip)
# Use already-extracted directory
add_snomed_ct_uk_monolith(
path = "~/data/SnomedCT_MonolithRF2_PRODUCTION_20251217T120000Z"
)
} # }
# Example with dummy data (for testing/demonstration)
if (FALSE) { # \dontrun{
build_database(db_path = tempfile(fileext = ".db"))
add_snomed_ct_uk_monolith(
path = dummy_snomed_ct_uk_monolith_path()
)
} # }