Skip to main content

EHR / EMR Integration

This guide walks through connecting an EHR or EMR system to VitaRelay to automate the escript-to-fulfillment workflow.

What you’ll build

  • Push patients and intakes from your EHR into VitaRelay
  • Receive fulfillment status updates (order shipped, delivered) back in your system
  • Keep patient records in sync

Prerequisites

  • A VitaRelay API key issued by a VitaRelay admin (vr_live_… or vr_test_…) with the write scopes your integration needs
  • An HTTPS URL to receive webhook events, configured for your org by a VitaRelay admin

Step 1 — Create the patient

You don’t need to look up existing patients — POST /patients is idempotent on external_patient_id, so re-sending returns the original patient.
Use your own EHR record id as external_patient_id. A replay with the same id and the same body returns the original record (200 instead of 201); the same id with a different body returns 409 duplicate_request. Store the returned patient id (a UUID) against your local patient record.

Step 2 — Submit the intake

When a prescriber signs the resulting escript, VitaRelay fires intake.reviewed.

Step 3 — Get your webhook endpoint configured

Webhook endpoints are not self-registered through the API. Give your VitaRelay admin the HTTPS URL that should receive events and the events you want (order.paid, order.shipped, order.delivered, order.exception, intake.reviewed). The admin configures it in the dashboard and shows you the signing secret once — store it in your secret manager.

Step 4 — Handle incoming events

In your EHR’s webhook handler:
See Webhook Security for the verification helper.

Flow diagram