Objective
Coding a reporter's free-text verbatim ("sore aching muscles in my legs") to the right MedDRA Preferred Term is slow and coder-dependent, and keyword lookups break on paraphrase. This recipe ranks candidate PTs by meaning, so the coder gets a short, confident shortlist to confirm — consistent coding without hard-coding a synonym dictionary.
Step 1: A small MedDRA PT dictionary with embeddings
In production this table is your licensed MedDRA PT list; here we use a handful. Each PT name is
embedded once with EMBED().
DROP TABLE IF EXISTS meddra_pt;
CREATE TABLE meddra_pt (
pt_code TEXT,
pt_name TEXT,
emb VECTOR(384)
);
INSERT INTO meddra_pt VALUES
('10028411','Myalgia', EMBED('Myalgia')),
('10019211','Headache', EMBED('Headache')),
('10028813','Nausea', EMBED('Nausea')),
('10013573','Dizziness', EMBED('Dizziness')),
('10039020','Rhabdomyolysis', EMBED('Rhabdomyolysis'));
Step 2: Rank Preferred Terms for a verbatim
SELECT pt_code,
pt_name,
COSINE_SIMILARITY(emb, EMBED('sore aching muscles in my legs')) AS sim
FROM meddra_pt
ORDER BY sim DESC
LIMIT 3;
Result — Myalgia tops the shortlist for the leg-muscle verbatim:
| pt_code | pt_name | sim |
|---|---|---|
| 10028411 | Myalgia | 0.424 |
| 10019211 | Headache | 0.255 |
| 10028813 | Nausea | 0.249 |
Why it matters
The coder confirms the top suggestion instead of searching the dictionary — faster, and more consistent across coders. The absolute score matters less than the ranking: the correct PT is cleanly separated from the rest. Swap in your full PT list and the same query scales to the whole terminology.
Log the accepted code to a tamper-evident audit ledger so coding decisions are reconstructable at inspection.