A pharmacy POS lives or dies on one box: the cashier types three letters of a brand, and the right medicine has to be on the screen before the customer finishes asking. This guide shows how to build that box on the Oushodh API, and the few rules that keep it fast and inside the terms.
How does the search call work?
Your server sends the words the cashier typed to GET /v1/medicines/search, with your API key:
curl -G "https://api.oushodh.dev/v1/medicines/search" \
--data-urlencode "q=napa" \
-d "limit=10" \
-H "Authorization: Bearer $OUSHODH_KEY"
The answer holds up to limit medicines, best match first, and the count of every match:
{
"items": [
{
"id": "MED-012933",
"uuid": "01a1ba6f-f4d6-7143-ac84-9376f520eef8",
"product_name": "Napa 500 mg Tablet",
"generic_name": "Paracetamol",
"manufacturer": "Beximco Pharmaceuticals PLC.",
"dgda_listed": true
}
]
}
The answer also carries total, the count of every match. A shortened answer is shown here.
limit runs from 1 to 50, and the default is 20. For a POS, 8 to 10 is plenty: the cashier picks from the top of the list, not the bottom.
What does the search match?
Each word the cashier types matches the start of a word in the brand, an alternate name, the generic or the manufacturer, and every word must match. So nap finds Napa, and para beximco finds Beximco’s paracetamol. Strength is not searched: show product_name on each row, which carries the strength and form, and let the cashier pick Napa 500 mg Tablet from the list.
| Match on | Ranks |
|---|---|
| Brand | First |
| Alternate name (another source’s spelling) | Second |
| Generic | Third |
| Manufacturer | Fourth |
Ties go in a fixed order, so the same words always give the same list. An Oushodh ID or a UUID typed in the box returns that one medicine, which is handy for a barcode label that carries the ID.
Why must the key stay on your server?
Anyone who has the key can use your plan. A key inside a desktop POS, a phone app or a web page can be copied out of it. So the POS sends the typed words to your own server, your server calls Oushodh with the key, and passes the matches back. That one hop also lets you log what cashiers search for and never find.
What should the POS store on a sale?
Store the medicine’s uuid and id on the sale line, beside your own quantity and the price you charged. The uuid never changes, and the id is never given to another medicine, so a sale from today still points at the right medicine next year.
Do not store the search results or the medicine records themselves. The terms of use do not allow caching or storing API responses: your apps call the API each time they need data. The IDs and the data in your own records, such as the sale and the invoice, may stay.
How many requests will a busy POS use?
A search box that calls the API on each keystroke makes several requests a search. Wait about 250 ms after the last keystroke before you call, and start only after two or three letters. Then one search costs one or two requests.
The Developer plan allows 60 requests a minute per key and 50,000 a month, which suits one pharmacy. A chain with many tills needs a plan with more per minute. The rate limits page has every plan’s numbers, and a 429 answer tells you how many seconds to wait.
What if a medicine has no price?
A price no source states is null, never zero. Show the medicine anyway, and let the pharmacy enter its own price for that sale. When a price is there, prices tells you whether it is per unit, per strip or per pack, and which source stated it.
