Communication
CareTeam-based real-time messaging system
Overview
The messaging system uses CareTeam-based rooms rather than 1:1 messaging. Each conversation is identified by:
All CareTeam participants can see and send messages in the room.
List Conversations
Returns all conversations for the authenticated user with unread counts.
Response
Get Messages
Parameters
| Parameter | Type | Description |
|---|---|---|
room_id | string | Room identifier |
_count | number | Page size |
_offset | number | Pagination offset |
Send Message
Message Types
| Type | Description |
|---|---|
text | Plain text message |
medication_request | Medication-related request |
medication_response | Response to medication request |
system_notification | System-generated notification |
template | Message from a template |
Mark Messages as Read
Message Templates
List Templates
Create Template
Patient Groups
List Groups
Bulk Message
Send a message to a group of patients:
CareTeam Lookup
| Endpoint | Description |
|---|---|
GET /communication/patient-care-teams?patient={id} | Care teams for a patient |
GET /communication/care-team-patients?care_team={id} | Patients in a care team |
GET /communication/default-team?patient={id} | Default care team for a patient |
GET /communication/check-team-membership?care_team={id} | Check if current user is a member |
Real-time
Messages are delivered in real-time via Supabase Realtime. The frontend subscribes to the communication.messages table for the current user's rooms.
Database Tables
| Table | Description |
|---|---|
communication.messages | Message storage with real-time triggers |
communication.message_read_status | Per-user read tracking |
communication.message_templates | Reusable templates |
communication.patient_groups | Patient groups for bulk messaging |
communication.patient_group_members | Group membership |