Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/lint_sqlfluff.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
input: "./annotations.json"
ignore-unauthorized-error: true
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion mimic-iv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
```

## Vitamin C / ascorbic acid

No dedicated table — see [docs/VITAMIN_C.md](docs/VITAMIN_C.md).
4 changes: 4 additions & 0 deletions mimic-iv/concepts/documentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Documentation helper queries

Ad-hoc SQL that illustrates known data quirks. Not part of the official derived
concept build.
10 changes: 10 additions & 0 deletions mimic-iv/concepts/documentation/vitamin_c_emar.sql
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions mimic-iv/concepts/documentation/vitamin_c_prescriptions.sql
Original file line number Diff line number Diff line change
@@ -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;
38 changes: 38 additions & 0 deletions mimic-iv/docs/VITAMIN_C.md
Original file line number Diff line number Diff line change
@@ -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)

Loading