feat(editor): cross-region vertebra picks spawn their spine zone
Picking vertebrae in a region tab other than the clicked zone now creates (or additively merges) the matching spine zone, so the SVG highlights it, it appears in the observation's selected zones, and its findings picker shows. Extract distributeVertebraeToZones + findSpineZoneId + regionFromLabel into src/lib/spineZones.ts (regionFromLabel re-exported from VertebraPicker for back-compat). Target region replaces (deselection sticks); other regions union (side-tab picks never wipe a pre-existing zone). Unmapped regions fall back to the target zone. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8e94196e5a
commit
9544924165
4 files changed
+220
-20
No files matched your search
@@ -6,6 +6,8 @@ import type { Vertebra, VertebralRegion } from '@/domain/schema/observation'
|
||||
import type { VertebralFormula } from '@/domain/species/types'
|
||||
import { useT } from '@/i18n/useT'
|
||||
|
||||
export { regionFromLabel } from '@/lib/spineZones'
|
||||
|
||||
const REGIONS: VertebralRegion[] = ['C', 'T', 'L', 'S', 'Cd']
|
||||
const REGION_KEY: Record<VertebralRegion, string> = {
|
||||
C: 'vertebra.region.C',
|
||||
@@ -15,24 +17,6 @@ const REGION_KEY: Record<VertebralRegion, string> = {
|
||||
Cd: 'vertebra.region.Cd',
|
||||
}
|
||||
|
||||
/**
|
||||
* Infers the matching vertebral region from a free-form anatomical label
|
||||
* (zone name in FR or EN). Matches on substring roots, case-insensitive,
|
||||
* accent-insensitive. Returns undefined when no root matches.
|
||||
*/
|
||||
export function regionFromLabel(label: string): VertebralRegion | undefined {
|
||||
const norm = label
|
||||
.normalize('NFD')
|
||||
.replace(/\p{Diacritic}/gu, '')
|
||||
.toLowerCase()
|
||||
if (norm.includes('cervic')) return 'C'
|
||||
if (norm.includes('thorac') || norm.includes('dors')) return 'T'
|
||||
if (norm.includes('lombair') || norm.includes('lumbar')) return 'L'
|
||||
if (norm.includes('sacral') || norm.includes('sacre')) return 'S'
|
||||
if (norm.includes('caudal') || norm.includes('coccyg')) return 'Cd'
|
||||
return undefined
|
||||
}
|
||||
|
||||
export interface VertebraPickerProps {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
|
||||
Reference in new issue
Block a user