Zum Inhalt springen

Termine in der Physiotherapiepraxis

Ein Patient kann um 10 Uhr nicht. Finden Sie den nächsten Slot, der Pausen und Reinigung respektiert.

  • Gesundheit
  • Forma
  • Minutenraster
  • Summenzeilen
  • Minimap
  • Live-Suche
  • Aktive Bereiche
  • Verschieberegeln
  • Gesperrte Zeiten
  • Zeilenspalten
  • Theming
  • Demo mit synthetischen Daten
Quellcode laden.zip

Aufgabe

0 von 3 Schritten erledigt

Donnerstag, 9:40 Uhr: Owen Hart (F-2318, Knie-Reha um 10:00 Uhr bei Alba R.) ruft an und bittet um einen späteren Termin.

  1. Ziehen Sie F-2318 um 12:00 Uhr in die Zeile von Marc D., während sein Raum gereinigt wird. — Offen

    Gestreifte Slots sind gesperrt. Die Drag-Karte nennt den Grund, und der Termin lässt sich dort nicht ablegen.

  2. Legen Sie ihn um 12:30 Uhr in der Zeile von Marc D. ab, direkt nach der Reinigung. — Offen

    Jeder freie Slot passt, wenn die Fachkraft Knie-Reha anbietet. Die Zeile des Osteopathen lehnt ihn ab.

  3. Wechseln Sie zu 15-Minuten-Slots und verlängern Sie einen Termin um eine Viertelstunde. — Offen

    Wählen Sie „15 Min.“ in der Leiste und ziehen Sie den rechten Rand einer Karte. Per Tastatur ändert Alt+Umschalt+Pfeil die Dauer.

Etwa 30 Sekunden. Erledigte Schritte werden abgehakt.

Tastatur: Raster fokussieren, dann Pfeiltasten, Eingabe und Alt+Pfeile zum Verschieben.

Forma
PhysiotherapieAlba R.32%Marc D.31%Nora S.36%Manuelle TherapieTeo V.33%Iris M.38%Lucía FerrerErstbefundOwen HartKnie-RehaMia LaurentSchultermobilisationJonas WeberRückenbehandlungAitana RuizKnie-RehaTomás IbarraRückenbehandlungClaire DuboisKnie-RehaLeo BrandtSchultermobilisationSara ContiErstbefundHugo MartínRückenbehandlungNoah BeckerTrainingstherapieInés NavarroTrainingstherapieYuki TanakaTrainingstherapieMarta VidalTrainingstherapieRafael CostaOsteopathieAnna KowalskiOsteopathieDiego HerreraErstbefundChloé MartinRückenbehandlungEmma LarsenSportmassageLucas MoreauSportmassageNadia HaddadSportmassage243344333100003Belegte Räumevon 5Donnerstag, 15. Oktober08:0008:3009:0009:3010:0010:3011:0011:3012:0012:3013:0013:3014:0014:3015:00

Vorschau des ersten BildesLive: die echte Pro-Engine, in Ihrem BrowserEtwa 30 Sekunden. Erledigte Schritte werden abgehakt. Tastatur: Raster fokussieren, dann Pfeiltasten, Eingabe und Alt+Pfeile zum Verschieben.

Die Ausgangslage.

Forma ist eine fiktive Praxis mit drei Physiotherapeutinnen und Physiotherapeuten, einem Osteopathen und einer Sportmasseurin. Termine dauern 15 bis 60 Minuten, jede Fachkraft arbeitet in einem festen Raum, und der Tag wird von Pausen, einer Fallbesprechung und der Raumreinigung zwischen den Behandlungen unterbrochen.

Ruft ein Patient an, um einen Termin zu verlegen, hat der Empfang nur Sekunden für einen freien Slot, während sich das Wartezimmer füllt. Ein Papierraster oder ein allgemeiner Kalender lässt Termine in Pausen zu oder gibt eine Osteopathie-Sitzung an einen Physiotherapeuten. Die Planungstafel muss solche Slots ablehnen und sagen, warum, auch hörbar für Screenreader. Patienten, Team und Termine sind erfunden.

