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/mimic-iii/concepts/severityscores/sirs.sql b/mimic-iii/concepts/severityscores/sirs.sql index 9de5bcff..e13096ef 100644 --- a/mimic-iii/concepts/severityscores/sirs.sql +++ b/mimic-iii/concepts/severityscores/sirs.sql @@ -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 @@ -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) diff --git a/mimic-iii/concepts_duckdb/severityscores/sirs.sql b/mimic-iii/concepts_duckdb/severityscores/sirs.sql index 5a449b75..2abd1d48 100644 --- a/mimic-iii/concepts_duckdb/severityscores/sirs.sql +++ b/mimic-iii/concepts_duckdb/severityscores/sirs.sql @@ -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, diff --git a/mimic-iii/concepts_postgres/severityscores/sirs.sql b/mimic-iii/concepts_postgres/severityscores/sirs.sql index 1a34cc28..9cf2ac0e 100644 --- a/mimic-iii/concepts_postgres/severityscores/sirs.sql +++ b/mimic-iii/concepts_postgres/severityscores/sirs.sql @@ -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 */ @@ -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 @@ -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, diff --git a/mimic-iv/concepts/score/sirs.sql b/mimic-iv/concepts/score/sirs.sql index ca4a933e..c0e86b62 100644 --- a/mimic-iv/concepts/score/sirs.sql +++ b/mimic-iv/concepts/score/sirs.sql @@ -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 @@ -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) diff --git a/mimic-iv/concepts_postgres/score/sirs.sql b/mimic-iv/concepts_postgres/score/sirs.sql index b1b28667..af10c491 100644 --- a/mimic-iv/concepts_postgres/score/sirs.sql +++ b/mimic-iv/concepts_postgres/score/sirs.sql @@ -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 @@ -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,