Ignixa.FhirPath
0.0.142
dotnet add package Ignixa.FhirPath --version 0.0.142
NuGet\Install-Package Ignixa.FhirPath -Version 0.0.142
<PackageReference Include="Ignixa.FhirPath" Version="0.0.142" />
<PackageVersion Include="Ignixa.FhirPath" Version="0.0.142" />
<PackageReference Include="Ignixa.FhirPath" />
paket add Ignixa.FhirPath --version 0.0.142
#r "nuget: Ignixa.FhirPath, 0.0.142"
#:package Ignixa.FhirPath@0.0.142
#addin nuget:?package=Ignixa.FhirPath&version=0.0.142
#tool nuget:?package=Ignixa.FhirPath&version=0.0.142
Ignixa.FhirPath
FHIRPath expression evaluation engine for FHIR resources. Provides a high-performance implementation of the FHIRPath specification for querying and navigating FHIR data structures.
Why Use This Package?
- Standards-compliant: Implements the FHIRPath specification
- High-performance: Visitor pattern architecture with compile-time optimization
- Compile-time optimizations: Constant folding, short-circuiting, algebraic simplification
- Expression caching: Compiled expressions are cached for repeated use
- Modern architecture: Works with
IElementfrom Ignixa.Abstractions - Extensible: Add custom functions via attributes and source generators
Installation
dotnet add package Ignixa.FhirPath
Quick Start
Evaluating FHIRPath Expressions
using Ignixa.FhirPath.Parser;
using Ignixa.FhirPath.Evaluation;
using Ignixa.Abstractions;
// Parse a FHIRPath expression with compile-time optimization
var parser = new FhirPathParser();
var options = new CompilationOptions { Optimize = true };
var expression = parser.Parse("Patient.name.family", options);
// Evaluate against a resource
var evaluator = new FhirPathEvaluator();
IElement patientElement = GetYourPatientElement();
IEnumerable<IElement> results = evaluator.Evaluate(patientElement, expression);
// Extract values
foreach (var result in results)
{
Console.WriteLine(result.Value); // Prints family names
}
Compile-Time Optimization Examples
The parser can optimize expressions at compile time:
var options = new CompilationOptions { Optimize = true };
// Constant folding
parser.Parse("1 + 1", options); // Optimized to: 2
parser.Parse("'hello' + 'world'", options); // Optimized to: 'helloworld'
// Short-circuit evaluation
parser.Parse("false and X", options); // Optimized to: false (X not evaluated)
parser.Parse("true or X", options); // Optimized to: true (X not evaluated)
// Algebraic simplification
parser.Parse("X + 0", options); // Optimized to: X
parser.Parse("X * 1", options); // Optimized to: X
parser.Parse("X and true", options); // Optimized to: X
Using the Compiled Delegate Mode (Faster)
For better performance on repeated evaluations:
using Ignixa.FhirPath.Evaluation;
// Set up compiler with fallback evaluator
var evaluator = new FhirPathEvaluator();
var compiler = new FhirPathDelegateCompiler(evaluator);
// Parse expression
var expression = parser.Parse("telecom.where(system='phone').value");
// Try to compile (falls back to interpreter if not supported)
var compiled = compiler.TryCompile(expression);
if (compiled != null)
{
// Use compiled delegate (80% faster for common patterns)
var context = new EvaluationContext();
var results = compiled(patientElement, context);
}
else
{
// Fallback to interpreter
var results = evaluator.Evaluate(patientElement, expression);
}
Common FHIRPath Patterns
// Simple path navigation
"Patient.name.family" // Get all family names
// Filtering with where()
"telecom.where(system='phone')" // Get phone telecoms
"name.where(use='official').family" // Get official family name
// Existence checks
"identifier.exists()" // Has any identifiers?
"name.family.exists()" // Has family name?
// First/single element
"name.first().family" // First family name
"identifier.where(system='SSN').value" // SSN value
// Boolean expressions
"active = true" // Is patient active?
"birthDate < @2000-01-01" // Born before 2000
Working with Evaluation Context
using Ignixa.FhirPath.Evaluation;
var context = new EvaluationContext();
// Set variables for use in expressions
context.SetVariable("minDate", someDate);
// Evaluate expression using context
var expression = parser.Parse("birthDate > %minDate");
var results = evaluator.Evaluate(patientElement, expression, context);
Supported FHIRPath Features
Compiled Mode (High Performance)
- Simple paths:
name,identifier - Two-level paths:
name.family,identifier.value - Where clauses:
telecom.where(system='phone') - Common functions:
first(),exists()
Interpreter Mode (Full Compatibility)
- All FHIRPath 2.0 operators
- All standard functions
- Complex nested expressions
- Type checking and conversions
Performance Notes
The FhirPathDelegateCompiler compiles ~80% of common search parameter patterns to optimized delegates:
- Simple paths: 30% of patterns (e.g.,
name) - Two-level paths: 40% of patterns (e.g.,
name.family) - Where clauses: 15% of patterns (e.g.,
telecom.where(system='phone')) - Functions: 10% of patterns (e.g.,
name.first())
Unsupported expressions automatically fall back to the interpreted mode.
Advanced Usage
Custom Function Registration
// Extend FhirPathEvaluator with custom functions
public class MyCustomEvaluator : FhirPathEvaluator
{
protected override IEnumerable<IElement> EvaluateFunctionCall(
IEnumerable<IElement> focus,
FunctionCallExpression func,
EvaluationContext context)
{
if (func.FunctionName == "myCustomFunc")
{
// Implement custom logic
return focus.Where(e => /* your logic */);
}
return base.EvaluateFunctionCall(focus, func, context);
}
}
Related Packages
- Ignixa.Abstractions: Provides
IElementandITypeinterfaces - Ignixa.Serialization: Parse JSON/XML to
IElementtrees - Ignixa.Search: Uses FHIRPath for search parameter extraction
- Ignixa.Validation: Uses FHIRPath for constraint evaluation
Specification Compliance
This implementation follows the FHIRPath N1 specification.
License
MIT License - see LICENSE file in repository root
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Fhir.Metrics (>= 1.3.1)
- Ignixa.Abstractions (>= 0.0.142)
- Ignixa.Specification (>= 0.0.142)
- Superpower (>= 3.1.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Ignixa.FhirPath:
| Package | Downloads |
|---|---|
|
Ignixa.SqlOnFhir
SQL on FHIR implementation for analytics queries |
|
|
Ignixa.FhirMappingLanguage
FHIR Mapping Language (FML) parser and execution engine |
|
|
Ignixa.Validation
FHIR resource validation with profile support |
|
|
Ignixa.Search
FHIR search parameter indexing and query infrastructure |
|
|
Ignixa.NarrativeGenerator
FHIR narrative generation using Scriban templates with FHIRPath support |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.142 | 67 | 1/12/2026 |
| 0.0.137 | 138 | 1/9/2026 |
| 0.0.127 | 256 | 12/29/2025 |
| 0.0.109 | 434 | 12/18/2025 |
| 0.0.101 | 327 | 12/16/2025 |
| 0.0.96 | 593 | 12/10/2025 |
| 0.0.87 | 746 | 12/8/2025 |
| 0.0.70 | 616 | 12/7/2025 |
| 0.0.68 | 564 | 12/7/2025 |
| 0.0.62 | 580 | 12/6/2025 |
| 0.0.59 | 538 | 12/5/2025 |
| 0.0.58 | 570 | 12/5/2025 |
| 0.0.57 | 598 | 12/3/2025 |
| 0.0.56 | 1,071 | 12/3/2025 |
| 0.0.55 | 911 | 12/1/2025 |
| 0.0.54 | 904 | 11/30/2025 |
| 0.0.53 | 904 | 11/30/2025 |
| 0.0.51 | 660 | 11/29/2025 |
| 0.0.50 | 637 | 11/29/2025 |