Add missing Postgres concepts for Sepsis-3 and SOFA pivot logic (MIMIC-III) #1963
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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):
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:
Integration approach
All additions are integrated into the existing pipeline by appending them to the end of postgres-make-concepts.sql, ensuring:
Verification
All scripts execute successfully in sequence.
Approximate execution time:
Materialized views are created as expected and align with the BigQuery-derived logic.
Impact
This PR improves:
No existing concepts are modified or removed.