Skip to main content

Class: Hl7Field

The Hl7Field class represents one HL7 field. A field is a collection of components.

Constructors

constructor

new Hl7Field(components, context?)

Creates a new HL7 field.

Parameters

NameTypeDescription
componentsstring[][]The HL7 components.
contextHl7ContextOptional HL7 parsing context.

Defined in

packages/core/src/hl7.ts:327

Properties

context

Readonly context: Hl7Context

Defined in

packages/core/src/hl7.ts:319


components

Readonly components: string[][]

Defined in

packages/core/src/hl7.ts:320

Methods

get

get(component, subcomponent?, repetition?): string

Returns an HL7 component by index.

Parameters

NameTypeDefault valueDescription
componentnumberundefinedThe component index.
subcomponent?numberundefinedOptional subcomponent index.
repetitionnumber0Optional repetition index.

Returns

string

The string value of the specified component.

Deprecated

Use getComponent() instead. This method will be removed in a future release.

Defined in

packages/core/src/hl7.ts:340


getComponent

getComponent(component, subcomponent?, repetition?): string

Returns an HL7 component by index.

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

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

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

Parameters

NameTypeDefault valueDescription
componentnumberundefinedThe component index.
subcomponent?numberundefinedOptional subcomponent index.
repetitionnumber0Optional repetition index.

Returns

string

The string value of the specified component.

Defined in

packages/core/src/hl7.ts:358


toString

toString(): string

Returns the HL7 field as a string.

Returns

string

The HL7 field as a string.

Defined in

packages/core/src/hl7.ts:372


parse

Static parse(text, context?): Hl7Field

Parses an HL7 field string into an Hl7Field object.

Parameters

NameTypeDescription
textstringThe HL7 field text.
contextHl7ContextOptional HL7 parsing context.

Returns

Hl7Field

The parsed HL7 field.

Defined in

packages/core/src/hl7.ts:382