How Real-Time Alerts Improve Patient Engagement and Treatment Adherence
In the evolving digital healthcare industry, patients and staff alike cannot solely rely on chat messages or calendar appointments for in-person visits and manual follow-ups. Timely interventions, like reminders to take medication, share lab results, notify irregular vital signs, or schedule a consultation, are critical to keeping patients on track with their treatment plans to improve patients’ health.
Real-time alerts provide a solution to promote engagement and adherence to treatment plans, as they can be set up to trigger automatically by staff or patients alike, aiming to reduce hospital readmissions, improve patient care, and provide the best quality care for patient safety.
The issue then becomes security and scalability: Patients need to ensure their real-time data is protected by technical standards (SOC 2 and ISO/IEC 27001:2013 ) but also protected by federal standards such as the Health Insurance Portability and Accountability Act (HIPPA), ensuring patient data is protected and safe. As your digital healthcare app grows in users, handling real-time alerts to notify many patients at the same time, both with real-time messages and push notifications, is crucial. Luckily, PubNub provides a HIPAA and secure patient-first platform for healthcare providers to engage patients with real-time alerts.
Learn more about how PubNub improves modern healthcare by utilizing both real-time messaging and push notifications to improve patient engagement and patient adherence to improve patient outcomes, as well as some practical use cases for patients to engage.
Why Real-Time Alerts Matter in Healthcare
Every patient is different - they all lead different lives and have different patient needs. While patients mean well when agreeing to a care and treatment plan, there will more than likely be missed appointments, reminders, chats, and scheduled times to take medicine.
Real-time alerts help alleviate these issues by providing clinicians a way to communicate with patients for care management, regardless of whether the app is in the foreground, background, or closed. There are a variety of workflows to utilize real-time alerts to promote engagement and adherence to treatment plans to improve patient satisfaction:
Medication Adherence: Missed doses can lead to health setbacks, unnecessary clinical visits, or even emergency room admissions. A single missed pill may not seem significant to a patient juggling numerous responsibilities, but frequent lapses can quickly cause complications for disease management. This can lead to unnecessary healthcare costs and side effects.
Appointment Reminders: Patients sometimes forget when they scheduled an appointment - helpful reminders will ensure missed meetings become less frequent.
Care Plan Updates: Patients might undergo lab tests, post-procedures, and clinical evaluations that warrant changes to their instructions, such as altering medication dosage or scheduling a follow-up scan. Delays in communicating these modifications can leave the patient following outdated guidelines, risking complications, especially if they have chronic conditions.
Remote Patient Monitoring: Advancements in wearable devices and at-home sensors track critical data such as blood pressure, heart rate, oxygen levels, or glucose readings. Abnormalities in these ratings should be delivered to both staff and patients so staff can be alerted and check-in with patients to improve health outcomes.
Gamification & Engagement: Interactive approaches, such as awarding points for daily check-ins to complete goals, offer a fun way to motivate patients to stick to the management goals of their health. The alerts can remind patients to complete tasks and reward them with achievements.
Regardless of the use case, alerts are a fantastic way for patients and staff to communicate the needs of the patient no matter where they are.
Set up Real-time Alerts
There are two types of alerts to notify patients and staff alike: messages and push notifications.
Messages
Messages contain any kind of serializable data, like objects, numbers, and UTF-8 encoded strings, typically in JSON format. To transmit Messages across the PubNub platform, you would Publish/Subscribe Publish (send) messages. To receive messages, clients will Subscribe to guarantee their messages will be delivered in the order they were sent. A mechanism called Channels is used to transmit this data between devices. This type of communication is called Pub/Sub and is the cornerstone of real-time messaging for features such as chat, IoT device control, data streaming, multiuser collaboration, and more.
Push Notifications
Push notifications are messages typically sent from a server to a device that instructs mobile applications (iOS and Android) to perform some action. Push notifications can deliver information to users when the application is in the foreground, background, or even closed - this is incredibly useful for notifying and communicating with patients when they are not actively using your application.
Most of the time, to send mobile push notifications, you’ll need to register client devices with Apple Push Notificcation service (APNs) for IoS devices and Firebase Cloud Messaging (FCM) for Android devices, which will then deliver messages to these registered or certified devices. Normally, you would have to integrate each service provider’s framework into your application. This means that you’ll need to include the extra libraries, SDKs, and code handling for each type of device that you want to send push notifications.
Luckily, PubNub supports push notifications with the same SDK that you normally use to integrate your application with PubNub’s real-time messaging via PubNub’s Push Gateway. Since the application has already registered the device, you just need to provide the push registration token and format the message payload, which contains a reserved section for push notifications. You can then add your iOS, Android, messages, signals, and metadata all in one call, without needing to depend on the frameworks and libraries of the other services - all you need to do is include information in the payload, and let PubNub handle the rest.
Push notifications are delivered in the following manner using the Push Gateway:
The application publishes to PubNub via a channel that has a device registered to receive push notifications with the push payload.
PubNub inspects the payload. If a specific mobile payload is found, it checks for device registrations on the channel. If found, PubNub forwards the push to that service provider (FCM/APNs).
FCM/APNs providers then deliver the push notification to one or more devices.
While PubNub does not deliver push notifications to devices directly (we forward them to the service provider based on if the specific mobile payload is found and if the device is registered on that channel), utilizing the Push Gateway reduces the complexity of utilizing different frameworks, libraries, and API calls and instead groups everything in one message publish.
Keyset Creation and Register Service Provider
To get started implementing real-time alerts in your application, you’ll need to create a free PubNub account to obtain your publish/subscribe keys, manage the settings for your application, and register your service provider’s certification. Learn more about creating your keyset here.
You’ll need to enable the following features in the keyset for this guide:
App Context: Store and manage metadata for users, channels, and relationships between them (memberships). The Chat SDKs rely on utilizing App Context to store information about users, channels, and memberships.
Push Notifications: Enable push notifications to be forwarded to respective service providers. More set-up on registration below.
Message Persistence: Also known as storage, allows you to store/retrieve past messages.
Presence (Optional): Gives you visibility into who is currently subscribed to a channel (online/offline status), as well as providing the ability to track custom state information. These are not discussed in this tutorial but are important for future app enhancement.
In the keyset, you’ll need to register your service provider based on which platforms you would like to target. To enable FCM for Android devices, please follow the steps in this guide. For APNs for Apple devices, refer to this guide.
For purposes of this guide, we’ll be utilizing the Kotlin Chat and Swift Chat. While we offer Core SDKs that can perform the same functionality, our Chat SDKs specialize in implementing chat with PubNub such that we provide specific chat functionality and abstraction without the hassle of managing real-time infrastructure. Most of the links to the features simply use the Kotlin Chat SDK links, but the exact same references are available for the Swift Chat SDK.
Messaging and In-App Real-time Alerts
To begin, add the Chat SDK to your application:
Next, you will need to initialize the Chat object, which establishes the connection between users and channels on the PubNub network. You’ll want to follow the initialization and configuration for the Chat SDK by closely following our documentation. It provides all the details you need to initialize PubNub, including details on the varied parameters of the Chat object. We’ll provide a basic implementation that requires your publish and subscribe keys, as well as a unique User ID:
If the User ID you use to initialize the SDK does not exist in the keyset’s App Context metadata, it will automatically create a PubNub User using that User ID. You’ll need to create. You can only have one instance of the chat entity object constructed at a time.
Before establishing the communication channels between patients (Public, Direct, and Group), you’ll need to create or retrieve User objects from App Context. Given the above statement about User IDs being automatically created when initializing the SDK for each client, this may not pose an issue. Retrieve the Users and update their Metadata if necessary.
After initializing the Chat object and obtaining User objects, you’ll need to create a channel entity of one the following types to establish a connection between you and interested subscriber(s):
Public: Let patients engage in open conversations with many people. Anyone can join public channels, such as a mental health forum or group.
Direct: Enable conversations between two users, such as a provider and the patient.
Group: Enable conversations between multiple users and can only be accessed when invited by another user. Useful for conversations between multiple staff members and a patient.
Depending on your application, Direct conversations are more than likely the route to implement due to security and HIPAA compliance:
However, some digital healthcare applications encourage group or public discussion. Please refer to the documentation for the other types of communication if you’d like to communicate with them. This Direct message type is perfect for staff and patients alike to communicate within the application. Utilizing the Unread messages and Read Recipts features, you can highlight and notify patients and staff of missed messages in a conversation, highlighting or marking the message unread while they are in or out of the application, informing them of what they missed.
In terms of real-time alerts, the principle is the same. Create a Direct channel that is unique to that patient and serves as the alerting source for the patient. This can be one unified channel name, such as janedoe-alerts
, or there can be different channel names depending on the source of the alert (janedoe-meeting-alert
, janedoe-treatment-reminder
, etc).
To listen for the alerts (and chat messages), users need to join a given channel to not only set its membership to connect users and channels but also allow the user to watch the channel and receive messages.
While this establishes the foundation of patients and staff to receive alerts, more features are required. You’ll need to determine how you want to send the alert, such as through the provider, an automated backend system, or both. Do you want to implement retrieving chat or alert history so users can view historical messages and watch for when users come online with Presence? Be sure to reference and explore the Chat SDK documentation to determine what types of features you would like to build or explore our Chat SDK tutorials to learn how to implement these features.
Push Notifications
As mentioned above, you can traditionally include push notification payload information for both APNs and FCM service providers in the same message payload as the message. Luckily, the Chat SDK simplifies this process during the Chat SDK initialization.
First, you’ll need to configure a few parameters when initializing the Chat object:
The parameters are as follows:
sendPushes
: Set to true if you want a client to send push notifications to mobile devices.deviceToken
: The unique identifier assigned to a specific mobile device, set up from obtaining a device token for the APNs and FCM services.apnsTopic
: Bundle ID that you must define yourself for iOS devices so Apple could enable push notifications - must set this option and sendPushes to true.apnsEnvironment
: Used for notifications on iOS devices; specify whether you want to use development or production APNs environments.
Defining these parameters is necessary for push notifications to send/receive push notifications.
As mentioned in Push Gateway earlier, you’ll need to register the channels for the registered devices you would like to receive push notifications about new messages. You can utilize the registerForPush()
or registerPushChannels()
to register a device on a single channel or multiple channels at the same time, respectively.
You can also unregister the channels to receive push notifications for the device in case the user closes their account or you change your architecture setup with unregisterFromPush()
and unregsiterPushChannels()
methods.
Since you’ve configured the push options in the init()
parameters above, you no longer have to add push notification payloads to every message you send because the Chat SDK automatically does this for you. The default payload structure to the registered channels look something like the following:
You can and should adjust the payload to fit your application needs. You should then be able to expand this application with more in-depth features for [the above use cases]. Please reference our documentation about setting up Mobile Push Notifications for the Chat SDK, as well as following our mobile push notifications tutorial, where you can learn how to set up and add mobile push notifications for both Android and iOS devices.
What’s Next
Real-time alerts provide a solution to promote engagement and adherence to treatment plans to ensure that patients and healthcare professionals alike are aware of communication channels. Patients will be notified of calendar appointments, medication adherence, remote patient monitoring, care plan updates, missed chats, and more, regardless of whether the application is in the foreground via PubNub Messages or in the background/closed by Push Notifications. PubNub ensures that the communication channel between patients and staff is secured, protected, and engaging.
You can learn more about how you can rely on PubNub to power your digital healthcare application by following our resources or signing up for a free PubNub account to get started building today:
Discover how PubNub powers Patient First Digital Healthcare Technology
Follow our in-depth documentation to build the features you need.
Feel free to get in touch with us anytime to explore how you can enhance your platform's real-time alerts.