library(codemapper)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
all_lkps_maps_dummy <- build_all_lkps_maps_dummy()
Use map_codes()
to map a vector of codes from one clinical coding system to another:
map_codes(codes = "G20..",
from = "read2",
to = "icd10",
all_lkps_maps = all_lkps_maps_dummy)
#> # A tibble: 1 × 3
#> code description code_type
#> <chr> <chr> <chr>
#> 1 I10X Essential (primary) hypertension icd10
Alternatively, use get_mapping_df()
to return a mapping data frame:
get_mapping_df(from = "read3",
to = "icd10",
all_lkps_maps = all_lkps_maps_dummy)
#> # A tibble: 5 × 2
#> read3 icd10
#> <chr> <chr>
#> 1 X40J4 E109
#> 2 C10.. E149
#> 3 XaIP9 L721
#> 4 XE0e0 N390
#> 5 XE0Uc I10X
Mapping between different clinical coding systems is not perfect and should be manually reviewed. Some mapping tables list multiple possible code mappings, with a separate column indicating the type of mapping.1 For example, the Read 2 to Read 3 mapping table includes an ‘IS_ASSURED’ column, where ‘1’ and ‘0’ indicate that a code mapping is or is not assured respectively:
all_lkps_maps_dummy$read_v2_read_ctv3 %>%
dplyr::select(READV2_CODE,
READV3_CODE,
IS_ASSURED)
#> # A tibble: 26 × 3
#> READV2_CODE READV3_CODE IS_ASSURED
#> <chr> <chr> <chr>
#> 1 C106. XE10H 1
#> 2 C106. X00Ag 1
#> 3 C106. XE15k 1
#> 4 C106. Xa0lK 0
#> 5 C106. XaPmX 1
#> 6 C108. X40J4 1
#> 7 C108. X40J4 0
#> 8 C108. X40J4 1
#> 9 C108. X40J4 0
#> 10 C108. X40J4 1
#> # … with 16 more rows
Similarly, the Read 3 to ICD10 mapping table includes ‘mapping_status’ and ‘refine_flag’ columns:
all_lkps_maps_dummy$read_ctv3_icd10 %>%
dplyr::select(read_code:refine_flag)
#> # A tibble: 36 × 4
#> read_code icd10_code mapping_status refine_flag
#> <chr> <chr> <chr> <chr>
#> 1 X40J4 E109 D C
#> 2 X40J4 E10 A M
#> 3 X40J4 O240 R C
#> 4 C10.. E149 D C
#> 5 C10.. E14 A M
#> 6 C10.. E109 R C
#> 7 C10.. E119 R C
#> 8 C10.. E129 R C
#> 9 C10.. E139 R C
#> 10 C10.. O249 R C
#> # … with 26 more rows
It is important to decide which mappings to include. For example, if no filters are applied then the Read 3 code for sebaceous cyst ‘XaIP9’ will map to a number of ICD10 codes, some of which are sex-specific (‘N508’ and ‘N948’):
map_codes(codes = "XaIP9",
from = "read3",
to = "icd10",
all_lkps_maps = all_lkps_maps_dummy,
col_filters = NULL)
#> # A tibble: 5 × 3
#> code description code_type
#> <chr> <chr> <chr>
#> 1 H028 Other specified disorders of eyelid icd10
#> 2 L721 Trichilemmal cyst icd10
#> 3 N508 Other specified disorders of male genital organs icd10
#> 4 N608 Other benign mammary dysplasias icd10
#> 5 N948 Other specified conditions associated with female genital org… icd10
Default filters are applied by default_col_filters()
:
map_codes(codes = "XaIP9",
from = "read3",
to = "icd10",
all_lkps_maps = all_lkps_maps_dummy,
col_filters = default_col_filters())
#> # A tibble: 1 × 3
#> code description code_type
#> <chr> <chr> <chr>
#> 1 L721 Trichilemmal cyst icd10
See additional notes at https://rmgpanw.gitlab.io/codemapper_notes/.
Refer to the accompanying documentation for UKB resource 592 for further details.↩︎