Skip to main content

core.hl7message

Home > @medplum/core > Hl7Message

Hl7Message class

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

Signature:

export declare class Hl7Message

Constructors

Constructor

Modifiers

Description

(constructor)(segments, context)

Creates a new HL7 message.

Properties

Property

Modifiers

Type

Description

context

readonly

Hl7Context

header

readonly

Hl7Segment

Returns the HL7 message header.

segments

readonly

Hl7Segment

Methods

Method

Modifiers

Description

buildAck(options)

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

get(index)

Returns an HL7 segment by index or by name.

getAll(name)

Returns all HL7 segments of a given name.

getAllSegments(name)

Returns all HL7 segments of a given name.

getSegment(index)

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.

parse(text)

static

Parses an HL7 message string into an Hl7Message object.

setSegment(index, segment)

Sets or replaces a segment at the specified index. Only allows MSH header to be replaced as first segment. If index is a number and is larger than the length of the segments array, it will be appended as the last segment. If the index is a string, replaces the first segment with that name.

toString()

Returns the HL7 message as a string.