{
"cells": [
{
"cell_type": "markdown",
"id": "beb97ca4",
"metadata": {},
"source": [
"# Charlson & Elixhauser Comorbidity Scores Dataset"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "e3b8790c",
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [
{
"data": {
"text/markdown": [
">Last modified: 27 Oct 2025"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import sys\n",
"import os\n",
"sys.path.append(os.path.abspath('../../../scripts/'))\n",
"from data_doc_helper import UKLLCDataSet as DS, last_modified\n",
"API_KEY = os.environ['FASTAPI_KEY']\n",
"ds = DS(\"rtn_comorbidity_scores_mar19feb20\")\n",
"last_modified()"
]
},
{
"cell_type": "markdown",
"id": "5b3e81e6",
"metadata": {},
"source": [
"<div style=\"background-color: rgba(0, 178, 169, 0.3); padding: 5px; border-radius: 5px;\"><strong>UK LLC worked with researchers to derive comorbidity scores for a number of LPS using the NHS England HES Admitted Patient Care dataset.</strong></div> "
]
},
{
"cell_type": "markdown",
"id": "fe073008",
"metadata": {},
"source": [
"## 1. Summary"
]
},
{
"cell_type": "markdown",
"id": "c938a7b1",
"metadata": {},
"source": [
"The **Charlson & Elixhauser** dataset (UKLLC_rtn_comorbidity_scores_mar19feb20_v0001_20230420) contains comorbidity measures derived from the [NHS England Hospital Episode Statistics (HES) Admitted Patient Care (APC)](../../../linked_health_data/NHS_England/HES%20datasets/APC/HESAPC.ipynb) dataset for the period **1 March 2019 to 29 February 2020**. Participants from the following LPS are included in the dataset: ALSPAC, BCS70, BIB, ELSA, EPICN, EXCEED, FENLAND, GLAD, MCS, NCDS58, NEXTSTEP, NIHRBIO_COPING, NSHD46, TWINSUK and UKHLS. The comorbidity indices included are **Charlson** and **Elixhauser** scores, each in multiple variants based on published weighting schemes. These measures are widely used in health services research for risk adjustment, mortality prediction and burden of disease studies. All scores were calculated using the comorbidity R package. **Higher scores** indicate greater comorbidity burden; **unweighted scores** simply count the number of comorbidity categories present; and **weighted scores** apply coefficients to comorbidities to reflect their relative impact on mortality or other outcomes, as estimated in the cited publications."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "fb0becc7",
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [
{
"data": {
"text/html": [
"<style type=\"text/css\">\n",
"#T_ec5cf th {\n",
" text-align: left;\n",
"}\n",
"#T_ec5cf_row0_col0, #T_ec5cf_row0_col1, #T_ec5cf_row1_col0, #T_ec5cf_row1_col1, #T_ec5cf_row2_col0, #T_ec5cf_row2_col1, #T_ec5cf_row3_col0, #T_ec5cf_row3_col1, #T_ec5cf_row4_col0, #T_ec5cf_row4_col1, #T_ec5cf_row5_col0, #T_ec5cf_row5_col1, #T_ec5cf_row6_col0, #T_ec5cf_row6_col1, #T_ec5cf_row7_col0, #T_ec5cf_row7_col1, #T_ec5cf_row8_col0, #T_ec5cf_row8_col1, #T_ec5cf_row9_col0, #T_ec5cf_row9_col1, #T_ec5cf_row10_col0, #T_ec5cf_row10_col1, #T_ec5cf_row11_col0, #T_ec5cf_row11_col1 {\n",
" text-align: left;\n",
"}\n",
"</style>\n",
"<table id=\"T_ec5cf\" style=\"font-size: 14px\">\n",
" <thead>\n",
" <tr>\n",
" <th id=\"T_ec5cf_level0_col0\" class=\"col_heading level0 col0\" >Dataset Descriptor</th>\n",
" <th id=\"T_ec5cf_level0_col1\" class=\"col_heading level0 col1\" >Dataset-specific Information</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row0_col0\" class=\"data row0 col0\" >Name of Dataset in TRE</td>\n",
" <td id=\"T_ec5cf_row0_col1\" class=\"data row0 col1\" >UKLLC_rtn_comorbidity_scores_mar19feb20</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row1_col0\" class=\"data row1 col0\" >Citation (APA)</td>\n",
" <td id=\"T_ec5cf_row1_col1\" class=\"data row1 col1\" >UK Longitudinal Linkage Collaboration. (2023). <i>UK LLC Managed: Charlson & Elixhauser Comorbidity Scores Dataset.</i> UK Longitudinal Linkage Collaboration (UK LLC). <a href=\"https://doi.org/10.71760/ukllc-dataset-00438-01\" rel=\"noopener noreferrer\" target=\"_blank\">https://doi.org/10.71760/ukllc-dataset-00438-01</a></td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row2_col0\" class=\"data row2 col0\" >Download Citation</td>\n",
" <td id=\"T_ec5cf_row2_col1\" class=\"data row2 col1\" > <a href=\"https://api.datacite.org/application/vnd.citationstyles.csl+json/10.71760/ukllc-dataset-00438-01\" rel=\"noopener noreferrer\" target=\"_blank\">Citeproc JSON</a> <a href=\"https://api.datacite.org/application/x-bibtex/10.71760/ukllc-dataset-00438-01\" rel=\"noopener noreferrer\" target=\"_blank\">BibTeX</a> <a href=\"https://api.datacite.org/application/x-research-info-systems/10.71760/ukllc-dataset-00438-01\" rel=\"noopener noreferrer\" target=\"_blank\">RIS</a></td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row3_col0\" class=\"data row3 col0\" >Series</td>\n",
" <td id=\"T_ec5cf_row3_col1\" class=\"data row3 col1\" > <a href=\"https://guidebook.ukllc.ac.uk/docs/ukllc_managed_data/ukllc_data\">UK LLC Managed</a></td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row4_col0\" class=\"data row4 col0\" >Owner</td>\n",
" <td id=\"T_ec5cf_row4_col1\" class=\"data row4 col1\" >UK Longitudinal Linkage Collaboration</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row5_col0\" class=\"data row5 col0\" >Temporal Coverage</td>\n",
" <td id=\"T_ec5cf_row5_col1\" class=\"data row5 col1\" >03/2019 - 02/2020</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row6_col0\" class=\"data row6 col0\" >Keywords</td>\n",
" <td id=\"T_ec5cf_row6_col1\" class=\"data row6 col1\" >comorbidity charlson elixhauser health NHS</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row7_col0\" class=\"data row7 col0\" >Participant Count</td>\n",
" <td id=\"T_ec5cf_row7_col1\" class=\"data row7 col1\" >31820</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row8_col0\" class=\"data row8 col0\" >Number of variables</td>\n",
" <td id=\"T_ec5cf_row8_col1\" class=\"data row8 col1\" >8</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row9_col0\" class=\"data row9 col0\" >Number of observations</td>\n",
" <td id=\"T_ec5cf_row9_col1\" class=\"data row9 col1\" >31820</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row10_col0\" class=\"data row10 col0\" >Specific Restrictions to Data Use</td>\n",
" <td id=\"T_ec5cf_row10_col1\" class=\"data row10 col1\" >None</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_ec5cf_row11_col0\" class=\"data row11 col0\" >Build a Data Request</td>\n",
" <td id=\"T_ec5cf_row11_col1\" class=\"data row11 col1\" > <a href=\"https://explore.ukllc.ac.uk/\" rel=\"noopener noreferrer\" target=\"_blank\">https://explore.ukllc.ac.uk/</a></td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n"
],
"text/plain": [
"<pandas.io.formats.style.Styler at 0x1fe0a8fee40>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ds.info_table()"
]
},