RxNav

RxNorm API

updated: 10/7/2009

Lister Hill Center

The RxNorm API is a web service for accessing the current RxNorm data set from your program via SOAP/WSDL.

The WSDL file for the RxNorm API can be found here.

Recent changes to the RxNorm API can be found here.


Building Applications to Use the RxNorm API

This page describes how to build applications to use the RxNorm API.
We provide documentation for coding Java and .Net applications. Documentation for building applications in other programming languages (e.g. Perl) may be added at a later time.

Building a Java Application to use the RxNorm API

The RxNorm API provides developers with functions for retrieving RxNorm data from the most current RxNorm data set. Building applications to use the RxNorm API require initial setup of the development environment and developing code. Each of these is described in detail in this chapter.

Java Development Environment Setup

Setup of a Java developer's environment involves the following steps. All steps must be completed before application code can be compiled and built to execute requests with the RxNorm API.
  1. Obtain a Simple Object Access Protocol (SOAP) 1.2 compatible engine for web service message routing.
  2. Download the WSDL for the RxNorm API web service.
  3. Generate the client side stubs using Axis's WSDL2Java utility for the WSDL (for applications written in Java).

1. Obtaining a SOAP 1.2 Engine

Developers will require a Simple Object Access Protocol (SOAP) 1.2 compatible engine to route the web service messages to/from the RxNorm API. The client programs shown in this guide have been tested with Apache Axis Version 1.4 Follow the link to their website and download and install the version onto your development machine. The location of this download will be referred to as <AXIS_DIR> in this guide.

2. Downloading the RxNorm WSDL

The RxNorm WSDL may be downloaded from the RxNav web site. Right-click on the RxNorm Service WSDL and save the WSDL file to your development machine. The path to this file will be hereafter referred to as <RXNORM_WSDL_LOCATION>.

3. Generating Client Stubs for Java

Apache Axis is delivered with a utility to generate Java classes from a WSDL. Using WSDL2Java generates client stubs that enable communication with a defined web service.
  prompt> java -classpath  <CLASSPATH> org.apache.axis.wsdl.WSDL2Java \
      <RXNORM_WSDL_LOCATION>
The call to the utility places generated Java class files in the directory where the utility is run. The <CLASSPATH> must include the following jar files generally found in the lib directory of the Axis installation:
axis.jar
wsdl4j-1.5.1.jar
commons-logging-1.0.4.jar
commons-discovery-0.2.jar
jaxrpc.jar
saaj.jar
activation.jar
mail.jar
Other SOAP engines use different utilities to generate the client stubs. Refer to your specific SOAP engine documentation for instructions on building the client stubs using the downloaded WSDL.

Coding Java Applications to use the RxNorm API

The basic paradigm for obtaining RxNorm data from the RxNorm API web service is as follows:
  1. Establish a connection to the RxNorm API web service.
  2. Obtain the data from the RxNorm API web service.

Java Code: Establishing a Connection to the RxNorm API Web Service

The RxNorm API web service is an Axis web service running at the NLM on the RxNav production machine. The web service endpoint URI is http://mor.nlm.nih.gov/axis/services/RxNormDBService The classes generated during WSDL2Java execution must be imported into your application. For Java applications, include these import statements:
import java.net.URL;
import BeanService.*;
import gov.nih.nlm.rxnav.axis.services.RxNormDBService.*;
The following code snippet shows how to establish a connection to the RxNorm API web service.
String rxhost = "http://mor.nlm.nih.gov";
String rxURI = rxhost + "/axis/services/RxNormDBService";

// Locate the RxNorm API web service
URL rxURL = new URL(rxURI);
DBManagerService rxnormService = new DBManagerServiceLocator();
DBManager dbmanager = rxnormService.getRxNormDBService(rxURL);

Java Code: Obtaining RxNorm Data

