View raw Markdown
type: fhirpath-functionfunction: unioncategory: Combiningsection: 5.4.1source: fhirpath/functions.json

FHIRPath Function: union

Merge the two collections into a single collection, eliminating any duplicate values (using equals (=) to determine equality). There is no expectation of order in the resulting collection.

In other words, this function returns the distinct list of items from both inputs. For example, consider two lists of integers A: 1, 1, 2, 3 and B: 2, 3:

A.union( B ) // 1, 2, 3
A.union( { } ) // 1, 2, 3

This function can also be invoked using the | operator.

e.g. x.union(y){:.fhirpath} is synonymous with x | y{:.fhirpath}

e.g. name.select(use.union(given)){:.fhirpath} is the same as name.select(use | given){:.fhirpath}, noting that the union function does not introduce an iteration context, in this example the select introduces the iteration context on the name element.

Summary

Description

Merge the two collections into a single collection, eliminating any duplicate values (using equals (=) to determine equality). There is no expectation of order in the resulting collection.

Arguments

Type Mapping

Example

A.union(B) // 1, 2, 3
A.union({}) // 1, 2, 3