Skip to main content

core.getidentifierbytype

Home > @medplum/core > getIdentifierByType

getIdentifierByType() function

Returns the resource identifier for the given identifier type.

Whereas getIdentifier() matches on Identifier.system, i.e. who assigned the identifier, this matches on Identifier.type, i.e. what kind of identifier it is. For example, MRN_IDENTIFIER_TYPE finds the medical record number no matter which organization issued it.

Both the system and the code of the type coding must match. Matching on code alone would be ambiguous, because the same code means different things in different code systems.

If multiple identifiers exist with the same type, the first one is returned.

If the type is not found, then returns undefined.

Signature:

export declare function getIdentifierByType(resource: Resource, type: Coding): string | undefined;

Parameters

Parameter

Type

Description

resource

Resource

The resource to check.

type

Coding

The identifier type coding, such as MRN_IDENTIFIER_TYPE.

Returns:

string | undefined

The identifier value if found; otherwise undefined.