Title: | Metadata Processing for the German Modification of the ICD-10 Coding System |
---|---|
Description: | Provides convenient access to the German modification of the International Classification of Diagnoses, 10th revision (ICD-10-GM). It provides functionality to aid in the identification, specification and historisation of ICD-10 codes. Its intended use is the analysis of routinely collected data in the context of epidemiology, medical research and health services research. The underlying metadata are released by the German Institute for Medical Documentation and Information <https://www.dimdi.de>, and are redistributed in accordance with their license. |
Authors: | Ewan Donnachie [aut, cre] |
Maintainer: | Ewan Donnachie <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.2.5 |
Built: | 2025-04-01 06:49:41 UTC |
Source: | https://github.com/edonnachie/icd10gm |
Specification of the Charlson comorbidity index in the version of the Royal College of Surgeons (2010).
charlson_rcs
charlson_rcs
An object of class spec_tbl_df
(inherits from tbl_df
, tbl
, data.frame
) with 124 rows and 2 columns.
The specification can be expanded using the icd_expand function to return all corresponding ICD-10-GM codes.
This table was created on the basis of the publication referenced below. It is provided as is with no guarantee of accuracy. Furthermore, the applicability of the codes in the context of the German ICD-10-GM is unclear.
Disease entity
Secification of the corresponding ICD-10 codes, suitable for input to icd_expand
Other Charlson:
charlson_sundararajan
Specification of the Charlson comorbidity index in the version of Sunhararahan et al. (2004).
charlson_sundararajan
charlson_sundararajan
An object of class spec_tbl_df
(inherits from tbl_df
, tbl
, data.frame
) with 17 rows and 3 columns.
The specification can be expanded using the icd_expand function to return all corresponding ICD-10-GM codes.
This table was created on the basis of the publication referenced below. It is provided as is with no guarantee of accuracy. Furthermore, the applicability of the codes in the context of the German ICD-10-GM is unclear.
Disease entity
Controbition of the disease entity towords the combined comorbidity index
Secification of the corresponding ICD-10 codes, suitable for input to icd_expand
doi:10.1016/j.jclinepi.2004.03.012
Other Charlson:
charlson_rcs
A utility function to query the icd_meta_transition table.
get_icd_history(years = NULL, icd3 = NULL)
get_icd_history(years = NULL, icd3 = NULL)
years |
Year or years to get (numeric or character vector) |
icd3 |
(optional) ICD codes to select (regular expression, matched exactly using grep) |
Returns a data frame with ICD transition history, consisting of year, ICD code and label. Optional arguments allow selection of entries by year or ICD code. This is beneficial because the entire history is relatively large and rarely required in full.
data.frame, see icd_hist
get_icd_history(years = 2009:2010, icd3 = "K52")
get_icd_history(years = 2009:2010, icd3 = "K52")
A utility function to get or query icd_meta_codes, returning a limited selection of ICD-10 codes and labels.
get_icd_labels(year = NULL, icd3 = NULL, search = NULL, ...)
get_icd_labels(year = NULL, icd3 = NULL, search = NULL, ...)
year |
Year or years to get (numeric or character vector) |
icd3 |
A character vector of three-digit ICD-10 codes to select |
search |
(optional) A string to search for in the label column using fuzzy matching (agrep) |
... |
(optional) Further arguments passed to agrep when searching with icd_label |
If an ICD code is provided as argument icd3
, all
corresponding codes and subcodes are returned. If a search
term is provided, all codes are returned whose label matches
the string approximately.
Returns a data frame with ICD metadata, consisting of year, ICD code and label. Optional arguments allow selection of entries by year, code or label. This is beneficial because the entire history is relatively large and rarely required in full.
data.frame(year, icd3, icd_code, icd_normcode, icd_sub, label), see icd_labels
get_icd_labels(year = 2019, icd3 = "I25") get_icd_labels(year = 2019, search = "Asthma")
get_icd_labels(year = 2019, icd3 = "I25") get_icd_labels(year = 2019, search = "Asthma")
Given a 3-digit ICD-10-GM code, this function will generate the URL of the
corresponding page of the BfArM ICD-10-GM browser, and use browseURL()
to
open it.
icd_browse(icd3, year = NULL, open_browser = TRUE)
icd_browse(icd3, year = NULL, open_browser = TRUE)
icd3 |
3-digit ICD-10-GM code (e.g. "A01") |
year |
ICD-10-GM version (default: most recent available version). Only works for year >= 2009. |
open_browser |
Whether to open the ICD-10-GM documentation in the default browser (Default: TRUE, as this is the primary intention of the function) |
This currently provides the correct URL for ICD-10-GM versions from 2009. Given that BfArM are still using the old dimdi.de domain for this purpose, it is possible that the URL schema will change in the near future.
This is a convenience function intended for interactive use.
Called for side-effect, but returns the URL invisibly
icd_search()
to search for a string in the ICD-10-GM labels
icd_lookup()
to lookup an ICD-10-GM code in the console
icd_browse("R50", open_browser = FALSE)
icd_browse("R50", open_browser = FALSE)
The function icd_expand
takes a data.frame containing ICD codes
and optional metadata as input. It returns a data.frame containing
all ICD codes at or below the specified level of the hierarchy
(e.g. the specification "E11" is expanded to include all three,
four and five-digit codes beginning with E11).
icd_expand( icd_in, year, col_icd = "ICD", col_meta = NULL, type = "strict", ignore_icd_errors = FALSE )
icd_expand( icd_in, year, col_icd = "ICD", col_meta = NULL, type = "strict", ignore_icd_errors = FALSE )
icd_in |
Data frame defining ICD codes of interest |
year |
ICD 10 version |
col_icd |
Column of icd_in containing ICD codes (Default: ICD) |
col_meta |
(Optional) Columns containing meta information to retain (e.g. Grouper, age or other criteria for later use). If left NULL, only col_icd is retained. |
type |
A character string determining how strictly matching should be performed, passed to |
ignore_icd_errors |
logical. Whether to ignore incorrectly specified input (potentially leading to incomplete output) or stop if any ICD specification does not correspond to a valid ICD code. Default: |
data.frame with columns YEAR, ICD_CODE, ICD_COMPRESSED, ICD_LABEL and, if specified, columns specified by col_meta
icd_history()
to historize the output
# Incomplete or non-terminal codes expand to the right. # This is useful to specified code blocks in a compact manner icd_meta <- data.frame(ICD = "R1") icd_expand(icd_meta, year = 2019) # Optional metadata columns can be carried # through with the specification icd_meta <- data.frame(ICD = "M54", icd_label = "Back pain") icd_expand(icd_meta, year = 2019, col_meta = "icd_label")
# Incomplete or non-terminal codes expand to the right. # This is useful to specified code blocks in a compact manner icd_meta <- data.frame(ICD = "R1") icd_expand(icd_meta, year = 2019) # Optional metadata columns can be carried # through with the specification icd_meta <- data.frame(ICD = "M54", icd_label = "Back pain") icd_expand(icd_meta, year = 2019, col_meta = "icd_label")
The function icd_history
takes the result of icd_expand
,
specified for a particular year, and returns a data.frame
containing all corresponding codes for the specified years
(from 2003). To do this, it applies the ICD-10-GM transition
tables to map codes between successive ICD-10-GM versions.
Only automatic transitions are followed.
icd_history(icd_expand, years, custom_transitions = NULL)
icd_history(icd_expand, years, custom_transitions = NULL)
icd_expand |
A data.frame (e.g. as generated by the function icd_expand) |
years |
Years to historize (e.g. 2005:2014) |
custom_transitions |
(Optional) A data.frame containing custom transitions to complement the official transitions provided by |
data.frame with columns YEAR, ICD_CODE, ICD_COMPRESSED, ICD_LABEL and, if specified, DIAG_GROUP
#' @seealso icd_expand()
to generate the necessary input
# Between 2018 and 2019, causalgia (G56.4) was reclassified # under G90 as a complex regional pain syndrome icd_meta <- data.frame(ICD = "G56.4", ICD_LABEL = "Causalgia") icd_meta_expanded <- icd_expand(icd_meta, year = 2018, col_meta = "ICD_LABEL") icd_history(icd_meta_expanded, years = 2018:2019)
# Between 2018 and 2019, causalgia (G56.4) was reclassified # under G90 as a complex regional pain syndrome icd_meta <- data.frame(ICD = "G56.4", ICD_LABEL = "Causalgia") icd_meta_expanded <- icd_expand(icd_meta, year = 2018, col_meta = "ICD_LABEL") icd_history(icd_meta_expanded, years = 2018:2019)
This is a convenience function to quickly look up the label associated with one or more ICD-10 codes. By default, it performs the lookup using the most recent version of the ICD-10-GM available.
icd_lookup(icd, year = NULL, expand = TRUE)
icd_lookup(icd, year = NULL, expand = TRUE)
icd |
ICD code to look up (any format that can be recognised by |
year |
ICD-10-GM version to use (Default: most recent year available) |
expand |
Should all subcodes of the given code be returned? (Default: TRUE) |
This is a convenience function intended for interactive use. The browser will only be opened if R is being used interactively. The function always returns invisibly the URL of the page to be opened.
A tibble with three columns: (year, icd_sub, label) and one row for each result
icd_search()
to search for a string in the ICD-10-GM labels
icd_browse()
to lookup an ICD-10-GM code in the official BfArM documentation, opening the page in a browser
icd_lookup("E10.9")
icd_lookup("E10.9")
The ICD blocks (German: "Gruppen") constitute a level in the hierarchy between the chapters and the three-digit codes. The three-digit code are grouped in sequence to form 240 groups that represent similar aetiological diagnoses. Unlike some other grouper systems, the ICD blocks do not consider similar diagnoses from different chapters of the ICD classification, for example chronic pain coded as a unspecific symptom (R52.1) and as a somatoform disorder (F45.4).
icd_meta_blocks
icd_meta_blocks
An object of class data.frame
with 4813 rows and 6 columns.
Year of validity (from 2004)
First three-digit ICD code in the block
Last three-digit ICD code in the block
ICD-10 chapter to which the block belongs
Label for the block
Short label for the block in format "A00-A09"
The source data was downloaded from the official download centre of the German Institute for Medical Documentation and Information (DIMDI). See also https://www.dimdi.de/dynamic/en/classifications/icd/icd-10-gm/tabular-list/structure/
Other ICD-10-GM metadata:
icd_meta_chapters
,
icd_meta_codes
,
icd_meta_transition
The ICD chapters group codes according to their aetiology.
icd_meta_chapters
icd_meta_chapters
An object of class data.frame
with 440 rows and 4 columns.
Year of validity (from 2004)
Chapter number (arabic numerals)
Chapter number (Roman numerals)
Label for the chapter
The source data was downloaded from the official download centre of the German Institute for Medical Documentation and Information (DIMDI). See also https://www.dimdi.de/dynamic/en/classifications/icd/icd-10-gm/tabular-list/structure/
Other ICD-10-GM metadata:
icd_meta_blocks
,
icd_meta_codes
,
icd_meta_transition
DIMDI provide a CSV file with metadata on all valid codes. This table is read in with only minor modifications to facilitate changes between versions.
icd_meta_codes
icd_meta_codes
A data.frame containing the following variables:
Year of validity (from 2004)
Level of the hierarchy (3, 4 or 5 digits)
Whether the code is a terminal code (i.e. with no further subcodes) (T: yes; N: no)
Whether the subcode is pre- or postcombinated (X: precombinated; S: postcombinated). Precombinated codes are listed directly under the three-digit ICD code, whereas postcombinated codes are lists of possible values for the fourth and fifth digits that are not specific to the particular code (e.g. the group E10-E14 shares a common list of postcombinated fourth and fifth digits)
Chapter number (arabic digits 1-22)
First code in the respective ICD block, can be used to join with the table ICD10gm::icd_meta_blocks
Full icd code (up to 7 characters) with all symbols except the "dagger" (for aetiological codes that can be combined with an "asterisk" code to denote the manifestation)
The ICD "normcode", consisting of up to 6 characters and without all symbols except the period (e.g. E11.30)
Complete ICD code without any symbols or punctuation, consisting of up to 5 characters (e.g. E1130)
ICD label for the complete code.
ICD label for the three-digit ICD code.
ICD label for fourth digit of the ICD code.
ICD label for the fifth digit of the ICD code.
Usage of the code in the ambulatory sector (Paragraph 295 SGB V) (P: primary code; O: only as a "star" code in conjunction with a "dagger" code for aetiology; Z: only an optional "!" code in conjunction with a primary code; V: not to be used for coding)
Usage of the code in the stationary (hospital) sector (Paragraph 301 SGB V) (P: primary code; O: only as a "star" code in conjunction with a "dagger" code for aetiology; Z: only an optional "!" code in conjunction with a primary code; V: not to be used for coding)
Key to join with the WHO mortality list 1
Key to join with the WHO mortality list 2
Key to join with the WHO mortality list 3
Key to join with the WHO mortality list 4
Key to join with the WHO morbidity list
Whether the diagnosis is gender specific (M: male; W: female; 9: Not gender specific)
Type of error implied by the field gender_specific
(9: irrelevant; K: possible error)
Minimum age for which the diagnosis is plausible (T001: from one day; Y005: from five years)
Maximum age for which the diagnosis is plausible (T010: up to 10 days; Y005: up to five years)
Type of error resulting from implausible age (9: irrelevant; M: always an error ("Muss-Fehler"); K: possible error ("Kann-Fehler"))
Indicates whether the diagnosis is rare in Central Europe (J: yes; N: no)
Indicates whether the code has content associated with it (J: yes; N: no, leads to an error)
Indicates whether the diagnosis is notifiable in Germany (J: yes; N: no)
Indicates whether the diagnosis is notifiable for laboratories in Germany (J: yes; N: no)
This metadata is not suitable for operative coding and does not include all relevant information concerning the codes. For example, the file contains neither the inclusion and exclusion notes nor the detailed definitions (where present, mainly in Chapter V). DIMDI provide additional reference material for operative coding and detailed research.
The block U00-U49 contains reserved codes that can be allocated quickly for the documentation of new diseases or epidemiological phenomena. Such usage is allowed only when mandated by DIMDI. In particular, the codes may not be utilised on the initiative of other parties, for example, for clinical trials or contractual purposes. Notable uses of the reserved codes are for the Zika and COVID-19 viruses. These are included in the DIMDI online documentation, but not in the download files. They are therefore added manually to this data set as documented in the package source.
Die Schlüsselnummern U05.0-U05.9 dieser Kategorie sollen ein schnelles Reagieren auf aktuelle epidemiologische Phänomene ermöglichen. Sie dürfen nur zusätzlich benutzt werden, um einen anderenorts klassifizierten Zustand besonders zu kennzeichnen. Die Schlüsselnummern dieser Kategorie dürfen nur über das Deutsche Institut für Medizinische Dokumentation und Information (DIMDI) mit Inhalten belegt werden; eine Anwendung für andere Zwecke ist nicht erlaubt. DIMDI wird den Anwendungszeitraum solcher Schlüsselnummern bei Bedarf bekannt geben.
The source data was downloaded from the official download centre of the German Institute for Medical Documentation and Information (DIMDI). See also https://www.dimdi.de/dynamic/en/classifications/icd/icd-10-gm/tabular-list/#metadata
Other ICD-10-GM metadata:
icd_meta_blocks
,
icd_meta_chapters
,
icd_meta_transition
A data.frame providing old and new ICD codes (identical if no changes) and information as to whether the transition is automatic when transitioning forwards or backwards
icd_meta_transition
icd_meta_transition
An object of class data.frame
with 257310 rows and 12 columns.
Year of validity of the old code (from 2004)
Year of validity of the new code (from 2005)
Old ICD code
New ICD code
Whether the transition is automatic in the forward direction (i.e. the old code can always be converted to the new code). (A: automatic, otherwise NA)
Whether the transition is automatic in the forward direction (i.e. the new code can always be converted to the old code) (A: automatic, otherwise NA)
Whether the change relates to the fifth digit of the ICD-10 code (TRUE/FALSE).
Whether the change relates to the fourth digit of the ICD-10 code (TRUE/FALSE).
Whether the change relates to the three-digit ICD-10 code (TRUE/FALSE).
The first three digits of icd_from
.
The first character of icd_from
(i.e. the letter denoting the chapter).
The source data was downloaded from the official download centre of the German Institute for Medical Documentation and Information (DIMDI). See also https://www.dimdi.de/dynamic/en/classifications/icd/icd-10-gm/tabular-list/#crosswalks
Other ICD-10-GM metadata:
icd_meta_blocks
,
icd_meta_chapters
,
icd_meta_codes
An ICD code consists of, at a minimum, a three digit ICD-10 code (i.e. one upper-case letter followed by two digits). This may optionally be followed by a two digit subcode, selected punctuation symbols (cross "*", dagger "U2020" or exclamation mark "!"). Both the period separating the three-digit code from the subcode, and the hyphen indicating an "incomplete" subcode, are optional. Finally, in the ambulatory system, an additional letter G, V, Z or A may be appended to signify the status ("security") of the diagnosis.
icd_parse(str, type = "bounded", bind_rows = TRUE)
icd_parse(str, type = "bounded", bind_rows = TRUE)
str |
Character vector from which to extract all ICD codes |
type |
A character string determining how strictly matching should be performed. This must be one of "strict" ( |
bind_rows |
logical. Whether to convert the matrix output of |
By default, the function returns a data.frame
containing the matched codes and the standardised
three digit code (icd3
), subcode (icd_subcode
),
normcode (icd_norm
) and code without period (icd_sub
).
If bind_rows = FALSE
, the list output of
stringi::stri_match_all_regex
is returned.
This is particularly useful to retrieve the
matches from each element of the str
vector
separately.
data.frame (if bind_rows = TRUE) or matrix
icd_parse("E11.7") icd_parse("Depression: F32") icd_parse(c( "Backpain (M54.9) is one of the most common diagnoses in primary care", "Codes for chronic pain include R52.1 and F45.4" ))
icd_parse("E11.7") icd_parse("Depression: F32") icd_parse(c( "Backpain (M54.9) is one of the most common diagnoses in primary care", "Codes for chronic pain include R52.1 and F45.4" ))
Search ICD-10-GM labels for a string
icd_search(pattern, level = 5, year = NULL, ignore.case = TRUE, ...)
icd_search(pattern, level = 5, year = NULL, ignore.case = TRUE, ...)
pattern |
String to search for (character object of length 1) |
level |
Maximum level of the ICD-10 hierarchy to search. level = 3 will search ohne 3-digit codes, level = 4 all 3 and 4 digit codes, level = 5 will search through all codes. |
year |
Year in which to search (Default: most recent year available) |
ignore.case |
Should the search be case insensitive? (Default: TRUE) |
... |
Further parameters passed to |
Usually called for side-effect (open browser), returns the corresponding URL invisibly.
icd_browse()
to lookup an ICD-10-GM code in the official BfArM documentation, opening the page in a browser
icd_lookup()
to lookup an ICD-10-GM code in the console
icd_search("vitamin", level = 3) icd_search("vitamin", level = 5)
icd_search("vitamin", level = 3) icd_search("vitamin", level = 5)
Show all changes in ICD history relating to the 3-digit codes contained in the data.frame icd_in. The output of icd_expand can be passed directly to this function to display relevant changes.
icd_showchanges(icd_in, years = NULL)
icd_showchanges(icd_in, years = NULL)
icd_in |
Data frame created by |
years |
Years to check, corresponding to the variable |
data.frame, as icd_meta_transition
, with labels icd_from_label and icd_to_label
icd_showchanges_icd3()
to provide one or more three-digit codes as input
dat_icd <- icd_expand( data.frame(ICD_SPEC = c("K52.9")), col_icd = "ICD_SPEC", year = 2019) icd_showchanges(dat_icd)
dat_icd <- icd_expand( data.frame(ICD_SPEC = c("K52.9")), col_icd = "ICD_SPEC", year = 2019) icd_showchanges(dat_icd)
Show all changes in ICD history relating to the 3-digit codes contained in a given vector icd
icd_showchanges_icd3(icd3)
icd_showchanges_icd3(icd3)
icd3 |
Vector of three-digit ICD codes |
data.frame with columns YEAR, ICD_CODE, ICD_LABEL and, if specified, DIAG_GROUP
icd_showchanges()
if the input has been generated by icd_expand()
icd_showchanges_icd3("A09")
icd_showchanges_icd3("A09")
An ICD code consists of, at a minimum, a three digit ICD-10 code (i.e. one upper-case letter followed by two digits). This may optionally be followed by a two digit subcode, selected punctuation symbols (cross "*", dagger "U2020" or exclamation mark "!"). Both the period separating the three-digit code from the subcode, and the hyphen indicating an "incomplete" subcode, are optional. Finally, in the ambulatory system, an additional letter G, V, Z or A may be appended to signify the status ("security") of the diagnosis.
is_icd_code(str, year = NULL, parse = TRUE)
is_icd_code(str, year = NULL, parse = TRUE)
str |
Character vector to be tested |
year |
Year for which to test whether the specification is a valid code. Default: NULL (test whether |
parse |
logical. Whether to first parse the input |
Logical vector the same length as the character input
is_icd_code("A09.9") is_icd_code("A099") is_icd_code("A09.9-") is_icd_code("AA9") # The following code is syntactically correct but # has never been in use is_icd_code("E15.9")
is_icd_code("A09.9") is_icd_code("A099") is_icd_code("A09.9-") is_icd_code("AA9") # The following code is syntactically correct but # has never been in use is_icd_code("E15.9")