Was Sie tun werden

Sie versuchen, einen Termin in ein Reinigungsfenster zu legen, hören, warum das abgelehnt wird, verschieben ihn in den ersten freien Slot nach der Reinigung und passen seine Dauer in 15-Minuten-Schritten an.

Wo die Bibliothek endet und Ihre Anwendung beginnt.

SuperScheduler liefert

  • Minutenskalen als zoomLevels (30- und 15-Minuten-Zellen) mit Einrasten und ausgeblendeter Nacht (showNonBusiness: false).
  • Eine fixierte Übersichtszeile (frozen: ‘top’, cellsDisabled), gefüllt von onBeforeCellRender, und Kopfzeilen je Fachkraft mit Live-Auslastung über rowHeaderColumns.
  • Reichhaltige Karten aus onBeforeEventRender mit Bereichen: der Avatar des Patienten als klickbarer Status-Chip (action: ‘None’, onClick) und die zeitverankerte Raumvorbereitung (start, end).
  • Patientensuche mit events.filter und onEventFilter, der Viewport aus super-scheduler/hooks (useSchedulerState) für die Tagesauswahl und das Jetzt der Praxis als separator.
  • Gesperrte Zellen und Prüfungen in jedem Frame (allowed, message) beim Ziehen und Ändern der Dauer, die Drag-Karte, die Hover-Karte, Tastaturbedienung und kontrollierte Ereignisse (onEventsChange).
  • Die Minimap (super-scheduler/minimap) mit festem Bereich über beide Praxistage, gespeist mit einer eigenen Reihe der Anwendung; ihr Ausschnitt lässt sich auch per Tastatur wie ein Schieberegler bedienen.

Der Code dieses Beispiels entscheidet

  • Welche Fachrichtungen welche Behandlung anbieten, dazu Pausen, Teamrunde und Raumreinigung.
  • Die Besuchsstatus und ihre Reihenfolge, die belegten Räume, die Auslastung je Fachkraft und die Zahlen des Empfangs.
  • Ein Satz pro Ablehnungsgrund, angesagt in einer höflichen Live-Region, wenn ein Ablegen abgelehnt wird.
  • Das Detailpanel, die Aufgabe und alle Texte dieser Seite.
  • Der gebuchte Anteil jeder Stunde, den die Minimap zeichnet, die Spitzenstunde und die Schwellen „ausgelastet“ und „voll“, die sie mit den Auslastungsbalken teilt.

Der Code hinter dieser Demo.

Das sind die Dateien, die diese Seite ausführt, keine vereinfachte Kopie. Sie kompilieren gegen die öffentlichen Exporte von SuperScheduler Pro.

tsx.zip

Die Integration: Slotgrößen, die fixierte Zeile, Karten mit Bereichen, gesperrte Zellen aus der Sperrliste, der Ereignisfilter und die Callbacks, in denen die Regeln einen Slot ablehnen.

/**
 * Forma appointment board: practitioners over two clinic days in 30- or 15-minute slots, a frozen
 * "rooms in use" row on top and the clinic's now.
 *
 * Library: minute-scale zoom levels, a frozen summary row (frozen: 'top', cellsDisabled) filled by
 * onBeforeCellRender, row header columns with a live load meter, rich cards from
 * onBeforeEventRender with areas (a clickable status chip, a time-anchored room reset), disabled
 * cells, a separator for "now", the event filter (events.filter + onEventFilter) behind the
 * patient search, drag/resize with per-frame vetoes, the drag card, the event hover card
 * (super-scheduler/react-render), conflict highlighting, a context menu and keyboard moves.
 * Application: who may deliver which treatment, the clinic's fixed blocks, the status cycle and
 * the sentence that explains every refusal. Those rules live in ./rules.
 */
