Quick Start
This guide will help you get started with OctoFHIR FHIRPath quickly using the CLI tool.
Prerequisites
Section titled “Prerequisites”Make sure you have installed the CLI tool:
cargo install --path fhirpath-cli
Basic Usage
Section titled “Basic Usage”Evaluate FHIRPath Expressions
Section titled “Evaluate FHIRPath Expressions”The most common use case is evaluating FHIRPath expressions against FHIR resources.
# Evaluate an expression against a FHIR resourceoctofhir-fhirpath eval "Patient.name.given" patient.json
# Specify output formatoctofhir-fhirpath eval "Patient.name.given" patient.json --format jsonoctofhir-fhirpath eval "Patient.name.given" patient.json --format pretty
Validate FHIRPath Expressions
Section titled “Validate FHIRPath Expressions”You can also validate FHIRPath expression syntax:
# Check if an expression is syntactically validoctofhir-fhirpath validate "Patient.name.given"octofhir-fhirpath validate "Patient.invalid..syntax"
Example FHIR Resource
Section titled “Example FHIR Resource”Create a sample patient.json
file to test with:
{ "resourceType": "Patient", "id": "example", "name": [ { "use": "official", "family": "Smith", "given": ["John", "Michael"] } ], "gender": "male", "birthDate": "1990-01-01"}
Common FHIRPath Expressions
Section titled “Common FHIRPath Expressions”Try these expressions with your sample patient:
# Get the resource typeoctofhir-fhirpath eval "resourceType" patient.json
# Get the patient's family nameoctofhir-fhirpath eval "name.family" patient.json
# Get all given namesoctofhir-fhirpath eval "name.given" patient.json
# Get the first given nameoctofhir-fhirpath eval "name.given[0]" patient.json
# Get the genderoctofhir-fhirpath eval "gender" patient.json
# Get names with official useoctofhir-fhirpath eval "name.where(use = 'official')" patient.json
Output Formats
Section titled “Output Formats”OctoFHIR FHIRPath supports different output formats:
Pretty Format (Default)
Section titled “Pretty Format (Default)”octofhir-fhirpath eval "name.given" patient.json --format pretty
Output:
["John", "Michael"]
JSON Format
Section titled “JSON Format”octofhir-fhirpath eval "name.given" patient.json --format json
Output:
["John", "Michael"]
Next Steps
Section titled “Next Steps”- Learn more about CLI usage
- Explore usage examples
- Integrate with Rust or Node.js
- Read the FHIRPath specification