Inferensys

Glossary

FHIRPath

FHIRPath is a path-based navigation and extraction language used in FHIR to query and compute expressions on FHIR data, for use in invariants, search parameters, and slicing.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
PATH-BASED EXTRACTION

What is FHIRPath?

FHIRPath is a path-based navigation and extraction language used to query and compute expressions on FHIR data, for use in invariants, search parameters, and slicing.

FHIRPath is a domain-specific, path-based expression language designed to traverse and extract data from FHIR resources. It provides a standard, implementation-independent syntax for navigating the hierarchical structure of a resource, filtering collections, and computing scalar values. The language is formally defined as part of the FHIR specification and is used wherever a computable expression is required to reference a specific data element.

Its primary applications include defining invariants in StructureDefinition profiles, constructing search parameter expressions, and specifying slicing discriminator paths. FHIRPath expressions evaluate against a resource instance to return a collection of matching nodes, enabling precise, programmatic validation and querying without relying on external scripting languages.

EXPRESSION LANGUAGE

Key Features of FHIRPath

FHIRPath is a path-based navigation and extraction language used to query and compute expressions on FHIR data. It is essential for defining invariants, search parameters, and slicing logic within FHIR profiles and implementation guides.

01

Path-Based Navigation

FHIRPath uses a dot-notation syntax to traverse the hierarchical structure of FHIR resources. It allows developers to navigate from a root resource into nested elements, backbone elements, and data types.

  • Navigate to Patient.name.given to extract first names
  • Traverse collections using Condition.stage.summary
  • Access deeply nested extensions with .extension.where(url='...').value

The language treats all paths as collections, meaning a single path can return zero, one, or multiple values depending on cardinality.

02

Invariant Constraints

FHIRPath is the standard language for defining formal constraints (invariants) within FHIR profiles. These constraints enforce business rules that go beyond simple cardinality and terminology bindings.

  • Define rules like start <= end on a Period element
  • Enforce co-occurrence: condition.exists() implies severity.exists()
  • Validate cross-element logic within a single resource

Invariants are expressed in the constraint element of a profile's ElementDefinition, providing machine-readable validation rules.

03

Collection Filtering and Projection

FHIRPath provides powerful functions for filtering and transforming collections of elements. The where() and select() functions enable SQL-like querying directly within FHIR expressions.

  • Filter by criteria: Patient.identifier.where(type.coding.code = 'MR')
  • Project specific properties: Observation.component.select(code)
  • Combine with exists(), all(), and count() for cardinality checks

These functions are critical for slicing discriminators and search parameter expressions.

04

Type-Specific Operators

FHIRPath includes operators tailored to FHIR data types, enabling precise manipulation of clinical and administrative data without custom parsing logic.

  • String operators: startsWith(), contains(), matches(regex)
  • Quantity math: (value + 10) > 50 'mg' for dose comparisons
  • Date arithmetic: today() - birthDate > 18 years for age checks
  • Coding equality: code.memberOf('http://snomed.info/sct?fhir_vs=isa/404684003')

This type-awareness makes FHIRPath uniquely suited for healthcare data validation.

05

Search Parameter Definition

FHIRPath is used to define custom search parameters in FHIR profiles and implementation guides. The expression specifies exactly which element a search parameter indexes.

  • Define a search on Patient.extension.where(url='...').value.ofType(CodeableConcept)
  • Enable composite parameters by combining multiple paths
  • Support chained and reverse chained searches through path expressions

This allows implementers to expose domain-specific query capabilities beyond the base FHIR search parameters.

06

Slicing Discriminators

FHIRPath expressions serve as discriminators for slicing, the mechanism that differentiates between repeated elements in a profile. The discriminator path tells validators which element value distinguishes one slice from another.

  • Slice Observation.component by code using path code
  • Differentiate Patient.identifier slices by system and type
  • Support multi-key slicing with compound discriminator paths

This is fundamental to profiling patterns like US Core Blood Pressure, where systolic and diastolic components are distinct slices.

FHIRPATH ESSENTIALS

Frequently Asked Questions

Clear, technical answers to the most common questions about navigating and extracting data from FHIR resources using the standard path-based expression language.

FHIRPath is a path-based navigation and extraction language designed specifically for traversing and computing expressions on FHIR data. It operates on the tree-structured object model of a FHIR resource, allowing developers to navigate from a root node down through nested elements, filter collections, and extract specific values. The language is evaluated against a context—typically a FHIR resource or a specific element within one—and returns a collection of values. FHIRPath is used extensively in invariants (constraints defined in StructureDefinition), search parameter expressions, and slicing discriminator paths to define rules that must be true for a resource to be valid. Its syntax is derived from XPath but adapted for the JSON-centric, strongly-typed world of FHIR, supporting functions like exists(), where(), select(), and aggregate() to manipulate collections of complex data types.

PRACTICAL APPLICATIONS

Common FHIRPath Use Cases

FHIRPath is a path-based navigation and extraction language used to query and compute expressions on FHIR data. It is essential for defining invariants, search parameters, and slicing logic within FHIR profiles and implementation guides.

COMPARATIVE ANALYSIS

FHIRPath vs. Similar Query Languages

A feature comparison of FHIRPath against other path-based and query languages used in healthcare and general-purpose data contexts.

FeatureFHIRPathXPath 3.1JSONPath

Primary Design Purpose

Navigating and extracting data from FHIR resources; evaluating invariants and search parameters

Navigating and querying XML documents

Navigating and extracting data from JSON documents

Native Data Model

FHIR tree of resources, elements, and data types

XML Infoset (elements, attributes, text nodes)

JSON object and array structures

Expression Context

Rooted in a FHIR resource; context is a collection of nodes

Rooted in an XML document; context is a sequence of nodes

Rooted in a JSON value; context is a nodelist

Collection Handling

Implicit flattening and collection-centric functions (e.g., where(), select())

Explicit sequence manipulation; no implicit flattening

Limited collection operations; primarily array slicing and filtering

Terminology Awareness

Type System

FHIR primitive and complex data types (e.g., dateTime, Quantity, CodeableConcept)

XML Schema Definition types (e.g., xs:string, xs:integer)

JSON types (string, number, boolean, object, array, null)

Invariant Evaluation

Standardized by

HL7 International

W3C

IETF (proposed standard RFC 9535)

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.