import { useCallback, useEffect, useMemo, type RefObject } from 'react'
import type { SchedulerEventsChangeArgs, SuperScheduler } from 'super-scheduler'
import type { SchedulerHistory } from 'super-scheduler/history'
import { SuperSchedulerComponent, type SchedulerRenderProps } from 'super-scheduler/react-render'
import { format, plural } from '~/i18n/format'
import { DAY, HOUR, MINUTE, civil, parseCivil } from '../../scheduler/civil'
import { headerLabel } from '../../scheduler/header-format'
import { unitOfSpan } from '../../scheduler/live-headers'
import { createEventMenu } from '../kit/context-menu'
import { formatClock, formatDay, formatSpan, formatWhen } from '../kit/format'
import { defaultHints } from '../kit/hover-card'
import { KEYS } from '../kit/keys'
import { useDropRefusal } from '../kit/use-drop-refusal'
import { createDragCard } from '../kit/verdict'
import type { DemoCommon } from '../types'
import {
  CARD_HEIGHT,
  CARD_INSET,
  HEADER_ROW,
  PRACTITIONER_COLUMNS,
  SLOT_WIDTH,
  civilOf,
  isAppointmentEvent,
  practitionerOf,
  readAppointmentFields,
  toResources,
  type AppointmentEvent,
} from './adapter'
import {
  blockHtml,
  cardHtml,
  createHtmlCache,
  dayHtml,
  loadHtml,
  nowTagHtml,
  practitionerHtml,
  roomsCellHtml,
  slotHtml,
  statusChipHtml,
  summaryHeadHtml,
  teamHtml,
} from './cards'
import {
  BLOCKS,
  CLINIC_DAYS,
  NOW,
  OPENING_HOURS,
  PRACTITIONERS,
  PRACTITIONER_NAMES,
  RESET_MINUTES,
  TODAY,
  type Appointment,
} from './model'
import {
  TREATMENT_DISCIPLINES,
  blockAt,
  initials,
  matchesSearch,
  nextFreeSlot,
  nextStatus,
  roomsInUse,
  shortName,
  slotRefusal,
  utilisation,
  type Refusal,
} from './rules'
import { ZOOM_IDS, type FormaText, type ZoomId } from './text'
import { useVisitHover, type VisitCardModel } from './visit-card'
import './tokens.css'
import './forma.css'

/** What the board asks the demo to do (context menu, status chip). */
export type AppointmentAction = 'details' | 'cycle-status' | 'next-slot'

export interface FormaSchedulerProps {
  readonly events: AppointmentEvent[]
  /** The same appointments in model form: cards, figures and the menu read them. */
  readonly appointments: readonly Appointment[]
  readonly text: FormaText
  readonly common: DemoCommon
  /** BCP 47 tag for labels, and the scheduler locale id. */
  readonly tag: string
  readonly schedulerLocale: string
  /** Slot size on mount. Later changes go through control.zoom so the view animates. */
  readonly initialZoom: ZoomId
  /** The appointment shown in the detail sheet: it gets the selection ring. */
  readonly selected: string | null
  /** The patient search ('' shows everyone): applied with events.filter. */
  readonly query: string
  /** Narrow stage: a slimmer practitioner column. */
  readonly narrow: boolean
  /** The product skin: a class for the scheduler root (hover cards copy it) and the menu theme. */
  readonly skin: { readonly cssClass: string; readonly menuTheme: string }
  readonly history: SchedulerHistory
  readonly controlRef: RefObject<SuperScheduler.Scheduler | null>
  readonly onEventsChange: (args: SchedulerEventsChangeArgs) => void
  readonly onSelect: (id: string) => void
  readonly onMoved: (id: string) => void
  readonly onResized: (id: string) => void
  readonly onRefused: (id: string, refusal: Refusal) => void
  readonly onAction: (action: AppointmentAction, id: string) => void
  readonly onZoomLevel: (level: ZoomId) => void
}

/** Where an appointment could go next, by the clinic's rules (menu and sheet share it). */
export function nextSlotOf(
  appointment: Appointment,
  appointments: readonly Appointment[],
): { start: string; end: string } | null {
  const practitioner = practitionerOf(appointment.practitioner)
  if (practitioner === null) return null
  return nextFreeSlot(
    appointment,
    practitioner,
    BLOCKS,
    appointments,
    { first: CLINIC_DAYS.start, count: CLINIC_DAYS.count },
    OPENING_HOURS,
  )
}

