Skip to main content

core.hl7segment.getcomponent

Home > @medplum/core > Hl7Segment > getComponent

Hl7Segment.getComponent() method

Returns an HL7 component by field index and component index.

This is a shortcut for getField(field).getComponent(component).

Note that both indexex are 1-based, not 0-based.

For example, to get the first component, use getComponent(1, 1).

This aligns with HL7 component names such as MSH.9.2.

Signature:

getComponent(fieldIndex: number, component: number, subcomponent?: number, repetition?: number): string;

Parameters

ParameterTypeDescription
fieldIndexnumberThe HL7 field index.
componentnumberThe component index.
subcomponentnumber(Optional) Optional subcomponent index.
repetitionnumber(Optional) Optional repetition index.

Returns:

string

The string value of the specified component.