switch

Last updated: Feb 20, 2026
DEVELOPER
IMPLEMENTATION
HEALTH TECH VENDOR

Definition

In a config modifier schema, use switch to check the value of a path against possible values that require different outcomes (i.e., returning a constant or parsing a different value).

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:
    1. properties
    2. if
    3. concat
    4. switch
    5. pipe
    6. merge
    7. prefer
    8. items
  7. default
  8. plugin

Example

You can look at every observation code and shift the value from 0 to 1 for certain codes. If the code matches one of the cases, the schema then checks the observations Value against a nested switch statement.

Example: Switch input from initial payload
json
1
{
2
"Observations": [
3
{
4
"DateTime": "2025-06-26T22:15:15.969369",
5
"Value": "1",
6
"ValueType": "Numeric",
7
"Units": null,
8
"Code": "68520-6",
9
...
10
},
11
{
12
"DateTime": "2025-06-26T22:15:15.969369",
13
"Value": "2",
14
"ValueType": "Numeric",
15
"Units": null,
16
"Code": "66864-0",
17
...
18
},
19
{
20
"DateTime": "2025-06-26T22:15:15.969369",
21
"Value": "3",
22
"ValueType": "Numeric",
23
"Units": null,
24
"Code": "66867-3",
25
...
26
}
27
]
28
}
Example: Switch selector
json
1
$.Observations[*].Value

For instance, if Observations[0].Code is 68520-6, it matches the second case. The nested switch then uses select: {} to look back at the original selector ($.Observations[*].Value). Because the Value is 1, the nested switch maps it to 2.

Example: Config modifier with switch keyword
yaml
1
switch:
2
select:
3
use: '@parent'
4
get: Code
5
cases:
6
- terms:
7
- constant: 68525-5
8
- constant: 68526-3
9
- constant: 68527-1
10
- constant: 68528-9
11
- constant: 68529-7
12
- constant: 68530-5
13
- constant: 68531-3
14
- constant: 68532-1
15
- constant: 68533-9
16
- constant: 68534-7
17
then:
18
switch:
19
select: {}
20
cases:
21
- terms:
22
- constant: '0'
23
then:
24
constant: '2'
25
else:
26
comment: do nothing
27
- terms:
28
- constant: 68518-0
29
- constant: 68519-8
30
- constant: 68520-6
31
- constant: AUDITCQ1
32
- constant: AUDITCQ2
33
- constant: AUDITCQ3
34
then:
35
switch:
36
select: {}
37
cases:
38
- terms:
39
- constant: '0'
40
then:
41
constant: '1'
42
- terms:
43
- constant: '1'
44
then:
45
constant: '2'
46
- terms:
47
- constant: '2'
48
then:
49
constant: '3'
50
- terms:
51
- constant: '3'
52
then:
53
constant: '4'
54
- terms:
55
- constant: '4'
56
then:
57
constant: '5'
58
else:
59
comment: do nothing
60
- terms:
61
- constant: 102011-4
62
- constant: 102012-2
63
- constant: 102013-0
64
- constant: 102014-8
65
- constant: 102015-5
66
- constant: 102016-3
67
then:
68
switch:
69
select: {}
70
cases:
71
- terms:
72
- constant: '0'
73
then:
74
constant: '2'
75
else:
76
comment: do nothing
77
else:
78
comment: do nothing

Based on this example config modifier, the Value is now 2.

Example: Switch output from processed payload
json
1
{
2
"Observations": [
3
{
4
"DateTime": "2025-06-26T22:15:15.969369",
5
"Value": "2",
6
"ValueType": "Numeric",
7
"Units": null,
8
"Code": "68520-6",
9
...
10
},
11
{
12
"DateTime": "2025-06-26T22:15:15.969369",
13
"Value": "2",
14
"ValueType": "Numeric",
15
"Units": null,
16
"Code": "66864-0",
17
...
18
},
19
{
20
"DateTime": "2025-06-26T22:15:15.969369",
21
"Value": "3",
22
"ValueType": "Numeric",
23
"Units": null,
24
"Code": "66867-3",
25
...
26
}
27
]
28
}