Skip to main content
Version: v0.0.3

Function: parseCwe()

parseCwe(rep, enc): CWE

Parse an HL7 v2 CWE repetition into a structured CWE 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

CWE

Example

import { parseCwe, DEFAULT_ENCODING_CHARACTERS } from "@cosyte/hl7";
const rep = { components: [
{ subcomponents: ["GLU"] },
{ subcomponents: ["Glucose"] },
{ subcomponents: ["LN"] },
] };
const cwe = parseCwe(rep, DEFAULT_ENCODING_CHARACTERS);
console.log(cwe.identifier); // "GLU"