vvcb / comorbidipy

Python package to calculate comorbidity scores including Charlson Comorbidity Score and Elixhauser Score and their weighted variants.
MIT License
10 stars 5 forks source link

Does not return scores <0 for scores other than SHMI #6

Open jcherington opened 2 weeks ago

jcherington commented 2 weeks ago

Description

The calculator returns a "0" score for ECI_raw with van-walraven weights for rows where it should return score of <0. For example for a row with a "drug" comorbidity without other flags, it should return -7 in ECI_raw (and a corresponding value for ECI_age).

I believe the problem stems from this code in calculator.py:

# if sum of weights is less than zero, set it zero (this only applies to UK SHMI) dfp["comorbidity_score"] = dfp["comorbidity_score"].where( dfp["comorbidity_score"] >= 0, 0 ) return dfp

There is no check in that code for weighting="shmi". Commenting out the code ensures the calculator returns the full range of results for non SHMI weighted scores.