Docs · Validators

atc_code validator

WHO ATC classification code, level 1 or level 5.

Resolver-backed — free text that fails the format check is looked up before it is rejected · One of 19 validator types · pure compute, no AI cost

Reference

Format

Matches `/^[A-Z]\d{2}([A-Z]{2}\d{2})?$/` after uppercasing. Either level 1 (e.g. `C09`, 3 chars) or full level 5 (e.g. `C09AA05`, 7 chars). Levels 2, 3, 4 are NOT accepted.

Examples

  • C09AA05 (Enalapril)
  • A10BA02 (Metformin)
  • N02 (Analgesics, level 1)

How it runs

Implementation

A faithful summary of lib/validators.ts. Validators are pure functions and run identically in the Worker, the Workbench and the MCP server — one implementation, so the three cannot disagree about whether a value is valid.

lib/validators.ts
function validAtc(value) {
  return /^[A-Z]\d{2}([A-Z]{2}\d{2})?$/.test(value.toUpperCase())
    ? OK
    : fail('atc_format', 'expected ATC pattern')
}
// Plus the resolver wrapper.

Config

Use in a template

Validators attach to a field on a custom template. The cascade runs them after mapping but before commit; failures surface in the per-row validation report.

template.yaml
fields:
  - column: atc_code
    type: string
    required: true
    validators:
      - type: atc_code

Watch out

Common gotchas

  • Only ATC levels 1 and 5 are accepted by the regex. Level 2 (`C09A`), level 3 (`C09AA`), level 4 (`C09AA`) all fail. If you receive intermediate levels, normalise upstream.
  • No ATC validity table — `Z99ZZ99` matches the pattern. WHO does not publish a closed-form check.
  • Case-insensitive: `c09aa05` is uppercased before matching.

Where it runs

Three routes, no AI cost.

  • POST/v1/validate-rowValidate one row against a template. Stateless, no key, pure compute — the fastest way to try atc_code against a real value.no key
  • POST/v1/uploads/:id/validateRun every field validator over the parsed upload, without committing. Returns errors and warnings per row.read
  • POST/v1/uploads/:id/commitValidates on the way out. skip_invalid_rows drops the failures instead of failing the commit.commit

Validators are pure functions, so they add nothing to the AI bill. Every map draws a small flat per-map fee from your prepaid token wallet ($10 minimum, shared across the phi-cloud suite); only columns that reach the metered LLM layer, plus any-to-any convert and structural reshape, bill real AI tokens. See pricing

Catalogue

Related templates

  • Drug formularydrug_formulary_v1

    ATC/GTIN-coded drug catalog. Emits FHIR Medication.

    Fields · atc_code

  • One line-of-therapy / pathway recommendation from a clinical guideline (NCCN/ESMO/NICE/ASCO). Maps to drug-database.clinical_guidelines.

    Fields · atc_code

  • One HTA body's cost-effectiveness decision for a drug×indication, with ICER/QALY economics. Maps to drug-database.hta_assessments.

    Fields · atc_code

Explore

All 19 validator types

The complete list a template field can declare. There is no SNOMED validator — it required an affiliate licence, no template used it, and it was removed in 2026.

Ready when you are

Validate every row — before it lands.

Attach checksum-strict validators to any field, and gate risky commits behind the requires_hitl flag. One key runs the whole cascade.

Prepaid token wallet · schema-only data-minimization mode · no free tier