Skip to content

qie.parseHL7String

Signature: qie.parseHL7String(value, field*, comp*, repeat*, escape*, subComp*, segDel*, encoding*)

Returns: HL7 Message hl7Message - the associated HL7 message object

Parse the input string as HL7 and return the associated message object.

Note

The return value CAN NEVER be assigned to the bound-in message object; it should be assigned to a locally declared variable.

Parameters

Type Name Description Default
String value the source string to be parsed
String field* (optional) the HL7 field delimiter character `
String comp* (optional) the HL7 field component delimiter character ^
String repeat* (optional) the HL7 field value repeat character ~
String escape* (optional) the HL7 escape character "
String subComp* (optional) the HL7 field sub-component character &
String segDel* (optional) the HL7 segment delimiter specified in hexadecimal ('0D' or 'OA') or ascii ('\r' or '\n') 0D
String encoding* (optional) the character encoding for this message Source Node encoding

Example

var hl7String = `
MSH|^~\\&|SendingApp|SendingFacility|ReceivingApp|ReceivingFacility|202501070830||ADT^A01|12345|P|2.5
PID|1||123456^^^Hospital^MR||Doe^John||19800101|M|||123 Main St^^Anytown^CA^12345^USA||555-555-1234||S||123456789|987-65-4321
PV1|1|I|W^123^1^A|||12345^PrimaryDoctor|||SUR|||||12345^ConsultingDoctor|||||||||||||||||||||||||202501070800
`;

// Only 'value' is required. All other parameters are optional and may be omitted to use defaults.
var hl7MessageDefault = qie.parseHL7String(
    hl7String    // value: source HL7 string
);

// Optional: specify delimiters/encoding explicitly (overrides defaults).
var hl7MessageParsed = qie.parseHL7String(
    hl7String, // value: source HL7 string
    '|',       // field: field delimiter (optional)
    '^',       // comp: component delimiter (optional)
    '~',       // repeat: repeat delimiter (optional)
    '\\',      // escape: escape character (optional)
    '&',       // subComp: sub-component delimiter (optional)
    '\r',      // segDel: segment delimiter (CR) (optional)
    'UTF-8'    // encoding: character encoding (optional)
);