Skip to main content

Messaging

Carium allows for messaging between care teams and patients using in-app or SMS delivery mechanisms. Messaging is done using channels. There are three types of channels available for messaging.

Channel TypeDescription
Single ParticipantEnables communication between a single patient and a care team group
Multiple ParticipantEnables communication between a multiple patients or groups of patients and a care team group
Care Team OnlyEnables communication within a care team group. No patients are allowed in these message threads.

All messages from care team members originate from a care team group. Care team members can be added and removed from the group to include or remove them from the messaging thread. Messages are tracked in a single channel regardless of whether they're sent using in-app or SMS transports.

Messages are represented in the database by four tables.

The courier_messaging_channel table lists all the channels present in the system. A channel can be thought of as a message thread and holds all the messages associated with a given conversation. The message themselves are each associate with a channel and contained in the courier_messsaging_message table. The message entries include all the information relevant to a single message including the timestamp, content, sender ID, and channel ID. The courier_messaging_subscription table defines the full membership of a channel. This defines the group of users (patient or providers) that will receive the messages sent to the channel.

Messaging can also include attachments (photo, PDF, etc). These are captured in the courier_messaging_attachment table and reference the message where it was included. This table includes a column that references the URL of the attachment, but the attachment itself isn't available in the data warehouse.

Examples

List all message channel subscriptions

SELECT
channel.id AS channel_id,
channel.name AS channel_name,
usr.first_name AS first_name,
usr.last_name AS last_name,
usr.email AS email
FROM courier_messaging_channel AS channel
JOIN courier_messaging_subscription AS sub
ON sub.channel_id = channel.id
JOIN identity_core_user AS usr
ON sub.individual_id = usr.primary_individual_id
ORDER BY 1 ASC
LIMIT 50

List messages for a single channel

SELECT
channel.name AS channel_name,
msg.posted_time AS time,
msg.msg AS message,
usr.first_name AS sender_first_name,
usr.last_name AS sender_last_name,
usr.email AS sender_email
FROM courier_messaging_channel AS channel
JOIN courier_messaging_message AS msg
ON channel.id = msg.channel_id
JOIN identity_core_user AS usr
ON usr.id = msg.user_id
WHERE msg.posted_time >= '2024-01-01'
AND channel.id = '5162e97b0f524f368a21ff0221fa8353' -- replace with your channel id
ORDER BY 2 DESC
LIMIT 50