Skip to contents

Returns a lazy dplyr::tbl() containing the relationship table with standardised column names (from, to, type, code_type) plus all additional columns from the underlying database table. Call dplyr::collect() to materialise the result.

Usage

get_relationship_table(
  type,
  relationship_version = "latest",
  col_filters = "default",
  con = NULL,
  call = rlang::caller_env()
)

Arguments

type

The code type for which to retrieve relationships.

relationship_version

The version to retrieve. Defaults to "latest".

col_filters

Column filters to apply. See CODES() for details.

con

Optional DBI connection. If NULL (default), uses the workbench connection.

call

The calling environment. Passed to codeminer_abort.

Value

A lazy dplyr::tbl() with standardised columns (from, to, type, code_type) plus all other columns from the underlying table.

Details

This is useful for inspecting the raw relationship data used by CHILDREN(), PARENTS(), and other graph traversal functions.

See also

CHILDREN(), PARENTS() for graph traversal, get_codeminer_metadata() for discovering available tables.

Other Clinical code lookups and mappings: CODES(), MAP(), get_lookup_table(), get_mapping_table()

Examples

create_dummy_database()
#>  Dummy database ready to use!
#>  To reconnect to your previous database:
#>   `Sys.setenv(CODEMINER_DB_PATH = "/tmp/RtmpXyzdMY/file19d46734cc5f.duckdb")`
#>   `codeminer_connect()`

# Get the full ICD-10 relationship table
get_relationship_table("ICD-10") |> dplyr::collect()
#>  Using 'UKB v4' as latest version
#> # A tibble: 140 × 4
#>    from  to    type  code_type
#>    <chr> <chr> <chr> <chr>    
#>  1 A000  A00   is a  ICD-10   
#>  2 A001  A00   is a  ICD-10   
#>  3 A009  A00   is a  ICD-10   
#>  4 A020  A02   is a  ICD-10   
#>  5 A021  A02   is a  ICD-10   
#>  6 A022  A02   is a  ICD-10   
#>  7 A028  A02   is a  ICD-10   
#>  8 A029  A02   is a  ICD-10   
#>  9 A170  A17   is a  ICD-10   
#> 10 A171  A17   is a  ICD-10   
#> # ℹ 130 more rows