JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q43131F
  • License MIT

A simple but robust TypeScript client for the RxNorm API — for normies. This package provides a simple and intuitive way to interact with the RxNorm API.

Package Exports

  • rxnormie
  • rxnormie/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rxnormie) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

RxNormie

A simple but robust TypeScript client for the RxNorm API — for normies 😊. This package provides a simple and intuitive way to interact with the RxNorm API.

Installation

# Using npm
npm install rxnormie

# Using yarn
yarn add rxnormie

# Using pnpm
pnpm add rxnormie

Usage

Basic Usage

import { RxNormie } from 'rxnormie';

// Initialize the client with default options (JSON format)
const rxnormie = new RxNormie();

// Initialize with options
const rxnormieWithOptions = new RxNormie({
  // Your UMLS/UTS API key for the RxNorm API (optional)
  apiKey: 'your-api-key',
  // Response format - 'json' (default) or 'xml'
  format: 'json'
});

// If you prefer XML responses
const rxnormieXml = new RxNormie({ format: 'xml' });

// Example: Find NDCs related to a specific NDC
async function findRelatedNDCs() {
  // Find all active NDCs that are packagings of the same product as NDC 0069-3060
  const relatedNDCs = await rxnormie.findRelatedNDCs('0069-3060', 'product');
  
  console.log(`Found ${relatedNDCs.length} related NDCs`);
  
  // Print out the related NDCs
  relatedNDCs.forEach(ndcInfo => {
    console.log(`NDC: ${ndcInfo.ndc11} | Name: ${ndcInfo.conceptName} | Status: ${ndcInfo.status}`);
  });
}

findRelatedNDCs();

// Example: Filter a drug by property
async function filterDrugByProperty() {
  // Filter for a drug with specific property
  // For example, checking if a drug with rxcui "198440" has the property "TTY" with value "SBD"
  const result = await rxnormie.filterByProperty('198440', 'TTY', 'SBD');
  
  if (result) {
    console.log('Drug matches the filter criteria');
  } else {
    console.log('Drug does not match the filter criteria');
  }
}

filterDrugByProperty();

API Reference

RxNormie

The main class for interacting with the RxNorm API.

Constructor

constructor(options?: { apiKey?: string; format?: ResponseFormat })
  • options (optional): Configuration options
    • apiKey (optional): Your RxNorm API key if you have one
    • format (optional): Response format, either 'json' or 'xml'. Defaults to 'json'

Methods

filterByProperty(rxcui: string, propName: string, propValues: string): Promise<string | null>

Filter a drug by its properties.

  • rxcui: The RxNorm concept unique identifier
  • propName: The name of the property to filter by
  • propValues: The values of the property to match
  • Returns: The rxcui if the drug matches the criteria, otherwise null
findRelatedNDCs(ndc: string, relation: 'concept' | 'product' | 'drug', ndcStatus?: 'active' | 'obsolete' | 'alien' | 'ALL'): Promise<NDCInfo[]>

Find NDCs related to a given NDC by concept, product, or drug.

  • ndc: The NDC code to find related NDCs for
  • relation: The relation type to search by
    • concept: NDCs associated with the same RxNorm concept
    • product: NDCs having the same initial two-segment code (different packagings)
    • drug: NDCs associated with any drug concept related to the RxNorm concept
  • ndcStatus (optional): Status filter for NDCs to retrieve. Default is 'active'
    • active: Only active NDCs
    • obsolete: Previously existing NDCs
    • alien: NDCs in vocabularies other than RxNorm
    • ALL: Any status
  • Returns: An array of related NDC information objects with the following properties:
    • ndc11: National Drug Code in CMS 11-digit format
    • status: NDC status
    • rxcui: RxNorm identifier
    • conceptName: A name for the concept
    • conceptStatus: RxNorm concept status
    • tty: RxNorm Term type

Types

ResponseFormat

type ResponseFormat = 'json' | 'xml'

NDCInfo

interface NDCInfo {
  ndc11: string;
  status: string;
  rxcui: string;
  conceptName: string;
  conceptStatus: string;
  tty: string;
}