Examples
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
| Page | Description |
|---|---|
| Basic Queries | Extract demographics, navigate nested structures, work with arrays, and use path syntax |
| Filtering Data | Use where(), select(), exists(), count(), and empty() to filter and project FHIR® data |
| FHIR® Validation | Evaluate FHIR® constraints and invariants using Boolean expressions |
| Working with Extensions | Access, check, and extract values from FHIR® extensions |
| Quantities and Units | Compare and manipulate UCUM quantities in Observation values |
| Real-World Patterns | Production patterns including HTTP middleware, batch pipelines, and error handling |
Prerequisites
All examples assume you have the library installed:
go get github.com/gofhir/fhirpathAnd 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