This example application demonstrates how to use Medplum's custom FHIR operations to send and receive faxes via eFax integration.
NOTE: This demo uses Medplum's hosted eFax integration. The Medplum team must enable eFax for your project before you can use it. Contact Medplum to enable eFax for your project.
- Fax Inbox: View received faxes and refresh from eFax using the
$receive-efaxoperation - Sent Faxes: View outbound faxes
- Send Fax: Compose and send faxes using the
$send-efaxoperation
- A Medplum account with the eFax integration enabled (contact the Medplum team)
- eFax API credentials configured in your Medplum project's secrets (see eFax Integration Documentation)
-
Install dependencies:
npm install
-
Configure environment variables by creating a
.envfile (OPTIONAL)MEDPLUM_BASE_URL=https://api.medplum.com/ MEDPLUM_CLIENT_ID=your-client-id -
Start the development server:
npm run dev
-
Open http://localhost:3000 in your browser
Recipient fax numbers must be in E.164 format: a leading + and country calling code (e.g. +1 for US/Canada), then the number—eFax requires this; a local number without a country code may fail.
The demo creates resources sequentially when sending a fax:
// Step 1: Upload the file as an attachment (creates Binary resource)
const attachment = await medplum.createAttachment({
data: file,
contentType: file.type,
filename: file.name,
});
// Step 2: Create the recipient Organization
const recipient = await medplum.createResource<Organization>({
resourceType: 'Organization',
name: 'Acme Medical Center',
contact: [{ telecom: [{ system: 'fax', value: '+15551234567' }] }],
});
// Step 3: Create the Communication
const communication = await medplum.createResource<Communication>({
resourceType: 'Communication',
status: 'in-progress',
category: [{ coding: [{ system: 'http://medplum.com/fhir/CodeSystem/fax-direction', code: 'outbound' }] }],
medium: [{ coding: [{ system: 'http://terminology.hl7.org/CodeSystem/v3-ParticipationMode', code: 'FAXWRIT' }] }],
sender: createReference(profile),
recipient: [createReference(recipient)],
payload: [{ contentAttachment: attachment }],
});
// Step 4: Call the $send-efax operation
await medplum.post(medplum.fhirUrl('Communication', '$send-efax'), communication);Send a fax via eFax from a Communication resource.
POST /fhir/R4/Communication/$send-efax
Poll for and receive faxes from eFax.
POST /fhir/R4/Communication/$receive-efax # Uses project-level eFaxUserId secret
POST /fhir/R4/Practitioner/{id}/$receive-efax # Uses Practitioner's eFax identifier
POST /fhir/R4/Organization/{id}/$receive-efax # Uses Organization's eFax identifier