Skip to main content

core.hl7segment

Home > @medplum/core > Hl7Segment

Hl7Segment class

The Hl7Segment class represents one HL7 segment. A segment is a collection of fields. The name field is the first field.

Signature:

export declare class Hl7Segment 

Constructors

ConstructorModifiersDescription
(constructor)(fields, context)Creates a new HL7 segment.

Properties

PropertyModifiersTypeDescription
contextreadonlyHl7Context
fieldsreadonlyHl7Field[]
namereadonlystring

Methods

MethodModifiersDescription
get(index)Returns an HL7 field by index.
getComponent(fieldIndex, component, subcomponent, repetition)

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.

getField(index)

Returns an HL7 field by index.

Note that the index is 1-based, not 0-based.

For example, to get the first field, use getField(1).

This aligns with HL7 field names such as PID.1, PID.2, etc.

Field zero is the segment name.

parse(text, context)staticParses an HL7 segment string into an Hl7Segment object.
toString()Returns the HL7 segment as a string.