For developers

Medication data for AI agents: how to code medications with ATC and store them in FHIR so a model can use them

How developers should choose a medication database for an AI agent: what ATC codes give you, what a bundled terminology subset covers and what it does not (no interactions), how MedicationStatement and MedicationAdministration are structured, and how an agent reads and proposes medications through Anpheros Platform.

by Published 4 min read

An AI agent that reads "Nolvadex 20 mg in the morning" needs to know that this is tamoxifen, an antiestrogen, ATC L02BA01, and that it is a daily oral dose, not a one-off. Where that knowledge comes from, and how the medication is stored so the next system reads it the same way, is the real question behind "which medication database should I use". This guide answers it for the Anpheros Platform and is honest about what the platform provides and what it does not.

Codes first: ATC

The WHO's Anatomical Therapeutic Chemical classification gives every active substance a code organised by what it acts on and what it does: C09AA02 is enalapril (C cardiovascular, C09 renin-angiotensin, C09AA ACE inhibitors). ATC is free, international and stable, which is why Anpheros codes every medication with it. The product name stays in code.text, so the person still sees "Nolvadex" and the agent sees L02BA01.

What ATC does not give you: dosage forms, package sizes, national product identifiers, prices, or interactions. Those are country-specific and often licensed. An agent that needs them needs a second source.

What the platform provides

  • A bundled ATC subset for lookup, enough for the medications people in Europe actually take, with display names, searchable at GET /v1/terminology/atc?q= and by code at GET /v1/terminology/atc/{code}. The same subset backs the MCP tool lookup_code. A code outside the subset may still be used on a resource; the lookup simply has no display for it.
  • A bundled LOINC subset for measurements and lab results, with the same endpoints under /v1/terminology/loinc.
  • FHIR resources with the right shape: MedicationStatement for the treatment plan (what the person takes, since when, how often), MedicationAdministration for each dose taken, linked to its statement, Immunization with ATC J07 vaccine codes, and AllergyIntolerance with ATC for drug allergies.

What the platform does not provide: a complete drug database, interaction checking, dose-range checking or clinical decision support. Those are deliberately outside, because they would make the platform a medical device. If your agent needs them, use a licensed service and keep the platform as the record.

How an agent reads medications

The context API returns active medications with their ATC code, text, dosing and provenance (who entered it: the patient, a practitioner, an import), within a token budget, so the model sees a clean list rather than a pile of resources. Over MCP the same is get_patient_context, and search_fhir with MedicationStatement?patient=…&status=active gives the raw resources.

curl "$BASE/v1/patients/$PID/medications?status=active" -H "Authorization: Bearer $TOKEN"

How an agent writes medications

It does not write; it proposes. A MedicationStatement sent by an application registered as an AI agent, under the person's consent, is validated and held as a proposal. The person sees "Assistant X wants to add tamoxifen 20 mg daily", accepts or rejects, and only an accepted proposal enters the record, marked as AI-written. The agent should send the ATC code when it is confident, and the product name in code.text always; a human-readable text with no code is still accepted and can be coded later.

Before sending, validate_fhir_resource (or POST /fhir/R4/MedicationStatement/$validate) tells the agent whether the resource is well-formed, so the person is never asked to approve something malformed.

Choosing a second source, if you need one

If the agent must answer "does this interact with that", pick a source by country (interaction data and product identifiers differ) and by licence (most are commercial). Keep the result as your own annotation, not as a resource in the person's record, unless a clinician confirms it. The record should carry what was taken; the advice layer is yours.

Frequently asked questions

Does Anpheros have a full drug database?

No. It has a bundled ATC subset for coding and lookup, and it stores medications as FHIR resources with ATC codes. Interactions, dose checks and national product catalogues are not included.

Why ATC rather than RxNorm or a national list?

ATC is international and free, which matters for a record that follows a person across borders. RxNorm is US-centric; national lists stop at the border. An application can add a second coding (for example a national product code) next to the ATC one on the same resource.

Can an agent add a medication to a person's record?

Only as a proposal the person approves. Nothing an AI agent sends is applied without that approval.

How does the agent know who entered a medication?

Every item in the context API carries author_type and a source, and every resource has a Provenance. A medication entered by a practitioner and one typed by the patient look different to the model, which is the point.

Is there a free way to try this?

Yes: the sandbox is free and its 30 synthetic patients have realistic ATC-coded medications. See Free FHIR server: the sandbox.

This guide is for information and does not replace medical advice. For decisions about your health, talk to your doctor. In an emergency, call 112.
About the author
Adrian Kereky

Founder of Anpheros. An electronics engineer, he spent six years in autonomous driving, on automotive projects run in partnership with Samsung and NVIDIA, designing the architecture of driver-assistance and AI systems that run on NVIDIA chips with CUDA. He then built Anpheros: the patient-controlled medical record and the HL7 FHIR R4 platform it runs on.

More about Anpheros and the author →

Keep your medical record with you

Anpheros Daily keeps symptoms, lab results, medications and documents in one place, in a standard format, under your control. The Basic plan is free.

Get Anpheros Daily