API Reference
API Reference
The github.com/gofhir/fhirpath package provides a complete FHIRPath 2.0 expression evaluator for FHIR® resources in Go. This section documents every public function, type, and interface available in the library.
Package Overview
The library is organized into two packages:
| Package | Import Path | Description |
|---|---|---|
| fhirpath | github.com/gofhir/fhirpath | Core evaluation engine, compilation, caching, and options |
| types | github.com/gofhir/fhirpath/types | FHIRPath type system: Value, Collection, and all primitive types |
Quick Navigation
Core Evaluation
- Evaluate Functions –
Evaluate,MustEvaluate, andEvaluateCachedfor one-shot expression evaluation against JSON resources. - Compile and Expression –
Compile,MustCompile, and theExpressiontype for precompiling expressions and evaluating them many times. - Typed Evaluation – Convenience functions that return Go-native types:
EvaluateToBoolean,EvaluateToString,EvaluateToStrings,Exists, andCount.
Resource Handling
- Resource Interface – The
Resourceinterface,EvaluateResource,EvaluateResourceCached, andResourceJSONfor evaluating Go structs directly.
Performance and Configuration
- Expression Cache –
ExpressionCachewith LRU eviction,DefaultCache, cache statistics, and monitoring. - Evaluation Options –
EvalOptions, functional options (WithTimeout,WithContext,WithVariable, etc.), and theReferenceResolverinterface.
Type System
- Types Package – The
Valueinterface,Collectiontype with all its methods, and all FHIRPath primitive types (Boolean,Integer,Decimal,String,Date,DateTime,Time,Quantity,ObjectValue).
Choosing the Right Function
Use the following decision tree to pick the best entry point for your use case:
Do you have a Go struct implementing Resource?
YES --> Do you evaluate many expressions on it?
YES --> Use ResourceJSON (serialize once, evaluate many)
NO --> Use EvaluateResource / EvaluateResourceCached
NO --> (You have raw JSON bytes)
Do you reuse the same expression many times?
YES --> Use Compile + Expression.Evaluate
(or ExpressionCache for automatic caching)
NO --> Do you need a specific Go type back?
YES --> Use EvaluateToBoolean / EvaluateToString / Exists / Count
NO --> Use Evaluate or EvaluateCachedLast updated on