Skip to main content
Version: v0.0.2

Function: relatedByRela()

relatedByRela(graph, rxcui, predicate): RxNormNavResult

Follow one or more RELA predicates out of a concept (the generic navigation primitive). Direction is the authored edge direction (subject ⟶predicate⟶ object); the engine never inverts.

Parameters

graph

RxNormGraph

A loaded RxNormGraph.

rxcui

string

The source concept.

predicate

string | readonly string[]

A RELA name, or an array of them (any-of).

Returns

RxNormNavResult

A RxNormNavResult: the related concepts (possibly empty), or a typed unknown source.

Example

import { loadRxNormGraph, relatedByRela, RELA } from "@cosyte/terminology";

// "SCDC(2) has_ingredient IN(1)": subject=RXCUI2=2, object=RXCUI1=1.
const g = loadRxNormGraph({
conso: "1|ENG||||||||||RXNORM|IN||lisinopril||N||\n2|ENG||||||||||RXNORM|SCDC||lisinopril 10 MG||N||",
rel: "1|||RN|2|||has_ingredient|||RXNORM||||||",
});
const r = relatedByRela(g, "2", RELA.HAS_INGREDIENT);
r.found && r.targets[0]?.name; // => "lisinopril"