From 981815217905213e4e54ae88f5612a3c1d533288 Mon Sep 17 00:00:00 2001 From: Taksh Date: Fri, 31 Jul 2026 14:22:53 +0300 Subject: [PATCH 1/3] fix: include wbc_max in SIRS WBC missing-data guard WBC scoring uses wbc_min, wbc_max, and bands_max, but the null arm only checked coalesce(wbc_min, bands_max), so a present wbc_max alone yielded NULL instead of 0. Align the guard across BigQuery, Postgres, and DuckDB. Co-authored-by: Cursor --- mimic-iii/concepts/severityscores/sirs.sql | 2 +- mimic-iii/concepts_duckdb/severityscores/sirs.sql | 2 +- mimic-iii/concepts_postgres/severityscores/sirs.sql | 2 +- mimic-iv/concepts/score/sirs.sql | 2 +- mimic-iv/concepts_duckdb/score/sirs.sql | 2 +- mimic-iv/concepts_postgres/score/sirs.sql | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mimic-iii/concepts/severityscores/sirs.sql b/mimic-iii/concepts/severityscores/sirs.sql index 9de5bcffa..32a171aca 100644 --- a/mimic-iii/concepts/severityscores/sirs.sql +++ b/mimic-iii/concepts/severityscores/sirs.sql @@ -89,7 +89,7 @@ left join `physionet-data.mimiciii_derived.labs_first_day` l 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 coalesce(wbc_min, bands_max) is null then null + when coalesce(wbc_min, wbc_max, bands_max) is null then null else 0 end as wbc_score diff --git a/mimic-iii/concepts_duckdb/severityscores/sirs.sql b/mimic-iii/concepts_duckdb/severityscores/sirs.sql index 5a449b758..289ba2f31 100644 --- a/mimic-iii/concepts_duckdb/severityscores/sirs.sql +++ b/mimic-iii/concepts_duckdb/severityscores/sirs.sql @@ -56,7 +56,7 @@ WITH bg AS ( THEN 1 WHEN bands_max > 10 THEN 1 - WHEN COALESCE(wbc_min, bands_max) IS NULL + WHEN COALESCE(wbc_min, wbc_max, bands_max) IS NULL THEN NULL ELSE 0 END AS wbc_score diff --git a/mimic-iii/concepts_postgres/severityscores/sirs.sql b/mimic-iii/concepts_postgres/severityscores/sirs.sql index 1a34cc285..7c370c250 100644 --- a/mimic-iii/concepts_postgres/severityscores/sirs.sql +++ b/mimic-iii/concepts_postgres/severityscores/sirs.sql @@ -59,7 +59,7 @@ WITH bg AS ( THEN 1 WHEN bands_max > 10 THEN 1 /* > 10% immature neurophils (band forms) */ - WHEN COALESCE(wbc_min, bands_max) IS NULL + WHEN COALESCE(wbc_min, wbc_max, bands_max) IS NULL THEN NULL ELSE 0 END AS wbc_score diff --git a/mimic-iv/concepts/score/sirs.sql b/mimic-iv/concepts/score/sirs.sql index ca4a933e7..40ae266b6 100644 --- a/mimic-iv/concepts/score/sirs.sql +++ b/mimic-iv/concepts/score/sirs.sql @@ -77,7 +77,7 @@ WITH scorecomp AS ( 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 COALESCE(wbc_min, bands_max) IS NULL THEN NULL + WHEN COALESCE(wbc_min, wbc_max, bands_max) IS NULL THEN NULL ELSE 0 END AS wbc_score diff --git a/mimic-iv/concepts_duckdb/score/sirs.sql b/mimic-iv/concepts_duckdb/score/sirs.sql index a806e7c72..43e557848 100644 --- a/mimic-iv/concepts_duckdb/score/sirs.sql +++ b/mimic-iv/concepts_duckdb/score/sirs.sql @@ -53,7 +53,7 @@ WITH scorecomp AS ( THEN 1 WHEN bands_max > 10 THEN 1 - WHEN COALESCE(wbc_min, bands_max) IS NULL + WHEN COALESCE(wbc_min, wbc_max, bands_max) IS NULL THEN NULL ELSE 0 END AS wbc_score diff --git a/mimic-iv/concepts_postgres/score/sirs.sql b/mimic-iv/concepts_postgres/score/sirs.sql index b1b28667a..65578a772 100644 --- a/mimic-iv/concepts_postgres/score/sirs.sql +++ b/mimic-iv/concepts_postgres/score/sirs.sql @@ -55,7 +55,7 @@ WITH scorecomp AS ( THEN 1 WHEN bands_max > 10 THEN 1 /* > 10% immature neurophils (band forms) */ - WHEN COALESCE(wbc_min, bands_max) IS NULL + WHEN COALESCE(wbc_min, wbc_max, bands_max) IS NULL THEN NULL ELSE 0 END AS wbc_score From b79f88fb1a3f8c5e5b31bb8a859d9abfc1ec44ff Mon Sep 17 00:00:00 2001 From: Taksh Date: Sat, 1 Aug 2026 15:14:13 +0300 Subject: [PATCH 2/3] 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 0986785bf..71f08fca2 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 37b38f6315fb7c98fa38ab63a0fc7452568b6e20 Mon Sep 17 00:00:00 2001 From: Taksh Date: Sat, 1 Aug 2026 15:16:18 +0300 Subject: [PATCH 3/3] 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 71f08fca2..d6e1c3f0b 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 }}"