Calculate comorbidities, medical risk scores, and work very quickly and precisely with ICD-9 and ICD-10 codes. This package enables a work flow from raw tables of ICD codes in hospital databases to comorbidities. ICD-9 and ICD-10 comorbidity mappings from Quan (Deyo and Elixhauser versions), Elixhauser and AHRQ included. Common ambiguities and code formats are handled. Comorbidity computation includes Hierarchical Condition Codes, and an implementation of AHRQ Clinical Classifications. Risk scores include those of Charlson and van Walraven. US Clinical Modification, Word Health Organization, Belgian and French ICD-10 codes are supported, most of which are downloaded on demand.
comorbidities for a set of patients with one or more ICD codes each. All
the comorbidity functions guess which columns are the identifiers and which
are ICD code fields. You may also specify these. Most 'long' or 'wide' data
can simply be passed directly, e.g.:
The AHRQ comorbidity mappings from ICD-9 and ICD-10 are provided as
icd10_map_ahrq. The easiest
way to use them is by calling the function
directly with your
icd_long_data format patient data.
Quan revised both Deyo/Charlson and Elixhauser ICD-9 and ICD-10 to
comorbidity mappings. These are presented as:
Like the AHRQ mappings, these are all carefully extracted from the original
publications or source code. These mappings can be used on patient data by
There is no canonical Charlson ICD-9 or ICD-10 mapping, so
comorbid_charlson uses the thoroughly researched and widely
comorbid_quan_deyo method by default.
The original Elixhauser mappings are provided by the lists
Elixhauser comorbidities can be calculated directly from patient data using
The US Center for Medicare and Medicare services (CMS) publishes
Hierarchical Condition Codes (HCC) which are essentially comorbidity maps
with very many comorbidities, complicated by a single- or multi-level
system. These categories can be computed using
AHRQ also publishes Clinical Classification Software (CCS) which
provides another set of disease groups, and this SAS code is implemented in
charlson calculates Charlson scores (Charlson Comorbidity
Indices) directly from your patient data. If you already calculated the
Charlson comorbidities, it is more efficient to use
calculates Van Walraven scores (based on the Elixhauser comorbidities,
instead of Charlson), and
van_walraven_from_comorbid if you
already calculated Elixhauser comorbidities
is_valid checks whether ICD codes are syntactically valid
(although not necessarily genuine ICD diagnoses). In contrast,
is_defined checks whether ICD-9 codes correspond to defined
diagnoses or diagnostic groups in the hierarchy of ICD codes.
is_leaf (and for the US,
whether given codes are leaves in the hierarchy, or not. icd may need
to download data due to package size or copyright restrictions on
redistributing data, and needs a cache directory and your permission to do
set_icd_data_dir to do this, e.g.,
set_icd_data_dir() for a default location in a suitable place for
your OS, e.g.
~/.local/icd/icd-ver-num on Linux. Use
download_all_icd_data to download everything at once, which
will take a few minutes on a broadband connection.
Validation depends on the class of code, and is different if the code is
from France, Belgium, the USA, or the World Health Organization (WHO). Use
as.icd10cm to set the class of
a set of ICD codes. This doesn't affect comorbidity calculations, but will
change the result of the above validation functions, and
There are many functions to convert ICD-9 codes or their components between
different formats and structures. The most commonly used are:
short_to_decimal to convert,
e.g., 002.3 to 0023 and back again. See convert for other options.
Conversion between ICD-9, ICD-10, and ICD-11 codes is not yet supported,
but is the subject of an upcoming US National Institutes of Health (NIH)
You can find children of a higher-level ICD-9 code with
children and find a common parent to a set of children (or
arbitrary list of ICD-9 codes) with
etc.) sorts in hierarchical, then numerical order, so '100.0' comes before
'100.00', for example.
The comorbidity functions in icd accept 'wide' or 'long' format data,
but you may wish to use
long_to_wide, which convert between these two most common
data structures containing patient disease data. This is more sophisticated
and tailored to the problem than base reshaping or packages like
dplyr, although these could no doubt be used.
These functions use base R functions to avoid dependencies, so are not very fast for very big datasets.
explain_code to convert a set of ICD codes into
human-readable descriptions. See above for discussion on WHO, French,
Belgian and US ICD code classes. This function can can also reduce the
codes to their top-level groups if all the child members of a group are
diff_comorbid allows summary of the differences
between comorbidity mappings, e.g. between revisions by different authors.
Jack O. Wasey firstname.lastname@example.org
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.