Skip to content

Agenda — events

Per-module slice of docs/events-catalog.md (auto-generated). Update both files when adding or removing events.

Published

Appointment lifecycle. The specific appointment.<status> event is dispatched from a status→EventType map in AppointmentService.transition_status (service.py), so the publish call passes a variable — the catalog resolves it from the constants referenced in that file.

EventWhenConsumers
appointment.scheduledAppointment creatednotifications, patient_timeline, recalls, schedules
appointment.updatedAppointment fields editedschedules
appointment.status_changedAny status transition (generic)
appointment.confirmed→ confirmedpatient_timeline
appointment.checked_in→ checked-inpatient_timeline
appointment.in_treatment→ in-treatmentpatient_timeline
appointment.completed→ completedpatient_timeline, recalls, treatment_plan
appointment.cancelled→ cancelledcopilot, notifications, patient_timeline, recalls, schedules
appointment.no_show→ no-showpatient_timeline
appointment.cabinet_changedCabinet reassigned
agenda.visit_note_updatedVisit note / completion flag edited on an appointment-treatmentpatient_timeline

Payloads carry clinic_id, appointment_id, and (where relevant) patient_id / professional_id / status fields. See the module CLAUDE.md for the per-event payload contract.

Subscribed

EventHandlerEffect
clinic.createdevents.py:on_clinic_createdCreate one default cabinet ("Gabinete 1" / "Room 1" by clinic language) when the clinic has none.

Adding a new event

  1. Add the constant to backend/app/core/events/types.py (EventType).
  2. Publish from a service method after flush() — the bus runs handlers inline, before the request commits. Pass db=db so transactional subscribers can join the transaction (ADR 0019, issue #183).
  3. Add the row to the table above.
  4. Run python backend/scripts/generate_catalogs.py to refresh the global catalog.