Fix Charlson age_score off-by-one at decade boundaries#1992
Open
Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Open
Fix Charlson age_score off-by-one at decade boundaries#1992Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Chessing234 wants to merge 1 commit intoMIT-LCP:mainfrom
Conversation
Charlson Comorbidity Index per Charlson et al. 1987 (and Quan et al. 2005 referenced at the top of this file) adds 1 age point per decade starting at age 50: age < 50 -> 0 age in [50, 60) -> 1 age in [60, 70) -> 2 age in [70, 80) -> 3 age >= 80 -> 4 The current cutoffs use `<=`, so the boundary ages collapse into the lower bin (e.g. age 50 scores 0 instead of 1, age 80 scores 3 instead of 4). Switch to strict `<` so each decade is bounded as [lower, upper).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
`mimic-iv/concepts/comorbidity/charlson.sql` computes the age component of the Charlson Comorbidity Index as:
```sql
, CASE WHEN age <= 50 THEN 0
WHEN age <= 60 THEN 1
WHEN age <= 70 THEN 2
WHEN age <= 80 THEN 3
ELSE 4 END AS age_score
```
Root cause
Per the file's own references (Charlson et al. 1987; Quan et al. 2005), CCI adds one age point per decade starting at 50:
The boundaries belong to the higher bin (50 → 1, 80 → 4). With `<=` they collapse into the lower bin: an age-50 patient gets 0 instead of 1, age-60 gets 1 instead of 2, age-70 gets 2 instead of 3, and age-80 gets 3 instead of 4. Each integer decade boundary is consistently understated by 1.
Fix
Switch the cutoffs to strict `<` so each decade is bounded as `[lower, upper)`. Auto-generated `concepts_postgres` and `concepts_duckdb` copies will pick up the fix on the next regeneration (they are marked "AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.").