Skip to main content
Version: v0.0.4

Function: parsePl()

parsePl(rep, enc): PL

Parse an HL7 v2 PL repetition into a structured PL object. Components are returned verbatim (already decoded once by the tokenizer: never re-unescaped). Absent / empty components are OMITTED from the result (exactOptionalPropertyTypes semantics). Component 4 (facility) is parsed as a nested HD; see component table in the PL interface JSDoc for the v1 simplifications.

Parameters

rep

RawRepetition

enc

EncodingCharacters

Returns

PL

Example

import { parsePl, DEFAULT_ENCODING_CHARACTERS } from "@cosyte/hl7";
const rep = { components: [
{ subcomponents: ["ICU"] },
{ subcomponents: ["101"] },
{ subcomponents: ["A"] },
{ subcomponents: ["HOSP", "1.2.3", "UUID"] },
] };
const pl = parsePl(rep, DEFAULT_ENCODING_CHARACTERS);
console.log(pl.pointOfCare); // "ICU"
console.log(pl.facility?.namespaceId); // "HOSP"