Validating FHIR resources with the HAPI FHIR Instance Validator

The HAPI FHIR Instance Validator checks FHIR resources against core and profile StructureDefinitions and terminology. This page covers how to configure it, what it costs in performance, and what to confirm before rollout.

On this page

Validating FHIR resources with the HAPI FHIR Instance Validator: when teams need it

The HAPI FHIR Instance Validator checks FHIR resources against the core specification and against StructureDefinitions, such as those in the US Core implementation guide, and reports every failure as an OperationOutcome. Teams need it when a HAPI FHIR JPA server accepts data it cannot trust, or when they must show that stored or submitted resources conform to a profile such as US Core. Without validation, a server built on the JPA API will store anything that is syntactically parseable, including resources with missing required elements, wrong cardinality, unknown codes or values that break the profile a downstream consumer expects.

The validator checks structure, cardinality, profile conformance, terminology bindings and FHIRPath invariants. Terminology checks depend on which code systems and value sets the server can resolve, so a validator without the right terminology support will report failures or skip bindings that your data actually relies on. Confirm which terminology services and IG packages are loaded in each environment before you treat a pass as meaningful. Also confirm which FHIR versions your server runs, since the JPA server supports DSTU2, DSTU3, R4, R4B and R5 and validation rules differ between them.

The validator does not decide what your organization should accept. It has no opinion on whether a missing optional element matters clinically, whether legacy records that fail a new profile should be blocked, rejected, or migrated, or which profiles apply to which data senders. Those are governance decisions for the data owner, the compliance lead and the integration team. Plan them before you enable validation on writes, and agree how failures are reported back to senders, because the choice of where validation runs and what it costs at write time shapes every other decision in this topic.

Which validation configuration fits which server

Core-only validation checks a resource against the base FHIR definitions for its version, including structure, cardinality, data types and the base bindings the specification requires. It fits a development server, a proof-of-concept build, or an internal exchange where every consumer accepts base FHIR and no named implementation guide applies. Setup is small because no additional packages are installed beyond the FHIR version the server runs. Runtime overhead is the lowest of the four options because the validator has fewer definitions to resolve per write.

  • Fit: development servers, test environments and internal exchanges with no named profile requirement.
  • Setup: choose the FHIR version the server runs, with no profile packages to install or version.
  • Runtime: lowest overhead of the four options, with fewer definitions to load and evaluate.
  • Limit: a resource can pass core validation and still fail US Core or another guide, so a pass here does not prove conformance to a profile.

Before relying on this option, ask each data consumer whether it requires a named profile, because that answer decides whether core-only validation is enough.

Validation support modules and their trade-offs

This table compares the components that make up the validation support chain in the HAPI FHIR Instance Validator, by what each supplies, what it depends on and the operational risk it adds. Read each row as a question to answer for your deployment: which components you have enabled, where their content comes from, and what happens when that content is missing or changes between releases.

ComponentWhat it providesWhat it depends onOperational risk to plan for
Base specification contentCore FHIR resource definitions and base StructureDefinitions for the release you runVersion of the HAPI FHIR library matching your FHIR versionMismatch between library and data FHIR version causes false failures; confirm the pairing in the release docs
Snapshot generationExpands differential profiles into full snapshots so the validator can check element rulesLoaded StructureDefinitions, including base types and any profile they inherit fromProfiles that fail to snapshot can block validation of every resource they govern; test each IG load
In-memory terminologyAnswers code and value set checks from content loaded into the process at startupCode systems and value sets loaded into memory, usually from packages or resourcesMemory use grows with loaded content; restarts reload it, so confirm sizing before loading large code systems
JPA-backed terminologyAnswers code and value set checks from the terminology tables in the server databaseA populated database, uploaded terminology, and the JPA terminology services enabledDatabase load and latency on every code check; slow terminology queries slow every write that is validated
Package-loaded profilesMakes IG profiles available by installing implementation guide packages into the serverPackage sources, the package installation process, and matching IG and core versionsVersion drift across environments and profiles that change or are removed in later packages; pin versions and test upgrades
Terminology content for external code systemsSupports checks against code systems such as SNOMED CT, LOINC or ICD-10 where licensed content is loadedLicensed or freely available code system files and version choices made by your organizationLicensing limits and version mismatches; confirm distribution rights and which code system versions your data uses

