Delivered remotely for a business based in Utrecht, Netherlands. Names withheld by agreement.
Project Overview
Clinical continuity breaks down at institutional boundaries. A general practitioner in Utrecht may update an antihypertensive dosage on Monday, a regional diagnostic lab posts elevated potassium on Wednesday, and an urgent care physician sees the patient on Friday with only half the picture. Legacy point-to-point HL7 feeds and scanned PDF referrals leave clinicians guessing which medication list is current.
We architected a digital health records platform using Java, PostgreSQL, and HL7 FHIR R4 to unify fragmented clinical artifacts into a single standards-based longitudinal repository. The platform validates incoming clinical resources against regional implementation profiles, enforces granular patient consent on every query, and exposes fast RESTful search and React timeline views across participating care providers.
Interoperability & Data Integrity Bottlenecks
Regional care networks face four recurring obstacles when consolidating patient histories across autonomous EHR vendors:
- Schema drift across clinics: Each hospital and GP system exports slightly different extensions, units, and local code systems that break brittle relational ETL pipelines.
- Coarse access controls: Binary all-access permissions fail privacy standards when patients consent to sharing allergy and medication summaries while restricting sensitive encounter notes.
- Unindexed search latency: Naive document stores slow to a crawl on chained clinical queries such as retrieving recent
Observationlab panels alongside linkedMedicationRequestrecords. - Mutable history gaps: Overwriting corrected diagnoses erases forensic evidence of what clinical data informed an earlier prescribing decision.
Architectural Strategy
The design centers on canonical FHIR R4 storage backed by relational search indexing and policy-enforced mediation. Rather than inventing a proprietary clinical database schema and translating back and forth on every API call, Java and HAPI FHIR treat the FHIR R4 resource model as the native domain boundary.
Every Patient, Encounter, Condition, AllergyIntolerance, Observation, and DocumentReference enters through a validation pipeline. Resources are checked against regional Dutch profile rules, persisted in versioned PostgreSQL tables combining full JSONB payloads with extracted search tokens, and published as domain events onto Kafka so downstream care alerts react in near real time.
Core Capabilities
- Standards-Compliant FHIR R4 Gateway: Full CRUD, version history (
_history), conditional updates, and atomic transaction bundles supporting_includeand_revincludegraph queries. - Profile & Terminology Validation: Enforces required elements, UCUM units, and SNOMED CT, LOINC, and ATC coding bindings at ingestion time with clear
OperationOutcomediagnostics. - Consent-Aware Query Mediation: Evaluates active FHIR
Consentresources and practitioner role claims on every search response, stripping unauthorized compartments cleanly. - Enterprise Master Patient Index: Reconciles cross-clinic identities via deterministic BSN/national-ID rules and fuzzy demographic matching while preserving source-system provenance.
- Clinician Longitudinal Timeline: A clean React workspace presenting active problems, allergies, medication reconciliations, and trended lab observations without raw JSON noise.
- Break-the-Glass Emergency Access: Allows emergency clinicians to elevate access with a mandatory clinical justification, immediately notifying privacy officers via Kafka audit alerts.
Technical Architecture
Incoming requests from clinic connectors and the React clinician portal terminate at an mTLS API gateway before reaching Spring Boot and HAPI FHIR resource providers. After Keycloak JWT introspection and SMART on FHIR scope verification, the query planner executes indexed lookups in PostgreSQL, applies compartment consent filters, and records an immutable AuditEvent.
Flow: External EHR / React Portal → Keycloak SMART OIDC → Java / Spring Boot Gateway → HAPI FHIR Profile Validator → PostgreSQL (JSONB + Search Index Tables) → Consent Filter → Kafka Clinical Event Bus & Audit Ledger
Separating raw resource JSONB blobs from typed search-parameter tables (hfj_spidx_token, hfj_spidx_date, hfj_spidx_string) lets PostgreSQL execute B-tree and GIN index scans across millions of clinical observations while returning exact, unmodified FHIR JSON payloads.
Technology Stack
| Category | Technology detail |
|---|---|
| Core Service Runtime | Java 21 with Spring Boot exposing RESTful clinical workflows and background validators |
| Interoperability Engine | HAPI FHIR R4 server framework enforcing StructureDefinitions and search semantics |
| Primary Data Store | PostgreSQL storing versioned FHIR JSONB payloads alongside extracted search-index tables |
| Identity & Access | Keycloak OIDC/OAuth2 issuer supporting SMART on FHIR scopes and practitioner roles |
| Event Backbone | Apache Kafka propagating clinical resource mutations to care-coordination subscribers |
| Clinician Portal | React TypeScript timeline viewer rendering allergies, meds, encounters, and labs |
| Terminology Validation | Embedded SNOMED CT, LOINC, and ICD code-system validation caches |
| Audit & Provenance | Append-only PostgreSQL AuditEvent and Provenance partitions with cryptographic chaining |
| Container Deployment | Kubernetes deployments with mTLS service-to-service communication and zero-downtime migrations |
Engineering Trade-offs & Solutions
| Engineering Challenge | Solution & Trade-off |
|---|---|
| Full FHIR validation on every write adds CPU latency during bulk clinic backfills | Loaded pre-compiled StructureDefinitions and local terminology caches in Java heap, plus a fast-path profile mode for trusted internal batch loaders; trades higher JVM memory footprint for predictable ingestion throughput. |
| Chained FHIR search parameters generate expensive SQL joins on large Observation tables | Materialized composite index columns (patient_id, code, effective_date) and enforced bounded pagination with _total=accurate opt-in; restricts arbitrary unindexed wildcard searches while keeping clinician timelines sub-second. |
| Fine-grained consent filtering risks leaking resource existence via total search counts | Evaluated consent predicates inside the SQL query plan via tenant/compartment joins before counting results, avoiding post-fetch pagination drift at the cost of tighter query builder complexity. |
| Cross-clinic updates can arrive out of chronological order | Required source-system logical timestamps and conditional If-Match ETag concurrency headers on updates, routing stale writes to a reconciliation queue rather than silently overwriting newer clinical observations. |
Security & Auditability
Healthcare repositories demand verifiable accountability for every read and write. Every external API call authenticates using short-lived OAuth2 access tokens issued by Keycloak, scoped down to specific FHIR resource compartments (patient/Observation.read, user/MedicationRequest.write) and bound to organizational certificates over mutual TLS.
All resource reads, searches, exports, and break-the-glass overrides emit structured AuditEvent records into monthly range-partitioned PostgreSQL tables. Database roles enforce append-only privileges on audit partitions, while periodic hash-chain digests let compliance officers prove no historical access log was altered or truncated.
Performance & Interoperability Scale
Clinical workloads exhibit sharp morning peaks when outpatient clinics open and overnight spikes during batch lab result imports. Connection pooling via HikariCP, read replicas dedicated to heavy analytical and population-health FHIR $export bulk jobs, and in-memory caching of immutable CodeSystem and ValueSet expansions protect interactive clinician response times.
Asynchronous Kafka topics decouple slow downstream consumers—such as referral PDF generators and external notification gateways—from synchronous FHIR API responses. Clinics committing an updated DiagnosticReport receive immediate confirmation once PostgreSQL commits the transaction, while care-team notifications dispatch independently.
Operational Outcomes
Consolidating disparate regional feeds behind a strict Java, PostgreSQL, and HL7 FHIR R4 core transformed cross-organization care coordination:
- Unified clinical context: Physicians inspect reconciled allergies, active prescriptions, and longitudinal lab trends in one view without telephoning referring clinics for faxed charts.
- Enforced patient privacy: Granular consent rules follow every query automatically, building patient trust while supporting emergency break-the-glass accountability.
- Clean vendor onboarding: New diagnostic centers and GP software vendors integrate using standard FHIR R4 profiles and actionable validation feedback rather than bespoke ETL scripts.
- Forensic clinical traceability: Immutable resource versioning and chained audit trails satisfy regional healthcare governance inspections effortlessly.