fhirpath

package module
v0.0.0-...-232d5c3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2024 License: Apache-2.0, MIT Imports: 8 Imported by: 0

README

Go Project Template

Continuous Integration GitHub Release Gitter Channel readthedocs Godocs

An implementation of the FHIRPath query language in Go.

This is made with the go-fhir library.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnimplemented is returned when a feature is not yet implemented.
	ErrUnimplemented = errors.New("unimplemented")

	// ErrNotSingleton is an error raised if a collection is not a singleton, but
	// one was expected.
	ErrNotSingleton = collection.ErrNotSingleton
)

Functions

This section is empty.

Types

type Collection

type Collection = collection.Collection

Collection is a collection of FHIRPath values.

type CompileOption

type CompileOption interface {
	// contains filtered or unexported methods
}

func AddFunc

func AddFunc(name string, fn any) CompileOption

AddFunc returns a CompileOption that adds a custom function to the FHIRPath compiler.

fn must be a valid function that takes a collection.Collection, input parameters, and returns a collection.Collection and an [error]. Parameters must be a conforming FHIRPath type; either from the base FHIR instance, or from the system package.

func AddFuncs

func AddFuncs(funcs map[string]any) CompileOption

AddFuncs returns a CompileOption that adds custom functions to the FHIRPath compiler.

Supplied functions must be a valid function that takes a collection.Collection, input parameters, and returns a collection.Collection and an [error]. Parameters must be a conforming FHIRPath type; either from the base FHIR instance, or from the system package.

func N1

func N1() CompileOption

N1 returns a CompileOption that configures the compiler to use the FHIR N1 version of the FHIRPath language.

Only one of N1 or N2 may be specified at a time.

func N2

func N2() CompileOption

N2 returns a CompileOption that configures the compiler to use the FHIR N2 version of the FHIRPath language.

Only one of N1 or N2 may be specified at a time.

func R4

func R4() CompileOption

R4 returns a CompileOption that configures the compiler to use the FHIR R4 version of the FHIRPath language.

func SimpleR4

func SimpleR4() CompileOption

SimpleR4 returns a CompileOption that configures the compiler to use the FHIR R4 version of the FHIRPath language without any additional features.

type EvalOption

type EvalOption interface {
	// contains filtered or unexported methods
}

func WithResolver

func WithResolver(resolver resolver.Resolver) EvalOption

WithResolver returns an EvalOption that configures the evaluator to use the specified resolver for resolving FHIRPath references.

func WithTime

func WithTime(time time.Time) EvalOption

WithTime returns an EvalOption that configures the evaluator to use the specified time for evaluating time-dependent FHIRPath expressions.

By default, without this specified, the current time is used.

func WithTracer

func WithTracer(tracer tracer.Tracer) EvalOption

WithTracer returns an EvalOption that configures the evaluator to use the specified tracer for tracing FHIRPath evaluation.

type Path

type Path struct {
	// contains filtered or unexported fields
}

Path represents a compiled FHIRPath expression.

func Compile

func Compile(path string, opts ...CompileOption) (*Path, error)

Compile compiles the FHIRPath expression and returns a Path object. If the expression is invalid, an error is returned.

Compilation will always use the latest version of the FHIRPath language, but may be configured with options to enable other language features.

func MustCompile

func MustCompile(path string, opts ...CompileOption) *Path

MustCompile is a convenience function that compiles the FHIRPath expression and panics if the expression is invalid.

func (*Path) Equal

func (p *Path) Equal(other *Path) bool

func (*Path) Eval

func (p *Path) Eval(ctx context.Context, resource any, opts ...EvalOption) (Collection, error)

Eval evaluates the FHIRPath expression and returns the result as a collection of values. If the expression is invalid, an error is returned. The resource argument is the FHIR resource to evaluate the expression against.

func (*Path) EvalBool

func (p *Path) EvalBool(ctx context.Context, resource any, opts ...EvalOption) (bool, error)

EvalBool evaluates the FHIRPath expression and returns the result as a boolean value. If the result is a singleton, it will be converted to a truthy boolean value. If

func (*Path) EvalFloat64

func (p *Path) EvalFloat64(ctx context.Context, resource any, opts ...EvalOption) (float64, error)

EvalFloat64 evaluates the FHIRPath expression and returns the result as a float64 value. If the result is a singleton, it will be converted to a float64.

func (*Path) EvalString

func (p *Path) EvalString(ctx context.Context, resource any, opts ...EvalOption) (string, error)

EvalString evaluates the FHIRPath expression and returns the result as a string value. If the result is a singleton, it will be converted to a string. If the result is not a string, an error is returned.

func (*Path) MustEval

func (p *Path) MustEval(ctx context.Context, resource any, opts ...EvalOption) Collection

MustEval is a convenience function that evaluates the FHIRPath expression and panics if the expression is invalid.

func (*Path) MustEvalBool

func (p *Path) MustEvalBool(ctx context.Context, resource any, opts ...EvalOption) bool

MustEvalBool is a convenience function that evaluates the FHIRPath expression and panics if the expression is invalid.

func (*Path) MustEvalFloat64

func (p *Path) MustEvalFloat64(ctx context.Context, resource any, opts ...EvalOption) float64

MustEvalFloat64 is a convenience function that evaluates the FHIRPath expression and panics if the expression is invalid.

func (*Path) MustEvalString

func (p *Path) MustEvalString(ctx context.Context, resource any, opts ...EvalOption) string

MustEvalString is a convenience function that evaluates the FHIRPath expression and panics if the expression is invalid.

func (*Path) String

func (p *Path) String() string

String returns the FHIRPath expression as a string.

type Resolver

type Resolver = resolver.Resolver

type Tracer

type Tracer = tracer.Tracer

Directories

Path Synopsis
Package collection provides definitions for FHIRPath Collection objects, for semantically clear behavior of FHIRPath operations involving collections.
Package collection provides definitions for FHIRPath Collection objects, for semantically clear behavior of FHIRPath operations involving collections.
internal
envcontext
Package envcontext provides definitions for Context objects that document environment variables, as defined in FHIRPath.
Package envcontext provides definitions for Context objects that document environment variables, as defined in FHIRPath.
esc
Package esc provides basic functionality for handling the ESC (escape) sequences in the FHIRPath grammar.
Package esc provides basic functionality for handling the ESC (escape) sequences in the FHIRPath grammar.
Package reflect implements §10.2.
Package reflect implements §10.2.
Package resolver provides an interface for resolving FHIRPath references.
Package resolver provides an interface for resolving FHIRPath references.
resolvertest
Package resolvertest provides test-doubles for working with the FHIRPath resolver package.
Package resolvertest provides test-doubles for working with the FHIRPath resolver package.
Package system contains the definitions of FHIRPath "system"-namespace types.
Package system contains the definitions of FHIRPath "system"-namespace types.
Package tracer provides FHIRPath tracer implementations that may be used for the "trace" FHIRPath function.
Package tracer provides FHIRPath tracer implementations that may be used for the "trace" FHIRPath function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL