HomeCase studiesAI Medical Report Analyzer for Longitudinal Biomarker...

Case study · Boston, United States

AI Medical Report Analyzer for Longitudinal Biomarker Extraction and Cited Diagnostic Summarization

Clinical Diagnostics & Report Summarization

Patients and clinicians routinely confront multi-page pathology PDFs, scanned imaging narratives, and inconsistent laboratory units that obscure longitudinal health trends. We engineered an AI medical report analyzer in Python and FastAPI paired with a React review portal, deterministic unit normalization, and citation-anchored LLM summarization. The system parses heterogeneous lab tables into standardized biomarker series, highlights out-of-range shifts across visits, and links every plain-language summary claim directly to the source page and bounding box.

Industry
Clinical Diagnostics & Report Summarization
Solution
A Python FastAPI and React diagnostic document intelligence platform that extracts structured lab biomarkers via OCR, normalizes units against clinical ontologies, and produces source-cited summaries.
Platforms
Web & API
Stack
Python · FastAPI · React · TypeScript · PostgreSQL · Celery
Location
Boston, United States · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Boston, United States. Names withheld by agreement.

Project Overview

Diagnostic reports arrive in wildly inconsistent formats—from crisp electronic hematology exports to faxed pathology scans with handwritten margin notes and shifting reference ranges across different testing laboratories. Physicians reviewing ten years of historical PDFs during a brief appointment struggle to spot subtle downward hemoglobin trends or compare lipid panels reported in incompatible units, while patients reading raw medical jargon online often misinterpret benign flags.

Built for diagnostic and care-navigation workflows in Boston, we engineered an AI medical report analyzer powered by Python, FastAPI, React, Celery, and PostgreSQL. The platform transforms multi-format lab and imaging reports into verified, unit-normalized biomarker timelines paired with plain-language clinical summaries where every statement clicks straight back to its highlighted line on the original PDF.

Diagnostic Interpretation Gaps

Analyzing real-world diagnostic packets from regional reference laboratories and hospital portals exposed four technical hurdles:

  • Inconsistent analyte naming and units: The same biomarker appeared under dozens of abbreviations across clinics, mixing mg/dL, mmol/L, and µmol/L with varying laboratory-specific reference intervals.
  • Multi-column table alignment errors: Standard text scrapers scrambled multi-page comprehensive metabolic panels, pairing yesterday's reference range with today's numeric result.
  • Unverifiable AI prose: Naive generative wrappers frequently fabricated normal ranges or paraphrased findings inaccurately when faced with borderline results or OCR noise.
  • Siloed PDF attachments: Static document viewers forced clinicians and patients to open five separate files sequentially rather than viewing a unified longitudinal curve.

Architectural Strategy

We separated deterministic numeric extraction from probabilistic narrative synthesis. First, Python layout-aware OCR pipelines and geometric table parsers reconstruct structured lab rows anchored to exact page numbers and (x, y) coordinates. Next, a clinical normalization engine resolves analyte synonyms and converts units deterministically without involving any language model.

Only after structured records pass schema and range validation do constrained LLM APIs generate clinician-facing bullet digests or patient-friendly explanations—and every generated sentence must cite structured extraction IDs checked programmatically before display in React.

Core Capabilities

  • Multi-Format Diagnostic Ingestion: Parses native clinical PDFs, scanned lab printouts, and mobile captures of blood panels, urinalysis, and imaging impressions.
  • Canonical Biomarker & Unit Normalization: Maps variant test names to standardized clinical codes and converts units cleanly so multi-year charts compare apples to apples.
  • Longitudinal Trend & Delta Highlighting: Graphs biomarkers over time alongside lab-specific reference bands, surfacing clinically meaningful shifts across encounters.
  • Citation-Anchored Split-Pane Viewer: Displays structured tables and AI summaries alongside the original PDF canvas in React, auto-scrolling and highlighting source boxes on click.
  • Dual-Audience Summarization: Produces concise technical digests for physicians and jargon-translated, non-alarmist preparation notes for patients awaiting follow-up visits.

Technical Architecture

Clients upload diagnostic files to encrypted object storage via FastAPI pre-signed URLs. FastAPI records document state in PostgreSQL and enqueues an asynchronous Celery pipeline. Workers rasterize pages, execute layout OCR, normalize biomarkers, run de-identified LLM summarization over BAA-compliant endpoints, verify citation integrity, and push live readiness events to the React viewer.

Flow: Encrypted PDF Upload (FastAPI) → Celery Compute Queue → Layout OCR & Table Parser → Deterministic Unit & LOINC Normalizer → De-Identified LLM Summary & Verifier → PostgreSQL Biomarker Store → React Cited Viewer

Isolating OCR and LLM verification inside staged Celery tasks allows granular retries on transient API blips without re-running expensive image rasterization.

Technology Stack

