6. switch

Last updated: Sep 8, 2025
DEVELOPER
IMPLEMENTATION
HEALTH TECH VENDOR

Definition

In a config modifier schema, use switch to check the value of a path against possible values that need a different outcome for each case (i.e., either a constant or the value parsed from another).

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
  7. default
  8. plugin

Example

You could look at every observation code and shift the value from 0 start to 1 for certain codes. If the code matches one of the cases, then it would check the value against its own switch statement.

For instance, if Observations[0].Code was 68520-6, then we would get the Value. In the example below, the Observations array would match the second case. Because the Value is 1, it would then be mapped to 2 due to the switch statement.

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