rxnormie
Version:
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.
324 lines (207 loc) • 5.91 kB
Markdown
# 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
```bash
npm install rxnormie
```
## Usage
```typescript
import { RxNormie } from "rxnormie";
// Create a new instance with default options (JSON format)
const rxnormie = new RxNormie();
// Or specify options
const rxnormieWithOptions = new RxNormie({
format: "json", // 'json' or 'xml', defaults to 'json'
apiKey: "your-api-key", // Optional API key
});
// Example: Get drug information
async function getDrugInfo() {
const drugs = await rxnormie.getDrugs("ibuprofen");
console.log(drugs);
}
// Example: Find RxCUI by NDC
async function findRxCUIByNDC() {
const result = await rxnormie.findRxcuiById("00071015773", "NDC");
console.log(result);
}
```
## API Reference
The SDK provides methods for all RxNorm API endpoints. All methods return promises that resolve to typed objects.
### Constructor
```typescript
new RxNormie(options?: { apiKey?: string; format?: 'json' | 'xml' })
```
- `apiKey` (optional): API key for authentication
- `format` (optional): Response format, either 'json' or 'xml'. Defaults to 'json'
### Methods
#### filterByProperty
```typescript
filterByProperty(rxcui: string, propName: string, propValues: string): Promise<string | null>
```
Returns RxCUI if the predicate is true, null otherwise.
#### findRelatedNDCs
```typescript
findRelatedNDCs(
ndc: string,
relation: 'concept' | 'product' | 'drug',
ndcStatus: 'active' | 'obsolete' | 'alien' | 'ALL' = 'active'
): Promise<NDCInfo[]>
```
Find NDCs related to a given NDC by concept, product, or drug.
#### findRxcuiById
```typescript
findRxcuiById(id: string, idType: string): Promise<IdGroup | null>
```
Find RxCUI by ID.
#### findRxcuiByString
```typescript
findRxcuiByString(name: string, searchType: 'Exact' | 'Contains' = 'Exact'): Promise<IdGroup | null>
```
Find RxCUI by name.
#### getAllConceptsByStatus
```typescript
getAllConceptsByStatus(status: string): Promise<MinConcept[]>
```
Get all concepts by status.
#### getAllConceptsByTTY
```typescript
getAllConceptsByTTY(tty: string): Promise<MinConcept[]>
```
Get all concepts by term type.
#### getAllHistoricalNDCs
```typescript
getAllHistoricalNDCs(rxcui: string): Promise<HistoricalNDC[]>
```
Get all historical NDCs for a concept.
#### getAllNDCsByStatus
```typescript
getAllNDCsByStatus(status: string): Promise<NDCInfo[]>
```
Get all NDCs by status.
#### getAllProperties
```typescript
getAllProperties(rxcui: string, prop?: string): Promise<RxNormProperty[]>
```
Get all properties for a concept.
#### getAllRelatedInfo
```typescript
getAllRelatedInfo(rxcui: string): Promise<RelatedGroup | null>
```
Get all related information for a concept.
#### getApproximateMatch
```typescript
getApproximateMatch(term: string, maxEntries: number = 20, option?: string): Promise<MinConcept[]>
```
Get approximate match for a term.
#### getDisplayTerms
```typescript
getDisplayTerms(term: string, option?: string): Promise<string[]>
```
Get display terms for auto-completion.
#### getDrugs
```typescript
getDrugs(name: string, expand?: 'psn'): Promise<DrugGroup | null>
```
Get drug products associated with a specified name.
#### getIdTypes
```typescript
getIdTypes(): Promise<string[]>
```
Get ID types.
#### getMultiIngredBrand
```typescript
getMultiIngredBrand(ingredients: string): Promise<MinConcept[]>
```
Get brands containing specified ingredients.
#### getNDCProperties
```typescript
getNDCProperties(id: string): Promise<NDCProperty[]>
```
Get NDC properties.
#### getNDCStatus
```typescript
getNDCStatus(ndc: string): Promise<NDCStatus | null>
```
Get NDC status.
#### getNDCs
```typescript
getNDCs(rxcui: string): Promise<string[]>
```
Get NDCs for a concept.
#### getPropCategories
```typescript
getPropCategories(): Promise<PropertyCategory[]>
```
Get property categories.
#### getPropNames
```typescript
getPropNames(category?: string): Promise<PropertyName[]>
```
Get property names.
#### getProprietaryInformation
```typescript
getProprietaryInformation(rxcui: string, sourceTypes?: string): Promise<ProprietaryInfo | null>
```
Get proprietary information for a concept.
#### getReformulationConcepts
```typescript
getReformulationConcepts(rxcui: string): Promise<MinConcept[]>
```
Get reformulation concepts.
#### getRelaTypes
```typescript
getRelaTypes(): Promise<RelaType[]>
```
Get relationship types.
#### getRelatedByRelationship
```typescript
getRelatedByRelationship(rxcui: string, rela: string): Promise<ConceptProperty[]>
```
Get related concepts by relationship.
#### getRelatedByType
```typescript
getRelatedByType(rxcui: string, tty: string): Promise<ConceptProperty[]>
```
Get related concepts by type.
#### getRxConceptProperties
```typescript
getRxConceptProperties(rxcui: string): Promise<RxConceptProperties | null>
```
Get RxNorm concept properties.
#### getRxNormName
```typescript
getRxNormName(rxcui: string): Promise<string | null>
```
Get RxNorm name for a concept.
#### getRxNormVersion
```typescript
getRxNormVersion(): Promise<RxNormVersions | null>
```
Get RxNorm version information.
#### getRxProperty
```typescript
getRxProperty(rxcui: string, propName: string): Promise<string | null>
```
Get a specific property for a concept.
#### getRxcuiHistoryStatus
```typescript
getRxcuiHistoryStatus(rxcui: string): Promise<RxcuiHistoryStatus | null>
```
Get RxCUI history status.
#### getSourceTypes
```typescript
getSourceTypes(): Promise<SourceType[]>
```
Get source types.
#### getSpellingSuggestions
```typescript
getSpellingSuggestions(term: string): Promise<string[]>
```
Get spelling suggestions for a term.
#### getTermTypes
```typescript
getTermTypes(): Promise<TermType[]>
```
Get term types.
## License
ISC