Skip to main content

Class: Hl7Message

The Hl7Message class represents one HL7 message. A message is a collection of segments.

Constructors

constructor

new Hl7Message(segments, context?)

Creates a new HL7 message.

Parameters

NameTypeDescription
segmentsHl7Segment[]The HL7 segments.
contextHl7ContextOptional HL7 parsing context.

Defined in

packages/core/src/hl7.ts:55

Properties

context

Readonly context: Hl7Context

Defined in

packages/core/src/hl7.ts:47


segments

Readonly segments: Hl7Segment[]

Defined in

packages/core/src/hl7.ts:48

Accessors

get header(): Hl7Segment

Returns the HL7 message header.

Returns

Hl7Segment

The HL7 message header.

Defined in

packages/core/src/hl7.ts:64

Methods

get

get(index): undefined | Hl7Segment

Returns an HL7 segment by index or by name.

Parameters

NameTypeDescription
indexstring | numberThe HL7 segment index or name.

Returns

undefined | Hl7Segment

The HL7 segment if found; otherwise, undefined.

Deprecated

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

Defined in

packages/core/src/hl7.ts:74


getAll

getAll(name): Hl7Segment[]

Returns all HL7 segments of a given name.

Parameters

NameTypeDescription
namestringThe HL7 segment name.

Returns

Hl7Segment[]

An array of HL7 segments with the specified name.

Deprecated

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

Defined in

packages/core/src/hl7.ts:84


getSegment

getSegment(index): undefined | Hl7Segment

Returns an HL7 segment by index or by name.

When using a numeric index, the first segment (usually the MSH header segment) is at index 0.

When using a string index, this method returns the first segment with the specified name.

Parameters

NameTypeDescription
indexstring | numberThe HL7 segment index or name.

Returns

undefined | Hl7Segment

The HL7 segment if found; otherwise, undefined.

Defined in

packages/core/src/hl7.ts:98


getAllSegments

getAllSegments(name): Hl7Segment[]

Returns all HL7 segments of a given name.

Parameters

NameTypeDescription
namestringThe HL7 segment name.

Returns

Hl7Segment[]

An array of HL7 segments with the specified name.

Defined in

packages/core/src/hl7.ts:110


toString

toString(): string

Returns the HL7 message as a string.

Returns

string

The HL7 message as a string.

Defined in

packages/core/src/hl7.ts:118


buildAck

buildAck(): Hl7Message

Returns an HL7 "ACK" (acknowledgement) message for this message.

Returns

Hl7Message

The HL7 "ACK" message.

Defined in

packages/core/src/hl7.ts:126


parse

Static parse(text): Hl7Message

Parses an HL7 message string into an Hl7Message object.

Parameters

NameTypeDescription
textstringThe HL7 message text.

Returns

Hl7Message

The parsed HL7 message.

Defined in

packages/core/src/hl7.ts:182