6. prefer

Last updated: Jan 5, 2026
DEVELOPER
IMPLEMENTATION
HEALTH TECH VENDOR

Definition

In a config modifier schema, use prefer to specify which value to return when evaluating an array of property definitions. If the specified prefer value exists, it's returned, otherwise the next property is evaluated.

This is useful for common situations when there are multiple possible fields from the input that might be relevant to the output, and you want to choose the “best” from that list.

Nesting level

This keyword executes at the following nesting level:

  1. omit
  2. constant
  3. references
  4. use
  5. get
  6. properties or if or concat or switch or pipe or merge or prefer or items
  7. default
  8. plugin

Example

You’re receiving an ADT^02 message where Visit.VisitDateTime is normally mapped from PV1.44.1 but is sometimes null or doesn't exist. But you still want a value for Visit.VisitDateTime to map from PV2.8.1. This is a perfect usage for prefer where if our first choice is null, it falls back on the second, third, or N choice.

Example: Prefer input from initial payload
json
1
"PV1": {
2
"1": "1",
3
"2": "P",
4
"3": {
5
"1": "2EAE",
6
"2": "",
7
"3": "",
8
"4": {
9
"1": "HMC"
10
},
11
"5": "",
12
"6": "",
13
"7": "HMC"
14
},
15
"4": "Elective",
16
"7": [
17
{
18
"1": "",
19
"2": {
20
"1": "Zconnected"
21
},
22
"3": "PhysOrthopaedicSurg",
23
"4": "",
24
"5": "",
25
"6": "",
26
"7": "",
27
"8": "",
28
"9": {
29
"1": ""
30
},
31
"10": "PRSNL"
32
}
33
],
34
"10": "ORS",
35
"14": "Non-Health Care Fac",
36
"18": "B",
37
"20": [
38
{
39
"1": "Self-pay"
40
}
41
],
42
"39": "HMC^HMC MHMC^ADT",
43
"41": "P"
44
},
45
"PV2": {
46
"3": {
47
"1": "",
48
"2": "arthritis"
49
},
50
"8": {
51
"1": "20251215073000"
52
}
53
},
Example: Prefer selector
json
1
$.Visit.VisitDateTime
Example: Config modifier with prefer keyword
yaml
1
pipe:
2
- use: initialPayload
3
prefer:
4
- get: PV1.44.1
5
- get: PV2.8.1
6
- plugin:
7
name: date-time
8
action: parse
9
parameters:
10
standard: HL7

Based on this example config modifier schema, this is the output.

Example: Prefer output in processed payload
json
1
{
2
...,
3
"Visit": {
4
...,
5
"VisitDateTime": "2025-12-15T07:30:00.000Z"
6
}
7
}