Skip to main content
Version: v0.0.6

Function: parseReferenceRange()

parseReferenceRange(raw): ReferenceRange

Parse an R-record reference-range field (field 6) into a low/high (or open-ended) pair.

Recognized forms are low-high (closed), <high (open-low), and >low (open-high). Anything else, including an ambiguous multi-dash string or a bare non-numeric token, is returned as kind: "unparsed" with the raw text preserved and no bound invented. Bounds are surfaced as verbatim text, not coerced to numbers.

Parameters

raw

string

The verbatim field-6 text.

Returns

ReferenceRange

The parsed reference range.

Example

import { parseReferenceRange } from "@cosyte/astm";
parseReferenceRange("<5").kind; // "open-low"
parseReferenceRange(">10").low; // "10"
parseReferenceRange("weird").kind; // "unparsed" (never a fabricated bound)