A pharmacy that already runs a POS or an ERP has a stock list of its own: item codes, names typed by whoever set the item up, its own prices and stock counts. Before that software can show Oushodh data, each stock item needs to point at one Oushodh medicine. This guide shows how to make that link once, carefully, and keep your own records as they are.
What should the mapping table hold?
One row per stock item of yours, with the Oushodh medicine it is. Your SKU stays the key, because two of your items can be one medicine: a strip and a box of Napa 500 mg Tablet are two SKUs and one Oushodh medicine.
CREATE TABLE oushodh_match (
sku VARCHAR(64) PRIMARY KEY, -- your own item code
medicine_uuid CHAR(36), -- the key that never changes; NULL until matched
medicine_id VARCHAR(32), -- the id you show people, such as MED-012933
status VARCHAR(16) NOT NULL, -- matched, review or none
candidates TEXT, -- uuids a person chooses from
decided_by VARCHAR(64),
decided_at TIMESTAMP
);
CREATE INDEX oushodh_match_uuid ON oushodh_match (medicine_uuid);
Store the uuid to match records and show the id to people, as the IDs guide says. The table holds IDs only. The terms of use let you store medicine IDs with no time limit, but not the medicine records: no brand, price or generic copied from an answer. Your SKU, your price, your barcode and your stock count stay in your own tables, unchanged.
How do you find the candidates for one stock item?
Search its brand, then compare the answers with what your record says. Search matches the start of words in the brand, an alternate name, the generic and the manufacturer, but not the strength. So the strength, dosage form and maker are checked in your own code:
import os
import requests
API = "https://api.oushodh.dev/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['OUSHODH_API_KEY']}"}
def squash(s):
return "".join((s or "").lower().split())
def fits(item):
r = requests.get(f"{API}/medicines/search", headers=HEADERS,
params={"q": item["brand"], "limit": 50}, timeout=10)
r.raise_for_status()
return [m for m in r.json()["items"]
if squash(m["brand"]) == squash(item["brand"])
and squash(m["strength"]) == squash(item["strength"])
and squash(m["dosage_form"]) == squash(item["form"])
and squash((m["manufacturer"] or {}).get("name")).startswith(squash(item["maker"]))]
found = fits({"brand": "Napa", "strength": "500 mg", "form": "Tablet", "maker": "Beximco"})
status = "matched" if len(found) == 1 else "review" if found else "none"
squash drops spaces and case, so 500mg and 500 mg compare equal. Your records will have their own short forms, such as Tab for Tablet or Syp for Syrup. Keep a small table of yours and expand them before you compare.
A brand search can match more than 50 medicines. When total in the answer is larger than the list, add the first word of the maker, such as napa beximco: every word must match, so the list narrows to that maker.
When is a match safe to save without a person?
Only when exactly one medicine fits on brand, strength, dosage form and maker. Never take the first search result because it ranks first: rank says which name matched, not which medicine is on your shelf.
Maker names are the weak point. Oushodh spells each maker as the DGDA register does, and your records may not. A loose check on the first word can let two companies through, which is why How Oushodh matches one medicine across sources keeps such cases for a person too. When two medicines fit, that is the right outcome: the item goes to review.
What does the review queue look like?
A list of the items with status set to review, each with its candidate uuids. The reviewer’s screen gets each candidate with GET /v1/medicines/{ref} when it opens, and shows the product name, maker, pack size and picture beside your own record. The person picks one, or none.
Keep only the uuids on the queue, not the medicines. The terms do not allow storing API responses, and a candidate fetched when the screen opens is never out of date.
Items with status set to none need a person too. Some are not medicines at all. Some are spelled so differently that the brand search misses them: try the generic, or an alternate spelling, before you give up. Others may simply not be in the data yet, so search them again after the next import. Keeping your stock list current shows how to tell when that is.
What about pack sizes and DAR numbers?
An Oushodh medicine is one brand in one strength and dosage form. It is not a pack. So match every pack size of a medicine to the same uuid, and keep the pack in your own SKU. The size and unit fields, and the pack prices in prices, describe the packs the sources list, which may not be the ones you buy.
If your records carry DAR numbers, keep them, but do not plan to match on them. The API does not return a DAR number. dgda_listed says only whether a DGDA registration links to the medicine, and one medicine can hold more than one DAR number.
How many requests does the first match take?
One search for each stock item, plus one lookup for each candidate a person reviews. A key on the Developer plan makes up to 60 requests a minute, so for example 3,000 stock items take at least 50 minutes and use 3,000 of the month’s 50,000 requests. Run the first match at a quiet hour, and wait the seconds in Retry-After whenever the answer is a 429. The rate limits page has the numbers for every plan.
Match only the items you stock. Under the terms, paging through the whole list, or fetching far more medicines than your apps use, counts as collecting the data. Once the table is filled, the POS search guide covers new items added at the till. The pharmacy integration guide shows where the mapping and the key go in each kind of POS, including one that only imports and exports CSV.