FHIRPath Function: combine
Merge the input and other collections into a single collection without eliminating duplicate values. Combining an empty collection with a non-empty collection will return the non-empty collection.
Note: The contents of this section are Standard for Trial Use (STU) {: .stu-note } When
preserveOrderisfalse, or not supplied, there is no expectation of order. WhenpreserveOrderistrue, the items of the other collection are appended to the items of the input collection, preserving the order of items in both collections. {: .stu}
For example, considering the same two lists of integers used in the union example A: 1, 1, 2, 3 and B: 2, 3:
{: .stu}
A.combine(B) // 1, 1, 2, 2, 3, 3 - order is not guaranteed to be preserved (could be in any order)
A.combine(B, true) // 1, 1, 2, 3, 2, 3 - The order is preserved using the `preserveOrder` argument
A.combine( {} ) // 1, 1, 2, 3 - combining an empty collection with a non-empty collection returns the non-empty collection
{: .stu}
Note that the duplicate 1s are not removed from the collection using combine, where using union or | they would have been.
{: .stu}
Summary
- Category: Combining
- Section:
5.4.2 - Return Type:
collection - Empty Input Result:
empty - Errors on Multiple Input:
false
Description
Merge the input and other collections into a single collection without eliminating duplicate values. Combining an empty collection with a non-empty collection will return the non-empty collection. When preserveOrder is false, or not supplied, there is no expectation of order. When preserveOrder is true, the elements of the other collection are appended to the elements of the input collection, preserving the order of elements in both collections.
Arguments
other:collection- Collection to combine withpreserveOrder(optional):Boolean- Optional parameter to preserve order of elements
Type Mapping
Example
A.combine(B) // 1, 1, 2, 2, 3, 3 - order is not guaranteed to be preserved
A.combine(B, true) // 1, 1, 2, 3, 2, 3 - The order is preserved using the `preserveOrder` argument
A.combine( {} ) // 1, 1, 2, 3 - combining an empty collection with a non-empty collection returns the non-empty collection