Skip to main content

$uuid

$uuid(seed?) -> string
Compact type signature<j?:s>

Source: FUME

Availability​

Community v1.0.0+
Enterprise v1.0.0+

Documentation​

Returns a UUID string in one of two modes:

  • Random: $uuid() generates a new random UUID on each call. Passing a seed that evaluates to undefined also uses this mode.
  • Deterministic: $uuid(seed) generates the same UUID every time the same seed is supplied.

The seed can be any JSON value: a string, number, boolean, array, object or null. Functions are not accepted. Strings are used directly; other values are serialized with JSON.stringify() before the UUID is derived.

Determinism depends on the serialized text, not on semantic equality. Object property order can affect the UUID. A number such as 42 and the string "42" produce the same UUID because they produce the same seed text. Use a consistent seed type and structure when generating identifiers.

The input is not used as an implicit seed. Pass $uuid($) explicitly to derive a UUID from the current context value.

Examples​

Generate a random UUID​

$uuid()

The result changes on each call, for example "b639158b-902b-4adf-9fef-f1888c18d8f3".

Generate a deterministic UUID from a seed​

Input

"pat-0001"

Expression

$uuid($)

Result

"58a71063-28a4-57ba-bb3f-3dcdcf2b40fc"

Repeated calls with "pat-0001" return this same UUID.

Generate deterministic UUIDs from other JSON values​

[
$uuid(42),
$uuid(true),
$uuid(null),
$uuid(["Patient", "pat-0001"]),
$uuid({"resourceType": "Patient", "id": "pat-0001"})
]

Each UUID is repeatable for its respective seed.