
{
"cell_type": "markdown",
"id": "799ad0f1",
"metadata": {},
"source": [
"## 2. Variables"
]
},
{
"cell_type": "markdown",
"id": "0382a49e",
"metadata": {},
"source": [
"| Variable name | Description | Weighting scheme / Source |\n",
"|---------------|-------------|----------------------------|\n",
"| `unw_cci` | Number of Charlson comorbidity categories present for each patient, without weighting. | Unweighted count |\n",
"| `char_cci` | Charlson score calculated using the original weights proposed by Charlson et al. (1987) | <a href=\"https://pubmed.ncbi.nlm.nih.gov/3558716/\" target=\"_blank\" rel=\"noopener noreferrer\">Charlson et al. 1987</a> |\n",
"| `quan_cci` | Charlson score calculated using the revised weights proposed by Quan et al. (2011)| <a href=\"https://pubmed.ncbi.nlm.nih.gov/21330339/\" target=\"_blank\" rel=\"noopener noreferrer\">Quan et al. 2011</a> |\n",
"| `unw_eci` | Number of Elixhauser comorbidity categories present for each patient, without weighting| Unweighted count |\n",
"| `vw_eci` | Elixhauser score calculated using the weights proposed by van Walraven et al. (2009)| <a href=\"https://pubmed.ncbi.nlm.nih.gov/19433995/\" target=\"_blank\" rel=\"noopener noreferrer\">van Walraven et al. 2009</a> |\n",
"| `swiss_eci` | Elixhauser score calculated using the Swiss hospital weights proposed by Sharma et al. (2021)| <a href=\"https://pubmed.ncbi.nlm.nih.gov/33407455/\" target=\"_blank\" rel=\"noopener noreferrer\">Sharma et al. 2021</a> |"
]
},