Files
faunosteo/.claude/tasks/TODO.md
T
Bastien ChanotandClaude a3afdcb763 chore(domain): drop equine findings JSON v1.1 + refactor plan
Adds the schema-v1.1 hierarchical findings JSON authored by the
domain expert at src/domain/species/equine/pathologies.json
(3-zone sample: sphenoid/ssb/atm — placeholder before full-body
authoring).

JSON is inert: not yet imported by the loader (still exports the
empty Pathology[]), so build and tests stay green.

TODO rewritten to sequence the V1 refactor:
- B0 findings schema + JSON loader with Zod parse at boot
- B1 ReportSchema v2 (observation.findings = path + snapshot)
- B2 FindingsTreePicker replacing flat PathologyPicker
- B3 i18n FR/EN site + PDF (locale store, dict, switcher)
- B4 PDF observationPage rendering findings
- B5 stub cleanup
- C  full horse.json authoring + QA + docs + deploy

Known fixup: JSON species.id is "horse" but registry uses
"equine"; align JSON to "equine" at integration time.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-19 07:44:10 +02:00

8.1 KiB

TODO — Osteo Report MVP

Status (2026-05-19): editor flow + PDF roundtrip working — V1 pivots toward hierarchical findings + i18n

Major scope decision: pathology model rewritten from flat Pathology[] to hierarchical findings tree per zone, with FR/EN bilingual content for site and PDF. Schema v1.1 JSON authored by domain expert is in place. Refactor required before MVP can ship.

All 100 tests green pre-refactor.


Phase A — DONE (kept for reference)

  • Scaffold (deps, configs, Docker, schemas, stubs)
  • Lib: id, dates, assert
  • Anatomy: parseSvgBones, loadSvg, svgToPng raster
  • Zustand store: full action set (initReport, hydrateReport, observation CRUD, conclusion/recommendations/nextAppointment setters, identity setters)
  • sessionStorage draft mirror + localStorage practitioner cache
  • UI primitives: Button, Card, Dialog, Input, Label, Select, Textarea, Badge, Chip
  • Canvas: AnatomyCanvas (data-state highlighting, async-mount safe), DetailModal
  • Observation chain: ObservationList, ObservationCard, PathologyPicker (flat — TO REPLACE), VertebraPicker, SeveritySelector, FreeTextPathologyInput
  • Report forms + edit-infos dialog + home nav
  • Routes: Home, NewReport, Editor (split layout + dialog), NotFound
  • PDF pipeline: fonts, header, observationPage (2-col SVG grid), conclusionPage, attachment.ts, export, import
  • Docker: Dockerfile, compose, entrypoint.sh runtime env, nginx SPA fallback
  • Brand identity via env (ConfigProvider)
  • Tests: 100/100 pass
  • Pathology JSON sample dropped at src/domain/species/equine/pathologies.json (schema v1.1, 3 zones: sphenoid/ssb/atm — placeholder before full-body)

Phase B — V1 REFACTOR (hierarchical findings + i18n)

B0. Domain model — Findings tree (BLOCKING — foundational)

Decision: replace flat Pathology[] with FindingsTree per zone, path-based serialization in observations. Bump ReportSchema.version 1 → 2. No retro-compat (no production PDFs).

  • Schema: src/domain/schema/findings.ts (new)
    • FindingNodeSchema: { id, name_fr, name_en, description_fr?, description_en?, requires_vet_referral?, sources?, children? }
    • ZoneSchema: { id, name_fr, name_en, categories: FindingNode[] }
    • SpeciesFindingsSchema: { schema_version, scope_disclaimer, species, zones: Record<string, Zone> }
    • Recursive Zod (z.lazy) for children
  • Loader: rewrite src/domain/species/equine/pathologies.ts
    • import data from './pathologies.json'
    • SpeciesFindingsSchema.parse(data) at boot → fail-fast on bad JSON
    • Export both default (parsed object) AND a backward-compat empty Pathology[] until callers migrated, then drop the legacy export
  • Species manifest (types.ts): replace pathologies: PathologiesLoader with findings: () => Promise<{ default: SpeciesFindings }>
  • Fix JSON: change species.id from "horse" → "equine" to match registry
  • Tests: tests/unit/species.equineFindings.test.ts
    • Parse succeeds with provided JSON
    • Every leaf has name_fr+name_en
    • scope_disclaimer non-empty
    • At least 1 zone with at least 1 category with at least 1 leaf
    • Delete old species.equinePathologies.test.ts

