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: 2 additions & 2 deletions mimic-iii/concepts/severityscores/sirs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ left join `physionet-data.mimiciii_derived.labs_first_day` l
, case
when wbc_min < 4.0 then 1
when wbc_max > 12.0 then 1
when bands_max > 10 then 1-- > 10% immature neurophils (band forms)
when bands_max > 10 then 1 -- > 10% immature neutrophils (band forms)
when coalesce(wbc_min, bands_max) is null then null
else 0
end as wbc_score
Expand All @@ -97,7 +97,7 @@ left join `physionet-data.mimiciii_derived.labs_first_day` l
)
select
ie.subject_id, ie.hadm_id, ie.icustay_id
-- Combine all the scores to get SOFA
-- Combine all component scores to get SIRS
-- Impute 0 if the score is missing
, coalesce(temp_score,0)
+ coalesce(heartrate_score,0)
Expand Down
2 changes: 1 addition & 1 deletion mimic-iii/concepts_duckdb/severityscores/sirs.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
DROP TABLE IF EXISTS mimiciii_derived.sirs; CREATE TABLE mimiciii_derived.sirs AS
DROP TABLE IF EXISTS mimiciv_derived.sirs; CREATE TABLE mimiciv_derived.sirs AS
WITH bg AS (
SELECT
bg.icustay_id,
Expand Down
6 changes: 3 additions & 3 deletions mimic-iii/concepts_postgres/severityscores/sirs.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
DROP TABLE IF EXISTS mimiciii_derived.sirs; CREATE TABLE mimiciii_derived.sirs AS
DROP TABLE IF EXISTS mimiciv_derived.sirs; CREATE TABLE mimiciv_derived.sirs AS
/* ------------------------------------------------------------------ */ /* Title: Systemic inflammatory response syndrome (SIRS) criteria */ /* This query extracts the Systemic inflammatory response syndrome (SIRS) criteria */ /* The criteria quantify the level of inflammatory response of the body */ /* The score is calculated on the first day of each ICU patients' stay. */ /* ------------------------------------------------------------------ */ /* Reference for SIRS: */ /* American College of Chest Physicians/Society of Critical Care Medicine Consensus Conference: */ /* definitions for sepsis and organ failure and guidelines for the use of innovative therapies in sepsis" */ /* Crit. Care Med. 20 (6): 864–74. 1992. */ /* doi:10.1097/00003246-199206000-00025. PMID 1597042. */ /* Variables used in SIRS: */ /* Body temperature (min and max) */ /* Heart rate (max) */ /* Respiratory rate (max) */ /* PaCO2 (min) */ /* White blood cell count (min and max) */ /* the presence of greater than 10% immature neutrophils (band forms) */ /* The following views required to run this query: */ /* 1) vitals_first_day - generated by vitals-first-day.sql */ /* 2) labs_first_day - generated by labs-first-day.sql */ /* 3) blood_gas_first_day_arterial - generated by blood-gas-first-day-arterial.sql */ /* Note: */ /* The score is calculated for *all* ICU patients, with the assumption that the user will subselect appropriate ICUSTAY_IDs. */ /* For example, the score is calculated for neonates, but it is likely inappropriate to actually use the score values for these patients. */
WITH bg AS (
/* join blood gas to ventilation durations to determine if patient was vent */
Expand Down Expand Up @@ -58,7 +58,7 @@ WITH bg AS (
WHEN wbc_max > 12.0
THEN 1
WHEN bands_max > 10
THEN 1 /* > 10% immature neurophils (band forms) */
THEN 1 /* > 10% immature neutrophils (band forms) */
WHEN COALESCE(wbc_min, bands_max) IS NULL
THEN NULL
ELSE 0
Expand All @@ -68,7 +68,7 @@ WITH bg AS (
SELECT
ie.subject_id,
ie.hadm_id,
ie.icustay_id, /* Combine all the scores to get SOFA */ /* Impute 0 if the score is missing */
ie.icustay_id, /* Combine all component scores to get SIRS */ /* Impute 0 if the score is missing */
COALESCE(temp_score, 0) + COALESCE(heartrate_score, 0) + COALESCE(resp_score, 0) + COALESCE(wbc_score, 0) AS sirs,
temp_score,
heartrate_score,
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts/score/sirs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ WITH scorecomp AS (
, CASE
WHEN wbc_min < 4.0 THEN 1
WHEN wbc_max > 12.0 THEN 1
WHEN bands_max > 10 THEN 1-- > 10% immature neurophils (band forms)
WHEN bands_max > 10 THEN 1 -- > 10% immature neutrophils (band forms)
WHEN COALESCE(wbc_min, bands_max) IS NULL THEN NULL
ELSE 0
END AS wbc_score
Expand All @@ -86,7 +86,7 @@ WITH scorecomp AS (

SELECT
ie.subject_id, ie.hadm_id, ie.stay_id
-- Combine all the scores to get SOFA
-- Combine all component scores to get SIRS
-- Impute 0 if the score is missing
, COALESCE(temp_score, 0)
+ COALESCE(heart_rate_score, 0)
Expand Down
4 changes: 2 additions & 2 deletions mimic-iv/concepts_postgres/score/sirs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ WITH scorecomp AS (
WHEN wbc_max > 12.0
THEN 1
WHEN bands_max > 10
THEN 1 /* > 10% immature neurophils (band forms) */
THEN 1 /* > 10% immature neutrophils (band forms) */
WHEN COALESCE(wbc_min, bands_max) IS NULL
THEN NULL
ELSE 0
Expand All @@ -64,7 +64,7 @@ WITH scorecomp AS (
SELECT
ie.subject_id,
ie.hadm_id,
ie.stay_id, /* Combine all the scores to get SOFA */ /* Impute 0 if the score is missing */
ie.stay_id, /* Combine all component scores to get SIRS */ /* Impute 0 if the score is missing */
COALESCE(temp_score, 0) + COALESCE(heart_rate_score, 0) + COALESCE(resp_score, 0) + COALESCE(wbc_score, 0) AS sirs,
temp_score,
heart_rate_score,
Expand Down
Loading