--- type: "fhirpath-function" title: "FHIRPath Function: combine" function: "combine" category: "Combining" section: "5.4.2" source: "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} ```fhirpath 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 `1`s 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 with - `preserveOrder` (optional): `Boolean` - Optional parameter to preserve order of elements ## Type Mapping - `Any-Any` ## Example ```fhirpath 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 ```