diff --git a/src/components/observation/ObservationEditor.tsx b/src/components/observation/ObservationEditor.tsx index c3024ecb..b22c4a37 100644 --- a/src/components/observation/ObservationEditor.tsx +++ b/src/components/observation/ObservationEditor.tsx @@ -1,3 +1,126 @@ -export default function ObservationEditor() { - return
ObservationEditor placeholder
+import { useMemo } from 'react' +import type { Observation, ObservationZone, Vertebra } from '@/domain/schema/observation' +import type { Pathology } from '@/domain/schema/pathology' +import type { Bone } from '@/anatomy/types' +import Label from '@/components/ui/Label' +import Textarea from '@/components/ui/Textarea' +import Badge from '@/components/ui/Badge' +import PathologyPicker from './PathologyPicker' +import FreeTextPathologyInput from './FreeTextPathologyInput' +import SeveritySelector from './SeveritySelector' + +export interface ObservationEditorProps { + observation: Observation + bones: Map + speciesId: string + pathologyPool: Pathology[] + onChange: (next: Observation) => void + onOpenVertebraPicker: (zoneIndex: number) => void + onRemoveZone: (zoneIndex: number) => void +} + +function describeZone(z: ObservationZone, bones: Map): string { + const b = bones.get(z.boneId) + const label = b?.fr ?? z.boneId + if (z.vertebrae?.length) { + const vs = z.vertebrae.map((v: Vertebra) => `${v.region}${v.index}`).join(', ') + return `${label} (${vs})` + } + return label +} + +export default function ObservationEditor({ + observation, + bones, + speciesId, + pathologyPool, + onChange, + onOpenVertebraPicker, + onRemoveZone, +}: ObservationEditorProps) { + const zoneBoneIds = useMemo( + () => observation.zones.map((z) => z.boneId), + [observation.zones], + ) + + return ( +
+
+ + {observation.zones.length === 0 ? ( +

+ Cliquez sur les zones du schéma pour les ajouter à cette observation. +

+ ) : ( +
    + {observation.zones.map((z, i) => { + const b = bones.get(z.boneId) + const isSpine = b?.category === 'spine-zone' + return ( +
  • + + {describeZone(z, bones)} + {isSpine && ( + + )} + + +
  • + ) + })} +
+ )} +
+ +
+ + onChange({ ...observation, pathologyIds: ids })} + /> +
+ +
+ + onChange({ ...observation, freeTextPathologies: items })} + /> +
+ +
+ + onChange({ ...observation, severity: s })} + /> +
+ +
+ +