diff --git a/.github/workflows/lint_sqlfluff.yml b/.github/workflows/lint_sqlfluff.yml index 0986785b..d6e1c3f0 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/README.md b/README.md index 53fe9f9f..adb9fec9 100644 --- a/README.md +++ b/README.md @@ -114,3 +114,7 @@ By committing your code to the [MIMIC Code Repository](https://github.com/mit-lc ### Coding style Please refer to the [style guide](https://github.com/MIT-LCP/mimic-code/blob/main/styleguide.md) for guidelines on formatting your code for the repository. + +### MIMIC-IV notes + +- [Vitamin C / ascorbic acid](mimic-iv/docs/VITAMIN_C.md) diff --git a/mimic-iv/README.md b/mimic-iv/README.md index 919b196c..bf0e0c58 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 +``` + +## Vitamin C / ascorbic acid + +No dedicated table — see [docs/VITAMIN_C.md](docs/VITAMIN_C.md). diff --git a/mimic-iv/concepts/documentation/README.md b/mimic-iv/concepts/documentation/README.md new file mode 100644 index 00000000..64958c74 --- /dev/null +++ b/mimic-iv/concepts/documentation/README.md @@ -0,0 +1,4 @@ +# Documentation helper queries + +Ad-hoc SQL that illustrates known data quirks. Not part of the official derived +concept build. diff --git a/mimic-iv/concepts/documentation/vitamin_c_emar.sql b/mimic-iv/concepts/documentation/vitamin_c_emar.sql new file mode 100644 index 00000000..621dc1ba --- /dev/null +++ b/mimic-iv/concepts/documentation/vitamin_c_emar.sql @@ -0,0 +1,10 @@ +-- Candidate Vitamin C administrations in emar (#1962). + +SELECT medication, COUNT(*) AS n +FROM hosp.emar +WHERE LOWER(medication) LIKE '%ascorbic%' + OR LOWER(medication) LIKE '%vitamin c%' + OR LOWER(medication) LIKE '%vit c%' +GROUP BY medication +ORDER BY n DESC +LIMIT 50; diff --git a/mimic-iv/concepts/documentation/vitamin_c_prescriptions.sql b/mimic-iv/concepts/documentation/vitamin_c_prescriptions.sql new file mode 100644 index 00000000..0c0d5187 --- /dev/null +++ b/mimic-iv/concepts/documentation/vitamin_c_prescriptions.sql @@ -0,0 +1,11 @@ +-- Candidate Vitamin C / ascorbic acid orders in hosp.prescriptions (#1962). +-- Review hits manually — multivitamins and abbreviations create false positives. + +SELECT drug, COUNT(*) AS n +FROM hosp.prescriptions +WHERE LOWER(drug) LIKE '%ascorbic%' + OR LOWER(drug) LIKE '%vitamin c%' + OR LOWER(drug) LIKE '%vit c%' +GROUP BY drug +ORDER BY n DESC +LIMIT 50; diff --git a/mimic-iv/docs/VITAMIN_C.md b/mimic-iv/docs/VITAMIN_C.md new file mode 100644 index 00000000..641dc186 --- /dev/null +++ b/mimic-iv/docs/VITAMIN_C.md @@ -0,0 +1,38 @@ +# Finding Vitamin C (ascorbic acid) in MIMIC + +There is **no dedicated Vitamin C table** in MIMIC-III or MIMIC-IV. + +See [issue #1962](https://github.com/MIT-LCP/mimic-code/issues/1962). + +## Where exposure usually lives + +| Source | Module | What to search | +|--------|--------|----------------| +| `prescriptions` | hosp | drug / drug_name_generic containing `ascorbic`, `vitamin c`, `vit c` | +| `emar` / `emar_detail` | hosp | administered meds with the same name patterns | +| `inputevents` (III: `_cv` / `_mv`) | icu | infusions if charted as inputs (rare for vit C) | +| `labevents` + `d_labitems` | hosp | serum ascorbic acid **levels** (not doses), if ordered | + +Retrospective papers that report “Vitamin C exposure” almost always derive a +cohort from **medication orders / eMAR**, not from a first-class vit-C module. + +## Practical guidance + +1. Start with `prescriptions` / `emar` string filters; review false positives + (multivitamins, “C” abbreviations). +2. Decide whether you need **orders**, **administrations**, or **serum labs** — + they answer different questions. +3. Do not expect complete capture: OTCs and outside-hospital vitamins are often + absent. + +## What this repository will not add + +A curated “official” Vitamin C concept would need ongoing pharmacy vocabulary +maintenance. Contribute a versioned derived concept with explicit inclusion +strings if you build one for a paper. + +## Related + +- LOINC / terminology: `mimic-iv/docs/LOINC_MAPPING.md` (when present) +- Lab unit quirks: `mimic-iv/buildmimic/TABLE_NOTES.md` (when present) +