Skip to main content
Version: v0.0.3

Function: encodeComposite()

encodeComposite<K>(kind, value): RawField

Encode any typed composite into a spec-clean RawField by its CompositeKind. The single dispatcher setComposite and the typed builders (buildAdt/buildOru) route through.

Encoding takes no encoding-characters argument on purpose: the field it produces carries the decoded component values, and the actual delimiter-escaping happens later in the serializer against the message's own encoding characters: so a composite is delimiter-independent to encode.

Type Parameters

K

K extends CompositeKind

Parameters

kind

K

value

CompositeValueByKind[K]

Returns

RawField

Example

import { encodeComposite } from "@cosyte/hl7";
// A hostile family name cannot break framing on emit:
const f = encodeComposite("XPN", { familyName: "Smith^Jr", givenName: "Ann" });