Prescription Pharmacy Delivery Error

Fires when TelegraMD fails to transmit a prescription to the pharmacy. The failure detail is carried in eventData.error, and targetEntity is the Order. The eventType is prescription_pharmacy_delivery_error.

Field guarantees

FieldGuarantee
eventData.error⚠️ Conditional — present, but a raw pass-through; the internal {message, code} shape is not guaranteed
reason in v2✅ Always present — sanitized string on the PRESCRIPTION/PHARMACY allowlist; derived from eventData.error or eventDescription when safe, otherwise "Unable to send prescription to the pharmacy"
📘

v2 failure reasons are sanitized. v2 payloads always include a top-level reason string derived from eventData.error or eventDescription when available and safe to forward. Raw integration error objects and internal implementation details are never forwarded — system errors and missing sources fall back to "Unable to send prescription to the pharmacy".

v1 payload (legacy)

The full raw event document. The failure reason is in eventData.error (a pass-through of the pharmacy integration's response) and also as free text in eventDescription. ownerEntity is the full patient document (contains PHI); targetEntity is the full order.

{
  "ownerEntityModel": "Patient",
  "targetEntityModel": "Order",
  "deleted": false,
  "ownerEntity": { "id": "pat::74cb56c2-xxxx-xxxx-xxxx-aa85f3ba2727", "firstName": "<PATIENT_FIRST_NAME>", "lastName": "<PATIENT_LAST_NAME>", "email": "<PATIENT_EMAIL>", "…": "full patient document" },
  "targetEntity": {
    "status": "started",
    "patient": "pat::74cb56c2-xxxx-xxxx-xxxx-aa85f3ba2727",
    "affiliate": "aff::c1636be3-xxxx-xxxx-xxxx-9dddc26e77b3",
    "id": "order::b6b288b5-xxxx-xxxx-xxxx-074dcdbfc4b2"
  },
  "eventTitle": "Error Sending Prescription To The Pharmacy",
  "eventDescription": "Unable to send to the pharmacy for the following reason: Pharmacy API returned a validation error",
  "eventType": "prescription_pharmacy_delivery_error",
  "eventData": {
    "error": {
      "message": "Pharmacy API returned a validation error",
      "code": "INVALID_PRESCRIPTION_DATA"
    }
  },
  "createdAt": "2023-06-12T22:00:18.680Z",
  "updatedAt": "2023-06-12T22:00:18.680Z",
  "__v": 0,
  "id": "event::7a2b9c4d-xxxx-xxxx-xxxx-2f9e8b7a6c5d"
}
eventData fieldTypeAlways?Notes
errorobject | string⚠️Raw pass-through of the pharmacy integration's response. Often {message, code}, but the shape depends on the integration — treat it defensively

v2 payload

Sanitized envelope. The raw error object is stripped; reason is always included, falling back to "Unable to send prescription to the pharmacy" when eventData.error and eventDescription are unavailable or unsafe to forward.

{
  "event_type": "prescription_pharmacy_delivery_error",
  "event_id": "event::7a2b9c4d-xxxx-xxxx-xxxx-2f9e8b7a6c5d",
  "api_version": "2026-08-09",
  "timestamp": "2026-05-30T14:00:00.000Z",
  "affiliate_id": "aff::c1636be3-xxxx-xxxx-xxxx-9dddc26e77b3",
  "patient_id": "pat::74cb56c2-xxxx-xxxx-xxxx-aa85f3ba2727",
  "patient_external_id": "ext-patient-123",
  "patient_marketing_consent": false,
  "is_returning_patient": false,
  "order_id": "order::b6b288b5-xxxx-xxxx-xxxx-074dcdbfc4b2",
  "order_status": "started",
  "reason": "Unable to send prescription to the pharmacy"
}
FieldDelivered in v2Notes
Envelope + patient identityPresent on every v2 payload
order_id, order_statusResolved from the target order
reasonSanitized failure reason — generic fallback when eventData.error and eventDescription are unavailable or unsafe
Raw error objectStripped — objects are never forwarded in v2