B1. Report schema v2 — observation findings

  • Schema: src/domain/schema/observation.ts
    • Replace pathologyIds: string[] + freeTextPathologies: string[] with:
      findings: Array<{
        zoneId: string
        path: string[]          // ['category','sub','leaf']
        labelFrSnapshot: string
        labelEnSnapshot: string
        requiresVetReferral?: boolean
      }>
      freeTextFindings: string[]
      
  • Schema: src/domain/schema/report.ts — bump version literal 1 → 2
  • Store: rewrite observation update helpers, drop pathology-specific actions
  • PDF import: hard-fail on v1 with friendly message (no v1 PDFs in prod)
  • Tests: schema tests for v2 shape

B2. UI — Findings tree picker (replaces PathologyPicker)

  • New component: src/components/observation/FindingsTreePicker.tsx
    • Receives zoneId, tree: Zone, selected: Finding[], onChange
    • Breadcrumb (Zone > Category > Sub > ...)
    • Click intermediate node → drill into children
    • Click leaf → toggle selection
    • "Back" button to climb breadcrumb
    • Show description_fr/en (selected via current locale) when present
    • ⚠️ icon badge when requires_vet_referral true
  • Disclaimer: show scope_disclaimer once per session (e.g. in editor or NewReport)
    • Track shown-this-session via sessionStorage flag
  • Migrate ObservationCard: replace PathologyPicker render with FindingsTreePicker
  • Delete: old PathologyPicker.tsx + its test + flat schema field cleanup
  • Tests: tree navigation, leaf selection, breadcrumb, vet-referral flag

B3. i18n FR/EN — site + PDF

  • Locale state: src/state/localeStore.ts Zustand: 'fr' | 'en', persisted in localStorage osteo:locale
  • i18n strings: src/i18n/{fr,en}.ts — UI strings dictionary
    • Migrate hardcoded French labels in components (buttons, headers, placeholders, toasts)
    • Helper hook useT() returning (key: string) => string
  • Language switcher: small FR/EN toggle in ReportHeader (next to Brand)
  • Findings rendering: components pick name_fr/name_en based on current locale
  • PDF render: exportReportToPdf(report, { locale }) parameter
    • All static PDF labels (eyebrow, section names) read from i18n dict
    • Findings rendered via labelFrSnapshot/labelEnSnapshot depending on locale at export
    • Date formatting locale-aware (formatDateFr → formatDate(date, locale))
  • Tests: locale switch updates labels; PDF roundtrip preserves locale snapshot

B4. PDF observationPage updates

  • Render findings instead of pathologyIds (list joined ·)
  • Show vet-referral icon next to flagged findings
  • scope_disclaimer footer on each obs page or first page only — decide
  • Update LRN-009-style layout still applies (text-area reservation)

B5. Stub cleanup

  • ZoneTooltip.tsx — delete (unused)
  • Toast.tsx — implement OR delete (decide: notifications for PDF export/import?)
  • ObservationEditor.tsx — remove reference from CLAUDE.md folder map

Phase C — V1 SHIP gate

  • Author full horse.json (replacing 3-zone placeholder with all corps SVG zones)
  • PDF QA manual pass: full flow → export → re-import roundtrip
    • Fonts embed, JSON attached, multi-SVG grid OK, locale FR + EN exports
  • Docker build + compose up smoke test
  • env-var brand identity verified
  • README finalize (install, dev, Docker, env vars, locale, MIT)
  • CHANGELOG v1.0.0 entry
  • docs/PATHOLOGIES-FORMAT.md — schema doc + authoring guide for adding species
  • Scaleway VPS deploy (TLS + CI build/push/deploy)

Phase D — POST-V1 (not in MVP scope)

  • Capacitor wrap (iOS + Android)
  • Accounts + cloud sync (Supabase or self-host)
  • Multi-praticien (move localStorage cache to server profile)
  • RDV booking + push reminders
  • Other species (dog, cat, cow, goat, pig, chicken JSONs)
  • Pathology DB community contributions

Memory cross-refs

  • BDR-001..BDR-008 — decisions registry
  • LRN-001..LRN-010 — learnings registry
  • BLK-001..BLK-004 — blockers (all resolved)

Apply when implementing B-phase:

  • LRN-004 (data-anno-special opaque to parser) — zone IDs in JSON must match SVG data-anno-id
  • LRN-009 (pre-rasterize → reserve → grid) — keep applied in PDF observationPage
  • LRN-010 (gate DOM-mutate on async-mount) — relevant for any new SVG-mutating effect

Estimated effort

Phase Hours
B0. Findings schema + loader + tests 3
B1. ReportSchema v2 + store + PDF import 3
B2. FindingsTreePicker + disclaimer + integration 6
B3. i18n FR/EN site + PDF 5
B4. PDF observationPage update 2
B5. Stub cleanup 0.5
C. Full horse.json authoring (user) external
C. QA + docs + deploy 4
Total dev ~23h