core.replace | Medplum

replace() function

The "replace" operation replaces the value at the target location with a new value. The operation object MUST contain a "value" member whose content specifies the replacement value. The target location MUST exist for the operation to be successful.
This operation is functionally identical to a "remove" operation for a value, followed immediately by an "add" operation at the same location with the replacement value.
Even more simply, it's like the add operation with an existence check.

Signature:

export declare function replace(object: any, operation: ReplaceOperation, _options?: PatchOptions): MissingError | null;  

Parameters

Parameter Type Description
object any The object being patched.
operation ReplaceOperation The operation to perform on the object.
_options PatchOptions (Optional) Optional params.

Returns:
MissingError | null
null on success, or error if one occurred.