Skip to Content
ToolsMedicines

Medicines

ctx.MEDICINE looks up public medicine reference material. It reads no user data: pass in a name, get reference material back. These are reference tables, not prescribing advice.

Methods

MethodInputWhat it does
lookupReference{ name }What a medicine is, what it treats, and what its label warns about, from RxTerms, DailyMed and openFDA.
checkInteractions{ names }Interaction mentions between two or more medicines, read from their FDA labels via NIH RxNav.
searchSouthAfricanPrice{ name, nappiCode? }Single exit price (SEP), NAPPI code, and cheaper generics, from medicineprices.org.za.

Look up a medicine

const reference = await ctx.MEDICINE.lookupReference({ name: "ibuprofen" });

reference.normalizedNames lists RxNorm names for the term, best match first. dailyMed holds the matching labels with links, and openFda holds brand and generic names, uses, warnings, and when not to use it. Either can be { error } when that source is unavailable.

Check interactions

const check = await ctx.MEDICINE.checkInteractions({ names: ["warfarin", "ibuprofen"], });

Each item in findings names the medicine whose label mentions the other, and quotes the text around it. Medicines in unchecked could not be read at all.

Find a South African price

const prices = await ctx.MEDICINE.searchSouthAfricanPrice({ name: "Panado" });

matches lists each product with its nappiCode, singleExitPrice, and numberOfGenerics. Pass a nappiCode from a match to fill genericAlternatives, with pack size and cost per unit.

Use it

import { workflow } from "@loops/sdk"; type PriceRequest = { medicine: string }; export const priceCheckWorkflow = workflow<PriceRequest>({ id: "price-check", execute: async ({ step, event }) => step.do("Look up the price", ({ ctx }) => ctx.MEDICINE.searchSouthAfricanPrice({ name: event.body.medicine }), ), });

What it won’t do

An empty findings is not evidence that a combination is safe. Findings are label mentions, ungraded and one-directional. Prices are South African only, and it does not check medical aid benefits.

Last updated on