/** Slot sizes: snapping follows the cell, so 15-minute cells move appointments by quarters. */
const SLOT_LEVELS: Readonly<Record<ZoomId, SuperScheduler.ZoomLevelProperties>> = {
  fifteen: { scale: 'CellDuration', cellDuration: 15, cellWidth: SLOT_WIDTH.fifteen },
  thirty: { scale: 'CellDuration', cellDuration: 30, cellWidth: SLOT_WIDTH.thirty },
}

// Same order as ZOOM_IDS, so onZoom's level index maps back to an id.
const ZOOM_LEVELS: SuperScheduler.ZoomLevel[] = ZOOM_IDS.map((id) => ({
  id,
  properties: SLOT_LEVELS[id],
}))

const NOW_TICKS = parseCivil(NOW)
/** The avatar (and status chip) on a card, in px. */
const AVATAR = 28
const TODAY_TICKS = parseCivil(TODAY)
const ROOMS_TOTAL = PRACTITIONERS.length

/** Every appointment the control holds right now, in the shape the rules read. */
function appointmentsIn(
  control: SuperScheduler.Scheduler,
): Pick<Appointment, 'id' | 'practitioner' | 'start' | 'end'>[] {
  return control.events.list.flatMap((event) => {
    const practitioner = event.resource === undefined ? null : practitionerOf(event.resource)
    if (practitioner === null || !isAppointmentEvent(event)) return []
    return [
      {
        id: String(event.id),
        practitioner: practitioner.id,
        start: civilOf(event.start),
        end: civilOf(event.end),
      },
    ]
  })
}

/** Checks one proposed slot of an appointment against the clinic's rules. */
function refusalFor(
  control: SuperScheduler.Scheduler | null,
  data: object,
  id: string,
  resource: SuperScheduler.ResourceId,
  start: SuperScheduler.Date,
  end: SuperScheduler.Date,
): Refusal | null {
  const fields = readAppointmentFields(data)
  const practitioner = practitionerOf(resource)
  if (control === null || fields === null || practitioner === null) return null
  return slotRefusal(
    { id, treatment: fields.treatment, start: civil(start.ticks), end: civil(end.ticks) },
    practitioner,
    BLOCKS,
    appointmentsIn(control),
  )
}

