Function: parseCx()
parseCx(
rep,enc):CX
Parse an HL7 v2 CX repetition into a structured CX 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
(assigningAuthority) is parsed as a nested HD; see component table in
the CX interface JSDoc for the v1 simplifications on components 6/9/10.
Parameters
rep
enc
Returns
Example
import { parseCx, DEFAULT_ENCODING_CHARACTERS } from "@cosyte/hl7";
const rep = { components: [
{ subcomponents: ["123"] },
{ subcomponents: [""] },
{ subcomponents: [""] },
{ subcomponents: ["EPIC", "1.2.840.114350", "ISO"] },
{ subcomponents: ["MR"] },
] };
const cx = parseCx(rep, DEFAULT_ENCODING_CHARACTERS);
console.log(cx.idNumber); // "123"
console.log(cx.assigningAuthority?.namespaceId); // "EPIC"