Skip to main content

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

Categories are: Myocardial infarction, Congestive heart failure, Peripheral vascular disease, Cerebrovascular disease, Dementia, Chronic pulmonary disease, Rheumatic disease, Peptic ulcer disease, Mild liver disease, Diabetes without chronic complication, Diabetes with chronic complication, Hemiplegia or paraplegia, Renal disease, Any malignancy, including lymphoma and leukemia, except malignant neoplasm of skin, Moderate or severe liver disease, Metastatic solid tumor, AIDS/HIV.

Elixhauser Comorbidity Index

Categories are: Congestive heart failure, Cardiac arrhythmias, Valvular disease, Pulmonary circulation disorders, Peripheral vascular disorders, Hypertension uncomplicated, Hypertension complicated, Paralysis, Other neurological disorders, Chronic pulmonary disease, Diabetes uncomplicated, Diabetes complicated, Hypothyroidism, Renal failure, Liver disease, Peptic ulcer disease excluding bleeding, AIDS/HIV, Lymphoma, Metastatic cancer, Solid tumor without metastasis, Rheumatoid arthritis/collagen vascular diseases, Coagulopathy, Obesity, Weight loss, Fluid and electrolyte disorders, Blood loss anemia, Deficiency anemia, Alcohol abuse, Drug abuse, Psychoses, Depression.

Combined Comorbidity Score

Categories are: Alcohol abuse, Any tumor, Cardiac arrhythmias, Chronic pulmonary disease, Coagulopathy, Complicated diabetes, Congestive heart failure, Deficiency anemia, Dementia, Fluid and electrolyte disorders, Hemiplegia, HIV/AIDS, Hypertension, Liver disease, Metastatic cancer, Peripheral vascular disease, Psychosis, Pulmonary circulation disorders, Renal failure, Weight loss.

Hospital Frailty Risk Score

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycomorb-1.20260401.0.tar.gz (380.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycomorb-1.20260401.0-py3-none-any.whl (431.6 kB view details)

Uploaded Python 3

File details

Details for the file pycomorb-1.20260401.0.tar.gz.

File metadata

  • Download URL: pycomorb-1.20260401.0.tar.gz
  • Upload date:
  • Size: 380.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pycomorb-1.20260401.0.tar.gz
Algorithm Hash digest
SHA256 aec6ca74a156b15608bba42d17add54d014c34143b29a8350b65c54a1ec630ed
MD5 f48e17190c0fcdd9b1bea67714100688
BLAKE2b-256 35a366e374c3c2cc8345dcffcceeeed0c980340e4f30f0011fca6380fd455f86

See more details on using hashes here.

File details

Details for the file pycomorb-1.20260401.0-py3-none-any.whl.

File metadata

  • Download URL: pycomorb-1.20260401.0-py3-none-any.whl
  • Upload date:
  • Size: 431.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for pycomorb-1.20260401.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5120d3de0424ad8e7b993c4cb5108e9fd2433ca01f31e79b515474c3988c01a
MD5 c20fa92c462a430a1d3ff62728b0aaaa
BLAKE2b-256 b1b2788272ae2bca686dee078c69dffe48a64aa15b36e61a8309c811378bd028

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page