Comorbidity and frailty score calculation utilities (Charlson, Elixhauser, Gagne, HFRS) using polars
Project description
pycomorb
Python package to calculate comorbidity and frailty scores using ICD codes and polars DataFrames.
Overview
pycomorb provides fast, flexible, and reproducible calculation of clinical risk scores from ICD-coded data. It supports multiple comorbidity and frailty indices, including several international variants.
It is inspired by the R package comorbidity by Alessandro Gasparini and the corresponding Python rewrite comorbidipy by Vishnu V Chandrabalan.
As a special feature, it also implements the history of the German Modification of the ICD-10 (ICD-10-GM) coding system, allowing users to apply the correct mappings and weights based on the year of diagnosis.
Included Indices / Scores
- Charlson Comorbidity Index (multiple mappings and weights)
- Elixhauser Comorbidity Index (multiple mappings and weights)
- Combined Comorbidity Score (Gagne et al.)
- Hospital Frailty Risk Score (HFRS)
Supported Variants
See common/README.md for more details and references.
Charlson Comorbidity Index
- Mappings:
- Quan et al. 2005 (Quan 2005)
- Deyo et al. 1992 (Deyo 1992)
- Romano et al. 1993 (Romano 1993)
- Australia (Sundararajan et al. 2004, ICD-10-AM) (Sundararajan 2004)
- Sweden (Ludvigsson et al. 2021, ICD-10) (Ludvigsson 2021)
- UK SHMI (NHS Digital, v1.55)
- Weights:
- Charlson et al. 1987 (Charlson 1987)
- Quan et al. 2011 (Quan 2011)
- SHMI (NHS Digital, v1.55)
- Modified SHMI (NHS Digital, v1.55)
Elixhauser Comorbidity Index
- Mappings:
- Quan et al. 2005 (Quan 2005)
- Original Elixhauser et al. 1998 (ICD-9) (Elixhauser 1998)
- Weights:
- van Walraven et al. 2009 (van Walraven 2009)
- Thompson et al. 2015 (Thompson 2015)
- AHRQ (Moore et al. 2017, AHRQ Comorbidity Software)
Combined Comorbidity Score
- Gagne et al. 2011 (Gagne 2011), with ICD-9 and ICD-10 support (Sun 2017)
Hospital Frailty Risk Score
- Gilbert et al. 2018, ICD-10 (Gilbert 2018)
Installation
You can install pycomorb via pip:
pip install pycomorb
Usage
import polars as pl
from pycomorb import comorbidity
# Example: Calculate Charlson score
df = pl.DataFrame({
"id": [1, 2, 3],
"code": ["I21", "E119", "C349"],
"age": [65, 72, 80]
})
charlson = comorbidity(
score="charlson",
df=df,
id_col="id",
code_col="code",
age_col="age",
icd_version="icd10",
implementation="quan",
return_categories=True
)
See the docstrings in each module for details on arguments and supported variants.
License and Documentation
- Free software: MIT license
- Documentation: (TODO)
- Die Erstellung erfolgt unter Verwendung der maschinenlesbaren Fassung des Bundesinstituts für Arzneimittel und Medizinprodukte (BfArM).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycomorb-0.6.tar.gz.
File metadata
- Download URL: pycomorb-0.6.tar.gz
- Upload date:
- Size: 103.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c619131f8ef0fb36d3410236c5747bc43ef391a98678438d66eebe61850abbb0
|
|
| MD5 |
63a81d3a5ba7916abea80524b9712aae
|
|
| BLAKE2b-256 |
e6633a31be3b023fe093a029e719067831b96bf8b5a36b8a8f7180347f310639
|
File details
Details for the file pycomorb-0.6-py3-none-any.whl.
File metadata
- Download URL: pycomorb-0.6-py3-none-any.whl
- Upload date:
- Size: 114.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9ca9306d17e6f42b5b84e97ef161bcaecdc059564928d94eaa75fc83f2fd60a
|
|
| MD5 |
adf57d44f44b491e82792eedf3a00090
|
|
| BLAKE2b-256 |
aa27924ad8ed950559d7cd390a6c07c7be58f65a032c933d9e6be60d4b350e97
|