LLM-Powered Clinical Data Extraction & Analytics Pipeline
Objective
A pharmaceutical company needed an intelligent system to extract complex, nested clinical data from hundreds of unstructured medical discharge summaries for patients treated with Besremi (ropeginterferon alfa-2b) for Polycythemia Vera. The goal was to transform free-text clinical narratives into structured, analysis-ready datasets covering treatment response, biomarker trends, toxicity events, and molecular monitoring enabling rigorous cohort-level analytics that manual data entry could not support at scale.
Solution
We designed and built an end-to-end LLM-powered extraction and analytics pipeline using the OpenAI Batch API with JSON-mode constrained output. Domain-specific system prompts encoding medical extraction rules, data type constraints, and few-shot worked examples guided the model to extract 10+ clinical entity types, treatment response evaluations, interferon dosing records, hepatic/renal toxicity panels, JAK2 V617F molecular monitoring, and phlebotomy events from free-text narratives into structured JSON at scale. A multi-stage ETL pipeline then exploded the nested LLM output into five normalised dimension tables, applied temporal alignment joins with ±30-day tolerance windows to recover missing biomarker values across parallel clinical tables, and ran physiological anomaly detection to identify and correct implausible value swaps. Statistical analysis computed cohort-level descriptive statistics, per-patient Z-scores, and deviation flags, with automated visualisation generating trajectory plots and Z-score divergence charts across the full patient cohort.
Results
The pipeline successfully processed hundreds of patient records end-to-end, with timestamped artifact management providing a full audit trail at every stage. Temporal cross-referencing recovered measurable quantities of missing haemoglobin and haematocrit values that would otherwise have been lost, and automated anomaly detection flagged physiologically implausible records before they reached analysis. The resulting cohort analytics including per-patient biomarker trajectories overlaid on population ±2SD bands, gave clinicians and researchers structured, validated insights into treatment response patterns across the entire patient population.