diff --git a/.github/workflows/lint_sqlfluff.yml b/.github/workflows/lint_sqlfluff.yml index 0986785bf..d6e1c3f0b 100644 --- a/.github/workflows/lint_sqlfluff.yml +++ b/.github/workflows/lint_sqlfluff.yml @@ -1,11 +1,17 @@ name: SQLFluff +# Lints changed mimic-iv/concepts/*.sql on pull requests and posts GitHub +# annotations. Fork PRs skip Annotate — GITHUB_TOKEN cannot create check runs +# from forks (Resource not accessible by integration / 403). on: - pull_request jobs: lint-mimic-iv: runs-on: ubuntu-latest + permissions: + contents: read + checks: write steps: - name: checkout uses: actions/checkout@v7 @@ -35,8 +41,14 @@ jobs: shell: bash run: sqlfluff lint --format github-annotation --annotation-level failure --nofail ${{ steps.get_files_to_lint.outputs.lintees }} > annotations.json - name: Annotate + # Same-repo PRs only: fork tokens get 403 creating check runs, and + # ignore-unauthorized-error does not treat that as unauthorized. + if: > + steps.get_files_to_lint.outputs.lintees != '' && + github.event.pull_request.head.repo.full_name == github.repository uses: yuzutech/annotations-action@v0.6.0 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" title: "SQLFluff Lint" - input: "./annotations.json" \ No newline at end of file + input: "./annotations.json" + ignore-unauthorized-error: true diff --git a/mimic-iv/README.md b/mimic-iv/README.md index 919b196cc..a56f4d5b7 100644 --- a/mimic-iv/README.md +++ b/mimic-iv/README.md @@ -105,4 +105,8 @@ mimic_utils convert_folder mimic-iv/concepts mimic-iv/concepts_duckdb --destinat # To PostgreSQL: mimic_utils convert_folder mimic-iv/concepts mimic-iv/concepts_postgres --destination_dialect postgres -``` \ No newline at end of file +``` + +## Charlson ICD-10-CM notes + +See [concepts/comorbidity/README.md](concepts/comorbidity/README.md) for Quan (2005) vs ICD-10-CM (`C4A` / `C7A` / `C7B`). diff --git a/mimic-iv/concepts/comorbidity/README.md b/mimic-iv/concepts/comorbidity/README.md new file mode 100644 index 000000000..b4583fe53 --- /dev/null +++ b/mimic-iv/concepts/comorbidity/README.md @@ -0,0 +1,24 @@ +# Charlson comorbidity concepts (MIMIC-IV) + +SQL in this folder implements the Quan et al. (2005) ICD-9-CM / ICD-10 coding +algorithms for the Charlson Comorbidity Index against MIMIC-IV `diagnoses_icd`. + +## ICD-10 vs ICD-10-CM + +Quan et al. published ranges against **WHO ICD-10**. MIMIC-IV stores +**ICD-10-CM** codes. Most three-character prefixes align; a few CM-only +categories do not appear in the 2005 tables: + +| Code | Meaning | Charlson mapping in this repo | +|------|---------|--------------------------------| +| `C4A` | Merkel cell carcinoma | Excluded from `malignant_cancer` (skin malignancy carve-out); see PR discussion on #2017 / #2142 | +| `C7A` | Malignant neuroendocrine tumors | **Not mapped** — outside Quan’s WHO ICD-10 ranges | +| `C7B` | Secondary neuroendocrine tumors | **Not mapped** — outside Quan’s WHO ICD-10 ranges | + +Leaving `C7A` / `C7B` unmapped is intentional until a published CM-specific +extension is adopted. Do not widen the `C45`–`C58`-style prefix ranges without +updating this note and citing a coding reference. + +## Related PRs + +- [#2142](https://github.com/MIT-LCP/mimic-code/pull/2142) — exclude `C4A` from `malignant_cancer` diff --git a/mimic-iv/concepts/comorbidity/charlson.sql b/mimic-iv/concepts/comorbidity/charlson.sql index 15911b37b..789a2aa23 100644 --- a/mimic-iv/concepts/comorbidity/charlson.sql +++ b/mimic-iv/concepts/comorbidity/charlson.sql @@ -15,6 +15,8 @@ -- (3) Quan H, Sundararajan V, Halfon P, et al. Coding algorithms for -- defining Comorbidities in ICD-9-CM and ICD-10 administrative data. -- Med Care. 2005 Nov; 43(11): 1130-9. +-- +-- ICD-10-CM notes (C4A / C7A / C7B): see comorbidity/README.md -- ------------------------------------------------------------------ WITH diag AS ( diff --git a/mimic-iv/concepts_postgres/comorbidity/charlson.sql b/mimic-iv/concepts_postgres/comorbidity/charlson.sql index 1655dba02..b86111039 100644 --- a/mimic-iv/concepts_postgres/comorbidity/charlson.sql +++ b/mimic-iv/concepts_postgres/comorbidity/charlson.sql @@ -1,6 +1,6 @@ -- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY. DROP TABLE IF EXISTS mimiciv_derived.charlson; CREATE TABLE mimiciv_derived.charlson AS -/* ------------------------------------------------------------------ */ /* This query extracts Charlson Comorbidity Index (CCI) based on the */ /* recorded ICD-9 and ICD-10 codes. */ /* Reference for CCI: */ /* (1) Charlson ME, Pompei P, Ales KL, MacKenzie CR. (1987) A new method */ /* of classifying prognostic comorbidity in longitudinal studies: */ /* development and validation.J Chronic Dis; 40(5):373-83. */ /* (2) Charlson M, Szatrowski TP, Peterson J, Gold J. (1994) Validation */ /* of a combined comorbidity index. J Clin Epidemiol; 47(11):1245-51. */ /* */ /* Reference for ICD-9-CM and ICD-10 Coding Algorithms for Charlson */ /* Comorbidities: */ /* (3) Quan H, Sundararajan V, Halfon P, et al. Coding algorithms for */ /* defining Comorbidities in ICD-9-CM and ICD-10 administrative data. */ /* Med Care. 2005 Nov; 43(11): 1130-9. */ /* ------------------------------------------------------------------ */ +/* ------------------------------------------------------------------ */ /* This query extracts Charlson Comorbidity Index (CCI) based on the */ /* recorded ICD-9 and ICD-10 codes. */ /* Reference for CCI: */ /* (1) Charlson ME, Pompei P, Ales KL, MacKenzie CR. (1987) A new method */ /* of classifying prognostic comorbidity in longitudinal studies: */ /* development and validation.J Chronic Dis; 40(5):373-83. */ /* (2) Charlson M, Szatrowski TP, Peterson J, Gold J. (1994) Validation */ /* of a combined comorbidity index. J Clin Epidemiol; 47(11):1245-51. */ /* */ /* Reference for ICD-9-CM and ICD-10 Coding Algorithms for Charlson */ /* Comorbidities: */ /* (3) Quan H, Sundararajan V, Halfon P, et al. Coding algorithms for */ /* defining Comorbidities in ICD-9-CM and ICD-10 administrative data. */ /* Med Care. 2005 Nov; 43(11): 1130-9. */ /* ICD-10-CM notes (C4A / C7A / C7B): see comorbidity/README.md */ /* ------------------------------------------------------------------ */ WITH diag AS ( SELECT hadm_id,