One report's journey
This site ranks drug → reaction pairs that are reported together more than expected
Doctors, patients, and drug companies send the FDA reports of side effects they think a drug caused. PharmaWatch reads every report filed since 2004 and asks one question per drug → reaction pair: does this reaction show up with this drug more often than it shows up with every other drug?
When the answer is a clear yes, that pair is a signal.
A signal is a hypothesis, not a finding. It says "look here," not "this drug causes this." Reports aren't verified, and nobody reports the times a drug worked fine.
Example pair (drug → reaction): hydrocodone/acetaminophen (Vicodin, Norco) → dependence. The combination of hydrocodone and acetaminophen is the main suspect in 40,443 cases. If dependence were unrelated to it, we would expect only about 108 of those cases to report that reaction. Instead, 20,775 do. See this pair's signal page →
AEMS is the FDA's inbox for side-effect reports
AEMS (FDA Adverse Event Monitoring System, formerly FAERS) is the system behind the FDA's post-market drug safety work. Once a drug is approved and sold, this is how the FDA hears about problems clinical trials missed.
Every report contains who saw the event and who reported it to the FDA.
Who saw it (occp_cod)
| Consumer / patient | 43.8% |
|---|---|
| Other health professional / pharmacist | 24.9% |
| Physician | 21.9% |
| Unknown | 6.8% |
| Lawyer | 2.6% |
Who sent it (rept_cod)
- Drug manufacturers: 94.6%. Companies are legally required to forward any adverse event they hear about.
- Direct to FDA: 5.3%. Someone filled out the voluntary MedWatch form available online.
Three limits that affect how trustworthy these statistics are
- Not verified. A report says someone suspected the drug.
- No denominator. AEMS doesn't know how many people took the drug, so you can't compute a rate. You can only compare a drug's reports against everyone else's reports.
- Reporting is uneven. News, recalls, and lawsuits cause reporting spikes.
To lower the risk of a false signal, PharmaWatch scores only the primary-suspect (PS) drugs of every case.
Below shows a real example of case 18957553, a 36-year-old man in the US, reported March of 2021.
| primaryid | caseid | caseversion | occp_cod | rept_cod | mfr_sndr |
|---|---|---|---|---|---|
| 189575531 | 18957553 | 1 | CN | PER | ALLERGAN |
| primaryid | drug_seq | role_cod | drugname | prod_ai |
|---|---|---|---|---|
| 189575531 | 1 | PS | NORCO | ACETAMINOPHEN\HYDROCODONE BITARTRATE |
| 189575531 | 2 | SS | CONTINE (THEOPHYLLINE) | THEOPHYLLINE |
| 189575531 | 3 | SS | OXYCODONE | OXYCODONE |
| primaryid | reaction_pt |
|---|---|
| 189575531 | SUBSTANCE USE DISORDER |
| 189575531 | OVERDOSE |
| 189575531 | DRUG DEPENDENCE |
| primaryid | outc_cod |
|---|---|
| 189575531 | OT (other serious) |
- One case ≠ one drug ≠ one reaction. This case has 3 drugs and 3 reactions, but only the primary suspect (PS) is scored, so it feeds 3 pairs: Norco × each reaction.
drugnameis free text.prod_aiis the FDA's active-ingredient field. Turning these into one drug identity helps normalize many different drug brands carrying the same active ingredient.- A consumer saw it (
occp_codCN), and the company Allergan sent in the report.
FDA publishes AEMS as quarterly ZIP files
There's no AEMS database you can connect to. The public ways in are the FDA's AEMS dashboard, the openFDA API, and the FDA's quarterly ZIP files, which is what this site uses.
Each ZIP holds 7 $-delimited text tables, linked by primaryid: the four shown before (DEMO, DRUG, REAC, OUTC) plus RPSR (report source), THER (therapy dates), and INDI (why the drug was taken).
The example case shown before as it looks in the raw DRUG file (trimmed to the columns that matter):
primaryid$drug_seq$role_cod$drugname$prod_ai 189575531$1$PS$NORCO$ACETAMINOPHEN\HYDROCODONE BITARTRATE 189575531$2$SS$CONTINE (THEOPHYLLINE)$THEOPHYLLINE 189575531$3$SS$OXYCODONE$OXYCODONE
How PharmaWatch ingests the data
- Downloaded all 90 quarters (2004Q1–2026Q2) from
fis.fda.govwithdownload.py. At most one quarter's ZIP sits on disk at a time. - Parsed to Parquet with the raw column names unchanged (
parse.py), then wrote it once to Cloudflare R2. Raw data is never modified; every fix happens downstream. - Mapped 22 years of schema changes to one column set (
schema.py), verified against real downloaded quarters, not FDA docs alone:- 2012Q4:
ISR/CASE/FOLL_SEQ→primaryid/caseid/caseversion, filenames go fromaers_tofaers_, and columns go lowercase. - 2014Q3:
GNDR_COD→sex, andprod_aiis added. This means that, in order to use a drug's active ingredient as its identity, older reports without aprod_aicolumn will have to be joined against newer reports containing the same drug + itsprod_ai.
- 2012Q4:
DRUG11Q2.TXT line 322,967 25 fields, 12-column header
drugname: "VITAMINS" (NOS)
" as the start of a quoted field. AEMS never escapes quotes, so quoting is turned off.Why the quarterly files, not openFDA. openFDA is trustworthy, but its cleaning is a black box. Starting from the FDA's own release means every step a report goes through is documented and deterministic. The full pipeline can be walked through from start to finish.
One case arrives many times
A case isn't filed once. When a manufacturer learns more, it sends a follow-up, which arrives as a new copy of the case, often in a later quarter.
| primaryid | caseid | caseversion | init_fda_dt | fda_dt |
|---|---|---|---|---|
| 100033073 | 10003307 | 3 | 2014-03-12 | 2015-08-12 |
primaryid = caseid + version digit. This case was first reported in March 2014 (init_fda_dt), and version 3 arrived 17 months later (fda_dt). Counting raw rows would count the same cases multiple times, inflating every pair they appear in.
The FDA also retracts cases (duplicates, reports filed in error) and, since 2019Q1, publishes a deleted-case list in each ZIP.
How PharmaWatch handles multiple case versions
- Retracted cases removed per quarter in
clean.py, before merge and dedup. Retractions reach back 15+ years. - Latest version wins (
dedup.py). Percaseid, keep the row with the highestcaseversion. This runs across all 90 quarters at once, since a follow-up often lands in a different quarter than its original. - Ties broken deterministically. Some cases have multiple rows at their latest version. The winner is decided deterministically in this order: most child rows (drugs + reactions + outcomes …) → most non-null DEMO fields → lowest
primaryid. Same input, same winner, every run. - Child tables filtered to the surviving
primaryids, with exact duplicate rows dropped: 100.5M drug rows → 75.1M.
| Merged reports (after retractions) | 24,680,706 |
|---|---|
| Rows at their case's latest version | 21,503,562 |
| … cases with one row: kept | 19,992,545 |
| … rows across 595,952 tied cases: 1 winner each | 1,511,017 |
| … one primaryid won for two cases: fullest DEMO row wins | −1,842 |
| Final cases | 20,586,655 |
Engineering note: each step is a DuckDB temp table, not one long CTE chain. Each step is materialized and row-counted in the log. Minutes instead of hours on this volume.
Vicodin, Norco, and "HYDROCODONE + APAP" are one drug
To score a drug, you first need to know which reports include it. The drugname column of the DRUG table doesn't help much; it's a free-text field, and can get messy fast. PharmaWatch uses multiple steps to normalize drug names, increasing signal detection. The running example is a Norco row reported as NORCO (UNKNOWN) (WATSON LABORATORIES).
| Step | Term | What it is | Example |
|---|---|---|---|
| 1 | Reported name (drugname) | Whatever the reporter typed: brand, generic, misspelling, manufacturer, dose. | NORCO (UNKNOWN) (WATSON LABORATORIES) |
| 2 | Cleaned name (drugname_clean) | The reported name with the noise stripped: parentheticals, trailing dose form ("TABLETS"), trailing strength ("10 MG"). Kept beside the original. | NORCO |
| 3 | Active ingredient (prod_ai) | The chemicals that do the medical work, as opposed to the brand or the filler. Norco, Vicodin, and generic "hydrocodone/APAP" contain the same two. The FDA fills this field itself; \ separates ingredients. | ACETAMINOPHEN\HYDROCODONE BITARTRATE |
| 4 | RxNorm / rxcui | RxNorm is the National Library of Medicine's standard drug dictionary. Every concept gets one ID, an rxcui. Salt forms point to their base ingredient: hydrocodone bitartrate → hydrocodone. | ACETAMINOPHEN → 161HYDROCODONE BITARTRATE → 5489 |
| 5 | identity_key | The drug, as this site defines it: the sorted set of its ingredients' rxcuis. | rxcui:161|rxcui:5489 |
This particular row has an empty prod_ai, so step 3 comes from the lookup described below: the FDA gave NORCO that ingredient string on 100% of the 57,176 rows where it did fill the field.
Why a set, not one ID
- Combos are their own drug. Hydrocodone/APAP (
161|5489) is not acetaminophen (161), and its signals differ. - Order doesn't matter.
HYDROCODONE\ACETAMINOPHENandACETAMINOPHEN\HYDROCODONEare the same set once sorted.
Two routes into step 3, depending on era
- 2014Q3 onward: the FDA fills
prod_ai, which goes straight to RxNorm. - Before 2014Q3:
prod_aidoesn't exist, which leaves 4.4M primary-suspect rows with only a name. For every cleaned name, PharmaWatch uses a lookup function. This function finds whichprod_aithe FDA gave this name in the rows where it was filled. If oneprod_aicovers ≥ 95% of those rows, it's joined with every pre-2014Q3 row that contains that cleansed drug name. So a 2008VICODINinherits the ingredients the FDA gaveVICODINlater.
In the data, hydrocodone/acetaminophen arrives under 390 reported spellings (Vicodin, Norco, "HYDROCODONE + APAP", …) and collapses to one identity: 40,443 primary-suspect cases, 150 signals. See the drug page →
Real drugname normalization examples used in PharmaWatch
TOZINAMERAN (Pfizer) 49,278 rows ELASOMERAN (Moderna) 30,859 rows → one RxNorm ingredient
prod_ai: "AZITHROMYCIN OR METHOTREXATE SODIUM" 81 strings, 9,638 rows
ETIZOLAM 9,613 rows → local:ETIZOLAM
local: identity instead of being dropped. 161 drugs with a local: piece carry 1,990 signals between them.Match rate. 97.8% of the 20.9M primary-suspect drug rows resolve fully to RxNorm. Counted by distinct drug instead of by row, the rate is much lower: 8,440 of 11,954 drugs (70.6%) are all-RxNorm. The other 3,514 are a long tail of rare names, averaging to only ~8 reports each.
PharmaWatch's drugname normalization techniques are not perfect. For example, salt forms are lost in RxNorm matching. PharmaWatch also uses normalized-string matching in the RxNorm search, which has a small chance to falsely combine similarly-named drugs.
Signal = observed vs expected, discounted for small counts
AEMS has no denominator, so it's impossible to know what percentage of people on a certain drug get a certain reaction. The question instead is disproportionality: is this reaction a bigger share of this drug's reports than of every other drug?
As an example, 0.27% of all cases report dependence. 51.4% of hydrocodone/APAP cases do. This creates a massive signal for this pair.
Step 1: the 2×2. For one drug → reaction pair, every case lands in one of four boxes.
| dependence | other reactions | total | |
|---|---|---|---|
| hydrocodone/APAP | a20,775 | b19,668 | 40,443 |
| every other drug | c34,035 | d20,510,241 | |
| total | 54,810 | N20,584,719 |
N counts cases with a primary-suspect drug and at least one reaction: 1,936 fewer than chapter 3's 20,586,655 final cases.
Step 2: three quantities.
-
Expected cases if no signalE = (a+b)(a+c) / N = 40,443 × 54,810 / 20,584,719 = 107.7
-
IC (Information Component): observed vs expected, in doublingsIC = log₂((a+0.5) / (E+0.5)) = log₂(20,775.5 / 108.2) = 7.585
-
IC025: the pessimistic IC, bottom of the 95% credibility intervalIC025 = IC − 3.3(a+0.5)−1/2 − 2(a+0.5)−3/2 = 7.585 − 0.023 = 7.562
- Expected is the drug's cases × the share of all cases that report this reaction: 40,443 × 0.27%. If hydrocodone had nothing to do with dependence, about 108 of its cases would report it anyway, from the background rate alone. 20,775 do.
- log₂ turns the ratio into doublings. IC 0 = exactly as expected, 1 = 2×, 3 = 8×, 7.6 ≈ 190×. Negative = less often than expected.
- +0.5 is the shrinkage: half a case added to both sides. With huge counts it changes nothing. With tiny counts it drags the ratio toward 1.
- IC025 subtracts an uncertainty penalty that shrinks like 1/√cases, the way a standard error does. It answers "even in the worst plausible case, how far above expected is this?" IC025 > 0 = signal.
The penalty, by case count
Max IC is the IC a pair would get if its expected count were zero: log₂((a+0.5) / 0.5) = log₂(2a+1). It's the ceiling for that many cases. If the ceiling minus the penalty is still ≤ 0, that case count can never be a signal.
| Cases (a) | Max IC, log₂(2a+1) | Penalty | Best possible IC025 (max IC − penalty) | |
|---|---|---|---|---|
| 1 | 1.58 | 3.78 | −2.20 | never a signal |
| 2 | 2.32 | 2.59 | −0.27 | never a signal |
| 3 | 2.81 | 2.07 | 0.74 | smallest count that can be a signal. Hylan G-F 20 (below) hits this ceiling. |
| 30 | 5.93 | 0.61 | 5.32 | |
| 300 | 9.23 | 0.19 | 9.04 |
Where the formula comes from. This is the shrinkage IC that the WHO Uppsala Monitoring Centre uses on VigiBase, the global equivalent of AEMS. The closed-form IC025 is from Norén, Hopstadius & Bate (2013), and the IC itself from Bate et al. (1998).
Why rank by IC025, not PRR
PRR (proportional reporting ratio) is the classic measure: PRR = (a/(a+b)) / (c/(c+d)), this drug's reaction share ÷ everyone else's. It has no shrinkage, so tiny counts explode it.
| Pair | Cases | PRR | IC025 |
|---|---|---|---|
| Hylan G-F 20 → injection site joint effusion | 3 | 1,715,392 | 0.74 |
| Hydrocodone/APAP → dependence | 20,775 | 310 | 7.56 |
Ranked by PRR, a 3-case pair beats one of the best-known signals in AEMS by 5,500×. Ranked by IC025, they're in the right order. Hylan's 0.74 is the penalty table at work: max IC 2.81 − penalty 2.07.
Of the 2,849,232 pairs scored by PharmaWatch, 426,239 (15.0%) have an IC025 > 0.
How PharmaWatch calculates IC025
- One SQL model for the 2×2 (
int_contingency): count distinct cases per pair, per drug, per reaction, and overall, then derive b, c, and d by subtraction. Computed twice in the same pass, with and without lawyer reports. - Scores in SQL (
srv_signals): E, IC, and IC025 are plain column expressions. No fitted model, so the scores are deterministic.
Lawyers can inflate counts, so reports are flagged, not dropped
Since anyone can report claims and manufacturers must forward what they hear, lawyers can submit thousands of claims to manufacturers that must be submitted to AEMS. In a mass lawsuit, these claims can inflate signal. Fortunately, these claims are typically filed with reporter occupation LW (lawyer).
These reports are usually real people who took the drug and had the reaction. The problem is stimulated reporting: the count reflects whoever was recruited into the lawsuit, not how often the reaction happens. Signal detection assumes reporting is roughly even over time and across drugs, and a lawsuit breaks that assumption.
Small overall, concentrated where it lands. Lawyer-reported cases number 540,155, only 2.6% of the 20.6M, but they were 11.1% of cases first received in 2021. The drug ranitidine alone makes up 34.9% of all lawyer-reported cases, with oxycodone at 12.8%, and ranitidine plus opioids make up ~90% of 2021–22 LW cases.
Example: ranitidine (Zantac). On September 13, 2019 the FDA announced it had found NDMA, a probable human carcinogen, in ranitidine. The federal cancer litigation was consolidated as MDL 2924 on February 6, 2020, and on April 1, 2020 the FDA asked for all ranitidine products to be pulled from the market. The reports followed.
Ranitidine hydrochloride → prostate cancer, cases per quarter
Other reporters Lawyer-reported
How PharmaWatch handles lawyer-inflated reports
Flag, don't drop. Dropping LW cases would throw away real reports. Instead, every pair is scored twice in the same pass (chapter 5's int_contingency), and three columns travel with every signal:
| Column | Meaning |
|---|---|
pct_lw | share of this pair's cases that are lawyer-reported |
peak_quarter_share | share of its cases that landed in its single busiest quarter: a burst detector that doesn't depend on the LW code |
ic025_nolw | IC025 recomputed as if LW reports didn't exist |
Three pairs, two outcomes
| Pair | Cases | % LW | Peak quarter | IC025 → without LW | Reading |
|---|---|---|---|---|---|
| ranitidine hydrochloride → prostate cancer | 60,356 | 49% | 2021 Q3 (31.2%) | 5.22 → 5.75 | Holds up. Even stronger without lawyers. |
| ranitidine hydrochloride → incorrect dose administered | 9,372 | 80% | 2022 Q1 (46.0%) | 1.04 → −0.43 | Vanishes. A litigation artifact. |
| docetaxel → hair disorder | 5,645 | 99.9% | 2018 Q2 (18.5%) | 8.07 → −1.89 | Vanishes. Almost entirely litigation. Caused by the Taxotere permanent hair-loss suits, consolidated as MDL 2740 in October 2016. |
How many signals depend on lawyers: 1,934 of 426,239 (0.45%). A signal counts as lawyer-dependent only if all three hold: IC025 > 0 with LW reports, IC025 ≤ 0 without them, and at least 50% of its cases are LW.
The limit of voluntary reporting. The LW code only catches lawyers who file as lawyers. For ranitidine → prostate cancer, 30,915 of the 60,356 cases are not LW, yet the burst is obvious in the chart above.
Every number on a signal page traces back to the methods shown above
The site has three levels:
Search, by active ingredient → drug page, one row per reaction → signal page, one drug → reaction pair.
Reading tip: the drug page is ranked by IC025 (top 50). Glance down the Lawyer-reported column; if you see a high IC025 with a high lawyer share, open the signal page before believing it.
The signal page adds the IC itself, IC025 without lawyer reports, the cases-per-quarter chart (lawyer vs other, as in chapter 6), and a short "Before drawing conclusions" list.
Under the hood
- Serving layer: 3 tables copied out of the 10.9 GB warehouse into a 0.38 GB DuckDB file on a Hetzner server, opened read-only behind FastAPI + Jinja templates. No database server to run.
- Power BI: the same serving tables, exported as Parquet, feed a Power BI report as a side branch.
Serving schema (not every column shown). Joined on identity_key, the RxNorm ingredient set from chapter 4.
erDiagram
srv_drug ||--o{ srv_signals : "identity_key"
srv_signals ||--|{ srv_pair_quarters : "identity_key, reaction_pt"
srv_drug {
varchar drug_key PK "surrogate"
varchar identity_key UK "sorted RxNorm ingredients"
varchar drug_label "most-reported ingredient string"
bigint n_signals "pairs with ic025 > 0"
}
srv_signals {
varchar identity_key PK, FK
varchar reaction_pt PK "MedDRA term"
bigint a "2x2 counts a, b, c, d"
double ic025 "rank score"
double ic025_nolw "without lawyer reports"
double pct_lw "lawyer-reported share"
date peak_quarter
}
srv_pair_quarters {
varchar identity_key PK, FK
varchar reaction_pt PK, FK
date report_quarter PK
bigint n_cases
bigint n_cases_nolw
}
Stack & stats
Stack: Python + DuckDB ingest → Parquet on R2 → dbt → DuckDB file → FastAPI on Hetzner.