Skip to main content

core.applydefaultvaluestoresource

Home > @medplum/core > applyDefaultValuesToResource

applyDefaultValuesToResource() function

Adds default values to resource based on the supplied schema. Default values includes all required fixed and pattern values specified on elements in the schema. If an element has a fixed/pattern value but is optional, i.e. element.min === 0, the default value is not added.

Signature:

export declare function applyDefaultValuesToResource(resource: Resource, schema: InternalTypeSchema): Resource;

Parameters

Parameter

Type

Description

resource

Resource

The resource to which default values should be added.

schema

InternalTypeSchema

The schema to use for adding default values.

Returns:

Resource

A clone of resource with default values added.