export function FormaScheduler(props: FormaSchedulerProps) {
  const {
    events,
    appointments,
    text,
    common,
    tag,
    schedulerLocale,
    initialZoom,
    selected,
    query,
    narrow,
    skin,
    history,
    controlRef,
  } = props
  const { onEventsChange, onSelect, onMoved, onResized, onRefused, onAction, onZoomLevel } = props

  const resources = useMemo(() => toResources(text), [text])
  const byId = useMemo(
    () => new Map(appointments.map((appointment) => [appointment.id, appointment])),
    [appointments],
  )

  // The drag card shows a refusal while the shadow sits on a forbidden slot; the hook announces
  // the last reason when the pointer is released without a drop, so it is heard, not only seen.
  const refusal = useDropRefusal(onRefused)

  // Visit card: the patient, the care, when and where, how it was booked, and who may deliver it.
  const card = useCallback(
    (event: SuperScheduler.Event): VisitCardModel | null => {
      const appointment = byId.get(String(event.id()))
      const practitioner =
        appointment === undefined ? null : practitionerOf(appointment.practitioner)
      // The appointment open in the sheet needs no card.
      if (appointment === undefined || practitioner === null || appointment.id === selected)
        return null
      const start = parseCivil(appointment.start)
      const end = parseCivil(appointment.end)
      const day = start - (start % DAY)
      const who = new Intl.ListFormat(tag, { type: 'conjunction' }).format(
        TREATMENT_DISCIPLINES[appointment.treatment].map(
          (discipline) => text.disciplines[discipline],
        ),
      )
      const reset = RESET_MINUTES[appointment.treatment]
      return {
        id: appointment.id,
        initials: initials(appointment.patient),
        patient: appointment.patient,
        code: appointment.id,
        treatment: appointment.treatment,
        treatmentLabel: text.treatments[appointment.treatment],
        status: appointment.status,
        statusLabel: text.statuses[appointment.status],
        time: {
          start,
          end,
          day: formatDay(start, tag),
          startLabel: formatClock(start, tag),
          endLabel: formatClock(end, tag),
          span: formatSpan(end - start, tag),
          window: { start: day + OPENING_HOURS.begin * HOUR, end: day + OPENING_HOURS.end * HOUR },
        },
        facts: [
          {
            label: text.fields.practitioner,
            value: `${PRACTITIONER_NAMES[practitioner.id]} · ${text.rooms[practitioner.room]}`,
          },
          { label: text.fields.channel, value: text.channels[appointment.channel] },
          ...(reset === 0
            ? []
            : [{ label: text.card.resetLabel, value: plural(text.minutes, reset, tag) }]),
        ],
        rule: format(text.card.deliveredBy, { who }),
        hints: defaultHints(common),
      }
    },
    [byId, selected, text, common, tag],
  )
  const { eventHover, closeHover, suppressHover } = useVisitHover(card)

  // Drag verdict: practitioner, the new slot, minutes, and the clinic's reason when it refuses.
  const dragCard = useMemo(
    () =>
      createDragCard({
        tag,
        common,
        rowName: (id) => {
          const practitioner = practitionerOf(id)
          return practitioner === null
            ? null
            : `${PRACTITIONER_NAMES[practitioner.id]} · ${text.rooms[practitioner.room]}`
        },
      }),
    [tag, common, text],
  )

  // Context menu: rebuilt when the day changes, so its labels name the real slot and status.
  const contextMenu = useMemo(
    () =>
      createEventMenu({
        theme: skin.menuTheme,
        title: (event) => format(common.kit.menuTitle, { name: String(event.id()) }),
        onOpenChange: (open) => suppressHover(open),
        entries: (event) => {
          const id = String(event.id())
          const appointment = byId.get(id)
          if (appointment === undefined) return []
          const slot = nextSlotOf(appointment, appointments)
          const next = nextStatus(appointment.status)
          return [
            {
              label: common.kit.openDetails,
              icon: 'details',
              keys: KEYS.details,
              run: () => onAction('details', id),
            },
            {
              label: format(text.actions.markAs, { status: text.statuses[next] }),
              icon: next === 'done' ? 'confirm' : 'pending',
              primary: true,
              run: () => onAction('cycle-status', id),
            },
            'separator',
            {
              label:
                slot === null
                  ? text.actions.noSlot
                  : format(text.actions.nextSlot, { time: formatWhen(slot.start, tag) }),
              icon: 'slot',
              disabled: slot === null,
              run: () => onAction('next-slot', id),
            },
          ]
        },
      }),
    [byId, appointments, skin, common, text, tag, onAction, suppressHover],
  )

  // Narrow stages keep the practitioner column only: the load meter steps aside.
  const columns = useMemo<SuperScheduler.RowHeaderColumnData[]>(
    () =>
      narrow
        ? [
            {
              name: text.columns.practitioner,
              width: PRACTITIONER_COLUMNS.narrowPractitioner,
              nonresizable: true,
            },
          ]
        : [
            {
              name: text.columns.practitioner,
              width: PRACTITIONER_COLUMNS.practitioner,
              nonresizable: true,
            },
            { name: text.columns.load, width: PRACTITIONER_COLUMNS.load, nonresizable: true },
          ],
    [narrow, text],
  )

  const config = useMemo<SchedulerRenderProps>(() => {
    const cards = createHtmlCache()
    const cells = createHtmlCache(1200)
    const rows = createHtmlCache(200)
    const headers = createHtmlCache(400)
    // Today's load per practitioner, for the meters in their headers.
    const loads = new Map(
      PRACTITIONERS.map((practitioner) => [
        practitioner.id,
        utilisation(appointments, BLOCKS, practitioner.id, TODAY, OPENING_HOURS),
      ]),
    )

    return {
      locale: schedulerLocale,
      cssClass: skin.cssClass,
      startDate: CLINIC_DAYS.start,
      days: CLINIC_DAYS.count,
      timeHeaders: [{ groupBy: 'Day' }, { groupBy: 'Cell' }],
      headerHeight: HEADER_ROW,
      zoomLevels: ZOOM_LEVELS,
      zoom: initialZoom,
      zoomPosition: 'left',
      // The clinic is closed at night: only opening hours are drawn.
      businessBeginsHour: OPENING_HOURS.begin,
      businessEndsHour: OPENING_HOURS.end,
      showNonBusiness: false,
      useEventBoxes: 'Never',
      height: '100%',
      treeEnabled: true,
      treePreventParentUsage: true,
      treeIndent: 0,
      rowHeaderColumns: columns,
      rowHeaderColumnsMergeParents: true,
      rowHeaderWidth: narrow
        ? PRACTITIONER_COLUMNS.narrowPractitioner
        : PRACTITIONER_COLUMNS.practitioner + PRACTITIONER_COLUMNS.load,
      rowHeaderWidthAutoFit: false,
      eventHeight: CARD_HEIGHT,
      rowMarginTop: CARD_INSET,
      rowMarginBottom: CARD_INSET,
      eventBorderRadius: 12,
      durationBarVisible: false,
      // The clinic's now: a calm line through the day, its time in the slot header.
      separators: [{ location: NOW, layer: 'AboveEvents', width: 2, cssClass: 'fm-nowline' }],
      allowEventOverlap: false,
      conflictHighlight: true,
      showToolTip: false,
      keyboardEnabled: true,
      keyboardTarget: 'component',
      keyboardMode: 'Full',
      history,
      controlRef,
      onEventsChange,

      // The search: an appointment shows when its patient or code matches.
      onEventFilter: (args) => {
        const param = args.filterParam
        const fields = readAppointmentFields(args.e.data)
        if (typeof param !== 'string' || fields === null) return
        args.visible = matchesSearch({ id: String(args.e.id()), patient: fields.patient }, param)
      },

      onBeforeTimeHeaderRender: (args) => {
        const header = args.header
        const start = header.start.ticks
        const span = header.end.ticks - start
        if (header.level === 0) {
          const today = start - (start % DAY) === TODAY_TICKS
          header.html = headers(`d:${start}:${span}`, () =>
            span <= DAY
              ? dayHtml(headerLabel(start, 'day', tag, 'group'), today ? text.day.today : null)
              : slotHtml(headerLabel(start, unitOfSpan(span, 'group'), tag, 'group'), true),
          )
          return
        }
        const minutes = new Date(start).getUTCMinutes()
        header.html = headers(`c:${start}:${span}`, () =>
          slotHtml(
            headerLabel(start, unitOfSpan(span, 'cell'), tag, 'cell', args.control.cellWidth),
            minutes === 0,
          ),
        )
        header.cssClass = minutes === 0 ? 'fm-slot-cell fm-slot-cell--hour' : 'fm-slot-cell'
        if (NOW_TICKS >= start && NOW_TICKS < start + span) {
          header.cssClass += ' fm-slot-cell--now'
          header.areas = [
            {
              left: `${((NOW_TICKS - start) / span) * 100}%`,
              top: 0,
              bottom: 0,
              width: 64,
              cssClass: 'fm-now-area',
              html: headers(`now:${tag}`, () => nowTagHtml(formatClock(NOW_TICKS, tag))),
            },
          ]
        }
      },

      onBeforeRowHeaderRender: (args) => {
        const row = args.row
        const [first, second] = row.columns
        if (row.id === 'rooms') {
          row.cssClass = 'fm-rh fm-rh--summary'
          const html = rows(`s:${text.summary.label}`, () =>
            summaryHeadHtml(text.summary.label, format(text.summary.meta, { total: ROOMS_TOTAL })),
          )
          row.html = html
          if (first !== undefined) first.html = html
          return
        }
        const practitioner = practitionerOf(row.id)
        if (practitioner === null) {
          row.cssClass = 'fm-rh fm-rh--team'
          const count = PRACTITIONERS.filter((candidate) => candidate.team === row.id).length
          const html = rows(`t:${String(row.id)}:${row.name}`, () => teamHtml(row.name, count))
          row.html = html
          if (first !== undefined) first.html = html
          return
        }
        row.cssClass = 'fm-rh fm-rh--person'
        const name = PRACTITIONER_NAMES[practitioner.id]
        if (first !== undefined)
          first.html = rows(`p:${practitioner.id}:${text.roles[practitioner.discipline]}`, () =>
            practitionerHtml(initials(name), name, text.roles[practitioner.discipline]),
          )
        if (second !== undefined) {
          const percent = loads.get(practitioner.id) ?? 0
          const label = format(text.load, { percent })
          second.html = rows(`l:${practitioner.id}:${percent}:${label}`, () =>
            loadHtml(percent, label),
          )
        }
      },

      // The frozen row counts rooms in use per slot; breaks, meetings and cleaning become disabled
      // cells (the library refuses drops on them); the past is quieter.
      onBeforeCellRender: (args) => {
        const cell = args.cell
        const start = cell.start.ticks
        const end = cell.end.ticks
        if (cell.resource === 'rooms') {
          const used = roomsInUse(appointments, civil(start), civil(end))
          const label = format(text.summary.cell, { count: used, total: ROOMS_TOTAL })
          cell.properties.html = cells(`r:${used}:${label}`, () =>
            roomsCellHtml(used, ROOMS_TOTAL, label),
          )
          cell.properties.cssClass =
            start <= NOW_TICKS && NOW_TICKS < end ? 'fm-sum fm-sum--now' : 'fm-sum'
          return
        }
        const practitioner = practitionerOf(cell.resource)
        if (practitioner === null) {
          cell.properties.cssClass = 'fm-team-cell'
          return
        }
        const past = end <= NOW_TICKS ? 'fm-past' : ''
        const cellStart = civil(start)
        const block = blockAt(BLOCKS, practitioner.id, cellStart, civil(end))
        if (block === null) {
          cell.properties.cssClass = past
          return
        }
        cell.properties.disabled = true
        cell.properties.cssClass = `fm-block fm-block--${block.kind}${cellStart === block.start ? ' fm-block--first' : ''} ${past}`
        if (cellStart === block.start)
          cell.properties.html = cells(`b:${block.kind}:${text.blocks[block.kind]}`, () =>
            blockHtml(text.blocks[block.kind]),
          )
      },

      onBeforeEventRender: (args) => {
        const data = args.data
        const fields = readAppointmentFields(data)
        if (fields === null) return
        const id = String(data.id)
        const practitioner = data.resource === undefined ? null : practitionerOf(data.resource)
        const room = practitioner === null ? '' : text.rooms[practitioner.room]
        const classes = ['fm-ev', `fm-ev--${fields.status}`]
        if (id === selected) classes.push('fm-ev--selected')
        data.cssClass = classes.join(' ')
        data.html = cards(
          `${id}:${fields.patient}:${fields.treatment}:${room}:${text.treatments[fields.treatment]}`,
          () =>
            cardHtml({
              patient: fields.patient,
              short: shortName(fields.patient),
              treatment: fields.treatment,
              treatmentLabel: text.treatments[fields.treatment],
              room,
            }),
        )
        data.ariaLabel = `${id}, ${fields.patient}, ${text.treatments[fields.treatment]}, ${text.statuses[fields.status]}`
        const next = nextStatus(fields.status)
        const who = initials(fields.patient)
        const areas: SuperScheduler.AreaData[] = [
          // The patient's avatar is the status chip: one click moves the visit on (booked →
          // arrived → in treatment → done).
          {
            left: 8,
            top: (CARD_HEIGHT - AVATAR) / 2,
            width: AVATAR,
            height: AVATAR,
            action: 'None',
            cssClass: `fm-who fm-who--${fields.status}`,
            html: cards(`who:${who}:${fields.status}`, () => statusChipHtml(who, fields.status)),
            toolTip: format(text.card.statusHint, {
              status: text.statuses[fields.status],
              next: text.statuses[next],
            }),
            onClick: () => {
              closeHover()
              onAction('cycle-status', id)
            },
          },
        ]
        // The room reset at the end of the slot, anchored in time.
        const reset = RESET_MINUTES[fields.treatment]
        if (reset > 0) {
          const end = data.end.ticks
          areas.push({
            start: civil(end - reset * MINUTE),
            end: civil(end),
            top: 0,
            bottom: 0,
            cssClass: 'fm-reset',
            action: 'Default',
            toolTip: format(text.card.reset, { minutes: reset }),
          })
        }
        data.areas = areas
      },

      onEventMoving: (args) => {
        const id = String(args.e.id())
        const reason = refusalFor(
          controlRef.current,
          args.e.data,
          id,
          args.resource,
          args.start,
          args.end,
        )
        refusal.track(id, reason)
        if (reason !== null) {
          args.allowed = false
          args.message = text.rules[reason]
        }
      },

      // Final check before the commit; keyboard moves (Alt+arrows) arrive here without a drag.
      onEventMove: (args) => {
        const id = String(args.e.id())
        const reason = refusalFor(
          args.control,
          args.e.data,
          id,
          args.newResource,
          args.newStart,
          args.newEnd,
        )
        if (reason !== null) {
          args.preventDefault()
          refusal.clear()
          onRefused(id, reason)
        }
      },

      onEventResizing: (args) => {
        const id = String(args.e.id())
        const resource = args.e.resource()
        const reason =
          resource === undefined
            ? null
            : refusalFor(controlRef.current, args.e.data, id, resource, args.start, args.end)
        refusal.track(id, reason)
        if (reason !== null) {
          args.allowed = false
          args.message = text.rules[reason]
        }
      },

      onEventResize: (args) => {
        const id = String(args.e.id())
        const resource = args.e.resource()
        const reason =
          resource === undefined
            ? null
            : refusalFor(args.control, args.e.data, id, resource, args.newStart, args.newEnd)
        if (reason !== null) {
          args.preventDefault()
          refusal.clear()
          onRefused(id, reason)
        }
      },

      onEventMoved: (args) => {
        refusal.clear()
        onMoved(String(args.e.id()))
      },
      onEventResized: (args) => {
        refusal.clear()
        onResized(String(args.e.id()))
      },
      // A click (or Enter) docks the appointment into the detail sheet; the hover card steps aside.
      onEventClick: (args) => {
        closeHover()
        onSelect(String(args.e.id()))
      },

      onZoom: (args) => {
        if (args.phase !== 'end') return
        const level = ZOOM_IDS[args.level]
        if (level !== undefined) onZoomLevel(level)
      },
    }
  }, [
    appointments,
    columns,
    controlRef,
    history,
    initialZoom,
    narrow,
    selected,
    skin,
    closeHover,
    onAction,
    onEventsChange,
    onMoved,
    onRefused,
    onResized,
    onSelect,
    onZoomLevel,
    refusal,
    schedulerLocale,
    tag,
    text,
  ])

  // The search goes through the library's event filter; the predicate is onEventFilter above.
  useEffect(() => {
    controlRef.current?.events.filter(query.trim() === '' ? null : query)
  }, [controlRef, query, config])

  return (
    <SuperSchedulerComponent
      {...config}
      resources={resources}
      events={events}
      eventHover={eventHover}
      dragCard={dragCard}
      contextMenu={contextMenu}
    />
  )
}

Das Archiv enthält die Dateien dieses Beispiels und eine README. SuperScheduler Pro und Download-Schlüssel sind nicht enthalten.