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.
| Event | When | Consumers |
|---|---|---|
appointment.scheduled | Appointment created | notifications, patient_timeline, recalls, schedules |
appointment.updated | Appointment fields edited | schedules |
appointment.status_changed | Any status transition (generic) | — |
appointment.confirmed | → confirmed | patient_timeline |
appointment.checked_in | → checked-in | patient_timeline |
appointment.in_treatment | → in-treatment | patient_timeline |
appointment.completed | → completed | patient_timeline, recalls, treatment_plan |
appointment.cancelled | → cancelled | copilot, notifications, patient_timeline, recalls, schedules |
appointment.no_show | → no-show | patient_timeline |
appointment.cabinet_changed | Cabinet reassigned | — |
agenda.visit_note_updated | Visit note / completion flag edited on an appointment-treatment | patient_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
| Event | Handler | Effect |
|---|---|---|
clinic.created | events.py:on_clinic_created | Create one default cabinet ("Gabinete 1" / "Room 1" by clinic language) when the clinic has none. |
Adding a new event
- Add the constant to
backend/app/core/events/types.py(EventType). - Publish from a service method after
flush()— the bus runs handlers inline, before the request commits. Passdb=dbso transactional subscribers can join the transaction (ADR 0019, issue #183). - Add the row to the table above.
- Run
python backend/scripts/generate_catalogs.pyto refresh the global catalog.