| Title: | Tidy Utilities for 'RxNorm' and NDC Resolution |
|---|---|
| Description: | Provides a tidy, vectorized interface to the 'RxNorm' / 'RxNav' API for resolving drug names, 'RxNorm' Concept Unique Identifiers (RxCUIs), National Drug Codes (NDCs), and related drug concept metadata. The package supports workflows for mapping between drug names, RxCUIs, NDCs, ingredients, products, drug classes, and related concepts using data from the U.S. National Library of Medicine's 'RxNav' services <https://lhncbc.nlm.nih.gov/RxNav/APIs/> and 'RxNorm' <https://www.nlm.nih.gov/research/umls/rxnorm/>. |
| Authors: | Steven Smith [aut, cre] |
| Maintainer: | Steven Smith <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.0 |
| Built: | 2026-06-02 10:15:58 UTC |
| Source: | https://github.com/ssmithm/rxref |
Returns the default RxNorm term types used by rxref when identifying drug products.
default_product_ttys()default_product_ttys()
The default set is intentionally focused on product-level concepts: semantic clinical drugs, semantic branded drugs, generic packs, and branded packs.
A character vector of RxNorm term type abbreviations.
default_product_ttys()default_product_ttys()
Remove all rows for products that contain one or more user-specified ingredients. This is useful when broad ingredient-based product searches return fixed-dose combination products that contain an ingredient of interest but are not clinically relevant to a specific study definition.
exclude_products_with_ingredients( data, ingredients = NULL, ingredient_rxcuis = NULL, product_id_col = "product_rxcui", ingredient_name_col = "ingredient_name", ingredient_rxcui_col = "ingredient_rxcui", return_excluded = FALSE )exclude_products_with_ingredients( data, ingredients = NULL, ingredient_rxcuis = NULL, product_id_col = "product_rxcui", ingredient_name_col = "ingredient_name", ingredient_rxcui_col = "ingredient_rxcui", return_excluded = FALSE )
data |
A data frame containing product RxCUIs and ingredient information,
such as that produced by |
ingredients |
Optional character vector of ingredient names to exclude.
These are resolved to ingredient RxCUIs using |
ingredient_rxcuis |
Optional character vector of ingredient RxCUIs to exclude. These are used directly and do not require name resolution. |
product_id_col |
Name of the column containing product RxCUIs. Default
is |
ingredient_name_col |
Name of the column containing ingredient names.
Used for reporting and, when needed, fallback matching. Default is
|
ingredient_rxcui_col |
Name of the column containing ingredient RxCUIs.
Default is |
return_excluded |
Logical. If |
Exclusions are applied at the product level. If any ingredient in a product matches the exclusion list, all rows for that product are removed.
If return_excluded = FALSE, a data frame of the same general shape as
data, with excluded product rows removed.
If return_excluded = TRUE, a list with:
The filtered data frame.
Rows from the input data belonging to excluded products.
The ingredient names/RxCUIs used for exclusion.
## Not run: antihtn_clean <- antihtn_products |> exclude_products_with_ingredients(ingredients = "sacubitril") antihtn_audit <- antihtn_products |> exclude_products_with_ingredients( ingredients = "sacubitril", return_excluded = TRUE ) antihtn_audit$data antihtn_audit$excluded antihtn_audit$resolved_ingredients ## End(Not run)## Not run: antihtn_clean <- antihtn_products |> exclude_products_with_ingredients(ingredients = "sacubitril") antihtn_audit <- antihtn_products |> exclude_products_with_ingredients( ingredients = "sacubitril", return_excluded = TRUE ) antihtn_audit$data antihtn_audit$excluded antihtn_audit$resolved_ingredients ## End(Not run)
Returns an extended set of RxNorm term types that includes the default product term types plus dose-form and dose-form-group concepts.
extended_product_ttys()extended_product_ttys()
This can be useful when a broader set of product-related RxNorm concepts is desired.
A character vector of RxNorm term type abbreviations.
extended_product_ttys()extended_product_ttys()
Returns an extended set of RxNorm term types that includes the default and extended product term types plus drug component, brand name, and ingredient concepts. This list includes essentially all term types that capture a specific ingredient, thus it excludes dose form, dose form group, prescribable name, synonyms, and others that are not associated with a specific ingredient.
extended_ttys()extended_ttys()
This can be useful when the broadest set of RxNorm concepts that still capture an ingredient is desired.
A character vector of RxNorm term type abbreviations.
extended_ttys()extended_ttys()
Filters a product-level rxref table using route information from
get_clinical_attributes(). Useful when a drug or class includes
products across multiple routes, such as oral tablets, ophthalmic solutions,
injectables, patches, or topical formulations.
filter_products_by_route( products, route = "ORAL", keep_route_info = TRUE, include_historical = FALSE, show_progress = interactive() )filter_products_by_route( products, route = "ORAL", keep_route_info = TRUE, include_historical = FALSE, show_progress = interactive() )
products |
A tibble containing a |
route |
Character vector of routes to keep. Common values include
|
keep_route_info |
Logical. If |
include_historical |
Logical. If |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble containing only rows whose product_rxcui has at least one
matching route.
## Not run: ing <- find_ingredients("metoprolol") prods <- products_for_ingredients( ing$rxcui, include_combos = TRUE ) filter_products_by_route(prods, route = "ORAL") # Historical/current products can also be route-filtered prods_hist <- products_for_ingredients( ing$rxcui, include_combos = TRUE, concept_status = "active_and_historical" ) filter_products_by_route(prods_hist, route = "ORAL") ## End(Not run)## Not run: ing <- find_ingredients("metoprolol") prods <- products_for_ingredients( ing$rxcui, include_combos = TRUE ) filter_products_by_route(prods, route = "ORAL") # Historical/current products can also be route-filtered prods_hist <- products_for_ingredients( ing$rxcui, include_combos = TRUE, concept_status = "active_and_historical" ) filter_products_by_route(prods_hist, route = "ORAL") ## End(Not run)
Find RxClass drug classes by class name
find_classes(query, class_types = NULL)find_classes(query, class_types = NULL)
query |
Character string to search for. |
class_types |
Optional class type filter, such as |
A tibble of matching class concepts.
Uses RxNav approximateTerm, then fetches properties for each candidate and
filters to ingredient-type concepts (TTY IN and, optionally, PIN).
find_ingredients( term, max_entries = 10, include_pin = TRUE, show_progress = interactive() )find_ingredients( term, max_entries = 10, include_pin = TRUE, show_progress = interactive() )
term |
Character vector (free text). |
max_entries |
Integer. Max approximate-term candidates per input (default 10). |
include_pin |
Logical. Include precise-ingredient ( |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble with columns: input, rxcui, name, tty, score.
if (identical(Sys.getenv("RXREF_ONLINE"), "1")) { find_ingredients("metformin") }if (identical(Sys.getenv("RXREF_ONLINE"), "1")) { find_ingredients("metformin") }
get_atc() is a convenience wrapper for get_classes() that returns
Anatomical Therapeutic Chemical (ATC) class assertions for RxNorm drugs.
get_atc( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )get_atc( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of ATC class assertions.
get_atc() is a convenience wrapper for get_classes() that returns
Anatomical Therapeutic Chemical (ATC) product-level class assertions for
RxNorm drugs.
get_atcprod( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )get_atcprod( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of ATCPROD class assertions.
get_chemical_structure() is a convenience wrapper for get_classes() that
returns chemical-structure assertions for RxNorm drugs.
get_chemical_structure( x, by = c("rxcui", "name"), rela_source = c("FDASPL", "DAILYMED", "MEDRT"), keep_input = TRUE, show_progress = interactive() )get_chemical_structure( x, by = c("rxcui", "name"), rela_source = c("FDASPL", "DAILYMED", "MEDRT"), keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
rela_source |
Relationship source. Defaults to FDASPL, DAILYMED, and MEDRT. |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of chemical-structure assertions.
get_class_members() queries the RxClass API to identify members of a
specific drug class. Typically, this would be used to identify all
ingredient RxCUIs in a class, which can then be combined with other search
functions to extract related product RxCUIs or NDCs.
get_class_members( class_id, rela_source, rela = NULL, include_indirect = TRUE, ttys = NULL )get_class_members( class_id, rela_source, rela = NULL, include_indirect = TRUE, ttys = NULL )
class_id |
RxClass class identifier. |
rela_source |
RxClass relationship source, such as |
rela |
Optional relationship filter. |
include_indirect |
Logical; if |
ttys |
Optional RxNorm term type filter, such as |
A tibble of RxNorm drug members.
get_classes() returns RxClass assertions for RxNorm concepts or drug names.
These include drug-class relationships from sources such as ATC, FDASPL,
DAILYMED, MEDRT, SNOMEDCT, and VA. Depending on the source and relationship,
returned assertions may represent pharmacologic classes, chemical structures,
mechanisms of action, physiologic effects, indications, contraindications,
VA classes, ATC classes, or SNOMED CT dispositions/structures.
Because different sources use different classification logic, this function preserves class type, relationship, and relationship source rather than collapsing results into a single class label.
get_classes( x, by = c("rxcui", "name"), rela_source = NULL, relas = NULL, class_types = NULL, keep_input = TRUE, show_progress = interactive() )get_classes( x, by = c("rxcui", "name"), rela_source = NULL, relas = NULL, class_types = NULL, keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
rela_source |
Optional RxClass relationship source filter, such as
|
relas |
Optional relationship filter. Examples include |
class_types |
Optional filter on returned class types, such as |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble with one row per RxClass assertion.
If rxcui is already a clinical drug (TTY = SCD or SBD), parse attributes directly
from its own name. Otherwise, query /rxcui/{id}/related?tty=SCD,SBD and parse.
get_clinical_attributes( rxcui, include_historical = FALSE, show_progress = interactive() )get_clinical_attributes( rxcui, include_historical = FALSE, show_progress = interactive() )
rxcui |
Character vector of RxCUIs |
include_historical |
Logical. If |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
In addition to strength and dose form, this returns route, dose-form group (DFG), brand/generic flags, ingredient summaries, and a simple active/inactive status.
Note there is a fair amount of parsing of the RxNorm STR value to try to extract relevant information (e.g., strength, dose_form), so check closely before trusting. There may be edge cases that are not correctly parsed.
For combination products, ingredient-related columns may contain multiple
semicolon-delimited values, such as "amlodipine; valsartan".
A tibble with columns:
Input RxCUI
Clinical drug RxCUI (SCD/SBD) used for attributes
Clinical drug name
Term type (SCD/SBD, etc.)
Parsed strength string (e.g. "500 MG")
Parsed dose form (e.g. "Extended Release Oral Tablet")
Route parsed from dose form / DFG (e.g. "ORAL", "INJECTION")
Dose form group (DFG), if available
Logical; TRUE for branded clinical concepts (SBD/BPCK)
Logical; TRUE for generic clinical concepts (SCD/GPCK)
Number of distinct ingredients
Ingredient RxCUI. For combination products, multiple values are returned as semicolon-delimited strings.
Ingredient name. For combination products, multiple values are returned as semicolon-delimited strings.
Ingredient term type (IN/PIN/MIN). For combination products, multiple values are returned as semicolon-delimited strings.
Logical; TRUE if >1 ingredient
Raw RxNorm suppress flag from properties
Simple status derived from suppress: "ACTIVE" vs "INACTIVE"
## Not run: get_clinical_attributes(c("861007","860975")) |> dplyr::select(rxcui, related_rxcui, name, strength, dose_form, route, tty) |> head() ## End(Not run)## Not run: get_clinical_attributes(c("861007","860975")) |> dplyr::select(rxcui, related_rxcui, name, strength, dose_form, route, tty) |> head() ## End(Not run)
get_contraindications() is a convenience wrapper for get_medrt() that
returns only contraindication MED-RT assertions for RxNorm drugs.
get_contraindications( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )get_contraindications( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of MED-RT contraindication assertions.
get_drug_classes() is an experimental convenience function that returns
RxClass assertions that are likely to behave like drug-class labels.
It combines selected assertions from ATC, ATCPROD, FDA/SPL EPC, VA, and SNOMED CT disposition relationships. It intentionally excludes relationship types that usually describe contraindications, indications, physiologic effects, chemical structures, or other non-class assertions.
For a more compact and ingredient-oriented output, rely on defaults for include_sources. For extended list of product-level sources, consider adding "ATCPROD" and "VA".
This function is experimental because "drug class" is not a single native
RxClass concept. Different sources use different classification logic, and
this helper applies an opinionated filter to return class-like assertions.
For source-specific results, use get_classes(), get_atc(), get_epc(),
get_va(), or related functions directly.
get_drug_classes( x, by = c("rxcui", "name"), include_sources = c("ATC", "EPC", "SNOMEDCT"), collapse = TRUE, keep_input = TRUE, show_progress = interactive() )get_drug_classes( x, by = c("rxcui", "name"), include_sources = c("ATC", "EPC", "SNOMEDCT"), collapse = TRUE, keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
include_sources |
Character vector of class-like sources to include.
Defaults to |
collapse |
Logical; if |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of class-like RxClass assertions.
get_epc() is a convenience wrapper for get_classes() that returns
FDA labeling class assertions for RxNorm drugs.
get_epc( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )get_epc( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of established pharmacologic class assertions.
get_may_treat() is a convenience wrapper for get_medrt() that returns
indications (disease assertions) from MED-RT for RxNorm drugs, when
available. Note that absence of a row (or an empty table altogether)
should not necessarily be interpreted as absence of an indication.
get_may_treat( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )get_may_treat( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of MED-RT may-treat assertions.
get_medrt() is a convenience wrapper for get_classes() that returns
MED-RT assertions for RxNorm drugs. These include, for example, asserted
mechanisms of action, contraindications, physiologic effects (including
adverse side effects), etc.
get_medrt( x, by = c("rxcui", "name"), relas = NULL, class_types = NULL, keep_input = TRUE, show_progress = interactive() )get_medrt( x, by = c("rxcui", "name"), relas = NULL, class_types = NULL, keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
relas |
Optional MED-RT relationship filter. |
class_types |
Optional MED-RT class type filter. |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of MED-RT assertions.
get_medrt_moa() is a convenience wrapper for get_medrt() that returns
MED-RT mechanism-of-action assertions when available. Not all drugs have
MED-RT has_moa assertions; for some drugs, mechanism-like or class-like
information may instead be available from FDA/SPL EPC via get_epc() or as
physiologic effects via get_medrt_pe().
get_medrt_moa( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )get_medrt_moa( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of MED-RT mechanism-of-action assertions.
get_medrt_pe() is a convenience wrapper for get_medrt() that returns
only physiologic effect MED-RT assertions for RxNorm drugs.
get_medrt_pe( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )get_medrt_pe( x, by = c("rxcui", "name"), keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of MED-RT physiologic-effect assertions.
Get core RxNorm properties for one or more RxCUIs
get_properties(rxcui, show_progress = interactive())get_properties(rxcui, show_progress = interactive())
rxcui |
Character vector of RxCUIs |
show_progress |
Logical. Show a progress bar in interactive sessions. |
tibble with rxcui, name, synonym, tty, language, suppress, umlscui.
if (identical(Sys.getenv("RXREF_ONLINE"), "1")) { get_properties(c("860975","1049630")) }if (identical(Sys.getenv("RXREF_ONLINE"), "1")) { get_properties(c("860975","1049630")) }
get_va() is a convenience wrapper for get_classes() that
returns VA drug class assertions for RxNorm drugs.
get_va( x, by = c("rxcui", "name"), extended = TRUE, keep_input = TRUE, show_progress = interactive() )get_va( x, by = c("rxcui", "name"), extended = TRUE, keep_input = TRUE, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
extended |
Logical; if |
keep_input |
Logical; if |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble of VA class assertions.
Maps one or more RxCUIs to related ingredient concepts, returning ingredient RxCUIs, names, and term types. This is useful when the input is already a specific RxNorm product concept rather than a free-text drug name.
ingredients_for_rxcui( rxcui, include_pin = TRUE, include_min = FALSE, show_progress = interactive() )ingredients_for_rxcui( rxcui, include_pin = TRUE, include_min = FALSE, show_progress = interactive() )
rxcui |
Character vector of RxCUIs. |
include_pin |
Logical. Include precise ingredient concepts ( |
include_min |
Logical. Include multiple ingredient concepts ( |
show_progress |
Logical. Show a progress bar in interactive sessions. |
A tibble with columns rxcui, ingredient_rxcui,
ingredient_name, and ingredient_tty.
Convenience wrapper around map_to() for mapping National Drug Codes
(NDCs) to RxNorm Concept Unique Identifiers (RxCUIs).
map_ndc_to_rxcui(x, show_progress = interactive())map_ndc_to_rxcui(x, show_progress = interactive())
x |
Character vector of NDCs. |
show_progress |
Logical; if |
NDCs may be supplied as 10-digit, 11-digit, or hyphenated values. Input NDCs are normalized to 11-digit format before querying RxNorm.
A tibble with columns:
Original input NDC.
Normalized 11-digit NDC.
Mapped RxCUI, if found.
## Not run: map_ndc_to_rxcui("00093-7424-56") ## End(Not run)## Not run: map_ndc_to_rxcui("00093-7424-56") ## End(Not run)
Convenience wrapper around map_to() for mapping RxNorm Concept Unique
Identifiers (RxCUIs) to National Drug Codes (NDCs).
map_rxcui_to_ndc( x, status = NULL, history = c("active", "direct", "all"), show_progress = interactive() )map_rxcui_to_ndc( x, status = NULL, history = c("active", "direct", "all"), show_progress = interactive() )
x |
Character vector of RxCUIs. |
status |
Optional character vector of NDC statuses to retain, such as
|
history |
For
If |
show_progress |
Logical; if |
By default, this function retrieves currently active NDCs associated with
the supplied RxCUIs. Use history = "direct" or history = "all" to
retrieve historical NDC associations.
status = NULL means that no status filter is applied after NDCs are
retrieved. It does not, by itself, request historical NDCs. To retrieve
historical NDCs, set history = "direct" or history = "all".
A tibble with one row per RxCUI/NDC mapping.
For history = "active", returns columns:
Input RxCUI.
Mapped NDC.
NDC status returned by RxNorm, when available.
For history = "direct" or "all", the output may also include:
RxCUI associated with the historical NDC record. This may differ from the input RxCUI when historical or indirect associations are retrieved.
Start date of the NDC association, when available.
End date of the NDC association, when available.
## Not run: # Current active NDCs map_rxcui_to_ndc("1049630") # NDCs ever directly associated with this RxCUI map_rxcui_to_ndc("1049630", history = "direct") # All historical NDCs, retaining obsolete NDCs only map_rxcui_to_ndc( "1049630", history = "all", status = "OBSOLETE" ) ## End(Not run)## Not run: # Current active NDCs map_rxcui_to_ndc("1049630") # NDCs ever directly associated with this RxCUI map_rxcui_to_ndc("1049630", history = "direct") # All historical NDCs, retaining obsolete NDCs only map_rxcui_to_ndc( "1049630", history = "all", status = "OBSOLETE" ) ## End(Not run)
map_to() maps identifiers between National Drug Codes (NDCs) and RxNorm
Concept Unique Identifiers (RxCUIs).
map_to( x, to = c("rxcui", "ndc"), status = NULL, history = NULL, show_progress = interactive() )map_to( x, to = c("rxcui", "ndc"), status = NULL, history = NULL, show_progress = interactive() )
x |
Character vector of NDCs or RxCUIs. |
to |
Direction of mapping. One of |
status |
For |
history |
For
If |
show_progress |
Logical; if |
When mapping from NDC to RxCUI, NDCs may be supplied as 10-digit, 11-digit, or hyphenated values. Input NDCs are normalized to 11-digit format before querying RxNorm.
When mapping from RxCUI to NDC, the history argument controls whether
only currently active NDCs are retrieved or whether historical NDC
associations are also included.
RxNorm distinguishes between currently active NDCs and historical NDC
associations. The default behavior, history = "active", uses RxNorm's
active NDC endpoint and preserves the earlier behavior of map_to().
To retrieve obsolete, discontinued, or otherwise historical NDCs, use
history = "direct" or history = "all". Setting status = NULL does not
by itself request historical NDCs; it only means that no status filter is
applied after NDCs are retrieved.
A tibble.
For to = "rxcui", returns one row per input NDC/RxCUI mapping with columns:
Original input NDC.
Normalized 11-digit NDC.
Mapped RxCUI, if found.
For to = "ndc" and history = "active", returns one row per RxCUI/NDC
mapping with columns:
Input RxCUI.
Mapped NDC.
NDC status returned by RxNorm, when available.
For to = "ndc" and history equal to "direct" or "all", the output
may also include:
RxCUI associated with the historical NDC record. This may differ from the input RxCUI when historical or indirect associations are retrieved.
Start date of the NDC association, when available.
End date of the NDC association, when available.
## Not run: # Map an NDC to RxCUI map_to("00093-7424-56", to = "rxcui") # Map an RxCUI to currently active NDCs map_to("1049630", to = "ndc") # Map an RxCUI to all directly associated historical NDCs map_to("1049630", to = "ndc", history = "direct") # Map an RxCUI to all historical NDCs and retain obsolete NDCs only map_to("1049630", to = "ndc", history = "all", status = "OBSOLETE") ## End(Not run)## Not run: # Map an NDC to RxCUI map_to("00093-7424-56", to = "rxcui") # Map an RxCUI to currently active NDCs map_to("1049630", to = "ndc") # Map an RxCUI to all directly associated historical NDCs map_to("1049630", to = "ndc", history = "direct") # Map an RxCUI to all historical NDCs and retain obsolete NDCs only map_to("1049630", to = "ndc", history = "all", status = "OBSOLETE") ## End(Not run)
ndc_status() requests the status of an NDC entry for one or more user-supplied
NDC numbers. The returned status will be one "ACTIVE", "OBSOLETE", or "UNSPECIFIED".
On occasion, a NULL value may be pulled (resulting in an NA in the returned tibble),
when RxNorm has no status for a given NDC, or if an invalid NDC is supplied.
ndc_status(ndc, show_progress = interactive())ndc_status(ndc, show_progress = interactive())
ndc |
character vector; hyphenated or digits |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble with three columns: ndc_input, ndc11, ndc_hyph, status
Returns common RxNorm term type sets used by rxref.
product_ttys(set = c("default", "extended_product", "extended"))product_ttys(set = c("default", "extended_product", "extended"))
set |
One of |
A character vector of RxNorm term type abbreviations.
product_ttys() product_ttys("extended")product_ttys() product_ttys("extended")
Tries multiple RxNav endpoints and verifies candidates truly contain the queried ingredient or one of its acceptable related ingredient concepts. The function unions candidates from multiple sources, verifies ingredient containment, and reports the number of ingredients represented by each product concept.
products_for_ingredients( ingredient_rxcui, ttys = .rxref_default_ttys, route = NULL, include_combos = TRUE, concept_status = c("active", "active_and_historical"), historical_status = c("Obsolete", "Remapped", "Quantified", "NotCurrent"), show_progress = interactive() )products_for_ingredients( ingredient_rxcui, ttys = .rxref_default_ttys, route = NULL, include_combos = TRUE, concept_status = c("active", "active_and_historical"), historical_status = c("Obsolete", "Remapped", "Quantified", "NotCurrent"), show_progress = interactive() )
ingredient_rxcui |
Character vector of ingredient CUIs (TTY |
ttys |
Character vector of TTYs to include. Defaults to product-facing
TTYs returned by |
route |
Optional character vector of routes to retain. If |
include_combos |
Logical. If |
concept_status |
Character. Which RxNorm concept universe to search.
|
historical_status |
Character vector of historical RxNorm statuses to
include when
See the RxNorm API documentation for concept status values: https://lhncbc.nlm.nih.gov/RxNav/APIs/api-RxNorm.getAllConceptsByStatus.html. |
show_progress |
Logical. Show progress bars for long-running API
retrieval, product matching, and optional route filtering steps. Defaults
to |
A tibble with one row per matched ingredient/product concept pair.
For concept_status = "active", columns include ingredient_rxcui,
product_rxcui, name, tty, and n_ingredients. When
concept_status = "active_and_historical", additional columns include
concept_status, active_start_date, active_end_date,
release_start_date, and release_end_date.
Vectorized over x. For free text, uses RxNorm approximateTerm.
For NDC, uses findRxcuiById. For RxCUI, validates and returns properties.
resolve( x, type = c("auto", "name", "rxcui", "ndc"), max_entries = 1, show_progress = interactive() )resolve( x, type = c("auto", "name", "rxcui", "ndc"), max_entries = 1, show_progress = interactive() )
x |
Character vector: drug string, RxCUI, or NDC (10/11-digit or hyphenated) |
type |
One of c("auto","name","rxcui","ndc"). Default "auto" infers. |
max_entries |
Integer, passed to approximateTerm for name queries. |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble with columns: input, type, rxcui, name, tty, score (if name), ndc11 (if ndc input), matched_term (if name input)
Get RxClass relationship sources
rxclass_rela_sources()rxclass_rela_sources()
A tibble of RxClass relationship sources.
rxclass_relas() is a helper function that queries the RxClass API for
generally valid relationships within the data. Note that just because a
relationship is generally valid within a rela_source, not every drug or
RxCUI will have a corresponding relationship asserted.
rxclass_relas(rela_source)rxclass_relas(rela_source)
rela_source |
RxClass relationship source, such as |
A tibble of relationship names for the selected source.
rxclass_relationships() is a diagnostic helper that evaluates the type(s)
of relationship (rela) asserted in RxNorm MED-RT data and the number within
each relationship asserted. In some cases, get_medrt() or its various
convenience wrappers may return empty or shorter-than-expected tibbles
because some relationships expected by the user are not asserted in RxNorm
(for example, an MOA may not be asserted by MED-RT).
rxclass_relationships( x, by = c("rxcui", "name"), rela_source = NULL, show_progress = interactive() )rxclass_relationships( x, by = c("rxcui", "name"), rela_source = NULL, show_progress = interactive() )
x |
Character vector of RxCUIs or drug names. |
by |
One of |
rela_source |
Optional RxClass relationship source filter. |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
A tibble summarizing available relationship/class-type combinations.
rxref_cache() returns the currently configured cache object.
rxref_cache_info() returns a small summary of the current cache.
rxref_cache_clear() clears cached RxNorm/RxClass API responses.
rxref_cache_use_memory() switches rxref to an in-memory cache.
rxref_cache_use_disk() switches rxref to an on-disk cache.
rxref_cache_disable() uses an immediately expiring cache, effectively
disabling cache reuse for the current R session.
rxref_cache() rxref_cache_info() rxref_cache_clear() rxref_cache_use_memory( max_size = 200 * 1024^2, max_age = Inf, evict = c("lru", "fifo") ) rxref_cache_use_disk( dir = rxref_cache_dir(), max_size = 1024^3, max_age = Inf, evict = c("lru", "fifo") ) rxref_cache_disable()rxref_cache() rxref_cache_info() rxref_cache_clear() rxref_cache_use_memory( max_size = 200 * 1024^2, max_age = Inf, evict = c("lru", "fifo") ) rxref_cache_use_disk( dir = rxref_cache_dir(), max_size = 1024^3, max_age = Inf, evict = c("lru", "fifo") ) rxref_cache_disable()
max_size |
Maximum cache size in bytes. |
max_age |
Maximum age of cached objects, in seconds. |
evict |
Cache eviction policy passed to |
dir |
Directory to use for an on-disk cache. |
rxref caches memoised API responses through a cachem cache object stored in
getOption("rxref.cache"). By default, rxref uses an in-memory cache for the
current R session.
rxref_cache() returns a cachem cache object.
rxref_cache_info() returns a tibble with cache metadata.
rxref_cache_clear(), rxref_cache_use_memory(), rxref_cache_use_disk(),
and rxref_cache_disable() invisibly return the configured cache object.
rxref_cache_info() rxref_cache_clear() rxref_cache_use_memory() ## Not run: rxref_cache_use_disk() ## End(Not run)rxref_cache_info() rxref_cache_clear() rxref_cache_use_memory() ## Not run: rxref_cache_use_disk() ## End(Not run)
Configure package-level settings used by rxref, including the RxNav base URL, API rate delay, and memoised API-response cache.
rxref_conf( base_url = getOption("rxref.base_url"), rate_delay = getOption("rxref.rate_delay"), cache = getOption("rxref.cache") )rxref_conf( base_url = getOption("rxref.base_url"), rate_delay = getOption("rxref.rate_delay"), cache = getOption("rxref.cache") )
base_url |
Override the RxNav base URL (e.g., a local mirror) |
rate_delay |
Seconds to wait between HTTP calls |
cache |
A |
A named list of current settings
High-level convenience: free text -> ingredient(s) (IN/PIN) -> verified product CUIs, and optionally expand to NDCs with status filtering.
search_drug( term, return = c("rxcui", "ndc", "both"), ndc_status = NULL, ttys = .rxref_default_ttys, route = NULL, show_progress = interactive(), ... )search_drug( term, return = c("rxcui", "ndc", "both"), ndc_status = NULL, ttys = .rxref_default_ttys, route = NULL, show_progress = interactive(), ... )
term |
Character vector; free-text drug names. |
return |
One of |
ndc_status |
Optional character vector to filter NDCs. Options are "ACTIVE", "OBSOLETE", "UNSPECIFIED" (the API may also return no value, which will appear as NA). |
ttys |
Character vector of TTYs to include in product search.
Defaults to |
route |
Optional character vector of routes to retain before returning
products or mapping to NDCs. If |
show_progress |
Logical. Show a progress bar in interactive sessions. Progress is shown only when at least 5 inputs are supplied. |
... |
Passed to |
If return="rxcui": tibble of products.
If "ndc": tibble of NDCs with ingredient_rxcui, product_rxcui, ndc11, ndc_status.
If "both": list(products=…, ndcs=…).
Returns a tibble describing common RxNorm TTYs you may want to use when expanding ingredients to products. Includes whether each TTY typically maps cleanly to NDCs and whether it's included in the package's default or extended TTY sets.
tty_catalogue()tty_catalogue()
Columns:
tty: RxNorm term type code.
label: Short, human-friendly name.
description: What the TTY represents in RxNorm.
maps_to_ndc: Logical; whether CUIs of this TTY usually map to NDCs via
/rxcui/{rxcui}/ndcs.
typical_role: How it’s commonly used (product, component, group, name).
include_default: Logical; included in .rxref_default_ttys.
include_extended: Logical; included in .rxref_extended_ttys.
A tibble with metadata for key TTYs.
tty_catalogue() # TTYs that map to NDCs subset(tty_catalogue(), maps_to_ndc)$tty # See what your defaults and extended sets contain subset(tty_catalogue(), include_default)$tty subset(tty_catalogue(), include_extended)$tty # Pick a custom set: products + components with(tty_catalogue(), tty[tty %in% c("SCD","SBD","GPCK","BPCK","SCDC","SBDC")])tty_catalogue() # TTYs that map to NDCs subset(tty_catalogue(), maps_to_ndc)$tty # See what your defaults and extended sets contain subset(tty_catalogue(), include_default)$tty subset(tty_catalogue(), include_extended)$tty # Pick a custom set: products + components with(tty_catalogue(), tty[tty %in% c("SCD","SBD","GPCK","BPCK","SCDC","SBDC")])