The RxNorm API web service provides access to current RxNorm data through its calls defined in the WSDL. The code snippet below searches for a concept unique identifier (RxCUI) using exact matching of an input string. Each operation made available in the RxNorm API web service is described in detail in the RxNorm API design document.
// Get the concept unique identifier for a string
String [] rxcuis = dbmanager.findRxcuiByString("aspirin");
// print results
for (int j = 0; j < rxcuis.length; j++)
    System.out.println("RXCUI = " + rxcuis[j]);
if (rxcuis.length == 0) 
    System.out.println("No concept found");

Compiling the Java Application

When compiling the application using the RxNorm API, the CLASSPATH must include the directory into which the compiled stubs were put and the following jar files which are generally found in the lib directory of the Axis installation:
axis.jar
wsdl4j-1.5.1.jar
commons-logging-1.0.4.jar
commons-discovery-0.2.jar
jaxrpc.jar
saaj.jar
activation.jar
mail.jar


Building a .Net Application to use the RxNorm API

.Net Development Environment and Project Setup

Setup of a .Net developer's environment involves the following steps:
  1. Install Microsoft Visual Studio .Net 2008 (select at least these options: VB, C# and Web development)
  2. Start up Visual Studio. If it asks for default settings, choose C# or VB, depending on your preference. In this tutorial, we use C#.
  3. From the Visual Studio menu, choose File -> New Project
    In the Left pane, choose Visual C#
    In the Right Pane, choose either Console Application (for a command-line-driven application) or Windows Forms Application (for a GUI-driven application)
    In the "Name:" box, enter a name for your project: RxNormClient or RxNorm_GUI_Client (or any project name you want)
    A new C# file skeleton named Program.cs that contains an empty Main() method in the Program class will be generated.
  4. Do not close Visual Studio and do not close the project or the current program file. You will need to return here later to complete the project setup.

Downloading the RxNorm WSDL and Generating a Client Stub for .Net

In the steps below, [your_home_dir] refers to your user home folder (e.g. C:\Documents and Settings\[your_username]\ on Windows XP),

  1. Open a command prompt window
  2. cd [your_home_dir]\My Documents\Visual Studio 2008\Projects\RxNormClient\
  3. "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\wsdl.exe" /l:CS /protocol:SOAP http://mor.nlm.nih.gov/download/RxNormDBService.wsdl
  4. The following message should be displayed: Writing file '[your_home_dir]\My Documents\Visual Studio 2008\Projects\RxNormClient\DBManagerService.cs'
    Your client stub is in the .cs file that was just created (DBManagerService.cs in this example)

Putting the pieces together into a .Net project

  1. You can now either add your client stub source file to your project in Visual Studio: or compile the stub into a DLL:
  2. Your project needs a reference to the .Net Web Services namespace before it would compile: Right-click the project name in the Solution Explorer pane, and choose Add Reference... then select the .Net tab. Select System.Web.Services and click OK.
  3. You are now ready to code your class's Main() method in any way you wish.



RxNorm API Reference

This section contains the design details of the RxNorm API. Each function contains a description, the inputs to the function, the outputs from the function and examples. Available functions:


findRxcuiByString( searchString, source-list, allSourcesFlag )

Search for a name in the RxNorm data set and return the RxCUIs of any concepts which have that name as an RxNorm term or as a synonym of an RxNorm term.

Input:

searchString - the search string

source-list - an array containing the source vocabulary names to use. If null, all sources are allowed. Only used when allSourcesFlag is set to 1.

allSourcesFlag - a flag indicating whether all RxCUIs are to be returned. If set to 1, all non-suppressed RxCUIs will be returned which match any of the sources specified. Otherwise, only RxCUIs which contain a non-suppressed RxNorm term will be returned.

Output:

an array of RxNorm identifiers

Example

findRxcuiByString( "zyrtec", {"MMSL", "VANDF"}, 1)     

returns: 
  { 58930 }

findRxcuiById( idType, id, allSourcesFlag )

Search for an identifier from another vocabulary and return the RxCUIs of any concepts which have an RxNorm term as a synonym or have that identifier as an attribute.

Input:

idType - the identifier type. Valid types are: id - the identifier

allSourcesFlag - a flag indicating whether all RxCUIs are to be returned. If set to 1, all non-suppressed RxCUIs will be returned. Otherwise, only RxCUIs which contain a non-suppressed RxNorm term will be returned.

Output:

an array of RxNorm identifiers

Example

findRxcuiById ( "UMLSCUI", "C0162723", 0)    

returns:
  { 58930 }

getSpellingSuggestions( searchString )

Get spelling suggestions for a given term. The suggestions are RxNorm terms contained in the current version.

Input:

searchString - the name of the term

Output:

an array of names that are spelling suggestions of the input term, ranked by decreasing relevance.

Example

getSpellingSuggestions( "zyrteck" )

returns:
  {"Zyrtec", "Zyrtec-D", "zyrphen"}

getRxConceptProperties( rxcui )

Get the RxNorm Concept properties

Input:

rxcui - the RxNorm identifier

Output:

an RxNorm concept structure containing the following fields:

Example

getRxConceptProperties( "58930")    

returns:

{ Name = "Zyrtec",  Rxcui = "58930", Type = "BN", Lat = "ENG", 
Suppress = "N", Umlscui = "C0162723", SY = "" }

getRelatedByRelationship( rxcui, relationship-list )

Get the related RxNorm identifiers of an RxNorm concept specified by a relational attribute.

Input:

rxcui - the RxNorm identifier

relationship-list - an array of the relationship attribute names such as "tradename_of", "has_form", "isa", etc

Output:

an array of RxNorm concept group structures. An RxNorm concept group structure has the following fields:

Example

getRelatedByRelationship( "58930", {"tradename_of", "has_precise_ingredient"} )  

returns:

{
Type = "IN", {
{ Name = "Cetirizine", Rxcui = "20610", Type = "IN", Lat = "ENG", 
Suppress = "N", Umlscui = "C055147", SY = ""},
{ Name = "Cetirizine Dihydrochloride", Rxcui = "203150", Type = "PIN", Lat = "ENG", 
Suppress = "N", Umlscui = "C0700480", SY = ""} }
}

getRelatedByType( rxcui, type-list )

Get the related RxNorm identifiers of an RxNorm concept specified one or more term types.

Input:

rxcui - the RxNorm identifier

type-list - an array of one or more RxNorm term types

Output:

an array of RxNorm concept group structures. An RxNorm concept group structure has the following fields:

Example

getRelatedByType( "131725", {"IN", "PIN", "SBD"} )  

returns:

{
Type = "IN", { 
{ Name = "zolpidem", Rxcui = "39993", Type = "IN", Lat = "ENG", 
Suppress = "N", Umlscui = "C0078839", SY = ""},
{ Name = "Zolpidem tartrate", Rxcui = "221183", Type = "PIN", Lat = "ENG", 
Suppress = "N", Umlscui = "C0724725", SY = ""} }
Type = "SBD", {
{ Name = "zolpidem 10 MG Oral Tablet [Ambien]", Rxcui = "210762", Type = "SBD", Lat = "ENG", 
Suppress = "N", Umlscui = "C0712713", SY= "Ambien 10 MG Oral Tablet"},
{ Name = "zolpidem 12.5 MG Extended Release Tablet [Ambien]", Rxcui = "602455", Type = "SBD", Lat = "ENG", 
Suppress = "N", Umlscui = "C1628353", SY= "Ambien 12.5 MG Extended Release Tablet"}, 
{ Name = "zolpidem 5 MG Oral Tablet [Ambien]", Rxcui = "210749", Type = "SBD", Lat = "ENG", 
Suppress = "N", Umlscui = "C0712699", SY= "Ambien 5 MG Oral Tablet"}, 
{ Name = "zolpidem 6.25 MG Extended Release Tablet [Ambien]", Rxcui = "602459", Type = "SBD", Lat = "ENG", 
Suppress = "N", Umlscui = "C1630664", SY= "Ambien 6.25 MG Extended Release Tablet"} }
} 

getAllRelatedInfo( rxcui )

Get all the related RxNorm concepts for a given RxNorm identifier. This includes concepts of term types "IN", "PIN", "BN", "SBD", "SBDC", "SBDF", "SCD", "SCDC", "SCDF", "DF", "BPCK" and "GPCK".

Input:

rxcui - the RxNorm identifier

Output:

an array of RxNorm concept group structures. An RxNorm concept group structure has the following fields: Type - the RxNorm term type Array of RxNorm concept structures. See above for the description of the RxNorm concept structure.

Example

getAllRelatedInfo( "151524" ) 

returns:

{
Type = "IN", { 
{ Name = "Sulindac", Rxcui = "10237", Type = "IN", Lat = "ENG", Suppress = "N", 
Umlscui = "C0038792", SY = ""} }
Type = "BN", {
{ Name = "Clinoril", Rxcui = "151524", Type = "BN", Lat = "ENG", Suppress = "N", 
Umlscui = "C0591267", SY = ""} }
Type = "SCDC", {
{ Name = "Sulindac 150 MG", Rxcui = "316755", Type = "SCDC", Lat = "ENG", 
Suppress = "N", Umlscui = "C0990458", SY= ""},
{ Name = "Sulindac 200 MG", Rxcui = "316756", Type = "SCDC", Lat = "ENG", 
Suppress = "N", Umlscui = "C0990459", SY= ""} }
Type = "SBDC", {
{ Name = "Sulindac 150 MG [Clinoril]", Rxcui = "569138", Type = "SBDC", Lat = "ENG", 
Suppress = "N", Umlscui = "C1618559", SY= ""},
{ Name = "Sulindac 200 MG [Clinoril]", Rxcui = "564274", Type = "SBDC", Lat = "ENG", 
Suppress = "N", Umlscui = "C1617517", SY= ""} }
Type = "SCD", {
{ Name = "Sulindac 150 MG Oral Tablet", Rxcui = "198238", Type = "SCD", Lat = "ENG", 
Suppress = "N", Umlscui = "C0690432", SY= ""},
{ Name = "Sulindac 200 MG Oral Tablet", Rxcui = "198239", Type = "SCD", Lat = "ENG", 
Suppress = "N", Umlscui = "C0690433", SY= ""} }
Type = "SBD", {
{ Name = "Sulindac 150 MG Oral Tablet [Clinoril]", Rxcui = "198238", Type = "SBD", Lat = "ENG", 
Suppress = "N", Umlscui = "C0710020", SY= "Clinoril 150 MG Oral Tablet"}, 
{ Name = "Sulindac 200 MG Oral Tablet [Clinoril]", Rxcui = "105944", Type = "SBD", Lat = "ENG", 
Suppress = "N", Umlscui = "C0357508", SY= "Clinoril 200 MG Oral Tablet"} }
Type = "SCDF", {
{ Name = "Sulindac Oral Tablet", Rxcui = "374003", Type = "SCDF", Type = "SCDF", Lat = "ENG", 
Suppress = "N", Umlscui = "C1248075", SY= ""} }
Type = "SBDF", {
{ Name = "Sulindac Oral Tablet [Clinoril]", Rxcui = "367629", Type = "SBDF", Lat = "ENG", 
Suppress = "N", Umlscui = "C1621233", SY= ""} }
Type = "DF", {
{ Name = "Oral Tablet", Rxcui = "317541", Type = "DF", Lat = "ENG", 
Suppress = "N", Umlscui = "C0993159", SY= ""} }
Type = "PIN", {}
Type = "BPCK", {}
Type = "GPCK", {}
}

getDrugs( name )

Get the drug products associated with a specified name. The name can be an ingredient, brand name, clinical drug form, branded drug form, clinical drug component, or branded drug component.

Input:

name - the name of the drug

Output:

An array of concept group structures whose types are "SBD" and "BPCK" for brand names, branded drug forms or branded drug components, or "SCD" and "GPCK" for ingredients, clinical drug forms or clinical drug components.

Example 1:

getDrugs( "varenicline" )  

returns:

{
Type = "SCD", {
{ Name = "varenicline 0.5 MG Oral Tablet", Rxcui = "636671", Type = "SCD", 
Lat = "ENG", Suppress = "N", Umlscui = "C1711886", SY= ""},
{ Name = "varenicline 1 MG Oral Tablet", Rxcui = "636676", Type = "SCD", 
Lat = "ENG", Suppress = "N", Umlscui = "C1711889", SY= ""} }
Type = "GPCK", {
{ Name = "{ 56 (varencline 1 MG Oral Tablet) } Pack", RxCui = "749788", Type = "GPCK", 
Lat = "ENG", Suppress = "N", Umlscui = "", SY= ""} }
}
Example 2:
getDrugs("cymbalta")   

returns:

{
Type = "SBD", {
{ Name = "duloxetine 20 MG Enteric Coated Capsule [Cymbalta]", Rxcui = "596928", 
Type = "SBD", Lat = "ENG", Suppress = "N", Umlscui = "C1656295", 
SY= "Cymbalta 20 MG Enteric Coated Capsule"},
{ Name = "duloxetine 30 MG Enteric Coated Capsule [Cymbalta]", Rxcui = "596932", 
Type = "SBD", Lat = "ENG", Suppress = "N", Umlscui = "C1614249", 
SY= "Cymbalta 30 MG Enteric Coated Capsule"},
{ Name = "duloxetine 60 MG Enteric Coated Capsule [Cymbalta]", Rxcui = "615186", 
Type = "SBD", Lat = "ENG", Suppress = "N", Umlscui = "C1624617", 
SY= "Cymbalta 60 MG Enteric Coated Capsule"} }
Type = "BPCK", {}
}

getNDCs( rxcui )

Get the National Drug Codes (NDCs) for the RxNorm concept.

Input:

rxcui - the RxNorm identifier

Output:

An array of NDCs

Example

getNDCs( "105259")    

returns:
             
  { "00069305050", "00069305086", "51129930501", "60491072206" }

getRxNormVersion( )

Get the version of the RxNorm data set.

Input:

None

Output:

The version of the RxNorm data set. The date of the monthly release will be returned along (if applicable) the date of the last weekly update.

Example

getRxNormVersion()   

returns  "01-Oct-2008;08-Oct-2008"

getIdTypes()

Get the valid identifier types of the RxNorm data set. See findRxCuiById for use of these types.

Input:

None

Output:

An array of valid identifier types.

Example

getIdTypes()   

returns:
 
{"AMPID",  "GCN_SEQNO", "GFC", "GPPC", "LISTING_SEQ_NO", "MMSL_CODE",  "NDC", "SNOMEDCT", 
"SPL", "UMLSCUI", "UNII_CODE", "VUID" }

getRelaTypes()

Get the relationship names in the RxNorm data set.

Input:

None

Output:

An array of relationship names. See getRelatedByRelationship for use of these names.

Example

getRelaTypes()    

returns:

{ "consists_of", "constitutes", "contained_in", "contains", "dose_form_of", 
"form_of", "has_dose_form", "has_form", "has_ingredient", "has_precise_ingredient", 
"has_tradename", "ingredient_of", "inverse_isa", "isa", "precise_ingredient_of", 
"reformulated_to", "reformulation_of", "tradename_of" }

getTermTypes()

Get the valid term types in the RxNorm data set.

Input:

None

Output:

An array of the valid term types. See getRelatedByType for use of these term types.

Example

getTermTypes()     

returns:

{ "BN", "BPCK", "DF", "GPCK", "IN", "PIN", "SBD", "SBDC", "SBDF", "SCD", "SCDC", "SCDF"}

getProprietaryInformation( rxcui, source-list, proxyTicket )

Get the concept information associated with the concept for the specified sources. The user must have a valid UMLS license and be able to access the UMLSKS authority service to obtain proxy tickets to use this function.

Input:

rxcui - the RxNorm identifier

source-list - an array containing the source vocabulary names to use. If null, information from all sources is retrieved. Valid source values are: "GS", "MDDB", "MMSL", "MMX", "MSH", "MTHFDA", "MTHSPL", "NDDF", "RXNORM", "SNOMEDCT" and "VANDF".

proxyTicket - a proxy ticket obtained from the UMLSKS authority service. Here is how to obtain the proxy ticket:

Output:

an array containing concept information. Each structure contains the following fields:

Example

getProprietaryInformation( "61609", {"SNOMEDCT", "MMSL"}, ticket)

returns:

{{RxCui= "61609", Name= "Arbutamine", Type= "PT", Id= "109207004", Source= "SNOMEDCT"},
 {RxCui= "61609", Name= "Arbutamine (substance)", Type= "FN", Id= "109207004", Source= "SNOMEDCT"},
 {RxCui= "61609", Name= "arbutamine", Type= "GN", Id= "d04216", Source= "MMSL"}}

getMultiIngredBrand( rxcui-list )

Get the brands that contain all the specified ingredients. Note that the brands returned may contain other ingredients in addition to those specified.

Input:

rxcui-list - list of the RxCuis of the ingredients

Output:

an RxNorm concept structure containing the following fields:

Example

getMultiIngredBrand( {1191, 33408} ) 

returns:

{Name = "Momentum tradename", Rxcui = "218423", Type = "BN", Lat = "ENG", Suppress = "N", Umlscui = "C0721776", SY = ""}

getDisplayTerms( )

Gets the names used by RxNav for auto completion. This is a large list which includes names of ingredients, brands, and branded packs.

Input:

None

Output:

An array of ingredient, brand and branded pack RxNorm names.

Example

getDisplayTerms()

returns:
(a list of names used by the auto completion function of RxNav)



Recent API changes

Release Date: October 7, 2009
Modules effected: getDisplayTerms
Description of change:
New function added to user documentation and to the WSDL file.
Release Date: August 17, 2009
Modules effected: findRxcuiById, getIdTypes
Description of change:
The GCN identifier has been replaced by GCN_SEQNO.
Release Date: July 8, 2009
Modules effected: getAllRelatedInfo, getConceptProperties, getRelatedByType, getTermTypes
Description of change:
The PIN (precise ingredient) term type was added starting with the July 2009 release of the RxNorm data set. RxNorm terms of this type previously had an IN term type. The PIN term type will be returned as part of the structure returned by getAllRelatedInfo. PIN is also now a valid input type for getRelatedByType.
Release Date: April 28, 2009
Modules effected: findRxcuiById, with idType = "NDC"
Description of change:
The change fixes a problem in the findRxcuiById function when used with the NDC identifier type. In certain cases RxCUIs were not returned when the NDC identifier was contained in more than one concept. This problem occurred regardless of the value of the allSourcesFlag parameter.
Release Date: March 23, 2009
Modules effected: getRelatedByType, getAllRelatedInfo
Description of change:
The change fixes a problem in the getRelatedByType and the getAllRelatedInfo functions when the term type (TTY) associated with the RxCUI was a branded pack (BPCK). In certain cases the related ingredient (IN) and clinical drug component (SCDC) concepts were not returned.

U.S. National Library of Medicine, 8600 Rockville Pike, Bethesda, MD 20894
National Institutes of Health, Department of Health & Human Services
Copyright, Privacy, Accessibility