FHIR Validation Service

A horizontally scalable FHIR resource validation service built with Vert.x, HAPI FHIR and PostgreSQL.

It validates FHIR resources (STU3, R4, R4B, R5) against the base specification, stored Implementation Guide (IG) packages and terminology servers, with a p95 latency of about 60 ms under sustained load (load tests).

📖 Read this guide as a website, with search and a dark mode: https://nazrulworld.github.io/fhir-validation-service/. It is published from this wiki automatically after every edit.

Key features

  • ✅ Validate FHIR resources against the base specification, IGs and terminology servers
  • 📦 Store IG packages by upload, from a package registry, or from an approved https URL; dependencies are resolved automatically
  • 🌐 Terminology checks against servers listed by the official HL7 terminology registry, set per IG context and overridable per request (tx, txMode)
  • 📄 Results as a JSON summary (default) or a FHIR OperationOutcome (Accept: application/fhir+json or application/fhir+xml)
  • ⚖️ Horizontal scaling: stateless instances share one PostgreSQL database
  • 🩺 Liveness, readiness and Prometheus metrics; graceful shutdown on SIGTERM
  • 🐳 Container images for x86_64 and arm64 on ghcr.io/nazrulworld/fhir-validation-service

With access control on (the default):

  • 🔐 API keys for everything: ADMIN keys for IG management, VALIDATE keys for validation
  • 🏢 Organisations own their IG packages and validator contexts, and choose whether to share them
  • 🚦 Rate limits per API key and per organisation, shared across instances

Setting FV_GLOBAL_DISABLED_ACL_SECURITY=true turns this off (public mode). No endpoint needs a key, everything created is owned by the system organisation and is always shareable, and validation sees shareable content only. See Turning access control off.

Pages

Reference (in the repository)

System requirements

  • Docker with Compose v2, or Java 17 or later with your own PostgreSQL
  • PostgreSQL 16 (the Compose setup provides it)
  • 4 GB of memory per instance by default; more for large IG sets (see FV_MEMORY_LIMIT in Configuration)
  • Maven, only to build from source

Quick start

mkdir fhir-validation && cd fhir-validation
curl -fsSLO https://github.com/nazrulworld/fhir-validation-service/releases/latest/download/compose.yaml
cat > .env <<EOF
FV_TAG=latest
PG_PASSWORD=$(openssl rand -hex 24)
FV_ENABLED_FHIR_VERSIONS=R4
FV_GLOBAL_DISABLED_ACL_SECURITY=true
EOF
docker compose pull
docker compose up -d --wait        # waits until the validator is ready (1-2 minutes on first start)
curl -fsS http://127.0.0.1:8880/health/readiness

curl -X POST http://127.0.0.1:8880/R4/validate \
  -H 'Content-Type: application/fhir+json' \
  --data '{"resourceType":"Patient","active":true}'

⚠️ This quick start runs in public mode: no endpoint needs a key. Use it only to try the service on your own machine. To run with API keys, follow the Installation Guide and read Turning access control off.

FV_TAG=latest follows the newest release. Pin an exact version (for example FV_TAG=1.0.0) for anything you keep running.

The answer is a JSON summary. To get a FHIR OperationOutcome instead, add -H 'Accept: application/fhir+json' (or application/fhir+xml).

Validate against an IG

You have to store an IG package and then include it for a FHIR version before you can validate against it. Including it builds its validator context once. Validation never builds a context, so naming an IG that is stored but not included is answered 400 ... is not included for R4; include it first.

# 1. Store the package and its dependencies from the package registry
curl -H 'Content-Type: application/json' \
  --data '{"name":"hl7.fhir.dk.core","version":"3.4.0"}' http://127.0.0.1:8880/igs/register

# 2. Include it for R4 (builds the validator context on every instance)
curl -H 'Content-Type: application/json' \
  --data '{"igPackageId":"hl7.fhir.dk.core","igPackageVersion":"3.4.0"}' http://127.0.0.1:8880/R4/validator

# 3. Validate against it. Write '#' as %23: an unencoded '#' is cut off by the client, and the bare
#    name then silently resolves to the highest included version.
curl -X POST 'http://127.0.0.1:8880/R4/validate?ig=hl7.fhir.dk.core%233.4.0' \
  -H 'Content-Type: application/fhir+json' \
  --data '{"resourceType":"Patient","active":true}'

With access control on, add -H "Authorization: Bearer $FV_ADMIN_API_KEY" to steps 1 and 2, and a VALIDATE or ADMIN key to step 3. If an IG set is too large for the instance's memory, including it is refused with 413 package-too-large; raise FV_MEMORY_LIMIT.

See the Installation Guide for the full steps, the other installation options, upgrades and backups, and the API Documentation for every endpoint.