All work

03 / 04Case study · 2024 · Data · Healthcare

Healthcare Data Processing Platform

HIPAA-compliant HL7 ingestion, anonymization, and multi-tenant portal

Role
End-to-end (Frontend, Backend Pipeline, Anonymization, Infrastructure)
Year
2024
Type
Two-zone platform: air-gapped PHI processing + public portal
Stack
Next.jsPythonFastAPIHL7FHIRPostgreSQL
Healthcare Data Dashboard

Overview

This platform enables Health Information Exchanges (HIEs) to ingest raw HL7 v2 data, clean and validate it, anonymize all PHI per HIPAA Safe Harbor standards, and deliver anonymized datasets to customer-facing portals and APIs. The system uses a two-zone architecture: an air-gapped node for PHI processing and a public-facing orchestrator for the web app, dashboards, and exports. It supports multi-tenant isolation, batch job tracking, quality reports, and multiple export formats (clean HL7, FHIR R4, OMOP CSV).

The Challenge

Dozens of hospitals, dozens of formats, zero room for PHI leaks.

HIEs aggregate health data from dozens of hospitals and clinics, but each facility sends data in different formats with inconsistent quality. Raw HL7 v2 messages often contain duplicates, malformed fields, missing required data, and inconsistent coding systems. Before sharing data with researchers or payers, PHI must be removed or anonymized—a process that, if done manually, is slow and error-prone. The goal was to build an automated pipeline that could ingest, parse, clean, anonymize, and export health data at scale, while maintaining strict HIPAA compliance and multi-tenant isolation.

Approach

Four decisions that shaped the system.

  1. 01Built two-zone architecture (air-gapped PHI processing + anonymized customer portal) for HIPAA compliance
  2. 02Designed HL7 v2 ingestion pipeline with parsing, cleaning, FHIR R4 conversion, and OMOP CSV export
  3. 03Implemented HIPAA Safe Harbor anonymization library (date shifting, ID hashing, geo obfuscation, PHI detection)
  4. 04Created multi-tenant SaaS portal with RLS for org-level data isolation

Technical Architecture

Technical stack

Frontend

  • Next.js 16 (App Router)
  • React 19
  • TypeScript
  • TailwindCSS v4
  • shadcn/ui
  • Recharts

Backend & Pipeline

  • Python 3.11
  • FastAPI
  • python-hl7 (HL7 v2 parsing)
  • fhir.resources (FHIR R4)
  • pandas, numpy

Data & Storage

  • PostgreSQL (Supabase)
  • Row-Level Security (RLS)
  • Dual-zone DBs (PHI + Anonymized)

Infrastructure

  • Docker (Backend + DB)
  • Air-gapped Module1 (PHI)
  • Orchestrator (Public Portal)
  • SCP file transfer

Integrations

  • Clerk (Auth)
  • Knock (Notifications)
  • Stripe (Billing)
  • Mapbox (Geo viz)

Key Features Built

What was built

  • 01HL7 v2 file/ZIP upload with deduplication by SHA-256 hash and batch job tracking
  • 02Fast bulk loader: Batched INSERT for 100K+ messages with sub-second writes
  • 03HL7 parsing: Extract demographics, encounters, observations, diagnoses, medications, allergies, procedures
  • 04HIPAA Safe Harbor anonymization: Date shifting (deterministic per patient), ID hashing (SHA-256 + salt), ZIP 3-digit masking, synthetic names, PHI detection/validation, audit logs
  • 05FHIR R4 bundle generation: Convert HL7 to FHIR resources (Patient, Encounter, Observation, etc.)
  • 06OMOP CSV export: Map cleaned data to OMOP Common Data Model for research
  • 07Multi-tenant portal: Organizations, hospitals, users, roles, permissions with RLS enforcement
  • 08Quality dashboards: Data completeness, validation errors, processing metrics
  • 09API: REST endpoints for job status, record retrieval, and export downloads
  • 10File watcher service: Monitors delivery folder, transfers via SCP to air-gapped node, creates batch jobs

Platform Screenshots

Inside the product

Hard problems

Where it got difficult, and what fixed it.

Challenge

HL7 parsing failures on malformed segments.

Solution

Built fault-tolerant parser with fallback extraction; logged errors for manual review.

Challenge

Slow batch inserts for 100K+ messages.

Solution

Implemented batched INSERT with psycopg2 execute_batch; reduced ingestion time from minutes to seconds.

Challenge

Ensuring deterministic anonymization (same patient → same anonymized ID across batches).

Solution

Used HMAC-SHA256 with org-specific salt; stored mapping (never synced).

Challenge

Date shifting while preserving temporal relationships.

Solution

Applied consistent shift per patient; validated that event order remained intact.

Results

Research data, without the PHI.

100K+HL7 messages per batch
~0%Anonymization errors, audited
<5 minSync latency, air-gap to portal
<200msAPI response, p95
  • 01Processed 100K+ HL7 messages per batch with automated deduplication
  • 02Reduced anonymization errors to near-zero with deterministic algorithms and audit logs
  • 03Enabled secure data sharing for research without exposing PHI