Skip to main content

Expressions and selection

The FUME expression layer is JSONata-based. It is the part of the language that navigates input data, filters selections, and computes values for transformations, orchestration, custom JSON construction, and FLASH rules.

Path navigation

Use dot-separated field names to walk through nested JSON objects.

patient.name.family

If a path segment is missing, the expression evaluates to nothing rather than throwing an error.

Array selection

Use square brackets after an array path when you want to select by position.

phones[0]
phones[-1]
  • Indexes are zero-based.
  • Negative indexes count from the end of the array.
  • If no index is given, the whole array is selected.

Bracket expressions also support filtering, which is how you keep only the items that match a condition.

Predicates

Predicates refine a selection with the form [expr].

Each selected item becomes the current context for the predicate expression. Items where the predicate evaluates to true are kept.

encounters[status = 'finished']
observations[code.coding.code = '8867-4']

This is a general expression-layer feature. The same predicate rules apply whether you are extracting values directly, building your own JSON output, or feeding values into FLASH assignments.

Wildcards and descendant selection

  • * selects all fields in an object.
  • ** traverses descendants recursively.

These are useful when the structure is partially known or when you need broad selection before later filtering.

Singleton values and arrays

Within FUME expressions, a scalar value and an array containing only that value are treated as equivalent in many compositions. That makes it easier to chain selections and predicates without constantly reshaping the data yourself.

Selections feed transformations

Selections are often just the first step in a mapping. Once you have the right values, you can return them directly, fold them into a custom JSON object, or pass them into FLASH rules that write FHIR output.

{
"patientId": patient.id,
"finishedEncounterCount": $count(encounters[status = 'finished'])
}

The selection model stays the same across all of those outputs.

Continue from here

Use Variables and orchestration when you need to bind intermediate values or coordinate multiple expression and FLASH steps.

For detailed operator and function coverage, continue to: