FHIR validation means verifying that a resource is both well-formed and conforms to the FHIR specification. To play with the details of FHIR resource validation, I created a basic FHIR validator that you can try out below.
FHIR (Fast Healthcare Interoperability Resources) is a widely adopted standard for exchanging healthcare information electronically. FHIR-enabled interoperability, in turn, reduces the cost and complexity of integrating healthcare systems and applications.
In FHIR, every clinical concept is represented as a separate resource type. Examples of FHIR resources are Patient, Observation, and MedicationRequest.
FHIR resources can have complex structures, even if you don't consider profiling and extensions. This complexity makes it important to be able to validate FHIR resources, i.e. ensure that they conform to the specification.
The FHIR framework is designed to be easy to implement, use, extend, and customize, with the ultimate goal of improving the interoperability of healthcare systems. Beyond that, it's also designed to allow you to programmatically check if any FHIR resource conforms to the specification through FHIR validation.
The programmatic aspect of FHIR validation means that the rules and constraints of the FHIR specification can be checked automatically. This is only possible because the FHIR specification defines these rules and constraints in a machine-readable/computable way.
Each FHIR resource has a defined model/structure that is outlined in the FHIR specification. This structure is formally defined using FHIR structure definition resources. In essence, FHIR validation involves checking conformance to the relevant structure definitions.
The FHIR spec includes a lot of content on structure definitions and other conformance/infrastucture resources. In short, structure definitions capture the rules and constraints that apply to a resource type. These rules include but are not limited to cardinalities, value domains, and terminology bindings.
FHIR is a complex standard, and there are multiple aspects to consider when validating FHIR resources. It can take time to fully understand the standard and its conformance checking mechanisms.
All this means that validating FHIR resources programmatically from scratch is a not a trivial task. Thankfully, FHIR comes with a reference implementation of a validator to support this. The brains of that implementation (the core validation logic) sit in the org.hl7.fhir.validation.ValidationEngine class in the HAPI FHIR library.
I went deep into the specifics of conformance checking in FHIR early on to also see how it measures up to other standards. In the process, I started working on a simple FHIR validator that leverages the HAPI FHIR library.
As a result, I've created an online FHIR validator that you can try out below. I'm looking to add support for validating against custom profiles and terminology servers in the future.
Made by Anton Vasetenkov.
If you want to say hi, you can reach me on LinkedIn or via email. If you like my work, you can support me by buying me a coffee.