get_drug_ndcs
Retrieve National Drug Code (NDC) identifiers for medications using their DailyMed SET ID to facilitate accurate drug identification and inventory management.
Instructions
Get NDC codes for a specific drug by its SET ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| setId | Yes | The SET ID of the drug to get NDCs for |
Implementation Reference
- src/clients/spl-client.ts:316-342 (handler)The handler function `getSPLNDCs` in `SPLClient` class fetches NDC codes for a specific drug SET ID.
async getSPLNDCs(setId: string): Promise<any[]> { if (!setId || typeof setId !== "string") { throw new Error("Valid SET ID is required"); } try { const response = await this.client.get(`/spls/${setId}/ndcs.json`); if ( response.data && response.data.data && Array.isArray(response.data.data) ) { return response.data.data.map((item: any) => ({ ndc: item.ndc, packageNdc: item.package_ndc, productNdc: item.product_ndc, })); } else { throw new Error("Unexpected response structure for SPL NDCs"); } } catch (error) { throw new Error( `Failed to fetch SPL NDCs: ${error instanceof Error ? error.message : "Unknown error"}`, ); } } - src/index.ts:87-96 (registration)The tool "get_drug_ndcs" is registered and handled in `src/index.ts` within the `setupHandlers` method of the `DailyMedServer` class, delegating the call to the `DailyMedClient`.
case "get_drug_ndcs": const ndcs = await this.client.getSPLNDCs(args.setId as string); return { content: [ { type: "text", text: JSON.stringify(ndcs, null, 2), }, ], }; - src/tools.ts:41-53 (schema)The tool definition and input schema for "get_drug_ndcs" are defined in `src/tools.ts`.
name: "get_drug_ndcs", description: "Get NDC codes for a specific drug by its SET ID", inputSchema: { type: "object", properties: { setId: { type: "string", description: "The SET ID of the drug to get NDCs for", }, }, required: ["setId"], }, },