Skip to content

Examples

This section contains hands-on examples that demonstrate how to use the FHIRPath Go library in real-world scenarios. Each page includes complete, runnable Go code alongside realistic FHIR® JSON resources so you can copy, paste, and adapt them to your own projects.

What You Will Find Here

PageDescription
Basic QueriesExtract demographics, navigate nested structures, work with arrays, and use path syntax
Filtering DataUse where(), select(), exists(), count(), and empty() to filter and project FHIR® data
FHIR® ValidationEvaluate FHIR® constraints and invariants using Boolean expressions
Working with ExtensionsAccess, check, and extract values from FHIR® extensions
Quantities and UnitsCompare and manipulate UCUM quantities in Observation values
Real-World PatternsProduction patterns including HTTP middleware, batch pipelines, and error handling

Prerequisites

All examples assume you have the library installed:

go get github.com/gofhir/fhirpath

And imported in your Go files:

import "github.com/gofhir/fhirpath"

Most examples work with raw JSON bytes ([]byte) as input, which means you do not need any FHIR® model library. You can load resources from files, HTTP responses, or databases – anything that gives you the JSON as bytes.

Last updated on