When RxCUIs change: keeping stored medication codes current
An RxCUI is stable, but it isn’t permanent. Concepts get retired, remapped to another concept, merged or split, and the NDCs under them come and go. So store the code you were given next to the one it resolved to and the date, re-resolve on a schedule, and when a code is gone, show that in your app instead of swallowing the error.
NDC to RxCUI, and back explains why the RxCUI is the steadier of the two identifiers. Steadier doesn’t mean fixed. If you saved RxCUIs a year ago and never looked again, some of them may no longer be current, and some may have been merged or split since.
Why codes change
| What happens | What it looks like | What your stored code does |
|---|---|---|
| Retired | The concept is withdrawn, with nothing to point to | Stops resolving to a current drug |
| Remapped | The concept is replaced by one or more others | Stops being current; its meaning lives on under new codes |
| Merged | Two concepts turn out to be the same drug | One code keeps working; the other is remapped to it |
| Split | One concept turns out to cover more than one drug | Your code maps to several, and someone has to choose |
| Reformulated or relabeled | The product changes strength, form or labeler | The RxCUI may hold while the NDCs under it change |
The last row is the easy one to miss, because the RxCUI still looks fine. Packages are relisted often, and a product without an RxCUI of its own can gain one later.
What breaks
- Saved medication lists. A member’s entry resolves to nothing, and your app shows a blank row or drops it.
- Interaction and allergy checks. A check keyed on a dead code can silently find no ingredients, and so no problems. This one is dangerous because nothing looks wrong.
- Analytics joins. The same drug appears under an old and a new code, and adherence numbers split it in two or count it twice.
- Claims matching. An NDC on a claim no longer maps to the RxCUI on the member’s list, so the fill doesn’t match the prescription.
How to detect and migrate
Start by storing the source code. Whatever you were handed (an NDC from a barcode, an RxCUI from an EHR feed, a pick from your search) goes in its own column, next to what it resolved to and the date. The resolved code is derived and can be redone. The source code is evidence, and once it’s overwritten it’s gone.
Then re-resolve on a schedule. A nightly or weekly job that looks up every distinct stored code is cheap, because a medication list has far fewer distinct codes than rows. Compare each answer to what you stored and record a status: current, moved or gone.
When a code has moved, update the derived column and keep the old value. When one code splits into several, don’t pick for the member. Ask them, or flag it for a pharmacist.
Never delete a stored code because it stopped resolving. Show “no longer listed since…” with what it was, so support and audits can still explain the row.
Build or buy
Doing this in-house means reloading the concept files with every release, diffing against the last load, keeping a table of what moved where, and running a job that rewrites your stored codes. The NDC side can change daily on top of that. Then there are chains of moves, splits and codes that come back. Somebody owns it for as long as the product exists, and when it slips, the cost shows up as bugs nobody notices until a check misses something.
How Pillwise handles it
Store the Pillwise drug id you get from search or a lookup. It stays the same for as long as its drug is in the catalog, however the drug’s details change.
When the catalog retires an id, GET /v1/drugs/{id} answers 404 with superseded_by (the ids that answer for it now, best first, or empty when none does), last_version and last_seen. The successors are worked out from the codes it last carried against today’s catalog, so a chain of moves still lands on today’s drug. A split shows up as more than one successor.
Bare codes behave differently. GET /v1/drugs/rxcui/{rxcui} and GET /v1/drugs/ndc/{ndc} answer from the current catalog, so a code that is gone returns 404, and we don’t guess a replacement for it. That is why it pays to store the drug id alongside the code: the id carries the trail.
To catch up on what changed since you last looked, keep the graph_version from your last sync (every answer carries one) and call GET /v1/changes?since=<graph_version>. It lists the drug ids added, removed and changed since then, so you re-resolve only those. A since older than a year answers 410 gone_graph; re-resolve everything once and start again from the current version.
To see what a code meant on a past day, add ?as_of=YYYY-MM-DD to any lookup, up to a year back. Discontinued drugs and inactive NDCs covers the products that leave the market, and how search still finds them by the names people use.
If you keep member lists in Cabinet, each item already reports whether its drug is current, superseded or retired.
You can try medication search in your browser with no key, look up a code with the NDC lookup API, or get a sandbox key and run the codes you already store.