An example for a live patient-provider chat using Medplum's WebSocket subscriptions.
This example app demonstrates the following:
- Creating WebSocket
Subscriptionresource and connecting and listening to events - Loading chat history from FHIR server on initial load
- Sending chat messages by creating new
Communicationresources - Marking a message as received or read by updating received
Communicationresources from other chat participant - Parsing
Communicationresources and displaying message contents as well as read receipts, message timestamps, etc.
If you haven't already done so, follow the instructions in this tutorial to register a Medplum project to store your data.
Fork and clone the repo.
If you want to change any environment variables from the defaults, copy the .env.defaults file to .env
cp .env.defaults .envAnd make the changes you need.
Next, install the dependencies
npm installThen, run the app
npm run devThis app should run on http://localhost:3000/
Note
Because WebSocket Subscriptions are currently experimental, the websocket-subscriptions feature flag needs to be enabled on your Project resource for this demo to work.
To do this on a local dev server, login to @medplum/app as the Super Admin user and edit your Project resource.
Note that a Project Admin cannot edit Project.features and it must be done by a Super Admin.
Please contact Medplum if you would like to enable this on your project on the Medplum hosted instance.
Medplum is an open-source, API-first EHR. Medplum makes it easy to build healthcare apps quickly with less code.
Medplum supports self-hosting, and provides a hosted service. Medplum Hello World uses the hosted service as a backend.
- Read our documentation
- Browse our react component library
- Join our Discord