Skip to content

CUB-CORR/pycomorb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Elixhauser Comorbidity Index

Combined Comorbidity Score

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).

About

Comorbidity and frailty score calculation utilities (Charlson, Elixhauser, Gagne, HFRS).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages