Skip to main content
Version: v0.0.4

Function: loadRxNormGraph()

loadRxNormGraph(source): RxNormGraph

Load a caller-supplied RxNorm RRF release into an immutable RxNormGraph.

Parses RXNCONSO (concepts), RXNREL (directed edges, normalized to the documented direction), and — when supplied - RXNSAT (NDC attributes). Liberal on load: a structurally unusable row is a skipped, surfaced RxNormLoadWarning, never partial. Ships no RxNorm release - the graph is entirely the caller's release.

A concept is typed only by a defining atom, never by a synonym-class one and never by file order; an RXCUI no defining atom could type is skipped and surfaced as TERM_RXNORM_UNTYPED_CONCEPT. See the module documentation.

Parameters

source

RxNormGraphSource

The RxNormGraphSource (RRF file contents + optional version).

Returns

RxNormGraph

The immutable RxNormGraph.

Example

import { loadRxNormGraph } from "@cosyte/terminology";

// Synthetic rows in the RxNorm RRF wire format (no RxNorm release is bundled).
const graph = loadRxNormGraph({
conso: "1|ENG||||||||||RXNORM|IN||lisinopril||N||\n2|ENG||||||||||RXNORM|SCDC||lisinopril 10 MG||N||",
// "SCDC(2) has_ingredient IN(1)": subject=RXCUI2=2, object=RXCUI1=1.
rel: "1|||RN|2|||has_ingredient|||RXNORM||||||",
});
graph.conceptCount; // => 2