Part II: Sepsis Intelligence at the Point of Care
EHR-Embedded Sepsis Early Warning
Real-Time Clinical Intelligence Engine - Part II
Overview & Clinical Context
Clinical dashboards inside modern Electronic Health Records (EHRs) frequently fail to change outcomes due to “alert fatigue.” Clinicians are routinely inundated with passive notifications, leading to critical, time-sensitive warnings being dismissed. This project introduces a production-grade, end-to-end Clinical Decision Support (CDS) Hooks system designed to passively monitor adult ICU patients during their first six hours of admission and alert clinicians to early-stage sepsis risk.
Instead of requiring a physician to open a specific tab or manually calculate risk scores, this system operates entirely in the background. When specific clinical events occur within the EHR (such as an encounter opening or a lab value updating), the EHR automatically triggers an asynchronous HTTPS request to our external machine learning service. The service parses the raw data, evaluates an optimized XGBoost predictive model, runs a local game-theoretic interpretability model (SHAP), logs an immutable transaction record to a secure database for auditing, and returns a formatted “CDS Card” directly into the user interface of the clinician.
View Source Code
Click to expand interactive code modal
The engineering cycle is divided into distinct execution phases:
- Phase 0 (Infrastructure Setup): Provisioning the cloud environment, setting up local development pathways, establishing secure database links, and defining code repository webhooks.
- Phase 1 (Clinical Data Pipeline): Ingesting complex, unevenly sampled time-series data from the MIMIC-IV database, cleaning physiological anomalies, grouping time windows, and executing class-stratified medians to generate an analytical matrix.
- Phase 2 (Algorithmic Modeling): Training an XGBoost binary mortality classifier, adjusting parameters to accommodate a micro-scale validation cohort safely, and exporting cryptographic explainer configurations.
- Phase 3 (Algorithmic Governance): Running automated fairness evaluations across age, gender, and racial brackets using point-estimate methodologies to produce an FDA-aligned Good Machine Learning Practice (GMLP) asset.
- Phase 4 (Containerized API Deployment): Encapsulating the analytical weights, features, and schema structures into a high-performance FastAPI wrapper containerized via Docker and deployed automatically using continuous integration channels to a serverless compute cluster.
- Phase 5 (End-to-End Validation): Simulating standard real-world medical anomalies by feeding realistic synthetic health bundles against the active production service to guarantee algorithmic execution.
- Phase 6 (Portfolio Deployment): Binding the interactive user layout to web hosting services to demonstrate system utility transparently.
Phase 0: Foundations & Cloud Environments
Phase 0 establishes the underlying infrastructure. A dedicated Google Cloud Project (cytos-web) was created and linked to an isolated Firebase Native mode instance (cds-sepsis). Access permissions were restricted by generating an encrypted Google Service Account key file, mapping roles directly to document read/write parameters. The working environment was stabilized by linking local Google Drive persistent storage structures to automated development notebooks, preventing environmental drift across processing sessions.
Phase 1: Ingestion & Clinical Feature Engineering
The system extracts structured components from the MIMIC-IV clinical dataset. Time-series observations are restricted exclusively to the first six hours following ICU admission. Raw values are passed through a deterministic pipeline that filters physiological outliers (e.g., removing impossible blood pressure or oxygen saturation readings) and applies a class-stratified median imputation technique to fill missing observations based on broader cohort behavior.
Critical Processing Implementation
View Source Code
Click to expand interactive code modal
Analytical Visualization
During data compilation, the feature distributions are visually mapped to check for scaling anomalies before introducing arrays to the optimization algorithms.
Phase 2: Predictive Modeling & Cryptographic Explainability
Phase 2 builds the machine learning core. An extreme gradient boosted trees classifier (XGBClassifier) is configured to process the clinical vectors. Because the demonstration scale involves restricted patient volumes (N=7 total validation cohort), standard cross-validation mechanisms are bypassed using rigid stratified parameter splits to ensure compilation stability.
To satisfy clinical safety constraints and remove the typical “black box” barriers associated with neural architectures, a game-theoretic local explanation model (shap.TreeExplainer) is initialized directly alongside the model tree structures. This saves a local mathematical baseline mapping how every individual clinical metric impacts the final prediction percentage.
Core Optimization Script
View Source Code
Click to expand interactive code modal
Model Evaluation Metrics
After training, the model is evaluated against the test partition to establish baseline classification capabilities and reliability.
Clinical Explainability (SHAP)
To ensure physicians can trust the AI’s recommendation, the system generates visual explanations detailing exactly why a specific risk score was assigned.