Setting up the Instance Validator on a HAPI FHIR JPA server

This sequence takes a HAPI FHIR JPA server from a confirmed Java and release baseline to a validator that accepts known good resources and rejects known bad ones. Each step ends with a check, so problems surface before validation is switched on for real writes.

  1. Confirm the JDK and HAPI FHIR release

    The platform team confirms the Java Development Kit version on the build and runtime hosts and selects the HAPI FHIR release to run. HAPI FHIR 8.2.0 requires JDK 17, and v8.8.2 is the latest release supplied for this page, so the team should check the release notes for the version it pins. Confirm the chosen version against the upgrade notes if you are moving from an earlier release. Done when the JDK version reported on every build and runtime host matches the requirement for the pinned release, and the version is recorded in your configuration baseline.

  2. Confirm the FHIR version and IG scope

    Decide which FHIR versions the server must validate against and which implementation guides apply, such as US Core for a given FHIR release. The architect and the compliance lead should agree this list in writing, because each guide pins a specific FHIR version and its own dependencies. Ask the team responsible for your interoperability requirements to confirm the list. Done when you have a short register of core versions and IG packages with their versions, and every item is traceable to a requirement.

  3. Configure the validation support chain

    The developer or platform engineer configures the validation support modules that the Instance Validator uses to resolve StructureDefinitions, ValueSets, CodeSystems and terminology. The chain order matters: the module that supplies profiles and the module that supplies terminology must both be present, and the order determines which definition wins when two sources disagree. Record each module and its position in the chain. Done when a test startup logs the active chain and a simple lookup of a core StructureDefinition resolves from the expected source.

  4. Load the required IG packages

    The platform team installs the implementation guide packages identified in the earlier step into the server, using the method your deployment supports, and pins each package to the version in your register. Confirm that dependent packages load as well, since a profile often references terminology or extensions from another package. Keep the same versions in every environment. Done when the server lists each expected package and version, and a profile from each package can be retrieved by its canonical URL.

  5. Validate known good sample resources

    The test owner prepares a small set of sample resources that conform to the core specification and to each target profile, including resources that exercise bindings and extensions. Each sample is submitted to the validator, and the test owner expects an outcome with no error-severity issues. Warnings are reviewed and either accepted or fixed with a recorded reason. Done when every good sample passes, and the results are saved as the baseline for later regression runs.

  6. Validate known bad sample resources

    The same owner prepares deliberately invalid resources: a missing required element, a value outside a required binding, a wrong cardinality and a profile slice that does not match. The validator should report an error for each defect, pointing to the element and the rule it breaks. A silent pass on any bad sample means the chain, a package or a profile binding is not loaded as expected, and the step should be repeated after fixing the cause. Done when each bad sample fails with an error that names the expected rule.

  7. Verify the outcome and record the baseline

    The architect reviews the results from both sample sets together and checks that the validator reports the same outcomes after a server restart and on a second node if you run more than one. Compare the issue messages against the baseline and record the server version, Java version, package versions and chain order. Done when the good samples pass, the bad samples fail for the right reasons, and the configuration is recorded so that any future change can be tested against the same baseline.

How a write moves through the validator and the repository

A client's HTTP write enters the HAPI FHIR server's request layer, where the Instance Validator checks the resource against the core specification, loaded profile packages and terminology services. A rejected resource returns an OperationOutcome and never reaches the database. Only an accepted resource is written through the JPA repository, so the trust boundary sits between the HTTP layer and stored data. Check which validation interceptors are registered, because request validation and repository validation can behave differently.

Accepted writes reach the database only after the validator passes them.

Questions teams ask before validating every FHIR write

How much latency does validating every FHIR write add to a HAPI FHIR server?

