Skip to main content
Version: v0.0.4

Function: parseXpn()

parseXpn(rep, enc): XPN

Parse an HL7 v2 XPN repetition into a structured XPN object. Components are returned verbatim (already decoded once by the tokenizer: never re-unescaped). Absent / empty components are OMITTED from the result (exactOptionalPropertyTypes semantics).

Parameters

rep

RawRepetition

enc

EncodingCharacters

Returns

XPN

Example

import { parseXpn, DEFAULT_ENCODING_CHARACTERS } from "@cosyte/hl7";
const rep = { components: [
{ subcomponents: ["Smith"] },
{ subcomponents: ["Jane"] },
] };
const xpn = parseXpn(rep, DEFAULT_ENCODING_CHARACTERS);
console.log(xpn.familyName); // "Smith"
console.log(xpn.givenName); // "Jane"