prefer

Last updated: Feb 20, 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.

Order of execution

This keyword executes in the following order:

  1. omit
  2. constant
  3. references
  4. use
  5. get
  6. Mutually exclusive keywords at this level:
    • properties
    • if
    • concat
    • switch
    • pipe
    • merge
    • prefer
    • 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 doesnt exist. However, you still want to map a value from PV2.8.1 as a backup. This is a perfect use case for prefer. If the first choice is null or missing, the schema automatically falls back to the second, third, or Nth choice.

Example: Prefer input from initial payload
json
1
{
2
"PV1": {
3
"1": "1",
4
"2": "P",
5
"3": {
6
"1": "2EAE",
7
"2": "",
8
"3": "",
9
"4": {
10
"1": "HMC"
11
},
12
"5": "",
13
"6": "",
14
"7": "HMC"
15
},
16
"4": "Elective",
17
"7": [
18
{
19
"1": "",
20
"2": {
21
"1": "Zconnected"
22
},
23
"3": "PhysOrthopaedicSurg",
24
"4": "",
25
"5": "",
26
"6": "",
27
"7": "",
28
"8": "",
29
"9": {
30
"1": ""
31
},
32
"10": "PRSNL"
33
}
34
],
35
"10": "ORS",
36
"14": "Non-Health Care Fac",
37
"18": "B",
38
"20": [
39
{
40
"1": "Self-pay"
41
}
42
],
43
"39": "HMC^HMC MHMC^ADT",
44
"41": "P"
45
},
46
"PV2": {
47
"3": {
48
"1": "",
49
"2": "arthritis"
50
},
51
"8": {
52
"1": "20251215073000"
53
}
54
}
55
}
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
}