
{
"cell_type": "markdown",
"id": "8a469c49",
"metadata": {},
"source": [
"## 3. Version History"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "41fd9910",
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [
{
"data": {
"text/html": [
"<style type=\"text/css\">\n",
"#T_e50aa th {\n",
" text-align: left;\n",
"}\n",
"#T_e50aa_row0_col0, #T_e50aa_row0_col1, #T_e50aa_row1_col0, #T_e50aa_row1_col1, #T_e50aa_row2_col0, #T_e50aa_row2_col1, #T_e50aa_row3_col0, #T_e50aa_row3_col1, #T_e50aa_row4_col0, #T_e50aa_row4_col1 {\n",
" text-align: left;\n",
"}\n",
"</style>\n",
"<table id=\"T_e50aa\" style=\"font-size: 14px\">\n",
" <thead>\n",
" <tr>\n",
" <th id=\"T_e50aa_level0_col0\" class=\"col_heading level0 col0\" >Version</th>\n",
" <th id=\"T_e50aa_level0_col1\" class=\"col_heading level0 col1\" >1</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td id=\"T_e50aa_row0_col0\" class=\"data row0 col0\" >Version Date</td>\n",
" <td id=\"T_e50aa_row0_col1\" class=\"data row0 col1\" >20 Apr 2023</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_e50aa_row1_col0\" class=\"data row1 col0\" >Number of Variables</td>\n",
" <td id=\"T_e50aa_row1_col1\" class=\"data row1 col1\" >8</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_e50aa_row2_col0\" class=\"data row2 col0\" >Number of Observations</td>\n",
" <td id=\"T_e50aa_row2_col1\" class=\"data row2 col1\" >31820</td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_e50aa_row3_col0\" class=\"data row3 col0\" >DOI</td>\n",
" <td id=\"T_e50aa_row3_col1\" class=\"data row3 col1\" > <a href=\"https://doi.org/10.71760/ukllc-dataset-00438-01\" rel=\"noopener noreferrer\" target=\"_blank\">10.71760/ukllc-dataset-00438-01</a></td>\n",
" </tr>\n",
" <tr>\n",
" <td id=\"T_e50aa_row4_col0\" class=\"data row4 col0\" >Change Log</td>\n",
" <td id=\"T_e50aa_row4_col1\" class=\"data row4 col1\" > <a href=\"https://api.datacite.org/dois/10.71760/ukllc-dataset-00438-01/activities\" rel=\"noopener noreferrer\" target=\"_blank\">10.71760/ukllc-dataset-00438-01/activities</a></td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n"
],
"text/plain": [
"<pandas.io.formats.style.Styler at 0x1fe0a95da90>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ds.version_history()"
]
},
{
"cell_type": "markdown",
"id": "bedf5551",
"metadata": {},
"source": [
"## 4. Useful Syntax"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "29e9d5bb",
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [
{
"data": {
"text/markdown": [
"Below we will include syntax that may be helpful to other researchers in the UK LLC TRE. For longer scripts, we will include a snippet of the code plus a link to Git where you can find the full scripts."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ds.useful_syntax()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "jupbook",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}