DocsValidators

atc_code validator

WHO ATC classification code, level 1 or level 5.

Resolver-backed

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)

Implementation

Faithful summary of lib/validators.ts. Validators are pure functions and run identically in the worker, the Workbench, and the MCP server.

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.

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.

fields:
  - column: atc_code
    type: string
    required: true
    validators:
      - type: atc_code

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.

Related templates

  • Drug formularydrug_formulary_v1

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

    Fields: atc_code

Pricing

Validators run on every committed row

Schema-only mode (headers + ≤3 sample rows) is free and unlimited; full-data commits are metered. See plans →