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 mimic-iv/concepts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
This folder contains scripts to generate useful abstractions of raw MIMIC-IV data ("concepts").
The scripts are written using the **BigQuery Standard SQL Dialect**. Concepts are categorized into folders if possible, otherwise they remain in the top-level directory. The [concepts_postgres](/mimic-iv/concepts_postgres) and [concepts_duckdb](/mimic-iv/concepts_duckdb) folders contain automatically generated PostgreSQL and DuckDB versions of these scripts; see the [top-level readme](/mimic-iv/README.md#generating-the-concepts) for how these were generated.

Lab measurement concepts under `measurement/` generally exclude non-positive `valuenum` rows
(`valuenum IS NOT NULL AND valuenum > 0`) and, where documented in the source SQL, filter
`valueuom` to the expected unit for a given `itemid`.

The concepts are organized into individual SQL scripts, with each script generating a table. The BigQuery `mimiciv_derived` dataset under `physionet-data` contains the concepts pregenerated. Access to this dataset is available to MIMIC-IV approved users: see the [cloud instructions](https://mimic.mit.edu/docs/gettingstarted/cloud/) on how to access MIMIC-IV on BigQuery (which includes the derived concepts).

See the [top-level readme](/mimic-iv/README.md) for more information about generating the concepts.
Expand Down
1 change: 1 addition & 0 deletions mimic-iv/concepts/measurement/cardiac_marker.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ WHERE le.itemid IN
, 50963 -- N-terminal (NT)-pro hormone BNP (NT-proBNP)
)
AND valuenum IS NOT NULL
AND valuenum > 0
GROUP BY le.specimen_id
;
1 change: 1 addition & 0 deletions mimic-iv/concepts/measurement/coagulation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ WHERE le.itemid IN
, 51275 -- PTT
)
AND valuenum IS NOT NULL
AND valuenum > 0
GROUP BY le.specimen_id
;
2 changes: 1 addition & 1 deletion mimic-iv/concepts_duckdb/measurement/cardiac_marker.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ SELECT
MAX(CASE WHEN itemid = 50963 THEN valuenum ELSE NULL END) AS ntprobnp
FROM mimiciv_hosp.labevents AS le
WHERE
le.itemid IN (51003, 50911, 50963) AND NOT valuenum IS NULL
le.itemid IN (51003, 50911, 50963) AND NOT valuenum IS NULL AND valuenum > 0
GROUP BY
le.specimen_id
4 changes: 3 additions & 1 deletion mimic-iv/concepts_duckdb/measurement/coagulation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ SELECT
MAX(CASE WHEN itemid = 51275 THEN valuenum ELSE NULL END) AS ptt
FROM mimiciv_hosp.labevents AS le
WHERE
le.itemid IN (51196, 51214, 51297, 51237, 51274, 51275) AND NOT valuenum IS NULL
le.itemid IN (51196, 51214, 51297, 51237, 51274, 51275)
AND NOT valuenum IS NULL
AND valuenum > 0
GROUP BY
le.specimen_id
1 change: 1 addition & 0 deletions mimic-iv/concepts_postgres/measurement/cardiac_marker.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ WHERE
50963 /* N-terminal (NT)-pro hormone BNP (NT-proBNP) */
)
AND NOT valuenum IS NULL
AND valuenum > 0
GROUP BY
le.specimen_id
1 change: 1 addition & 0 deletions mimic-iv/concepts_postgres/measurement/coagulation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ WHERE
51275 /* PTT */
)
AND NOT valuenum IS NULL
AND valuenum > 0
GROUP BY
le.specimen_id
Loading