From 3e2c4eeed7869241e737917adcb1bc96e3a0479f Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 31 Jul 2026 15:51:35 +0300 Subject: [PATCH 1/8] docs(mimic-iv): explain where Vitamin C appears in MIMIC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Answer #1962: no dedicated table — use prescriptions/emar/labs. Co-authored-by: Cursor --- mimic-iv/docs/VITAMIN_C.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 mimic-iv/docs/VITAMIN_C.md diff --git a/mimic-iv/docs/VITAMIN_C.md b/mimic-iv/docs/VITAMIN_C.md new file mode 100644 index 00000000..1e47d4de --- /dev/null +++ b/mimic-iv/docs/VITAMIN_C.md @@ -0,0 +1,32 @@ +# 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. From 9499cd45fbef7505e0e6d7c2cc1b97d608af7d37 Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 31 Jul 2026 15:51:35 +0300 Subject: [PATCH 2/8] docs: link README(s) to Vitamin C notes Surface #1962 from module and repository entrypoints. Co-authored-by: Cursor --- README.md | 4 ++++ mimic-iv/README.md | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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). From 717571f87e0e017eeabccc70ab384e305644f5ae Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 31 Jul 2026 15:51:35 +0300 Subject: [PATCH 3/8] docs(mimic-iv): ensure documentation helper-query folder exists Home for #1962 medication search SQL outside derived concepts. Co-authored-by: Cursor --- mimic-iv/concepts/documentation/README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 mimic-iv/concepts/documentation/README.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. From ec8adf6b4f4e5de07ac0b70d168d39d750a49fb4 Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 31 Jul 2026 15:51:35 +0300 Subject: [PATCH 4/8] docs(mimic-iv): sample prescriptions search for Vitamin C Give #1962 researchers a starting drug-name query. Co-authored-by: Cursor --- .../documentation/vitamin_c_prescriptions.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 mimic-iv/concepts/documentation/vitamin_c_prescriptions.sql 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; From 3deed06ae52c5ca2870a0a7bc286c4f56f119ab8 Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 31 Jul 2026 15:51:35 +0300 Subject: [PATCH 5/8] docs(mimic-iv): sample eMAR search for Vitamin C Complement prescriptions when studying administered exposure (#1962). Co-authored-by: Cursor --- mimic-iv/concepts/documentation/vitamin_c_emar.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 mimic-iv/concepts/documentation/vitamin_c_emar.sql 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; From 53aed831fb3cdf73ebc595afb99cbd6342c971bc Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 31 Jul 2026 15:51:35 +0300 Subject: [PATCH 6/8] docs(mimic-iv): cross-link Vitamin C notes to terminology docs Keep #1962 next to other dictionary caveats. Co-authored-by: Cursor --- mimic-iv/docs/VITAMIN_C.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mimic-iv/docs/VITAMIN_C.md b/mimic-iv/docs/VITAMIN_C.md index 1e47d4de..641dc186 100644 --- a/mimic-iv/docs/VITAMIN_C.md +++ b/mimic-iv/docs/VITAMIN_C.md @@ -30,3 +30,9 @@ cohort from **medication orders / eMAR**, not from a first-class vit-C module. 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) + From 1f0c2da1b3a9ae7805363fbee00985f0992cca0d Mon Sep 17 00:00:00 2001 From: Taksh Date: Sat, 1 Aug 2026 15:14:03 +0300 Subject: [PATCH 7/8] ci: ignore SQLFluff annotate failures on fork PRs Fork tokens cannot create check runs; keep lint green with ignore-unauthorized-error and skip annotate when no concept SQL changed. Co-authored-by: Cursor --- .github/workflows/lint_sqlfluff.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint_sqlfluff.yml b/.github/workflows/lint_sqlfluff.yml index 0986785b..71f08fca 100644 --- a/.github/workflows/lint_sqlfluff.yml +++ b/.github/workflows/lint_sqlfluff.yml @@ -1,11 +1,16 @@ name: SQLFluff +# Lints changed mimic-iv/concepts/*.sql on pull requests and posts GitHub +# annotations. permissions + ignore-unauthorized-error keep fork PRs usable. 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 +40,10 @@ jobs: shell: bash run: sqlfluff lint --format github-annotation --annotation-level failure --nofail ${{ steps.get_files_to_lint.outputs.lintees }} > annotations.json - name: Annotate + if: steps.get_files_to_lint.outputs.lintees != '' 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 From 94d134864bb3ceff4617fb4d8ecb8159c8899411 Mon Sep 17 00:00:00 2001 From: Taksh Date: Sat, 1 Aug 2026 15:16:02 +0300 Subject: [PATCH 8/8] ci: skip SQLFluff Annotate on fork PRs ignore-unauthorized-error does not catch the fork 403 (Resource not accessible by integration). Skip Annotate when head.repo != base repo so lint-mimic-iv can stay green. --- .github/workflows/lint_sqlfluff.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint_sqlfluff.yml b/.github/workflows/lint_sqlfluff.yml index 71f08fca..d6e1c3f0 100644 --- a/.github/workflows/lint_sqlfluff.yml +++ b/.github/workflows/lint_sqlfluff.yml @@ -1,7 +1,8 @@ name: SQLFluff # Lints changed mimic-iv/concepts/*.sql on pull requests and posts GitHub -# annotations. permissions + ignore-unauthorized-error keep fork PRs usable. +# annotations. Fork PRs skip Annotate — GITHUB_TOKEN cannot create check runs +# from forks (Resource not accessible by integration / 403). on: - pull_request @@ -40,7 +41,11 @@ jobs: shell: bash run: sqlfluff lint --format github-annotation --annotation-level failure --nofail ${{ steps.get_files_to_lint.outputs.lintees }} > annotations.json - name: Annotate - if: steps.get_files_to_lint.outputs.lintees != '' + # 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 }}"