UNPKG

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.

412 lines (411 loc) 12.3 kB
export type ResponseFormat = 'json' | 'xml'; export interface RxNormApiResponse<T> { data: T; } export interface NDCInfo { ndc11: string; status: string; rxcui: string; conceptName: string; conceptStatus: string; tty: string; } export interface NDCInfoList { ndcInfo: NDCInfo[]; } export interface NDCStatus { status: string; comment?: string; } export interface NDCProperty { propertyName: string; propertyValue: string; } export interface NDCPropertyList { ndcProperty: NDCProperty[]; } export interface ConceptProperty { rxcui: string; name: string; synonym?: string; tty: string; language: string; suppress: string; umlscui?: string; psn?: string; } export interface ConceptGroup { tty: string; conceptProperties?: ConceptProperty[]; } export interface DrugGroup { name?: string; conceptGroup: ConceptGroup[]; } export interface RxTermInfo { rxcui: string; name: string; fullName?: string; rxtermForm?: string; rxnormDoseForm?: string; route?: string; strength?: string; suppress?: string; displayName?: string; } export interface MinConceptGroup { minConcept: MinConcept[]; } export interface MinConcept { rxcui: string; name: string; tty: string; } export interface RelatedGroup { rxcui: string; name?: string; tty?: string; conceptGroup: ConceptGroup[]; } export interface HistoricalNDC { ndc: string; startDate?: string; endDate?: string; } export interface HistoricalNDCList { historicalNdc: HistoricalNDC[]; } export interface RxNormProperty { propName: string; propValue: string; } export interface RxNormPropertyList { propConcept: RxNormProperty[]; } export interface RxNormVersion { version: string; releaseDate?: string; } export interface RxNormVersions { rxnormVersion: RxNormVersion[]; } export interface IdGroup { name?: string; idType?: string; id?: string; rxnormId: string[]; } export interface RelaType { name: string; value: string; category?: string; } export interface RelaTypeList { relationTypeList: RelaType[]; } export interface TermType { name: string; expanded: string; } export interface TermTypeList { termType: TermType[]; } export interface SourceType { abbr: string; name: string; } export interface SourceTypeList { sourceType: SourceType[]; } export interface SpellingSuggestion { suggestion: string[]; } export interface PropertyCategory { category: string; } export interface PropertyCategoryList { propCategory: PropertyCategory[]; } export interface PropertyName { name: string; category?: string; } export interface PropertyNameList { propName: PropertyName[]; } export interface DisplayTermsList { term: string[]; } export interface RxcuiHistoryStatus { rxcui: string; status: string; history?: RxcuiHistory[]; } export interface RxcuiHistory { rxcui: string; sab: string; code: string; sab2?: string; code2?: string; changeType: string; changeDate: string; } export interface RxConceptProperties { rxcui: string; name: string; synonym?: string; tty: string; language: string; suppress: string; umlscui?: string; } export interface ProprietaryInfo { rxcui: string; proprietary: ProprietarySource[]; } export interface ProprietarySource { sourceType: string; rxaui: string; code: string; source: string; suppressible: string; tty: string; str: string; } /** * RxNormie - A TypeScript SDK for the RxNorm API */ export declare class RxNormie { private api; private format; /** * Creates a new instance of the RxNormie SDK * @param options Configuration options for the SDK */ constructor(options?: { apiKey?: string; format?: ResponseFormat; }); /** * Helper method to handle XML responses * @param response The XML response string * @param pattern The regex pattern to extract data * @param defaultValue Default value if no match is found * @returns Extracted value or default value */ private extractFromXml; /** * Helper method to handle errors * @param error The error object * @param methodName The name of the method where the error occurred * @returns Appropriate error value based on the return type */ private handleError; /** * Filter by property * @param rxcui RxNorm concept ID * @param propName Property name * @param propValues Property values (comma-delimited) * @returns RxCUI if the predicate is true, null otherwise */ filterByProperty(rxcui: string, propName: string, propValues: string): Promise<string | null>; /** * Find NDCs related to a given NDC by concept, product, or drug * @param ndc The NDC code to find related NDCs for * @param relation The relation type: 'concept', 'product', or 'drug' * @param ndcStatus Optional status filter: 'active', 'obsolete', 'alien', or 'ALL' * @returns An array of related NDC information objects */ findRelatedNDCs(ndc: string, relation: 'concept' | 'product' | 'drug', ndcStatus?: 'active' | 'obsolete' | 'alien' | 'ALL'): Promise<NDCInfo[]>; /** * Find RxCUI by ID * @param id The identifier to look up * @param idType The type of identifier (e.g., 'NDC', 'RXCUI', etc.) * @returns An IdGroup object containing the RxNorm IDs */ findRxcuiById(id: string, idType: string): Promise<IdGroup | null>; /** * Find RxCUI by name * @param name The name to search for * @param searchType The type of search ('Exact' or 'Contains') * @returns An IdGroup object containing the RxNorm IDs */ findRxcuiByString(name: string, searchType?: 'Exact' | 'Contains'): Promise<IdGroup | null>; /** * Get all concepts by status * @param status The status to filter by * @returns An array of MinConcept objects */ getAllConceptsByStatus(status: string): Promise<MinConcept[]>; /** * Get all concepts by term type * @param tty The term type to filter by * @returns An array of MinConcept objects */ getAllConceptsByTTY(tty: string): Promise<MinConcept[]>; /** * Get all historical NDCs for a concept * @param rxcui The RxNorm concept ID * @returns An array of HistoricalNDC objects */ getAllHistoricalNDCs(rxcui: string): Promise<HistoricalNDC[]>; /** * Get all NDCs by status * @param status The status to filter by * @returns An array of NDCInfo objects */ getAllNDCsByStatus(status: string): Promise<NDCInfo[]>; /** * Get all properties for a concept * @param rxcui The RxNorm concept ID * @param prop The property name to filter by (optional) * @returns An array of RxNormProperty objects */ getAllProperties(rxcui: string, prop?: string): Promise<RxNormProperty[]>; /** * Get all related information for a concept * @param rxcui The RxNorm concept ID * @returns A RelatedGroup object */ getAllRelatedInfo(rxcui: string): Promise<RelatedGroup | null>; /** * Get approximate match for a term * @param term The term to match * @param maxEntries Maximum number of entries to return * @param option Options for the match (optional) * @returns An array of MinConcept objects */ getApproximateMatch(term: string, maxEntries?: number, option?: string): Promise<MinConcept[]>; /** * Get display terms for auto-completion * @param term The term to match * @param option Options for the match (optional) * @returns An array of display terms */ getDisplayTerms(term: string, option?: string): Promise<string[]>; /** * Get drug products associated with a specified name * @param name Name of ingredient, brand, clinical dose form, branded dose form, clinical drug component, or branded drug component * @param expand Additional result fields to retrieve (e.g., 'psn' for Prescribable Name) * @returns Drug group containing concept groups with drug information */ getDrugs(name: string, expand?: 'psn'): Promise<DrugGroup | null>; /** * Get ID types * @returns An array of ID types */ getIdTypes(): Promise<string[]>; /** * Get brands containing specified ingredients * @param ingredients Comma-delimited list of ingredients * @returns An array of MinConcept objects */ getMultiIngredBrand(ingredients: string): Promise<MinConcept[]>; /** * Get NDC properties * @param id The NDC code * @returns An array of NDC properties */ getNDCProperties(id: string): Promise<NDCProperty[]>; /** * Get NDC status * @param ndc The NDC code * @returns NDC status information */ getNDCStatus(ndc: string): Promise<NDCStatus | null>; /** * Get NDCs for a concept * @param rxcui The RxNorm concept ID * @returns An array of NDC codes */ getNDCs(rxcui: string): Promise<string[]>; /** * Get property categories * @returns An array of property categories */ getPropCategories(): Promise<PropertyCategory[]>; /** * Get property names * @param category The property category (optional) * @returns An array of property names */ getPropNames(category?: string): Promise<PropertyName[]>; /** * Get proprietary information for a concept * @param rxcui The RxNorm concept ID * @param sourceTypes Comma-delimited list of source types (optional) * @returns Proprietary information */ getProprietaryInformation(rxcui: string, sourceTypes?: string): Promise<ProprietaryInfo | null>; /** * Get reformulation concepts * @param rxcui The RxNorm concept ID * @returns An array of MinConcept objects */ getReformulationConcepts(rxcui: string): Promise<MinConcept[]>; /** * Get relationship types * @returns An array of relationship types */ getRelaTypes(): Promise<RelaType[]>; /** * Get related concepts by relationship * @param rxcui The RxNorm concept ID * @param rela The relationship type * @returns An array of ConceptProperty objects */ getRelatedByRelationship(rxcui: string, rela: string): Promise<ConceptProperty[]>; /** * Get related concepts by type * @param rxcui The RxNorm concept ID * @param tty The term type * @returns An array of ConceptProperty objects */ getRelatedByType(rxcui: string, tty: string): Promise<ConceptProperty[]>; /** * Get RxNorm concept properties * @param rxcui The RxNorm concept ID * @returns RxConceptProperties object */ getRxConceptProperties(rxcui: string): Promise<RxConceptProperties | null>; /** * Get RxNorm name for a concept * @param rxcui The RxNorm concept ID * @returns The name of the concept */ getRxNormName(rxcui: string): Promise<string | null>; /** * Get RxNorm version information * @returns RxNorm version information */ getRxNormVersion(): Promise<RxNormVersions | null>; /** * Get a specific property for a concept * @param rxcui The RxNorm concept ID * @param propName The property name * @returns The property value */ getRxProperty(rxcui: string, propName: string): Promise<string | null>; /** * Get RxCUI history status * @param rxcui The RxNorm concept ID * @returns RxCUI history status information */ getRxcuiHistoryStatus(rxcui: string): Promise<RxcuiHistoryStatus | null>; /** * Get source types * @returns An array of source types */ getSourceTypes(): Promise<SourceType[]>; /** * Get spelling suggestions for a term * @param term The term to get suggestions for * @returns An array of spelling suggestions */ getSpellingSuggestions(term: string): Promise<string[]>; /** * Get term types * @returns An array of term types */ getTermTypes(): Promise<TermType[]>; }