The lookup sheet in
UKB resource 592
for ICD-10 ("icd10_lkp") has a column called ALT_CODE
, which is an
alternative format for ICD-10 codes. This is the format used in the mapping
sheets for this resource, as well as in
Field ID 41270.
Note however that in contrast to the ICD10 lookup and mapping sheets,
undivided 3 character codes do not have an 'X' appended in the UK Biobank
dataset. This function converts from one format to the other, with the
option to strip the final 'X' from undivided 3 character codes if converting
to ALT_CODE
format.
reformat_icd10_codes(
icd10_codes,
all_lkps_maps = NULL,
input_icd10_format = "ICD10_CODE",
output_icd10_format = "ALT_CODE",
unrecognised_codes = "error",
strip_x = FALSE
)
character vector of ICD-10 codes
Either a named list of lookup and mapping tables (either
data frames or tbl_dbi
objects), or the path to a SQLite database
containing these tables (see also build_all_lkps_maps()
and
all_lkps_maps_to_db()
). If NULL
, will attempt to connect to an SQLite
database named 'all_lkps_maps.db' in the current working directory, or to a
a SQLite database specified by an environmental variable named
'ALL_LKPS_MAPS_DB' (see
here
for how to set environment variables using a .Renviron
file). The latter
method will be used in preference.
character. Must be either "ICD10_CODE" or "ALT_CODE".
character. Must be either "ICD10_CODE" or "ALT_CODE".
Either 'error' (default) or 'warning'. If any input
codes
are unrecognised, then either an error or warning will be raised.
If TRUE
and converting to ALT_CODE
format, 'X' is removed
from the end of undivided 3 character codes (default is FALSE
).
character vector of ICD-10 codes, reformatted as specified by
output_icd10_format
.
Other Clinical code lookups and mappings:
codes_starting_with()
,
default_col_filters()
,
get_mapping_df()
,
lookup_codes()
,
map_codes()
# build dummy all_lkps_maps
all_lkps_maps_dummy <- build_all_lkps_maps_dummy()
# reformat from ICD10_CODE to ALT_CODE
reformat_icd10_codes(
icd10_codes = c("E10.9"),
all_lkps_maps = all_lkps_maps_dummy,
input_icd10_format = "ICD10_CODE",
output_icd10_format = "ALT_CODE"
)
#> [1] "E109"
# reformat from ALT_CODE to ICD10_CODE
reformat_icd10_codes(
icd10_codes = c("E109"),
all_lkps_maps = all_lkps_maps_dummy,
input_icd10_format = "ALT_CODE",
output_icd10_format = "ICD10_CODE"
)
#> [1] "E10.9"