View raw Markdown
type: fhirpath-functionfunction: combinecategory: Combiningsection: 5.4.2source: fhirpath/functions.json

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 preserveOrder is false, or not supplied, there is no expectation of order. When preserveOrder is true, 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

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

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