Skip to content

Add EUCAST breakpoint import tooling with rich text (superscript) handling #302

Description

@msberends

Summary

The current EUCAST breakpoint import pipeline does not handle Excel rich text cells correctly. EUCAST uses superscript footnote references appended to breakpoint values (e.g. 0.5 with superscript 1 appears as 0.51 when read naively by readxl or openxlsx2). This causes silent data corruption in clinical_breakpoints.

Proposed solution

An R-based import script using tidyxl::xlsx_cells(), which exposes run-level formatting via the character_formatted column. The script:

  1. Parses rich text cells by separating base values from superscript footnote references using the vertAlign attribute
  2. Auto-detects sheet structure generically across all organism sheets:
    • Header rows (via "MIC breakpoint" pattern in col B)
    • Single-organism vs multi-organism sheets (col A at header = class name vs "Antimicrobial agent")
    • Organism names discovered above each header row for multi-organism sheets
    • Data ranges between sub-headers
  3. Resolves EUCAST footnotes per row by matching superscript references to parsed note blocks in col I, including correct handling of combined keys (e.g. 1/A)
  4. Outputs the clinical_breakpoints structure with added columns: version, is_screening, note

Tested on

  • EUCAST v13.1 Breakpoint Tables (all 29 data sheets)
  • 921 rows extracted, cross-validated against manually curated anaerobe corrections
  • Correctly handles: screening breakpoints in parentheses, IE/IP/Note exclusions, combined note keys, disk dose formatting

New columns

Column Description
version Raw EUCAST version string (e.g. "13.1")
is_screening TRUE for parenthesised breakpoint values
note Resolved per-row footnote text with key references

Remaining work

  • mo and ab conversion via as.mo() / as.ab()
  • rank_index assignment based on taxonomic level
  • site parsing from antimicrobial name qualifiers (meningitis, UTI, etc.)
  • uti flag derivation from site
  • Validation suite / unit tests
  • Version comparison reporting (e.g. EUCAST 2025 vs 2026 diff)
  • Handle Topical agents sheet (different structure)

Context

Developed interactively in a Claude chat session with @msberends. A working prototype (parse_eucast_generic.R) exists and has been tested end-to-end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions