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 robust TypeScript client for the RxNorm REST API. This package provides a simple and intuitive way to interact with the RxNorm API, making it easy to search for drugs, check interactions, and more.
Installation
npm install rxnormie
Usage
import { RxNormie } from 'rxnormie';
// Create a new instance with custom options (optional)
const rxnormie = new RxNormie({
timeout: 5000,
retries: 3
});
// Or use the default instance
import rxnormie from 'rxnormie';
// Examples
// Find a drug by name
const results = await rxnormie.findByName('Tylenol');
// Find drug by RxCUI
const drug = await rxnormie.findByRxcui('203155');
// Check drug interactions
const interactions = await rxnormie.findInteractions(['207106', '152923', '656659']);
// Get NDC codes
const ndcCodes = await rxnormie.getNDCsByRxcui('203155');
// Get spelling suggestions
const suggestions = await rxnormie.getSpellingSuggestions('setraline');
API Reference
Constructor Options
baseUrl
: Base URL for the RxNorm API (default: 'https://rxnav.nlm.nih.gov/REST')timeout
: Request timeout in milliseconds (default: 10000)retries
: Number of retry attempts for failed requests (default: 3)retryDelay
: Delay between retries in milliseconds (default: 1000)
Methods
findByName(name: string, searchType?: 'exact' | 'words' | 'startsWith' | 'contains')
Search for drugs by name with optional search type.
findByRxcui(rxcui: string)
Find drug information by RxCUI (RxNorm Concept Unique Identifier).
getAllRelatedByRxcui(rxcui: string)
Get all related concepts for a given RxCUI.
findInteractions(rxcuis: string[])
Find drug interactions between multiple RxCUIs.
getNDCsByRxcui(rxcui: string)
Get National Drug Codes (NDCs) for a given RxCUI.
getSpellingSuggestions(name: string)
Get spelling suggestions for a drug name.
isValidRxcui(rxcui: string)
Check if a specific RxCUI exists and is active.
findByNDC(ndc: string)
Find drug information by National Drug Code (NDC).
getPropertiesByRxcui(rxcui: string, propName?: string)
Get drug properties for a given RxCUI.
getHistoricalNDCsByRxcui(rxcui: string)
Get historical NDCs for a given RxCUI.
Error Handling
The package includes a custom RxNormieError
class for handling API errors:
try {
const drug = await rxnormie.findByRxcui('invalid-rxcui');
} catch (error) {
if (error instanceof RxNormieError) {
console.error('API Error:', error.message);
console.error('Status:', error.status);
console.error('Response:', error.responseData);
}
}
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.