$append
$append(array1, array2) -> arrayCompact type signature
<xx:a>Source: JSONata
Documentation
Returns an array containing the values in array1 followed by the values in array2. If either parameter is not an array, then it is treated as a singleton array containing that value.
Examples
Basic usage
$append([1,2,3], [4,5,6])=>[1,2,3,4,5,6]$append([1,2,3], 4)=>[1,2,3,4]$append("Hello", "World")=>["Hello", "World"]
Append a synthetic service code
Input
This example uses the claims-lines example input. The expression projects every serviceCode value and appends one synthetic code for display.
Example input
JSON
[
{
"claimId": "clm-2001",
"lineNumber": 1,
"serviceCode": "PROC-010",
"serviceDisplay": "office visit",
"units": 1,
"unitPrice": 125,
"allowedAmount": 110,
"modifiers": [
"MOD-A"
]
},
{
"claimId": "clm-2001",
"lineNumber": 2,
"serviceCode": "PROC-020",
"serviceDisplay": "imaging study",
"units": "1",
"unitPrice": 350,
"allowedAmount": 300,
"modifiers": [
"MOD-B",
"MOD-C"
]
},
{
"claimId": "clm-2001",
"lineNumber": 3,
"serviceCode": "PROC-030",
"serviceDisplay": "lab panel",
"units": 2,
"unitPrice": 40,
"allowedAmount": 70,
"modifiers": []
},
{
"claimId": "clm-2002",
"lineNumber": 1,
"serviceCode": "PROC-010",
"serviceDisplay": "office visit",
"units": 1,
"unitPrice": 125,
"allowedAmount": 115,
"modifiers": [
"MOD-A"
]
},
{
"claimId": "clm-2002",
"lineNumber": 2,
"serviceCode": "PROC-040",
"serviceDisplay": "counseling",
"units": 3,
"unitPrice": 60,
"allowedAmount": 150,
"modifiers": [
"MOD-D"
]
}
]
Expression
$append(serviceCode, "PROC-999")
Result
["PROC-010", "PROC-020", "PROC-030", "PROC-010", "PROC-040", "PROC-999"]