Skip to content

Conversation

@troojx
Copy link

@troojx troojx commented Jan 12, 2026

Summary

This PR completes the PostgreSQL implementation of Sepsis-3–related concepts for MIMIC-III, aligning it with the existing BigQuery logic and the Sepsis-3 implementation used in MIMIC-IV.

Specifically, it addresses missing execution steps, adds required pivoted views for SOFA-related metrics, and adapts the MIMIC-IV Sepsis-3 logic to MIMIC-III in PostgreSQL.

Motivation

While working with the PostgreSQL concepts for MIMIC-III, I observed three gaps that affect reproducibility and correctness of Sepsis-3–related analyses:

1. Treatment scripts exist but are not executed
The treatment scripts (e.g., antibiotic exposure and suspicion of infection) are present in the repository but are not invoked in postgres-make-concepts.sql.

2. Missing pivot logic compared to BigQuery implementation
In the BigQuery version, several SOFA-related measurements are explicitly pivoted.
These pivoted views are required for correct SOFA and Sepsis-3 computation, but are currently absent in the PostgreSQL pipeline.

3. Lack of a complete Sepsis-3 implementation for MIMIC-III
MIMIC-IV provides a well-defined Sepsis-3 implementation. This PR adapts that logic to MIMIC-III, ensuring conceptual consistency across datasets.

What this PR adds

1. Execution of missing treatment scripts

The following existing scripts are now explicitly executed as part of the Postgres concepts pipeline:

-- Missing scripts: treatment
\i treatment/abx_prescriptions_list.sql
\i treatment/suspicion_of_infection.sql

2. Addition of SOFA-related pivoted views

Based on the BigQuery implementation, the following pivoted views were manually rewritten in PostgreSQL syntax (automatic conversion was not applicable):

-- New addition: Pivot calculation for SOFA related metrics
\i pivot/pivoted_bg.sql
\i pivot/pivoted_bg_art.sql
\i pivot/pivoted_uo.sql
\i pivot/pivoted_lab.sql
\i pivot/pivoted_gcs.sql

These views are required for downstream SOFA and Sepsis-3 logic.

3. Sepsis-3 logic for MIMIC-III

A PostgreSQL-compatible Sepsis-3 script was implemented for MIMIC-III by adapting the logic used in MIMIC-IV:

-- Sepsis 3 script
\i sepsis/sepsis3.sql

Integration approach

All additions are integrated into the existing pipeline by appending them to the end of postgres-make-concepts.sql, ensuring:

  • No changes to existing execution order
  • Backward compatibility with current workflows
  • A single entry point for generating all required concepts

Verification

  • PostgreSQL version: 14.20
  • Dataset: MIMIC-III v1.4

All scripts execute successfully in sequence.

Approximate execution time:

  • Pivoted SOFA-related views: ~1 minute each
  • pivoted_sepsis view: ~550 seconds
  • Sepsis-3 script: ~1 minute

Materialized views are created as expected and align with the BigQuery-derived logic.

Impact

This PR improves:

  • Reproducibility of Sepsis-3 research using PostgreSQL
  • Consistency between MIMIC-III and MIMIC-IV Sepsis definitions
  • Parity between PostgreSQL and BigQuery concept implementations

No existing concepts are modified or removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant