FHIRPath Engine¶
FHIRPath evaluation engine components
engine ¶
Modules:
| Name | Description |
|---|---|
additional |
FHIR adds (compatible) functionality to the set of common FHIRPath functions. Some of these functions |
aggregates |
FHIRPath supports a general-purpose aggregate function to enable the calculation of aggregates such as sum, min, and max to be expressed |
boolean |
For all boolean operators, the collections passed as operands are first evaluated as Booleans. |
collection |
The comparison module contains the object representations of the collection FHIRPath operators. |
combining |
The filtering module contains the object representations of the combining-category FHIRPath functions. |
comparison |
The comparison module contains the object representations of the comparison FHIRPath operators. |
conversion |
FHIRPath defines both implicit and explicit conversion. Implicit conversions occur automatically, as opposed to explicit conversions |
core |
|
environment |
|
equality |
The equality module contains the object representations of the equality FHIRPath operators. |
existence |
The filtering module contains the object representations of the existence-category FHIRPath functions. |
filtering |
The filtering module contains the object representations of the filtering-category FHIRPath functions. |
literals |
|
math |
The tree navigation module contains the object representations of the math category FHIRPath operators/functions. |
navigation |
The tree navigation module contains the object representations of the tree-navigation category FHIRPath functions. |
strings |
The functions in this section operate on collections with a single item. If there is more than one item, or an item that is not a String, the evaluation of the expression will end and signal an error to the calling environment. |
subsetting |
The filtering module contains the object representations of the subsetting-category FHIRPath functions. |
types |
The tree navigation module contains the object representations of the types category FHIRPath operators/functions. |
utility |
The utility module contains the object representations of the utility FHIRPath functions. |
Classes:
| Name | Description |
|---|---|
Extension |
A representation of the FHIRPath |
HasValue |
A representation of the FHIRPath |
GetValue |
A representation of the FHIRPath |
Resolve |
A representation of the FHIRPath |
HtmlChecks |
A representation of the FHIRPath |
LowBoundary |
A representation of the FHIRPath |
HighBoundary |
A representation of the FHIRPath |
ElementDefinition |
A representation of the FHIRPath |
Slice |
A representation of the FHIRPath |
CheckModifiers |
A representation of the FHIRPath |
ConformsTo |
A representation of the FHIRPath |
MemberOf |
A representation of the FHIRPath |
Subsumes |
A representation of the FHIRPath |
SubsumedBy |
A representation of the FHIRPath |
Comparable |
A representation of the FHIRPath |
And |
A representation of the FHIRPath |
Or |
A representation of the FHIRPath |
Xor |
A representation of the FHIRPath |
Implies |
A representation of the FHIRPath |
Not |
A representation of the FHIRPath |
In |
A representation of the FHIRPath |
Union |
A representation of the FHIRPath |
Combine |
A representation of the FHIRPath |
GreaterThan |
A representation of the FHIRPath |
LessThan |
A representation of the FHIRPath |
LessEqualThan |
A representation of the FHIRPath |
GreaterEqualThan |
A representation of the FHIRPath |
Iif |
A representation of the FHIRPath |
ToBoolean |
A representation of the FHIRPath |
ConvertsToBoolean |
A representation of the FHIRPath |
ToInteger |
A representation of the FHIRPath |
ConvertsToInteger |
A representation of the FHIRPath |
ToDate |
A representation of the FHIRPath |
ConvertsToDate |
A representation of the FHIRPath |
ToDateTime |
A representation of the FHIRPath |
ConvertsToDateTime |
A representation of the FHIRPath |
ToDecimal |
A representation of the FHIRPath |
ConvertsToDecimal |
A representation of the FHIRPath |
ToQuantity |
A representation of the FHIRPath |
ConvertsToQuantity |
A representation of the FHIRPath |
ToString |
A representation of the FHIRPath |
ConvertsToString |
A representation of the FHIRPath |
ToTime |
A representation of the FHIRPath |
ConvertsToTime |
A representation of the FHIRPath |
FHIRPath |
Abstract base class for FHIRPath expressions. |
FHIRPathCollectionItem |
A context-aware representation of an item in a FHIRPath collection. |
FHIRPathFunction |
Abstract base class representing a FHIRPath function, used for functional evaluation of collections. |
Literal |
A class representation of a constant literal value in the FHIRPath. |
Element |
A class representing an element in a FHIRPath, used for navigating and manipulating FHIR resources. |
Invocation |
A class representing an invocation in the context of FHIRPath evaluation |
This |
A representation of a current element. Used for internal purposes and has no FHIRPath shorthand notation. |
RootElement |
A class representing the root of a FHIRPath, i.e. the top-most segment of the FHIRPath |
TypeSpecifier |
A type specifier is an identifier that must resolve to the name of a type in a model. |
Equals |
A representation of the FHIRPath |
Equivalent |
A representation of the FHIRPath |
NotEquals |
A representation of the FHIRPath |
NotEquivalent |
A representation of the FHIRPath |
Empty |
Representation of the FHIRPath |
Exists |
Representation of the FHIRPath |
All |
Representation of the FHIRPath |
AllTrue |
Representation of the FHIRPath |
AnyTrue |
Representation of the FHIRPath |
AllFalse |
Representation of the FHIRPath |
AnyFalse |
Representation of the FHIRPath |
SubsetOf |
Representation of the FHIRPath |
SupersetOf |
Representation of the FHIRPath |
Count |
Representation of the FHIRPath |
Distinct |
Representation of the FHIRPath |
IsDistinct |
Representation of the FHIRPath |
Where |
Representation of the FHIRPath |
Select |
Representation of the FHIRPath |
Repeat |
Representation of the FHIRPath |
OfType |
Representation of the FHIRPath |
Quantity |
Quantity(value: int | float, unit: str | None) |
Date |
Date(valuestring=None, value_date=None) |
Time |
Time(valuestring: str | None = None, value_time: datetime.time | None = None) |
DateTime |
DateTime(valuestring: str | None = None, value_datetime: datetime.datetime | None = None) |
Addition |
A representation of the FHIRPath |
Subtraction |
A representation of the FHIRPath |
Multiplication |
A representation of the FHIRPath |
Division |
A representation of the FHIRPath |
Div |
A representation of the FHIRPath |
Mod |
A representation of the FHIRPath |
Abs |
A representation of the FHIRPath |
Ceiling |
A representation of the FHIRPath |
Exp |
A representation of the FHIRPath |
Floor |
A representation of the FHIRPath |
Ln |
A representation of the FHIRPath |
Log |
A representation of the FHIRPath |
Power |
A representation of the FHIRPath |
Round |
A representation of the FHIRPath |
Sqrt |
A representation of the FHIRPath |
Truncate |
A representation of the FHIRPath |
Children |
Representation of the FHIRPath |
Descendants |
Representation of the FHIRPath |
Contains |
A representation of the FHIRPath |
IndexOf |
A representation of the FHIRPath |
Substring |
A representation of the FHIRPath |
StartsWith |
A representation of the FHIRPath |
EndsWith |
A representation of the FHIRPath |
Upper |
A representation of the FHIRPath |
Lower |
A representation of the FHIRPath |
Replace |
A representation of the FHIRPath |
Matches |
A representation of the FHIRPath |
ReplaceMatches |
A representation of the FHIRPath |
Length |
A representation of the FHIRPath |
ToChars |
A representation of the FHIRPath |
Concatenation |
A representation of the FHIRPath |
Index |
A representation of the FHIRPath index |
Single |
A representation of the FHIRPath |
First |
A representation of the FHIRPath |
Last |
A representation of the FHIRPath |
Tail |
A representation of the FHIRPath |
Skip |
A representation of the FHIRPath |
Take |
A representation of the FHIRPath |
Intersect |
A representation of the FHIRPath |
Exclude |
A representation of the FHIRPath |
Is |
A representation of the FHIRPath |
LegacyIs |
The is() function is supported for backwards compatibility with previous implementations of FHIRPath. |
As |
A representation of the FHIRPath |
LegacyAs |
The as() function is supported for backwards compatibility with previous implementations of FHIRPath. |
Trace |
A representation of the FHIRPath |
Now |
A representation of the FHIRPath |
TimeOfDay |
A representation of the FHIRPath |
Today |
A representation of the FHIRPath |
Extension
Path: fhircraft.fhir.path.engine.Extension
Bases: FHIRPathFunction
A representation of the FHIRPath extension() function.
Attributes:
| Name | Type | Description |
|---|---|---|
url |
str
|
URL to query the extensions. |
Note
This class is a syntactical shortcut equivalent to:
Invocation(Element('extension'), Where(Equals(Element('url'), url)))
Methods:
| Name | Description |
|---|---|
evaluate |
Filters the input collection for items named |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Filters the input collection for items named extension with the given url.
Will return an empty collection if the input collection is empty or the url is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
HasValue
Path: fhircraft.fhir.path.engine.HasValue
Bases: FHIRPathFunction
A representation of the FHIRPath hasValue() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns true if the input collection contains a single value which is a FHIR primitive, and it has a primitive |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns true if the input collection contains a single value which is a FHIR primitive, and it has a primitive value (e.g. as opposed to not having a value and just having extensions). Otherwise, the return value is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
GetValue
Path: fhircraft.fhir.path.engine.GetValue
Bases: FHIRPathFunction
A representation of the FHIRPath getValue() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Return the underlying system value for the FHIR primitive if the input collection contains a single |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Return the underlying system value for the FHIR primitive if the input collection contains a single value which is a FHIR primitive, and it has a primitive value (see discussion for hasValue()). Otherwise the return value is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
Resolve
Path: fhircraft.fhir.path.engine.Resolve
Bases: FHIRPathFunction
A representation of the FHIRPath resolve() function.
Methods:
| Name | Description |
|---|---|
evaluate |
For each item in the collection, if it is a string that is a |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
For each item in the collection, if it is a string that is a uri (or canonical or url), locate the target of the
reference, and add it to the resulting collection. If the item does not resolve to a resource, the item is ignored
and nothing is added to the output collection.
The items in the collection may also represent a Reference, in which case the Reference.reference is resolved.
If the input is empty, the output will be empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
HtmlChecks
Path: fhircraft.fhir.path.engine.HtmlChecks
Bases: FHIRPathFunction
A representation of the FHIRPath htmlChecks() function.
Methods:
| Name | Description |
|---|---|
evaluate |
When invoked on a single xhtml element returns true if the rules around HTML usage are met, and false if they are not. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
When invoked on a single xhtml element returns true if the rules around HTML usage are met, and false if they are not. The return value is empty on any other kind of element, or a collection of xhtml elements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
bool |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If the collection is not a single item. |
LowBoundary
Path: fhircraft.fhir.path.engine.LowBoundary
Bases: FHIRPathFunction
A representation of the FHIRPath lowBoundary() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the low boundary of a quantity or range based on precision. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the low boundary of a quantity or range based on precision. For date/time values, returns the earliest possible moment. For decimal values, returns the lowest value within precision range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
HighBoundary
Path: fhircraft.fhir.path.engine.HighBoundary
Bases: FHIRPathFunction
A representation of the FHIRPath highBoundary() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the high boundary of a quantity or range based on precision. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the high boundary of a quantity or range based on precision. For date/time values, returns the latest possible moment. For decimal values, returns the highest value within precision range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
ElementDefinition
Path: fhircraft.fhir.path.engine.ElementDefinition
Bases: FHIRPathFunction
A representation of the FHIRPath elementDefinition() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the FHIR element definition information for each element in the input collection. If the input collection is empty, the return value will be empty. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the FHIR element definition information for each element in the input collection. If the input collection is empty, the return value will be empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
Slice
Path: fhircraft.fhir.path.engine.Slice
Bases: FHIRPathFunction
A representation of the FHIRPath slice() function.
Attributes:
| Name | Type | Description |
|---|---|---|
structure |
str
|
The structure definition URL or name. |
name |
str
|
The name of the slice. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the given slice as defined in the given structure definition. The structure |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the given slice as defined in the given structure definition. The structure argument is a uri that resolves to the structure definition, and the name must be the name of a slice within that structure definition. If the structure cannot be resolved, or the name of the slice within the resolved structure is not present, or those parameters are empty, and empty value is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
CheckModifiers
Path: fhircraft.fhir.path.engine.CheckModifiers
Bases: FHIRPathFunction
A representation of the FHIRPath checkModifiers() function.
Attributes:
| Name | Type | Description |
|---|---|---|
modifier |
str
|
The modifier to check for. |
Methods:
| Name | Description |
|---|---|
evaluate |
For each element in the input collection, verifies that there are no modifying extensions defined other than the ones given by the modifier argument (comma-separated string). If the check passes, the input collection is returned. Otherwise, an error is thrown, including if modifier is empty. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
For each element in the input collection, verifies that there are no modifying extensions defined other than the ones given by the modifier argument (comma-separated string). If the check passes, the input collection is returned. Otherwise, an error is thrown, including if modifier is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
ConformsTo
Path: fhircraft.fhir.path.engine.ConformsTo
Bases: FHIRPathFunction
A representation of the FHIRPath conformsTo() function.
Attributes:
| Name | Type | Description |
|---|---|---|
structure |
str
|
The structure canonical URL. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns true if the single input element conforms to the profile specified by the structure argument, and false otherwise. If the input is not a single item, the structure is empty, or the structure cannot be resolved to a valid profile, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
MemberOf
Path: fhircraft.fhir.path.engine.MemberOf
Bases: FHIRPathFunction
A representation of the FHIRPath memberOf() function.
Attributes:
| Name | Type | Description |
|---|---|---|
valueset |
str
|
The valueset canonical URL. |
Methods:
| Name | Description |
|---|---|
evaluate |
When invoked on a single code-valued element, returns true if the code is a member of the given valueset. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
When invoked on a single code-valued element, returns true if the code is a member of the given valueset. When invoked on a single concept-valued element, returns true if any code in the concept is a member of the given valueset. When invoked on a single string, returns true if the string is equal to a code in the valueset, so long as the valueset only contains one codesystem. If the valueset in this case contains more than one codesystem, the return value is empty.
If the valueset cannot be resolved as a uri to a value set, or the input is empty or has more than one value, the return value is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
Subsumes
Path: fhircraft.fhir.path.engine.Subsumes
Subsumes(code: FHIRPath)
Bases: FHIRPathFunction
A representation of the FHIRPath subsumes() function.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
FHIRPath
|
The code to check for subsumption. |
Methods:
| Name | Description |
|---|---|
evaluate |
When invoked on a Coding-valued element and the given code is Coding-valued, returns true if the source code is equivalent to the given code, or if the source code subsumes the given code (i.e. the source code is an ancestor of the given code in a subsumption hierarchy), and false otherwise. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
When invoked on a Coding-valued element and the given code is Coding-valued, returns true if the source code is equivalent to the given code, or if the source code subsumes the given code (i.e. the source code is an ancestor of the given code in a subsumption hierarchy), and false otherwise.
If the Codings are from different code systems, the relationships between the code systems must be well-defined or the return value is an empty value.
When the source or given elements are CodeableConcepts, returns true if any Coding in the source or given elements is equivalent to or subsumes the given code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
SubsumedBy
Path: fhircraft.fhir.path.engine.SubsumedBy
SubsumedBy(code: FHIRPath)
Bases: FHIRPathFunction
A representation of the FHIRPath subsumedBy() function.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
FHIRPath
|
The code to check for subsumption. |
Methods:
| Name | Description |
|---|---|
evaluate |
When invoked on a Coding-valued element and the given code is Coding-valued, returns true if the source code is equivalent to the given code, or if the source code is subsumed by the given code (i.e. the given code is an ancestor of the source code in a subsumption hierarchy), and false otherwise. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
When invoked on a Coding-valued element and the given code is Coding-valued, returns true if the source code is equivalent to the given code, or if the source code is subsumed by the given code (i.e. the given code is an ancestor of the source code in a subsumption hierarchy), and false otherwise.
If the Codings are from different code systems, the relationships between the code systems must be well-defined or a run-time error is thrown.
When the source or given elements are CodeableConcepts, returns true if any Coding in the source or given elements is equivalent to or subsumed by the given code.
If either the input or the code parameter are not single value collections, the return value is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
Comparable
Path: fhircraft.fhir.path.engine.Comparable
Bases: FHIRPathFunction
A representation of the FHIRPath comparable() function.
Attributes:
| Name | Type | Description |
|---|---|---|
quantity |
Quantity | FHIRPath
|
The quantity to check for comparability or a FHIRPath that resolves to a Quantity. |
Methods:
| Name | Description |
|---|---|
evaluate |
This function returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
This function returns true if the engine executing the FHIRPath statement can compare
the singleton Quantity with the singleton other Quantity and determine their relationship
to each other. Comparable means that both have values and that the code and system for
the units are the same (irrespective of system) or both have code + system, system is
recognized by the FHIRPath implementation and the codes are comparable within that code system. E.g. days and hours or inches and cm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
And
Path: fhircraft.fhir.path.engine.And
Bases: FHIRPath
A representation of the FHIRPath and boolean logic operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns True if both operands evaluate to True, False if either operand evaluates to False, and the empty collection ([]) otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Or
Path: fhircraft.fhir.path.engine.Or
Bases: FHIRPath
A representation of the FHIRPath or boolean logic operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns False if both operands evaluate to False, True if either operand evaluates to True, and empty ([]) otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Xor
Path: fhircraft.fhir.path.engine.Xor
Bases: FHIRPath
A representation of the FHIRPath xor boolean logic operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns True if exactly one of the operands evaluates to True, False if either both operands evaluate to True or both operands evaluate to False, and the empty collection ([]) otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Implies
Path: fhircraft.fhir.path.engine.Implies
Bases: FHIRPath
A representation of the FHIRPath implies boolean logic operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
If the left operand evaluates to |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the left operand evaluates to True, this operator returns the boolean evaluation of the right operand. If the
left operand evaluates to False, this operator returns True. Otherwise, this operator returns True if the right
operand evaluates to True, and the empty collection ([]) otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Not
Path: fhircraft.fhir.path.engine.Not
Bases: FHIRPathFunction
A representation of the FHIRPath not boolean logic function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns True if the input collection evaluates to False, and False if it evaluates to True. Otherwise, the result is empty ([]):
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
In
Path: fhircraft.fhir.path.engine.In
Bases: FHIRCollectionOperator
A representation of the FHIRPath in operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
If the left operand is a collection with a single item, this operator returns true if the item is in the |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the left operand is a collection with a single item, this operator returns true if the item is in the right operand using equality semantics. If the left-hand side of the operator is empty, the result is empty, if the right-hand side is empty, the result is false. If the left operand has multiple items, an exception is thrown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If the left expression evaluates to a non-singleton collection. |
Union
Path: fhircraft.fhir.path.engine.Union
Union(other_collection: FHIRPath | FHIRPathCollection)
Bases: FHIRPathFunction
A representation of the FHIRPath union() function.
Attributes:
| Name | Type | Description |
|---|---|---|
other_collection |
FHIRPathCollection
|
The other collection to combine with. |
Methods:
| Name | Description |
|---|---|
evaluate |
Merge the two collections into a single collection, eliminating any duplicate values. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Merge the two collections into a single collection, eliminating any duplicate values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Combine
Path: fhircraft.fhir.path.engine.Combine
Combine(other_collection: FHIRPath | FHIRPathCollection)
Bases: FHIRPathFunction
A representation of the FHIRPath combine() function.
Attributes:
| Name | Type | Description |
|---|---|---|
other_collection |
FHIRPathCollection
|
The other collection to combine with. |
Methods:
| Name | Description |
|---|---|
evaluate |
Merge the input and other collections into a single collection without eliminating duplicate |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Merge the input and other collections into a single collection without eliminating duplicate values. Combining an empty collection with a non-empty collection will return the non-empty collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
GreaterThan
Path: fhircraft.fhir.path.engine.GreaterThan
Bases: FHIRComparisonOperator
A representation of the FHIRPath > operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
The greater than operator (>) returns true if the first operand is strictly greater than the second. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
The greater than operator (>) returns true if the first operand is strictly greater than the second. The operands must be of the same type, or convertible to the same type using an implicit conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
LessThan
Path: fhircraft.fhir.path.engine.LessThan
Bases: FHIRComparisonOperator
A representation of the FHIRPath < operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
The less than operator (<) returns true if the first operand is strictly less than the second. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
The less than operator (<) returns true if the first operand is strictly less than the second. The operands must be of the same type, or convertible to the same type using implicit conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
LessEqualThan
Path: fhircraft.fhir.path.engine.LessEqualThan
Bases: FHIRComparisonOperator
A representation of the FHIRPath <= operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
The less or equal operator (<=) returns true if the first operand is less than or equal to the second. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
The less or equal operator (<=) returns true if the first operand is less than or equal to the second. The operands must be of the same type, or convertible to the same type using implicit conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
GreaterEqualThan
Path: fhircraft.fhir.path.engine.GreaterEqualThan
Bases: FHIRComparisonOperator
A representation of the FHIRPath >= operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
The greater or equal operator (>=) returns true if the first operand is greater than or equal to the second. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
The greater or equal operator (>=) returns true if the first operand is greater than or equal to the second. The operands must be of the same type, or convertible to the same type using implicit conversion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
Iif
Path: fhircraft.fhir.path.engine.Iif
Iif(criterion: FHIRPath, true_result: FHIRPath | FHIRPathCollection, otherwise_result: FHIRPath | FHIRPathCollection = list())
Bases: FHIRPathFunction
A representation of the FHIRPath iif() function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
criterion
|
FHIRPath
|
The criterion expression, is expected to evaluate to a |
required |
true_result
|
Union[FHIRPath, Any]
|
Value to be returned if |
required |
otherwise_result
|
Optional[Union[FHIRPath, Any]]
|
Value to be returned if |
list()
|
Methods:
| Name | Description |
|---|---|
evaluate |
This function acts as an immediate if, also known as a conditional operator. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
This function acts as an immediate if, also known as a conditional operator.
If criterion evaluates to True, the function returns the value of the true_result argument.
If true_result is a FHIRPath expression it is evaluated.
If criterion is False or an empty collection, the function returns the otherwise_result argument,
unless the optional otherwise_result is not given, in which case the function returns an empty collection.
If otherwise_result is a FHIRPath expression it is evaluated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ToBoolean
Path: fhircraft.fhir.path.engine.ToBoolean
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath toBoolean() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return a single |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return a single Boolean if:
- the item is a Boolean
- the item is an Integer that is equal to one of the possible integer representations of Boolean values
- the item is a Decimal that is equal to one of the possible decimal representations of Boolean values
- the item is a String that is equal to one of the possible string representations of Boolean values
If the item is not one of the above types, or the item is a String, Integer, or Decimal, but is not equal to one of the possible values convertible to a Boolean, the result is false.
If the input collection is empty, the result is empty ('[]').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ConvertsToBoolean
Path: fhircraft.fhir.path.engine.ConvertsToBoolean
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath convertsToBoolean() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return True if the item can be converted to a Boolean, False otherwise.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ToInteger
Path: fhircraft.fhir.path.engine.ToInteger
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath toInteger() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return a single |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return a single Integer if:
- the item is an Integer
- the item is a String and is convertible to an integer
- the item is a Boolean, where True results in a 1 and False results in a 0.
If the item is not one the above types, the result is empty ([]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ConvertsToInteger
Path: fhircraft.fhir.path.engine.ConvertsToInteger
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath convertsToInteger() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return True if the item can be converted to an Integer, False otherwise.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ToDate
Path: fhircraft.fhir.path.engine.ToDate
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath toDate() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return a single date if: |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return a single date if:
- the item is a Date
- the item is a DateTime
- the item is a String and is convertible to a Date
If the item is not one of the above types, or is not convertible to a Date (using the format YYYY-MM-DD), the result is empty.
If the item contains a partial date (e.g. '2012-01'), the result is a partial date.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ConvertsToDate
Path: fhircraft.fhir.path.engine.ConvertsToDate
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath convertsToDate() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return True if:
- the item is a Date
- the item is a DateTime
- the item is a String and is convertible to a Date
If the item is not one of the above types, or is not convertible to a Date (using the format YYYY-MM-DD), the result is False.
If the item contains a partial date (e.g. '2012-01'), the result is a partial date.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ToDateTime
Path: fhircraft.fhir.path.engine.ToDateTime
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath toDateTime() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return a single datetime if: |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return a single datetime if:
- the item is a DateTime
- the item is a Date, in which case the result is a DateTime with the year, month, and day of the Date, and the time components empty (not set to zero)
- the item is a String and is convertible to a DateTime
If the item is a String, but the string is not convertible to a DateTime (using the format YYYY-MM-DDThh:mm:ss.fff(+|-)hh:mm), the result is empty.
If the item contains a partial datetime (e.g. '2012-01-01T10:00'), the result is a partial datetime.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ConvertsToDateTime
Path: fhircraft.fhir.path.engine.ConvertsToDateTime
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath convertsToDateTime() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return True if:
- the item is a DateTime
- the item is a Date, in which case the result is a DateTime with the year, month, and day of the Date, and the time components empty (not set to zero)
- the item is a String and is convertible to a DateTime
If the item is a String, but the string is not convertible to a DateTime (using the format YYYY-MM-DDThh:mm:ss.fff(+|-)hh:mm), the result is False.
If the item contains a partial datetime (e.g. '2012-01-01T10:00'), the result is 'True'.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ToDecimal
Path: fhircraft.fhir.path.engine.ToDecimal
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath toDecimal() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return a single decimal if: |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return a single decimal if:
- the item is an Integer or Decimal
- the item is a String and is convertible to a Decimal
- the item is a Boolean, where True results in a 1.0 and False results in a 0.0.
If the item is not one of the above types, the result is empty ([]).
If the item is a String, but the string is not convertible to a Decimal, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ConvertsToDecimal
Path: fhircraft.fhir.path.engine.ConvertsToDecimal
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath convertsToDecimal() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return True if:
- the item is an Integer or Decimal
- the item is a String and is convertible to a Decimal
- the item is a Boolean, where True results in a 1.0 and False results in a 0.0.
If the item is not one of the above types, or is not convertible to a Decimal, the result is False.
If the input collection is empty, the result is empty ('[]').
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ToQuantity
Path: fhircraft.fhir.path.engine.ToQuantity
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath toQuantity() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return a single quantity if: |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return a single quantity if:
- the item is an Integer, or Decimal, where the resulting quantity will have the default unit ('1')
- the item is a Quantity
- the item is a String and is convertible to a Quantity
- the item is a Boolean, where true results in the quantity 1.0 '1', and false results in the quantity 0.0 '1'
If the item is not one of the above types, the result is empty.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ConvertsToQuantity
Path: fhircraft.fhir.path.engine.ConvertsToQuantity
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath convertsToQuantity() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return True if:
- the item is an Integer, or Decimal, where the resulting quantity will have the default unit ('1')
- the item is a Quantity
- the item is a String and is convertible to a Quantity
- the item is a Boolean, where true results in the quantity 1.0 '1', and false results in the quantity 0.0 '1'
If the item is not one of the above types, the result is False.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ToString
Path: fhircraft.fhir.path.engine.ToString
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath toString() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return a single string if: |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return a single string if:
- the item in the input collection is a String
- the item in the input collection is an Integer, Decimal, Date, Time, DateTime, or Quantity the output will contain its String representation
- the item is a Boolean, where true results in 'true' and false in 'false'.
If the item is not one of the above types, the result is empty.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ConvertsToString
Path: fhircraft.fhir.path.engine.ConvertsToString
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath convertsToString() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return True if:
- the item in the input collection is a String
- the item in the input collection is an Integer, Decimal, Date, Time, DateTime, or Quantity the output will contain its String representation
- the item is a Boolean, where true results in 'true' and false in 'false'.
If the item is not one of the above types, the result is False.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ToTime
Path: fhircraft.fhir.path.engine.ToTime
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath toTime() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return a single time if: |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return a single time if:
- the item is a Time
- the item is a String and is convertible to a Time
If the item is a String, but the string is not convertible to a Time (using the format hh:mm:ss.fff(+|-)hh:mm), the result is empty.
If the item contains a partial datetime (e.g. '10:00'), the result is a partial datetime.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
ConvertsToTime
Path: fhircraft.fhir.path.engine.ConvertsToTime
Bases: FHIRTypeConversionFunction
A representation of the FHIRPath convertsToTime() function.
Methods:
| Name | Description |
|---|---|
evaluate |
If the input collection contains a single item, this function will return |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the input collection contains a single item, this function will return True if:
- the item is a Time
- the item is a String and is convertible to a Time
If the item is a String, but the string is not convertible to a DateTime (using the format hh:mm:ss.fff(+|-)hh:mm), the result is False.
If the item contains a partial datetime (e.g. '10:00'), the result is 'True'.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If input collection has more than one item. |
FHIRPath
Path: fhircraft.fhir.path.engine.FHIRPath
Bases: ABC
Abstract base class for FHIRPath expressions.
Methods:
| Name | Description |
|---|---|
values |
Evaluates the FHIRPath expression and returns all resulting values as a list. |
single |
Evaluates the FHIRPath expression and returns a single value. |
first |
Evaluates the FHIRPath expression and returns the first value. |
last |
Evaluates the FHIRPath expression and returns the last value. |
exists |
Checks if the FHIRPath expression matches any values in the data. |
count |
Returns the number of values that match the FHIRPath expression. |
is_empty |
Checks if the FHIRPath expression matches no values in the data. |
update_values |
Evaluates the FHIRPath expression and sets all matching locations to the given value. |
update_single |
Evaluates the FHIRPath expression and sets a single matching location to the given value. |
trace |
Returns a trace of evaluation steps for debugging purposes. |
debug_info |
Returns debugging information about the evaluation. |
evaluate |
Evaluates the current object against the provided FHIRPathCollection. |
values ¶
Evaluates the FHIRPath expression and returns all resulting values as a list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
environment
|
dict | None
|
Optional map of additional variables to include in the evaluation context. |
None
|
Returns:
| Type | Description |
|---|---|
List[Any]
|
List[Any]: A list of all values that match the FHIRPath expression. Returns an empty list if no matches are found. |
single ¶
Evaluates the FHIRPath expression and returns a single value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
default
|
Any
|
The default value to return if no matches are found. |
None
|
environment
|
dict | None
|
Optional map of additional variables to include in the evaluation context. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The single matching value. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If more than one value is found. |
first ¶
Evaluates the FHIRPath expression and returns the first value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
default
|
Any
|
The default value to return if no matches are found. |
None
|
environment
|
dict | None
|
Optional map of additional variables to include in the evaluation context. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The first matching value, or the default if no matches. |
last ¶
Evaluates the FHIRPath expression and returns the last value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
default
|
Any
|
The default value to return if no matches are found. |
None
|
environment
|
dict | None
|
Optional map of additional variables to include in the evaluation context. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
The last matching value, or the default if no matches. |
exists ¶
Checks if the FHIRPath expression matches any values in the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
environment
|
dict | None
|
Optional map of additional variables to include in the evaluation context. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if at least one value matches, False otherwise. |
count ¶
Returns the number of values that match the FHIRPath expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
environment
|
dict | None
|
Optional map of additional variables to include in the evaluation context. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of matching values. |
is_empty ¶
Checks if the FHIRPath expression matches no values in the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
environment
|
dict | None
|
Optional map of additional variables to include in the evaluation context. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if no values match, False otherwise. |
update_values ¶
Evaluates the FHIRPath expression and sets all matching locations to the given value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
value
|
Any
|
The value to set at all matching locations. |
required |
environment
|
dict | None
|
Optional map of additional variables to include in the evaluation context. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no matching locations are found or if locations cannot be set. |
update_single ¶
Evaluates the FHIRPath expression and sets a single matching location to the given value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
value
|
Any
|
The value to set at the matching location. |
required |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If zero or more than one matching locations are found. |
RuntimeError
|
If the location cannot be set. |
trace ¶
Returns a trace of evaluation steps for debugging purposes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
verbose
|
bool
|
If True, includes detailed information about each step. |
False
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: A list of trace messages showing the evaluation steps. |
debug_info ¶
Returns debugging information about the evaluation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to evaluate the FHIRPath expression against. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary containing debugging information including: - expression: String representation of the FHIRPath expression - expression_type: Type of the FHIRPath expression - input_data_type: Type of the input data - input_data_size: Size/length of input data if applicable - result_count: Number of results from evaluation - result_types: Types of result values - evaluation_success: Whether evaluation completed successfully - error: Error information if evaluation failed - collection_items: Information about FHIRPathCollectionItem objects |
evaluate
abstractmethod
¶
Evaluates the current object against the provided FHIRPathCollection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The collection of FHIRPath elements to evaluate. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The result of the evaluation as a FHIRPathCollection. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
This method must be implemented by subclasses. |
FHIRPathCollectionItem
Path: fhircraft.fhir.path.engine.FHIRPathCollectionItem
dataclass
¶
FHIRPathCollectionItem(value: Any, path: Any = None, element: Optional[str] = None, index: Optional[int] = None, parent: Optional[FHIRPathCollectionItem] = None, setter: Optional[Callable] = None)
Bases: object
A context-aware representation of an item in a FHIRPath collection.
Attributes¶
value (Any): The value of the collection item. path (Optional[FHIRPath]): The path associated with the collection item, by default This(). element (Optional[str]): The element name of the collection item, by default None. index (Optional[int]): The index of the collection item, by default None. parent (Optional[FHIRPathCollectionItem]): The item of the parent collection from which this item was derived, by default None. setter (Optional[callable]): The setter function for the collection item, by default None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
|
required |
path
|
Any
|
|
None
|
element
|
str | None
|
|
None
|
index
|
int | None
|
|
None
|
parent
|
ForwardRef | None
|
|
None
|
setter
|
Callable | None
|
|
None
|
Methods:
| Name | Description |
|---|---|
wrap |
Wraps data in a FHIRPathCollectionItem instance. |
set_value |
Sets the value of the item using the setter function. |
construct_resource |
Constructs a FHIR resource based on the field information. |
Attributes:
| Name | Type | Description |
|---|---|---|
field_info |
Retrieves the field information from the parent's value. |
|
is_list_type |
Checks if the field information indicates a list type. |
|
full_path |
Retrieves the full path of the item. |
field_info
property
¶
Retrieves the field information from the parent's value.
Returns:
| Type | Description |
|---|---|
Any
|
The field information, or None if not available. |
is_list_type
property
¶
Checks if the field information indicates a list type.
Returns:
| Type | Description |
|---|---|
bool
|
True if the field information indicates a list type, False otherwise. |
full_path
property
¶
wrap
classmethod
¶
wrap(data: Any) -> FHIRPathCollectionItem
Wraps data in a FHIRPathCollectionItem instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to be wrapped. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
item |
FHIRPathCollectionItem
|
The wrapped FHIRPathCollectionItem instance. |
set_value ¶
Sets the value of the item using the setter function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to set. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the value is a list. |
RuntimeError
|
If there is no setter function associated with this item. |
Literal
Path: fhircraft.fhir.path.engine.Literal
Literal(value: Any)
Bases: FHIRPath
A class representation of a constant literal value in the FHIRPath.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
Any
|
The literal value to be represented. |
Methods:
| Name | Description |
|---|---|
evaluate |
Simply returns the input collection. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Simply returns the input collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The collection of items to be evaluated. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
A list of FHIRPathCollectionItem instances after evaluation. |
Element
Path: fhircraft.fhir.path.engine.Element
Element(label: str | Literal | FHIRPrimitiveModel)
Bases: FHIRPath
A class representing an element in a FHIRPath, used for navigating and manipulating FHIR resources.
Attributes:
| Name | Type | Description |
|---|---|---|
label |
str
|
The name of the element. |
Methods:
| Name | Description |
|---|---|
create_element |
Ensure that the input parent object has the necessary field information to create a new element based on the label provided. |
setter |
Sets the value of the specified element in the parent object. |
create_element ¶
Ensure that the input parent object has the necessary field information to create a new element based on the label provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Any
|
The parent object from which the element will be created. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
element |
Any
|
The newly created element based on the field information of the parent object, or None if the parent is invalid or lacks the required field information. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If there is an issue with retrieving the field information from the parent object. |
AttributeError
|
If there is an attribute error while trying to create the new element. |
setter
staticmethod
¶
setter(value: Any, item: FHIRPathCollectionItem, index: int, label: str, is_list_type: bool) -> None
Sets the value of the specified element in the parent object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to set for the element. |
required |
item
|
FHIRPathCollectionItem
|
The parent collection item. |
required |
index
|
int
|
The index of the element in the parent object. |
required |
label
|
str
|
The label of the element to set. |
required |
Invocation
Path: fhircraft.fhir.path.engine.Invocation
Bases: FHIRPath
A class representing an invocation in the context of FHIRPath evaluation
indicated by two dot-separated identifiers <left>.<right>.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath
|
The left-hand side FHIRPath segment of the invocation. |
right |
FHIRPath
|
The right-hand side FHIRPath segment of the invocation. |
Methods:
| Name | Description |
|---|---|
evaluate |
Performs the evaluation of the Invocation by applying the left-hand side FHIRPath segment on the given collection to obtain a parent collection. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Performs the evaluation of the Invocation by applying the left-hand side FHIRPath segment on the given collection to obtain a parent collection. Then, the right-hand side FHIRPath segment is applied on the parent collection to derive the child collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The collection on which the evaluation is performed. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The resulting child collection after the evaluation process. |
This
Path: fhircraft.fhir.path.engine.This
Bases: FHIRPath
A representation of a current element. Used for internal purposes and has no FHIRPath shorthand notation.
Methods:
| Name | Description |
|---|---|
evaluate |
Simply returns the input collection. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Simply returns the input collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The collection of items to be evaluated. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The output collection. |
RootElement
Path: fhircraft.fhir.path.engine.RootElement
RootElement(type: str = 'Resource')
Bases: FHIRPath
A class representing the root of a FHIRPath, i.e. the top-most segment of the FHIRPath whose collection has no parent associated.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The expected FHIR resource type of the root element, by default. |
Methods:
| Name | Description |
|---|---|
evaluate |
Evaluate the input collection to assert that the entries are valid FHIR resources of the given type. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Evaluate the input collection to assert that the entries are valid FHIR resources of the given type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
Collection
|
The collection of items to be evaluated. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
Collection
|
The same collection after validation. |
TypeSpecifier
Path: fhircraft.fhir.path.engine.TypeSpecifier
TypeSpecifier(specifier: str)
Bases: FHIRPath
A type specifier is an identifier that must resolve to the name of a type in a model. Type specifiers can have qualifiers, e.g. FHIR.Patient, where the qualifier is the name of the model.
Attributes:
| Name | Type | Description |
|---|---|---|
specifier |
str
|
The type specifier string. |
namespace |
Optional[str]
|
The namespace of the type specifier, by default "FHIR". |
Methods:
| Name | Description |
|---|---|
evaluate |
Evaluate the input collection to assert that the entries are valid FHIR resources of the given type. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Evaluate the input collection to assert that the entries are valid FHIR resources of the given type.
The type is resolved based on the namespace and specifier using the FHIR release specified in the environment
variable %fhirRelease. If the variable is not present, it defaults to "R4" and will warn on usage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
Collection
|
The collection of items to be evaluated. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
Collection
|
The same collection after validation. |
Equals
Path: fhircraft.fhir.path.engine.Equals
Bases: FHIRPath
A representation of the FHIRPath = operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns true if the left collection is equal to the right collection: |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment, create: bool = False) -> FHIRPathCollection
Returns true if the left collection is equal to the right collection: As noted above, if either operand is an empty collection, the result is an empty collection. Otherwise: If both operands are collections with a single item, they must be of the same type (or be implicitly convertible to the same type), and: - For primitives: - String: comparison is based on Unicode values - Integer: values must be exactly equal - Decimal: values must be equal, trailing zeroes after the decimal are ignored - Boolean: values must be the same - Date: must be exactly the same - DateTime: must be exactly the same, respecting the timezone offset (though +00:00 = -00:00 = Z) - Time: must be exactly the same - For complex types, equality requires all child properties to be equal, recursively.= If both operands are collections with multiple items: - Each item must be equal - Comparison is order dependent Otherwise, equals returns false. Note that this implies that if the collections have a different number of items to compare, the result will be false.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Equivalent
Path: fhircraft.fhir.path.engine.Equivalent
Bases: FHIRPath
A representation of the FHIRPath ~ operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns true if the collections are the same. In particular, comparing empty collections for equivalence { } ~ { } will result in true. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns true if the collections are the same. In particular, comparing empty collections for equivalence { } ~ { } will result in true. If both operands are collections with a single item, they must be of the same type (or implicitly convertible to the same type), and: - For primitives - String: the strings must be the same, ignoring case and locale, and normalizing whitespace. - Integer: exactly equal - Decimal: values must be equal, comparison is done on values rounded to the precision of the least precise operand. Trailing zeroes after the decimal are ignored in determining precision. - Date, DateTime and Time: values must be equal, except that if the input values have different levels of precision, the comparison returns false, not empty ({ }). - Boolean: the values must be the same - For complex types, equivalence requires all child properties to be equivalent, recursively, except for "id" elements. If both operands are collections with multiple items: - Each item must be equivalent - Comparison is not order dependent Note that this implies that if the collections have a different number of items to compare, or if one input is a value and the other is empty ({ }), the result will be false.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
NotEquals
Path: fhircraft.fhir.path.engine.NotEquals
Bases: FHIRPath
A representation of the FHIRPath != operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
The converse of the equals operator, returning true if equal returns false; false if equal |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
The converse of the equals operator, returning true if equal returns false; false if equal returns true; and empty ({ }) if equal returns empty. In other words, A != B is short-hand for (A = B).not().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
NotEquivalent
Path: fhircraft.fhir.path.engine.NotEquivalent
Bases: FHIRPath
A representation of the FHIRPath !~ operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
The converse of the equivalent operator, returning true if equivalent returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
The converse of the equivalent operator, returning true if equivalent returns false and false is equivalent returns true. In other words, A !~ B is short-hand for (A ~ B).not().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
The output collection. |
Empty
Path: fhircraft.fhir.path.engine.Empty
Bases: FHIRPathFunction
Representation of the FHIRPath empty() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns True if the input collection is empty ({}) and False otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Exists
Path: fhircraft.fhir.path.engine.Exists
Exists(criteria: FHIRPath | None = None)
Bases: FHIRPathFunction
Representation of the FHIRPath exists() function.
Attributes:
| Name | Type | Description |
|---|---|---|
criteria |
FHIRPath
|
Optional criteria to be applied to the collection prior to the determination of the exists |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns True if the collection has any elements, and False otherwise.
This is the opposite of empty(), and as such is a shorthand for empty().not().
If the input collection is empty ({}), the result is False.
The function can also take an optional criteria to be applied to the collection
prior to the determination of the exists. In this case, the function is
shorthand for where(criteria).exists().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
All
Path: fhircraft.fhir.path.engine.All
All(criteria: FHIRPath | FHIRPathCollection)
Bases: FHIRPathFunction
Representation of the FHIRPath all() function.
Attributes:
| Name | Type | Description |
|---|---|---|
criteria |
FHIRPath
|
Criteria to be applied to the collection prior to the evalution. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns True if for every element in the input collection, criteria evaluates to True.
Otherwise, the result is False. If the input collection is empty ({}), the result is True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
AllTrue
Path: fhircraft.fhir.path.engine.AllTrue
Bases: FHIRPathFunction
Representation of the FHIRPath allTrue() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Takes a collection of Boolean values and returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Takes a collection of Boolean values and returns True if all the items are True. If any
items are False, the result is False. If the input is empty ({}), the result is True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
AnyTrue
Path: fhircraft.fhir.path.engine.AnyTrue
Bases: FHIRPathFunction
Representation of the FHIRPath anyTrue() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Takes a collection of Boolean values and returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Takes a collection of Boolean values and returns True if any of the items are True.
If all the items are False, or if the input is empty ({}), the result is False.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
AllFalse
Path: fhircraft.fhir.path.engine.AllFalse
Bases: FHIRPathFunction
Representation of the FHIRPath allFalse() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Takes a collection of Boolean values and returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Takes a collection of Boolean values and returns True if all the items are False.
If any items are True, the result is False. If the input is empty ({}), the result is True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
AnyFalse
Path: fhircraft.fhir.path.engine.AnyFalse
Bases: FHIRPathFunction
Representation of the FHIRPath anyFalse() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Takes a collection of Boolean values and returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Takes a collection of Boolean values and returns True if any of the items are False. If all
the items are True, or if the input is empty ({}), the result is False.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
SubsetOf
Path: fhircraft.fhir.path.engine.SubsetOf
SubsetOf(other: FHIRPathCollection | FHIRPath)
Bases: FHIRPathFunction
Representation of the FHIRPath subsetOf() function.
Attributes:
| Name | Type | Description |
|---|---|---|
other |
Union[FHIRPathCollection, FHIRPath]
|
other collection to which to determine whether input is a subset of. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns True if all items in the input collection are members of the collection passed as the
other argument.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Note
Conceptually, this function is evaluated by testing each element in the input collection for
membership in the other collection, with a default of True. This means that if the input collection
is empty ([]), the result is True, otherwise if the other collection is empty, the result is False.
SupersetOf
Path: fhircraft.fhir.path.engine.SupersetOf
SupersetOf(other: FHIRPathCollection | FHIRPath)
Bases: FHIRPathFunction
Representation of the FHIRPath supersetOf() function.
Attributes:
| Name | Type | Description |
|---|---|---|
other |
Union[FHIRPathCollection, FHIRPath]
|
Other collection to which to determine whether input is a superset of. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns true if all items in the collection passed as the other argument are |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns true if all items in the collection passed as the other argument are members of the input collection. Membership is determined using the = (Equals) (=) operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Note
Conceptually, this function is evaluated by testing each element in the other collection for
membership in the input collection, with a default of True. This means that if the other collection
is empty ([]), the result is True, otherwise if the other collection is empty, the result is False.
Count
Path: fhircraft.fhir.path.engine.Count
Bases: FHIRPathFunction
Representation of the FHIRPath count() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the integer count of the number of items in the input collection. Returns 0 when the input collection is empty. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the integer count of the number of items in the input collection. Returns 0 when the input collection is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Distinct
Path: fhircraft.fhir.path.engine.Distinct
Bases: FHIRPathFunction
Representation of the FHIRPath distinct() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns a collection containing only the unique items in the input collection. If the input collection is empty ( |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns a collection containing only the unique items in the input collection. If the input collection is empty ([]), the result is empty.
Note that the order of elements in the input collection is not guaranteed to be preserved in the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
IsDistinct
Path: fhircraft.fhir.path.engine.IsDistinct
Bases: FHIRPathFunction
Representation of the FHIRPath isDistinct() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns True if all the items in the input collection are distinct.
If the input collection is empty ([]), the result is True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection |
Where
Path: fhircraft.fhir.path.engine.Where
Where(expression: FHIRPath)
Bases: FHIRPathFunction
Representation of the FHIRPath where() function.
Attributes:
| Name | Type | Description |
|---|---|---|
expression |
FHIRPath
|
Expression to evaluate for each collection item. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns a collection containing only those elements in the input collection for which |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns a collection containing only those elements in the input collection for which
the stated criteria expression evaluates to True. Elements for which the expression
evaluates to false or empty ([]) are not included in the result.
If the input collection is empty ([]), the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
Select
Path: fhircraft.fhir.path.engine.Select
Select(projection: FHIRPath)
Bases: FHIRPathFunction
Representation of the FHIRPath select() function.
Attributes:
| Name | Type | Description |
|---|---|---|
projection |
FHIRPath
|
Expression to evaluate for each collection item. |
Methods:
| Name | Description |
|---|---|
evaluate |
Evaluates the projection expression for each item in the input collection. The result of each |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Evaluates the projection expression for each item in the input collection. The result of each
evaluation is added to the output collection. If the evaluation results in a collection with
multiple items, all items are added to the output collection (collections resulting from
evaluation of projection are flattened). This means that if the evaluation for an element
results in the empty collection ([]), no element is added to the result, and that if the
input collection is empty ([]), the result is empty as well.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
Repeat
Path: fhircraft.fhir.path.engine.Repeat
Repeat(projection: FHIRPath)
Bases: FHIRPathFunction
Representation of the FHIRPath repeat() function.
Attributes:
| Name | Type | Description |
|---|---|---|
projection |
FHIRPath
|
Expression to evaluate for each collection item. |
Methods:
| Name | Description |
|---|---|
evaluate |
A version of select that will repeat the projection and add it to the output collection, as |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
A version of select that will repeat the projection and add it to the output collection, as long as the projection yields new items (as determined by the = (Equals) (=) operator).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
OfType
Path: fhircraft.fhir.path.engine.OfType
OfType(_type: TypeSpecifier)
Bases: FHIRPathFunction
Representation of the FHIRPath ofType() function.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
class
|
Type class |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns a collection that contains all items in the input collection that are of the given type |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns a collection that contains all items in the input collection that are of the given type
or a subclass thereof. If the input collection is empty ([]), the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
DateTime
Path: fhircraft.fhir.path.engine.DateTime
dataclass
¶
Bases: FHIRPathLiteralType
DateTime(valuestring: str | None = None, value_datetime: datetime.datetime | None = None)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
year
|
int
|
|
required |
month
|
int | None
|
|
required |
day
|
int | None
|
|
required |
hour
|
int | None
|
|
required |
minute
|
int | None
|
|
required |
second
|
float | None
|
|
required |
hour_shift
|
int | None
|
|
required |
minute_shift
|
int | None
|
|
required |
Addition
Path: fhircraft.fhir.path.engine.Addition
Bases: FHIRMathOperator
A representation of the FHIRPath + operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
For Integer, Decimal, and quantity, adds the operands. For strings, concatenates the right |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
For Integer, Decimal, and quantity, adds the operands. For strings, concatenates the right operand to the left operand. When adding quantities, the units of each quantity must be the same.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
Subtraction
Path: fhircraft.fhir.path.engine.Subtraction
Bases: FHIRMathOperator
A representation of the FHIRPath - operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
Subtracts the right operand from the left operand (supported for Integer, Decimal, and Quantity). |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Subtracts the right operand from the left operand (supported for Integer, Decimal, and Quantity). When subtracting quantities, the units of each quantity must be the same.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
Multiplication
Path: fhircraft.fhir.path.engine.Multiplication
Bases: FHIRMathOperator
A representation of the FHIRPath * operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
Multiplies both arguments (supported for Integer, Decimal, and Quantity). For multiplication |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Multiplies both arguments (supported for Integer, Decimal, and Quantity). For multiplication involving quantities, the resulting quantity will have the appropriate unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
Division
Path: fhircraft.fhir.path.engine.Division
Bases: FHIRMathOperator
A representation of the FHIRPath / operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
Divides the left operand by the right operand (supported for Integer, Decimal, and Quantity). |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Divides the left operand by the right operand (supported for Integer, Decimal, and Quantity).
The result of a division is always Decimal, even if the inputs are both Integer. For integer division,
use the div operator.
If an attempt is made to divide by zero, the result is empty.
For division involving quantities, the resulting quantity will have the appropriate unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
Div
Path: fhircraft.fhir.path.engine.Div
Bases: FHIRMathOperator
A representation of the FHIRPath div operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
Performs truncated division of the left operand by the right operand (supported for Integer and Decimal). |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Performs truncated division of the left operand by the right operand (supported for Integer and Decimal).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
Mod
Path: fhircraft.fhir.path.engine.Mod
Bases: FHIRMathOperator
A representation of the FHIRPath mod operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
Computes the remainder of the truncated division of its arguments (supported for Integer and Decimal). |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Computes the remainder of the truncated division of its arguments (supported for Integer and Decimal).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
Log
Path: fhircraft.fhir.path.engine.Log
Bases: FHIRPathMathFunction
A representation of the FHIRPath log function.
Attributes:
| Name | Type | Description |
|---|---|---|
base |
int | Literal
|
The base of the logarithm. Must be an integer greater than 1. |
Methods:
| Name | Description |
|---|---|
evaluate |
Computes the logarithm of the input value to the specified base. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Computes the logarithm of the input value to the specified base.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
For non-singleton collections or invalid base. |
Power
Path: fhircraft.fhir.path.engine.Power
Bases: FHIRPathMathFunction
A representation of the FHIRPath power function.
Attributes:
| Name | Type | Description |
|---|---|---|
exponent |
int | float | Literal
|
The exponent to which the input value is raised. |
Methods:
| Name | Description |
|---|---|
evaluate |
Computes the input value raised to the specified exponent. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Computes the input value raised to the specified exponent. Args: collection (FHIRPathCollection): The input collection. environment (dict): The environment context for the evaluation. create (bool): Whether to create new elements during evaluation if necessary. Returns: FHIRPathCollection: The output collection.
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
For non-singleton collections or invalid exponent. |
Round
Path: fhircraft.fhir.path.engine.Round
Bases: FHIRPathMathFunction
A representation of the FHIRPath round function.
Attributes:
| Name | Type | Description |
|---|---|---|
precision |
int
|
The number of decimal places to round to. |
Methods:
| Name | Description |
|---|---|
evaluate |
Rounds the input value to the specified precision. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Rounds the input value to the specified precision.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
For non-singleton collections or invalid precision. |
Children
Path: fhircraft.fhir.path.engine.Children
Bases: FHIRPathFunction
Representation of the FHIRPath children() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns a collection with all immediate child nodes of all items in the input collection. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns a collection with all immediate child nodes of all items in the input collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Descendants
Path: fhircraft.fhir.path.engine.Descendants
Bases: FHIRPathFunction
Representation of the FHIRPath descendants() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns a collection with all descendant nodes of all items in the input collection. The result does not include |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns a collection with all descendant nodes of all items in the input collection. The result does not include the nodes in the input collection themselves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Note
This function is a shorthand for repeat(children()).
Contains
Path: fhircraft.fhir.path.engine.Contains
Bases: StringManipulationFunction
A representation of the FHIRPath contains() function.
Attributes:
| Name | Type | Description |
|---|---|---|
substring |
str | FHIRPath
|
Substring to query or FHIRPath that resolves to a string. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns true when the given substring is a substring of the input string. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns true when the given substring is a substring of the input string.
If substring is the empty string (''), the result is True.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
Note
Note: The FHIRPath .contains() function described here is a string function that looks
for a substring in a string. This is different than the contains FHIRPath operator, which
is a list operator that looks for an element in a list.
IndexOf
Path: fhircraft.fhir.path.engine.IndexOf
Bases: StringManipulationFunction
A representation of the FHIRPath indexOf() function.
Attributes:
| Name | Type | Description |
|---|---|---|
substring |
str | FHIRPath
|
Subtring query or FHIRPath that resolves to a string.. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the 0-based index of the first position substring is found in the input string, |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the 0-based index of the first position substring is found in the input string,
or -1 if it is not found.
If substring is an empty string (''), the function returns 0.
If the input or substring is empty ([]), the result is empty ([]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
Substring
Path: fhircraft.fhir.path.engine.Substring
Bases: StringManipulationFunction
A representation of the FHIRPath substring() function.
Attributes:
| Name | Type | Description |
|---|---|---|
start |
int | FHIRPath
|
Start index of the substring or FHIRPath that resolves to an integer. |
end |
Optional[int | FHIRPath]
|
Optional, end index of the substring or FHIRPath that resolves to an integer. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the part of the string starting at position start (zero-based). If length is given, will |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the part of the string starting at position start (zero-based). If length is given, will
return at most length number of characters from the input string.
If start lies outside the length of the string, the function returns empty ([]). If there are
less remaining characters in the string than indicated by length, the function returns just the
remaining characters.
If the input or start is empty, the result is empty.
If an empty length is provided, the behavior is the same as if length had not been provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
StartsWith
Path: fhircraft.fhir.path.engine.StartsWith
Bases: StringManipulationFunction
A representation of the FHIRPath startsWith() function.
Attributes:
| Name | Type | Description |
|---|---|---|
prefix |
str | FHIRPath
|
String prefix to query or FHIRPath that resolves to a string.. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns true when the input string starts with the given prefix. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns true when the input string starts with the given prefix.
If prefix is the empty string (''), the result is True.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
EndsWith
Path: fhircraft.fhir.path.engine.EndsWith
Bases: StringManipulationFunction
A representation of the FHIRPath endsWith() function.
Attributes:
| Name | Type | Description |
|---|---|---|
suffix |
str | FHIRPath
|
String suffix to query or FHIRPath that resolves to a string. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns true when the input string ends with the given suffix. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns true when the input string ends with the given suffix.
If suffix is the empty string (''), the result is True.
If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
Upper
Path: fhircraft.fhir.path.engine.Upper
Bases: StringManipulationFunction
A representation of the FHIRPath upper() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the input string with all characters converted to upper case. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the input string with all characters converted to upper case. If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
Lower
Path: fhircraft.fhir.path.engine.Lower
Bases: StringManipulationFunction
A representation of the FHIRPath lower() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the input string with all characters converted to lower case. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the input string with all characters converted to lower case. If the input collection is empty, the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
Replace
Path: fhircraft.fhir.path.engine.Replace
Replace(pattern: str | FHIRPath | FHIRPathCollection, substitution: str | FHIRPath | FHIRPathCollection)
Bases: StringManipulationFunction
A representation of the FHIRPath replace() function.
Attributes:
| Name | Type | Description |
|---|---|---|
pattern |
str | FHIRPath
|
Substring to substitute or FHIRPath that resolves to a string. |
substitution |
str | FHIRPath
|
String to substitute |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the input string with all instances of |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the input string with all instances of pattern replaced with substitution.
If the substitution is the empty string (''), instances of pattern are removed from the result.
If pattern is the empty string (''), every character in the input string is surrounded by
the substitution, e.g. 'abc'.replace('','x') becomes 'xaxbxcx'.
If the input collection, pattern, or substitution are empty, the result is empty ({ }).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
Matches
Path: fhircraft.fhir.path.engine.Matches
Bases: StringManipulationFunction
A representation of the FHIRPath matches() function.
Attributes:
| Name | Type | Description |
|---|---|---|
regex |
str | FHIRPath
|
Regular expression to match or FHIRPath that resolves to a string. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns True when the value matches the given regular expression. Regular expressions
should function consistently, regardless of any culture- and locale-specific settings
in the environment, should be case-sensitive, use 'single line' mode and allow Unicode characters.
If the input collection or regex are empty, the result is empty ([]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
ReplaceMatches
Path: fhircraft.fhir.path.engine.ReplaceMatches
Bases: StringManipulationFunction
A representation of the FHIRPath replaceMatches() function.
Attributes:
| Name | Type | Description |
|---|---|---|
regex |
str | FHIRPath
|
Regular expression to substitute or FHIRPath that resolves to a string. |
substitution |
str | FHIRPath
|
String to substitute |
Methods:
| Name | Description |
|---|---|
evaluate |
Matches the input using the regular expression in regex and replaces each match with the |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Matches the input using the regular expression in regex and replaces each match with the
substitution string. The substitution may refer to identified match groups in the regular expression.
If the input collection, regex, or substitution are empty, the result is empty ([]).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
Length
Path: fhircraft.fhir.path.engine.Length
Bases: StringManipulationFunction
A representation of the FHIRPath length() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the length of the input string. If the input collection is empty ( |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the length of the input string. If the input collection is empty ([]), the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
ToChars
Path: fhircraft.fhir.path.engine.ToChars
Bases: StringManipulationFunction
A representation of the FHIRPath toChars() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the list of characters in the input string. If the input collection is empty ( |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the list of characters in the input string. If the input collection is empty ([]), the result is empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If input collection has more than one item. |
FHIRPathException
|
If the item in the input collection is not a string. |
Concatenation
Path: fhircraft.fhir.path.engine.Concatenation
Bases: FHIRPath
A representation of the FHIRPath & operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
right |
FHIRPath | FHIRPathCollection
|
Right operand. |
Methods:
| Name | Description |
|---|---|
evaluate |
For strings, will concatenate the strings, where an empty operand is taken to be the empty string. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
For strings, will concatenate the strings, where an empty operand is taken to be the empty string. This differs from + on two strings, which will result in an empty collection when one of the operands is empty. This operator is specifically included to simplify treating an empty collection as an empty string, a common use case in string manipulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathException
|
If either expression evaluates to a non-singleton collection. |
Index
Path: fhircraft.fhir.path.engine.Index
Bases: FHIRPath
A representation of the FHIRPath index [idx] operator.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
The index value for the FHIRPath index. |
Methods:
| Name | Description |
|---|---|
evaluate |
The indexer operation returns a collection with only the index-th item (0-based index). If the input |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
The indexer operation returns a collection with only the index-th item (0-based index). If the input
collection is empty ([]), or the index lies outside the boundaries of the input collection,
an empty collection is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
create
|
bool
|
Pad the collection array if the index lies out of bounds of the collection. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The indexed collection item. |
Raises:
| Type | Description |
|---|---|
FHIRPathError
|
If |
Notes
The collection padding with create=True allows the function to create and later access new elements.
The padded object is initialized based on the collection items' common parent (if exists).
Therefore, this option is only available for a homogeneous collection of items.
Single
Path: fhircraft.fhir.path.engine.Single
Bases: FHIRPathFunction
A representation of the FHIRPath single() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Will return the single item in the input if there is just one item. If the input collection is empty ( |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Will return the single item in the input if there is just one item. If the input collection is empty ([]), the result is empty.
If there are multiple items, an error is signaled to the evaluation environment. This function is useful for ensuring that an
error is returned if an assumption about cardinality is violated at run-time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
Info
Equivalent to Index(0) with additional error raising in case of non-singleton input collection.
First
Path: fhircraft.fhir.path.engine.First
Bases: FHIRPathFunction
A representation of the FHIRPath first() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns a collection containing only the first item in the input collection. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns a collection containing only the first item in the input collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
Info
Equivalent to Index(0).
Last
Path: fhircraft.fhir.path.engine.Last
Bases: FHIRPathFunction
A representation of the FHIRPath last() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns a collection containing only the last item in the input collection. |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns a collection containing only the last item in the input collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
Info
Equivalent to Index(-1).
Tail
Path: fhircraft.fhir.path.engine.Tail
Bases: FHIRPathFunction
A representation of the FHIRPath tail() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns a collection containing all but the first item in the input collection. Will return |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns a collection containing all but the first item in the input collection. Will return an empty collection if the input collection has no items, or only one item.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
Skip
Path: fhircraft.fhir.path.engine.Skip
Bases: FHIRPathFunction
A representation of the FHIRPath skip() function.
Attributes:
| Name | Type | Description |
|---|---|---|
num |
int | FHIRPath
|
The number of items to skip or FHIRPath evaluating to an integer. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns a collection containing all but the first |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns a collection containing all but the first num items in the input collection. Will return
an empty collection if there are no items remaining after the indicated number of items have
been skipped, or if the input collection is empty. If num is less than or equal to zero, the
input collection is simply returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
Take
Path: fhircraft.fhir.path.engine.Take
Bases: FHIRPathFunction
A representation of the FHIRPath take() function.
Attributes:
| Name | Type | Description |
|---|---|---|
num |
int
|
The number of items to take. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns a collection containing the first |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns a collection containing the first num items in the input collection, or less if there
are less than num items. If num is less than or equal to 0, or if the input collection
is empty ([]), take returns an empty collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
Intersect
Path: fhircraft.fhir.path.engine.Intersect
Intersect(other_collection: FHIRPath | FHIRPathCollection)
Bases: FHIRPathFunction
A representation of the FHIRPath intersect() function.
Attributes:
| Name | Type | Description |
|---|---|---|
other_collection |
FHIRPathCollection
|
The other collection to compute the intersection with. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the set of elements that are in both collections. Duplicate items will be eliminated |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the set of elements that are in both collections. Duplicate items will be eliminated by this function. Order of items is preserved in the result of this function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
Exclude
Path: fhircraft.fhir.path.engine.Exclude
Exclude(other_collection: FHIRPath | FHIRPathCollection)
Bases: FHIRPathFunction
A representation of the FHIRPath exclude() function.
Attributes:
| Name | Type | Description |
|---|---|---|
other_collection |
FHIRPathCollection
|
The other collection to compute the exclusion with. |
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the set of elements that are not in the other collection. Duplicate items will not be |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Returns the set of elements that are not in the other collection. Duplicate items will not be eliminated by this function, and order will be preserved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Type | Description |
|---|---|
FHIRPathCollection
|
FHIRPathCollection): The output collection. |
Is
Path: fhircraft.fhir.path.engine.Is
Is(left: FHIRPath | FHIRPathCollection, type_specifier: TypeSpecifier)
Bases: FHIRTypesOperator
A representation of the FHIRPath is operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
type_specifier |
str
|
Type specifier. |
Methods:
| Name | Description |
|---|---|
evaluate |
If the left operand is a collection with a single item and the second operand is a type identifier, |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the left operand is a collection with a single item and the second operand is a type identifier, this operator returns true if the type of the left operand is the type specified in the second operand, or a subclass thereof. If the input value is not of the type, this operator returns false. If the identifier cannot be resolved to a valid type identifier, the evaluator will throw an error. If the input collections contains more than one item, the evaluator will throw an error. In all other cases this operator returns the empty collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
LegacyIs
Path: fhircraft.fhir.path.engine.LegacyIs
LegacyIs(type_specifier: TypeSpecifier)
Bases: FHIRPathFunction
The is() function is supported for backwards compatibility with previous implementations of FHIRPath. Just as with the is keyword, the type argument is an identifier that must resolve to the name of a type in a model.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
type_specifier |
str
|
Type specifier. |
As
Path: fhircraft.fhir.path.engine.As
As(left: FHIRPath | FHIRPathCollection, type_specifier: TypeSpecifier)
Bases: FHIRTypesOperator
A representation of the FHIRPath as operator.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
type_specifier |
str
|
Type specifier. |
Methods:
| Name | Description |
|---|---|
evaluate |
If the left operand is a collection with a single item and the second operand is an identifier, |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
If the left operand is a collection with a single item and the second operand is an identifier, this operator returns the value of the left operand if it is of the type specified in the second operand, or a subclass thereof. If the identifier cannot be resolved to a valid type identifier, the evaluator will throw an error. If there is more than one item in the input collection, the evaluator will throw an error. Otherwise, this operator returns the empty collection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
FHIRPathCollection |
FHIRPathCollection
|
The output collection. |
Raises:
| Type | Description |
|---|---|
FHIRPathRuntimeError
|
If either expression evaluates to a non-singleton collection. |
LegacyAs
Path: fhircraft.fhir.path.engine.LegacyAs
LegacyAs(type_specifier: TypeSpecifier)
Bases: FHIRPathFunction
The as() function is supported for backwards compatibility with previous implementations of FHIRPath. Just as with the as keyword, the type argument is an identifier that must resolve to the name of a type in a model.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
FHIRPath | FHIRPathCollection
|
Left operand. |
type_specifier |
str
|
Type specifier. |
Trace
Path: fhircraft.fhir.path.engine.Trace
Bases: FHIRPathFunction
A representation of the FHIRPath trace() function.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
(str | FHIRPath
|
Subtring query or FHIRPath to evaluate for the trace name. |
Methods:
| Name | Description |
|---|---|
evaluate |
Adds a |
evaluate ¶
evaluate(collection: FHIRPathCollection, environment: dict, create: bool = False) -> FHIRPathCollection
Adds a String representation of the input collection to the diagnostic log, using the name argument
as the name in the log. This log should be made available to the user in some appropriate fashion. Does not
change the input, so returns the input collection as output.
If the projection argument is used, the trace would log the result of evaluating the project expression on the input,
but still return the input to the trace function unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
FHIRPathCollection
|
The input collection. |
required |
environment
|
dict
|
The environment context for the evaluation. |
required |
create
|
bool
|
Whether to create new elements during evaluation if necessary. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
collection |
FHIRPathCollection
|
The input collection. |
Now
Path: fhircraft.fhir.path.engine.Now
Bases: FHIRPathFunction
A representation of the FHIRPath now() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the current date and time, including timezone offset. |
TimeOfDay
Path: fhircraft.fhir.path.engine.TimeOfDay
Bases: FHIRPathFunction
A representation of the FHIRPath timeOfDay() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the current time. |
Today
Path: fhircraft.fhir.path.engine.Today
Bases: FHIRPathFunction
A representation of the FHIRPath Today() function.
Methods:
| Name | Description |
|---|---|
evaluate |
Returns the current date. |