Healthcare AI evaluation · · 8 min read
AI in pharmacy compounding: how to evaluate calculations and beyond-use dating
Acumen Editorial · Updated November 27, 2026
Compounding is pharmacy with no margin for rounding. A pharmacist preparing a pediatric suspension, a hormone cream or a sterile IV bag converts units, scales a formula, picks a beyond-use date and documents it all. One misplaced decimal is a tenfold error. One wrong date sends a contaminated preparation to a patient. The 2012 fungal meningitis outbreak traced to a compounding pharmacy is why this work is now so tightly regulated.
That is exactly why AI is attractive here. The math is repetitive and the rules are long. It is also why a tool that is "usually right" is not good enough.
Where is AI showing up in compounding?
We see four uses.
- Formula and calculation checks. Verifying ingredient quantities, concentration conversions, dilutions and percent strength.
- Beyond-use date assignment. Recommending a date based on the USP category, starting components, sterility testing and storage.
- Compliance review. Checking master formulation and compounding records against USP 795 for nonsterile and USP 797 for sterile preparations.
- Question answering. Language models that answer staff questions on stability, compatibility and procedure.
Compliance software already tracks much of this. Wolters Kluwer added an advanced compounding module to its Simplifi 797 product in December 2025 to manage batch data, beyond-use dating and environmental monitoring records. The new step is AI that recommends the answer, not just stores it.
Why are beyond-use dates a good test of compounding AI?
Because the rules are exact and layered. Under the 2023 revision of USP 797, as summarized by Wolters Kluwer, the default dates depend on category, process, testing and storage.
| USP 797 category | Example condition | Default beyond-use date (room temp / refrigerated / frozen) |
|---|---|---|
| Immediate use | Prepared outside a controlled environment | 4 hours |
| Category 1 | ISO 5 hood in a segregated compounding area | 12 hours / 24 hours |
| Category 2 | Aseptic, nonsterile starting components, no sterility test | 1 / 4 / 45 days |
| Category 2 | Aseptic, sterility tested and passed | 30 / 45 / 60 days |
| Category 3 | Aseptic, all applicable tests passed | 60 / 90 / 120 days |
A model has to identify the category from the facts of the case, read whether sterility testing was done, apply storage, and then check whether the drug's own stability data shortens the date further. Each step is a place to fail. A model that knows the table but misreads the starting components still gives a wrong date with full confidence.
How accurate are language models on pharmacy questions?
Better than they were, and still uneven. In the DrugRAG study posted to arXiv in December 2025, ten language models scored between 46% and 92% on 141 licensure-style pharmacy questions. Adding retrieval of drug references raised accuracy by 7 to 21 percentage points across five models. Two lessons follow. Model choice matters a great deal, and retrieval helps but does not close the gap. Compounding questions add arithmetic on top of drug knowledge, so test them directly. Our guide to pharmacist-led AI evaluation covers the wider method.
How do you build a compounding AI evaluation?
Use this checklist.
- Write cases from real records. De-identified master formulation records and compounding records, nonsterile and sterile, covering the preparations you actually make.
- Plant errors. Add a decimal shift, a mg-to-mcg mix-up, a wrong base volume, a missing sterility test and a mislabeled storage condition. The tool should catch every one.
- Require exact answers. Score quantities and dates as right or wrong. Close is wrong.
- Check the reasoning. The tool should name the USP category, the conditions it used and the source for any stability limit. A right date for the wrong reason fails.
- Include edge cases. Pediatric and neonatal doses, hazardous drugs, preparations with limited stability data and products with no commercial equivalent.
- Grade with compounding pharmacists. Two graders per case, a third to adjudicate. Sterile cases need pharmacists with cleanroom experience.
- Re-test after every update. Re-run the held-out set whenever the model, its reference sources or USP chapters change.
Dose math overlaps with our guide to AI dose verification. For the wider workflow, including sterile IV preparation in hospitals, see how to evaluate AI in hospital pharmacy.
What failure modes should graders tag?
Tell graders to label each error by type, so the results show why the tool fails.
- Unit errors. Wrong conversion between mg, mcg, mEq or percent strength.
- Category errors. Treating a Category 2 preparation as Category 3, or missing that starting components were nonsterile.
- Stability overreach. Assigning the USP default when the drug's own data supports a shorter date.
- Invented references. Citing a stability study or USP section that does not exist.
- Silent assumptions. Filling in a missing storage condition or volume instead of asking.
A tool that asks a clarifying question when a record is incomplete is doing its job. A tool that guesses is not.
What should a compounding AI pilot look like?
Start in shadow mode. The tool checks every record, but pharmacists work exactly as they do today and never see its output while they decide. After a set period, compare the tool's flags against what pharmacist verification caught and what it missed. This gives you real-world sensitivity without putting a patient at risk.
Then move to assist mode on a narrow scope, such as nonsterile oral preparations with well-documented stability. Keep sterile and hazardous drug work out of scope until the tool has passed the held-out test set and the shadow period. Track three numbers throughout: errors caught that pharmacists missed, false alarms per hundred records and errors the tool missed that pharmacists caught. The last number decides whether the scope can grow.
Write the stop rules before the pilot starts. One missed tenfold error should pause the pilot and send the case back into the test set.
How do you compare compounding AI vendors?
Ask each vendor the same questions and compare the answers in one table, the way our expert data provider comparison lays out sourcing and review. Which USP chapter versions does the tool follow? How does it handle stability data that conflicts with the default date? Who reviewed its reference answers, and what were their credentials? How does it signal uncertainty? How fast does it update when USP or state boards change requirements?
How Acumen helps
We build compounding evaluation sets with credentialed pharmacists. Compounding and sterile preparation specialists write cases, plant errors, grade calculations and beyond-use dates, adjudicate disagreements and document the rationale behind every reference answer. You get held-out test sets with exact expected answers and reviewer agreement on every item. See our medical model evaluation service for how we run it.
For more on medication AI, read our guides to evaluating AI prescribing and building a golden dataset for medical AI.
FAQ
What is AI in pharmacy compounding?
AI in pharmacy compounding is software that supports the preparation of custom medications. It checks formulas, calculates ingredient quantities and dilutions, recommends beyond-use dates, reviews records against USP 795 and USP 797 and answers staff questions. A licensed pharmacist should verify every calculation and date before a preparation is dispensed.
Can AI calculate beyond-use dates correctly?
It can when it identifies the right USP category and conditions, but that is where errors happen. Under USP 797, dates depend on category, starting components, sterility testing and storage, and drug stability data can shorten them. Test the tool on cases with planted category and storage errors and require it to show its reasoning.
How accurate are large language models on pharmacy questions?
Accuracy varies widely by model. In the DrugRAG study posted to arXiv in December 2025, ten language models scored between 46% and 92% on 141 licensure-style pharmacy questions, and adding drug reference retrieval raised five models by 7 to 21 percentage points. Compounding calculations should be tested separately from knowledge questions.
Is AI safe for sterile compounding?
It can support sterile compounding inside a tested scope, with a pharmacist verifying every output. Sterile preparations carry contamination risk, so dating and category errors are serious. Evaluate the tool on cases with planted errors, graded by pharmacists with cleanroom experience, and re-test whenever the model, its references or USP requirements change.
Who should grade compounding AI outputs?
Compounding pharmacists should grade nonsterile cases, and pharmacists with sterile preparation and cleanroom experience should grade sterile cases. Use two graders per case and a third to adjudicate disagreements. Score quantities and dates as exact matches, and record the rationale so every reference answer can be defended in an inspection or audit.
What errors should a compounding AI test include?
Include decimal shifts, unit conversion mistakes such as mg versus mcg, wrong base volumes, missing sterility tests, wrong USP categories and storage conditions that change the beyond-use date. Add incomplete records to see whether the tool asks a question or guesses. A good tool flags every planted error and never invents a reference.