Skip to content

fix(mimic-iv): update Charlson ICD-10-CM codes for C4A, C7A, and C7B - #2043

Open
acnimma wants to merge 1 commit into
MIT-LCP:mainfrom
acnimma:fix/charlson-icd10cm-c7a-c7b
Open

fix(mimic-iv): update Charlson ICD-10-CM codes for C4A, C7A, and C7B#2043
acnimma wants to merge 1 commit into
MIT-LCP:mainfrom
acnimma:fix/charlson-icd10cm-c7a-c7b

Conversation

@acnimma

@acnimma acnimma commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Exclude C4A, include C7A in malignant_cancer, C7B in metastatic_solid_tumor
  • Regenerate postgres and duckdb copies from BigQuery source

Test plan

  • pytest tests/test_transpile.py (161 tests)
  • Transpiled postgres/duckdb charlson.sql
  • CI concept build on MIMIC-IV demo

Fixes #2017

ICD-10-CM added categories after Quan et al. (2005) that were absent from
the Charlson malignancy and metastatic mappings in MIT-LCP#2017. Exclude C4A
(Merkel cell carcinoma) as a skin malignancy per Quan's skin exception;
include C7A as primary malignant neuroendocrine tumor in malignant_cancer;
include C7B as secondary neuroendocrine tumor in metastatic_solid_tumor.
Regenerate postgres and duckdb dialect copies from the BigQuery source.

Fixes MIT-LCP#2017
@Chessing234

Copy link
Copy Markdown
Contributor

c4a/c7a/c7b handling is the right call for quan 2005. worth a short comment in the sql so the next person doesn't "fix" it back in.

@acnimma

acnimma commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Quan notes in charlson.sql thanks

@Chessing234 Chessing234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i checked the code ranges rather than taking them on trust, and the two additions do hold up: 'C7A' sorts above 'C76' and below 'C81', so it genuinely falls outside every existing range, and 'C7B' isn't in the IN ('C77','C78','C79','C80') list. the C4A exclusion is also doing real work — 'C4A' sorts between 'C45' and 'C58', so without it Merkel cell would have been picked up by that range. so the logic is sound and the operator precedence works out the way you intended.

two things before this lands.

the postgres copy isn't transpiler output. running the repo's transpiler (sqlglot 30.11.0 from requirements-lock) against your bigquery source and diffing mimic-iv/concepts_postgres/comorbidity/charlson.sql on this branch, sqlglot emits the reference header as a single line and the branch has it wrapped across 16. the duckdb copy matches exactly, and the same check on main is identical, so this branch introduces it. generated-up-to-date in transpile.yml compares that folder against transpiler output.

the one i'd actually push back on: excluding C4A while C43 stays in is inconsistent. your comment says C4A is excluded "as skin malignancy per Quan", but Quan's ICD-10 list explicitly includes C43 (malignant melanoma of skin) — main already has it in the IN ('C43','C88') branch. the Charlson convention is to exclude non-melanoma skin cancer (C44) and count melanoma. Merkel cell is an aggressive cutaneous malignancy, much closer to melanoma than to C44, so counting C43 but not C4A is hard to defend on the rationale given. i'd either drop the C4A exclusion or explain why it's grouped with C44 rather than C43.

and the evidence question: Quan 2005 predates all three codes, so this is a deliberate extension of the published algorithm rather than a correction to it — worth saying so in the body. could you also show how many hadm_ids actually change? C4A/C7A/C7B entered ICD-10-CM well into MIMIC-IV's coverage window, and if they appear in diagnoses_icd a handful of times or not at all, that's worth knowing before changing a widely-used comorbidity concept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICD-10-CM codes captured and not captured in charlson.sql

2 participants