Category Technology detail
API & Validation Tier Python FastAPI serving pre-signed upload endpoints, FHIR-aligned schemas, and summary APIs
Document & OCR Pipeline Layout-aware OCR and table reconstruction extracting lab rows, flags, and bounding boxes
Clinical Normalization Deterministic Python engine mapping analyte aliases and converting SI/US reference units
AI Synthesis Layer Constrained LLM APIs generating structured, citation-grounded plain-language explanations
Relational Data Store PostgreSQL storing normalized biomarker series, report provenance, and audit events
Async Processing Celery task workers orchestrating page rasterization, OCR, normalization, and validation
Diagnostic Viewer UI React and TypeScript split-screen PDF canvas paired with longitudinal biomarker trend charts
Encrypted File Vault KMS-encrypted object storage retaining original diagnostic PDFs and de-identified text views
Guardrail Verifier Post-generation schema and numeric verification checks matching LLM claims to extracted rows

Engineering Trade-offs & Solutions

Engineering Challenge Solution & Trade-off
Letting an LLM parse numbers from raw PDF text invites silent transcription errors Restricted numeric extraction strictly to geometric OCR + rule-based table parsers and ran numeric parity checks against LLM summaries; increases parser ruleset maintenance while protecting clinical accuracy.
Sending full patient headers to external LLM endpoints creates HIPAA exposure Applied automated PHI redaction (names, DOB, MRN, addresses) prior to LLM API calls inside BAA-covered tenants, trading slight preprocessing latency for strict privacy minimization.
Overlapping OCR text in skewed faxed reports drops confidence on borderline digits Built confidence-threshold gating that flags low-certainty cells visually in React and omits uncertain metrics from automated summaries rather than guessing values.
Comparing historical labs with shifting reference intervals misleads trend plots Stored each test's original reference range alongside converted values in PostgreSQL rather than applying one global threshold, preserving historical clinical context.

PHI Protection & Clinical Guardrails

Handling US diagnostic records requires strict HIPAA-aligned safeguards across storage, inference, and display. Source PDFs reside in KMS-encrypted object buckets served exclusively via short-lived authenticated endpoints, while PostgreSQL encrypts sensitive patient identifiers and logs every report upload, review, and API export in append-only audit tables.

Equally critical are clinical safety guardrails inside the synthesis layer. System prompts and post-processing validators enforce non-diagnostic framing—explaining terminology and highlighting documented out-of-range flags without issuing autonomous treatment recommendations or inventing urgency scores not present in the source report. Whenever an analyte value fails numeric cross-checking against the parsed PostgreSQL table, the pipeline blocks automated summary output and surfaces the raw verified table row for human review.

Pipeline Latency & Batch Scalability

Diagnostic volume fluctuates heavily between individual patient uploads and clinic-wide historical chart backfills. To preserve fast turnaround for live portal users, Celery routes interactive single-report uploads onto high-priority compute queues while pacing multi-hundred-document archive migrations on dedicated background workers.

Page-level SHA-256 fingerprinting avoids redundant OCR passes on duplicated cover sheets or repeated cumulative lab printouts, while normalized biomarker rows are indexed by (patient_id, canonical_code, collected_at) in PostgreSQL so React longitudinal trend dashboards render instantaneously across years of accumulated panels.

Operational Outcomes

Combining deterministic clinical normalization with verifiable AI summarization reshaped how care teams and patients interact with diagnostic paperwork:

  • Trusted report verification: Clinicians and patients validate every summarized insight in one click against highlighted source coordinates rather than trusting opaque text blocks.
  • Unified multi-lab timelines: Automated alias resolution and unit conversion merge fragmented PDF attachments into coherent longitudinal biomarker views.
  • Clearer patient preparation: Jargon-translated explanations backed by verified numbers help patients formulate focused questions ahead of specialist consultations.
  • Safe, auditable AI execution: Strict PHI scrubbing, confidence gating, and deterministic parity checks keep generative components bounded within clinical compliance standards.

01 — Questions

asked about this kind of project

How do you prevent the AI model from misreading or hallucinating lab values?

Language models never read raw unparsed PDFs directly for numeric extraction. A deterministic OCR and table parser extracts every analyte value, unit, and reference interval with bounding coordinates first, and a post-generation verifier rejects any summary claim whose numeric value or citation ID does not match the parsed PostgreSQL record.

How does the system compare lab trends when two laboratories report different measurement units?

Extracted analyte labels map onto canonical clinical identifiers (LOINC-aligned codes) inside a deterministic Python conversion table. Values in conventional US units and SI units normalize automatically to a consistent target unit before plotting longitudinal trend charts.

How is Protected Health Information handled when calling external LLM APIs?

Reports pass through a pre-synthesis de-identification step that strips patient names, dates of birth, medical record numbers, and clinic addresses before narrative generation, operating strictly within BAA-covered private LLM API endpoints with zero data retention.

Why orchestrate ingestion with Celery workers instead of processing reports inside FastAPI requests?

Multi-page diagnostic packets with skewed scans require rasterization, layout OCR, table reconciliation, and verification passes that exceed safe HTTP timeouts. Celery decouples FastAPI upload responsiveness from compute-heavy extraction while allowing per-stage retries.

Can the platform summarize radiology or pathology prose alongside tabular blood panels?

Yes. A document classifier routes structured blood and metabolic panels through table-row extractors while routing unstructured radiology and histopathology narratives through section-aware chunking that preserves impressions, findings, and exact page citations.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.