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

Parameter

Type

Description

fieldIndex

number

The HL7 field index.

component

number

The component index.

subcomponent

number

(Optional) Optional subcomponent index.

repetition

number

(Optional) Optional repetition index.

Returns:

string

The string value of the specified component.