Skip to main content
Version: v0.0.3

Function: parsePath()

parsePath(path): DotPath

Parse an HL7 dot-path string into a DotPath descriptor. Accepts shapes like SEG, SEG[n], SEG.N, SEG.N[r], SEG.N.C, SEG.N.C.S, and all combinations up to SEG[n].N[r].C.S. Throws TypeError with the offending path string on any malformed input.

Parameters

path

string

Returns

DotPath

Example

import { parsePath } from "@cosyte/hl7";
parsePath("PID.5.1"); // { segmentType: "PID", segmentIndex: 0, fieldIndex: 5, componentIndex: 1 }
parsePath("OBX[2].5"); // { segmentType: "OBX", segmentIndex: 2, fieldIndex: 5 }
parsePath("PID.3[1].1"); // { segmentType: "PID", segmentIndex: 0, fieldIndex: 3, repetitionIndex: 1, componentIndex: 1 }