Crates.io | octofhir-fhirpath |
lib.rs | octofhir-fhirpath |
version | 0.4.26 |
created_at | 2025-07-31 22:31:47.341427+00 |
updated_at | 2025-09-25 07:11:50.998682+00 |
description | A high-performance FHIRPath implementation in Rust with comprehensive spec compliance |
homepage | https://github.com/octofhir/fhirpath-rs |
repository | https://github.com/octofhir/fhirpath-rs |
max_upload_size | |
id | 1775833 |
size | 2,223,577 |
A focused, spec-first FHIRPath implementation in Rust. No fluff. The goal is correctness, clarity, and predictable behavior when evaluating FHIRPath over JSON FHIR resources.
This library is highly pluggable. In production, you can use our ModelProvider and other ecosystem components, or create your own custom implementations. The architecture supports:
Production-ready CLI: Our CLI already integrates all ecosystem providers and can be used on a daily basis for FHIRPath evaluation, REPL sessions, and server mode.
Docs: API Documentation | Spec coverage: TEST_COVERAGE.md | Benchmarks: benchmark.md | CLI: CLI.md | License: MIT OR Apache-2.0
Add to your Cargo.toml
:
[dependencies]
octofhir-fhirpath = "0.4"
cargo install --git https://github.com/octofhir/fhirpath-rs --bin octofhir-fhirpath
use octofhir_fhirpath::evaluate;
use octofhir_fhirpath::core::value::utils::json_to_fhirpath_value;
use serde_json::json;
#[tokio::main]
async fn main() -> octofhir_fhirpath::Result<()> {
let patient = json!({
"resourceType": "Patient",
"name": [{"family": "Smith", "given": ["Alice", "A."]}],
"active": true
});
// Convert JSON to FHIRPath value and evaluate
let ctx = json_to_fhirpath_value(patient);
let out = evaluate("Patient.name.given", &ctx).await?;
println!("{:?}", out);
Ok(())
}
use octofhir_fhirpath::{FhirPathEngine, create_standard_registry};
use octofhir_fhirpath::evaluator::EvaluationContext;
use octofhir_fhirpath::core::value::utils::json_to_fhirpath_value;
use octofhir_fhir_model::EmptyModelProvider;
use serde_json::json;
use std::sync::Arc;
#[tokio::main]
async fn main() -> octofhir_fhirpath::Result<()> {
// Engine is explicit about function registry and model provider
let registry = Arc::new(create_standard_registry().await);
let provider = Arc::new(EmptyModelProvider);
let mut engine = FhirPathEngine::new(registry, provider).await?;
// Context can be any FHIR JSON; engine auto-detects root resourceType
let ctx_val = json_to_fhirpath_value(json!({
"resourceType": "Patient",
"name": [{"given": ["Alice"], "family": "Smith"}]
}));
let ctx = EvaluationContext::from_value(ctx_val);
// "name.given" is automatically treated as "Patient.name.given"
let result = engine.evaluate("name.given", &ctx).await?;
println!("{:?}", result.value);
Ok(())
}
octofhir-fhirpath evaluate "Patient.name.given" --input patient.json
octofhir-fhirpath repl --input patient.json
octofhir-fhirpath server --port 8080
See CLI.md for full options and output formats.
FhirPathEngine
with AST cache and auto-context detection%context
, %resource
, %terminologies
, %sct
, %loinc
, etc.)Arc<JsonValue>
for efficient resource sharingname.given
→ Patient.name.given
)This codebase maintains the highest standards of Rust code quality:
Run just qa
to verify all quality checks pass.
As of September 2025, this implementation passes 100% of the official FHIRPath test suite (114 suites, 1118 tests). See TEST_COVERAGE.md for the full report.
✅ Fully Supported (100%)
where
, select
, first
, last
, count
, etc.)is
, as
, ofType
)resolve
, extension
, children
)See TEST_COVERAGE.md for detailed compliance status.
Licensed under MIT OR Apache-2.0
Built with ❤️ by the OctoFHIR team 🦀