Skip to content
Reference

Field paths

The one HL7 v2 path syntax (PID.3(2).1, OBX[2].5), JSON paths, Retrohook keys, and the flat field-path view that lists every field of a sample. The view is off by default.

On this page

A field path names one value in a message. The same HL7 v2 syntax works in a Data Map source, a filter rule, the builder's field pickers and hl7.get in a JavaScript step. JSON and FHIR samples use JSON paths.

HL7 v2 paths

A path is the segment, an optional segment occurrence in [ ], the field, an optional field repetition in ( ), then an optional component and subcomponent:

text
SEG[occurrence].field(repetition).component.subcomponent
PathReads
PID.5.1Component 1 of PID-5 (the family name).
OBX[2].5OBX-5 of the second OBX segment.
OBX[*].5OBX-5 of every OBX segment, as a list.
PID.3(2).1Component 1 of the second repetition (~) of PID-3.
PID.3(*).1Component 1 of every repetition of PID-3, as a list.
PID.3The whole of PID-3, every repetition as received.
PID.3(1)Only the first repetition of PID-3.
PID.3.4.1Subcomponent 1 of component 4 of the first repetition of PID-3.
  • Numbers start at 1. [0] and (0) are not valid. For MSH, field 1 is the field separator, so MSH.9 is the message type.
  • A plain path keeps its old meaning. OBX.5 is the first OBX. PID.3.1 is component 1 of the first repetition.
  • Occurrences count across the whole message, not inside a group: the first OBX under the second OBR can be OBX[3].
  • Indexes stop at 999. A larger field, repetition, component or subcomponent number is refused, so a mapping cannot grow a message without limit.
  • In a Data Map source, add hl7:: hl7:OBX[2].5. Filter rules take the path without it.

JSON paths

A JSON path starts at $ and uses dots for keys and [n] for array items: $.name[1].family, $.entry[0].resource.id, $.obx[*].value. Array items count from 0, unlike HL7 numbers.

A JSON sample is the message body. In a live run a webhook trigger holds the body under data and a polling trigger holds each item under item, so the builder lists a webhook sample's fields as $.data... and a polling sample's as $.item....

Retrohook keys

Retrohook wrote a field repetition as a 0-based index in square brackets after the field: PID.3[0].1. MedHook reads that as Retrohook syntax and saves it as PID.3(1).1. A MedHook path never has [ after a field number, so OBX[2].5 is never rewritten.

With the flat field-path view on, a key typed in the Data Map's Add row form, typed into a filter rule's field, or returned by AI is rewritten this way. The Add row form says so, for example Read PID.3[0].1 as Retrohook syntax and changed it to PID.3(1).1.

The flat field-path view (beta)

The flat field-path view lists every field of a sample as a path, with its HL7 name and its value, so you can pick a path instead of typing it. It is off by default. An administrator turns it on, see Turn it on.

The Fields view

In the builder's Sample message panel, a loaded sample gets a Raw / Fields toggle. Fields lists one row per non-empty value:

PathLabelValue
MSH.9.1Message Type · Message CodeORU
PID.3(2).1Patient Identifier List · ID NumberTEST000456
OBX[2].5Observation Value98

[n] appears only on a segment that occurs more than once, and (n) only on a field that repeats. Filter the list by path, label or value, and choose Copy path to copy the Data Map source: hl7:OBX[2].5 for an HL7 row, the $ path for a JSON row. The list is parsed in your browser, so the sample never leaves the page. X12 and CSV samples have no field list: Fields shows a message saying the format isn't supported, so use Raw for them.

Sample and dry run, in the ··· menu of the workflow's Versions tab, lists the same rows, with a Label column.

What else changes

  • Data Map. The field list shows every occurrence and repetition, such as OBX[2].5, PID.3(2) and PID.3(2).1. A mapping saved as OBX.5 sits on the OBX[1].5 row. Without the view, the list shows the first occurrence of each segment, and a field's later repetitions appear as components (PID.3.2.1).
  • Filter rules. The field picker offers PID.3(2).1, PID.3(*).1 and OBX[2].5.
  • Templates. A template over an HL7 v2 input reads {{hl7:PATH}}, such as {{hl7:OBX[2].5}}, and {{#each hl7:OBX[*].5}}{{this}}{{/each}} loops over every value. See Templates. If the view is turned off later, these tags render empty.
  • Messages. The message inspector gets a Fields tab. Viewers do not see it, because their message detail stays redacted.
  • AI. AI mapping suggest sends the model one de-identified path = value (label) line per field instead of the hashed sample, and accepts answers written as PID.3(2).1 or OBX[2].5. Condition suggestions accept HL7 paths as available fields. The AI parts still need AI turned on. See AI-assisted mapping and conditions.

Turn it on

Set FLAT_FIELD_PATHS_ENABLED=true on the engine and restart it. Only true turns it on; 1 or yes leave it off.

Where you deploySetting
EnvironmentFLAT_FIELD_PATHS_ENABLED=true
Helmengine.flatFieldPathsEnabled: true
GKE Terraformengine_flat_field_paths_enabled = true

GET /api/version reports features.flatFieldPaths: true once it is on. It does not turn AI on, and it changes no saved workflow. Saved paths work with the view on or off; only {{hl7:PATH}} template tags need it.

Reference