The added latency depends on the resource, the profiles applied and how warm the validation support is, so no single figure applies. Validation runs the Instance Validator on each write, which means more work per request than a plain create or update. Measure it on your own hardware with realistic payloads and your real profile set before deciding. Ask any partner to include a load test with your sample resources in the written scope, and ask for the measured p95 write time with validation on and off.

What drives the cost of validating every write?

Four factors drive most of the cost: the number and size of profiles and implementation guides loaded, the terminology checks enabled, the volume and shape of your writes, and how much memory and CPU the server has. Large IG sets with many dependencies take longer to load and use more memory, and terminology checks against external code systems can add remote calls. Write volume matters because every write pays the validation cost. Ask for a sizing estimate that names each of these inputs.

Can our own engineers configure the Instance Validator internally?

Many teams with Java and FHIR experience can configure the validation support modules and load IG packages internally, especially if they already run the HAPI FHIR JPA server. The harder work is deciding which profiles are enforced on writes, handling legacy data that fails, and testing terminology behavior against the code systems you license. If your team has no FHIR validation experience, the decisions and test cases take longer than the configuration itself. Confirm your team's skills against the setup steps in the HAPI FHIR documentation before you commit.

How long does a first validation setup take?

Duration depends mainly on how many profiles you enforce, how many national or industry guides they depend on, and how much terminology you need to check. A core-only setup with a few profiles is much shorter than a multi-guide setup with licensed code systems. No duration is stated here because none is supplied. Ask any partner for a timeline broken into profile loading, terminology setup, test data validation, performance testing and cutover, with the assumptions for each step.

What does the work need from our side before it starts?

You need to confirm the exact IG versions your organization must follow, because a profile version change can alter what passes validation. You also need the terminology licenses for any SNOMED CT, LOINC or other code systems you check, and access to licensed content for the server to load. Sample data is essential: representative resources, including known-bad examples and legacy records, let you test accept and reject behavior before go-live. Ask your partner to list these inputs and the owner for each one in the written scope.

What does an outside partner's scope usually cover for validation?

A partner's scope normally covers installing the validator configuration, loading the agreed profiles and guides, setting up terminology checks, testing accept and reject behavior with your data, measuring write performance and documenting the setup for your operators. DeployOpen implements, customizes, hardens, documents and supports self-hosted open-source platforms in your own infrastructure, and most engagements are fixed-scope with deliverables agreed in writing before work starts. DeployOpen does not issue compliance attestations, so evidence should be reviewed by your auditors.

When is it worth bringing in an outside partner for FHIR validation?

A partner is worth considering when your profiles span several guides, when you must check licensed terminology at write time, when legacy data will fail validation at scale, or when the server is a shared resource that many systems write to. It is also worth it when your team lacks capacity to test performance and failure modes before go-live. Ask any partner for a written scope that names the profiles, terminology, performance targets and test data before you compare quotes.

Security and operational risks of strict validation

Strict validation protects data quality, but it also creates new exposure: error messages, validation cost, package sources and logs can each leak information or degrade service. The cards below cover the risks to review before you turn validation on for every write.

Error messages revealing profile internals

Validation failures return OperationOutcome messages that name profiles, extensions, slices and sometimes server paths or configuration. Anyone who can submit a payload can use these messages to map which rules your server enforces. Review what the response contains for external callers, and return a generic outcome to untrusted clients while keeping full detail in server logs for your own team.

HAPI FHIR security docs

Denial of service from large bundles

Validating a large transaction or batch bundle means validating every entry against its profiles, which costs CPU and memory in proportion to the bundle size and the profile complexity. A few oversized requests can slow the server for all users. Set request size limits at the reverse proxy and in the server, and test representative and worst-case bundle sizes before go-live.

Stale implementation guide and terminology content

A validator checks data against the StructureDefinitions, ValueSets and CodeSystems it has loaded. If those packages lag behind the guide your senders follow, valid data may be rejected or invalid data accepted. Record which IG and terminology versions are installed in each environment, and schedule a review whenever a guide or code system publishes a new release.

Uncontrolled package sources

Profiles and terminology reach the server as packages, and a package fetched from an arbitrary location can change what the server accepts. Only install packages from sources your team has approved, and restrict which download URLs the server may call. The package download restrictions topic covers the allow list, private network rules and redirect handling in detail.

Patient data in rejected payload logs

Logging the body of a rejected request makes the log store a copy of patient data, often outside the access controls that protect the database. Log the resource type, the validation message and a correlation ID, and keep payload capture disabled or restricted to a short, approved debugging window. Confirm retention and access rules for the log platform with your privacy team.

Validator and profile version drift

Upgrading the HAPI FHIR library can change validator behavior, and a new IG version can add or tighten constraints. When the two move at different times, a server may accept data in one environment and reject it in another. Pin the library and IG versions together, promote them through the same environments, and rerun validation of a known test set after every upgrade.

What validation changes for data senders and your operations team

Strict validation moves the cost of a bad resource from the systems that consume it to the systems that send it. When the server runs the Instance Validator against core and profile StructureDefinitions on every write, a sender that posts a resource missing a required US Core element, or carrying a code outside the bound value set, gets a rejection at the point of submission instead of a silent defect discovered weeks later in a downstream report. That is the goal, but it changes the sender's job. Each sending system needs to read the OperationOutcome returned on failure, map each issue's severity and location back to the field in its own data model, and decide whether to retry, fix the mapping or escalate to the owner of the source data. Ask every sender which of these paths they have built before go-live, and test one deliberately invalid resource per profile with them.

Your operations team inherits a different set of duties. Validator failures become a monitored signal rather than an occasional support ticket, so someone must watch rejection rates by sender, by profile and by issue code, and notice when a single source starts failing after an upstream change. Package updates add another recurring task: the profile and terminology packages loaded into the server must stay in step across development, test and production, and a new IG version can turn previously accepted data into failures. Plan a release process that tests the candidate package against a sample of known-good and known-bad resources before the server is changed. Validation also has a performance cost that grows with resource size and profile complexity, so operations should track write latency before and after each change and confirm the sizing with the vendor's sizing guidance and your own load tests.

Decide early who owns the rules when a sender disputes a rejection. The server operator can show the exact validation message and the profile version that produced it, but only the team that maintains the profile can say whether the rule is correct for the use case. Agree on a short path for disputes, including who can approve a temporary relaxation, how long it may last, and how the relaxation is recorded so that it is removed rather than forgotten. Document the validator and package versions in your change records, because an auditor or a partner investigating a data quality issue will ask which rules were in force on a given date.

How DeployOpen works on this

DeployOpen treats HAPI FHIR validation as a written scope covering which profiles, validation modules and write paths are in play before any configuration changes. The work is delivered inside your own infrastructure, with the validation behavior tested and documented so your team can run it afterward.

How we scope

  • Inventory the FHIR versions, resource types and profiles your server must accept and reject.
  • Agree in writing which StructureDefinitions, IG packages and terminology sources the validator will load.
  • Record whether validation applies to HTTP requests, stored resources or both, with the latency limit you accept.
  • Confirm the fixed-scope deliverables and timeline in writing before any work starts.

How we build

  • Configure the validation support modules and package sources in your HAPI FHIR JPA server deployment.
  • Wire the validating interceptors into the server with settings matched to the agreed write paths.
  • Test valid and invalid sample resources against core and profile StructureDefinitions in a non-production environment.
  • Measure the write-time cost of validation under representative load and record the results for review.

How we hand over

  • Deliver configuration files, interceptor settings and the package versions used in each environment.
  • Document the validation rules, error handling and known terminology check limits for your team.
  • Provide a runbook for adding IG packages, reloading profiles and reviewing rejected resources.
  • Walk your engineers through the test cases so they can repeat the checks after changes.

How we support

  • Available as a retainer for ongoing profile updates, upgrades and continuous validation testing.
  • Retesting after HAPI FHIR version changes, since validator behavior can shift between releases.
  • Review of validation failures from data senders and adjustments to profiles or settings where agreed.
  • Support scope, response expectations and fees are set out in the written agreement, not assumed.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.