> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rxscale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Orders and Prescriptions

> How orders and prescriptions flow through the RxScale system

# Orders and Prescriptions

This page explains the complete lifecycle of an order in RxScale -- from the moment a patient places it to the moment they receive their medication.

## How Orders Flow Through the System

When a patient places an order through your shop, it triggers a series of steps managed by RxScale:

```
Patient places order
        |
        v
   Order created (init)
        |
        v
   Processing started (started)
        |
        v
   Waiting for doctor review
        |
        v
   Doctor approves prescription
        |
        v
   Prescription signed (QES)
        |
        v
   Order sent to pharmacy (waiting for pharmacy)
        |
        v
   Pharmacy processes order
        |
        v
   Order shipped
        |
        v
   Order completed
```

## Order Lifecycle Step by Step

<Steps>
  <Step title="Order created">
    The patient completes a checkout in your shop. An order is created in RxScale with a status of "init". The system validates the order and begins processing.
  </Step>

  <Step title="Processing started">
    The system verifies the order details, checks product availability, and prepares the prescription request for doctor review.
  </Step>

  <Step title="Waiting for doctor">
    The prescription is placed in a doctor's review queue. The doctor reviews the patient's questionnaire responses and medical information.
  </Step>

  <Step title="Doctor decision">
    The doctor either approves, declines, or places the prescription on hold.

    * **Approved** -- The prescription moves to signing.
    * **Declined** -- The order is updated and the patient is notified.
    * **On hold** -- The prescription is paused for additional information.
  </Step>

  <Step title="Prescription signed">
    The doctor electronically signs the prescription using a qualified electronic signature (QES). This makes it legally valid.
  </Step>

  <Step title="Sent to pharmacy">
    The system routes the order to an appropriate pharmacy based on product availability and location.
  </Step>

  <Step title="Pharmacy processing">
    The pharmacy reviews the order, prepares the medication, and ships it to the patient.
  </Step>

  <Step title="Order completed">
    The patient receives their medication and the order is marked as completed.
  </Step>
</Steps>

## Prescription Management

### Prescription Creation

A prescription is created automatically when an order enters the doctor review stage. You do not need to create prescriptions manually -- the system handles this based on the products in the order.

### Prescription Statuses

| Status               | What It Means                                                         |
| -------------------- | --------------------------------------------------------------------- |
| `waiting for doctor` | A doctor has not yet reviewed this prescription.                      |
| `approved`           | The doctor approved the prescription. It will be signed next.         |
| `signed`             | The prescription has been electronically signed and is legally valid. |
| `declined`           | The doctor declined this prescription.                                |
| `ON_HOLD`            | The prescription is on hold for additional review.                    |
| `cancelled`          | The prescription was cancelled.                                       |

For detailed status descriptions, see [Prescription Statuses](/help-center/prescription-statuses).

## Working with Pharmacy Partners

Once a prescription is signed, RxScale handles pharmacy assignment automatically. The system considers:

* **Product availability** -- Whether the pharmacy has the required products in stock.
* **Location** -- Geographic proximity to the patient for faster delivery.
* **Capacity** -- The pharmacy's current workload.

You do not need to manage pharmacy relationships directly. RxScale takes care of routing orders to the right pharmacy.

## Monitoring Orders

You can monitor order progress through:

* **Webhooks** -- Receive real-time notifications when order or prescription statuses change. See [Webhooks and Notifications](/for-telemedicine-providers/webhooks-and-notifications).
* **Management API** -- Query order and prescription details programmatically. See [Management API](/for-telemedicine-providers/management-api).

## Shopify Priority Settings

If your shop uses Shopify, you can pass priority values to RxScale so urgent patients or orders are surfaced ahead of normal-priority work. Use integer values; higher numbers mean higher priority. Missing or invalid values are ignored and the default priority is used.

| Setting          | Shopify location                              | Required key                               | Example value |
| ---------------- | --------------------------------------------- | ------------------------------------------ | ------------- |
| Order priority   | Order additional attribute / custom attribute | `_rxscale_priority`                        | `10`          |
| Patient priority | Customer metafield                            | namespace `custom`, key `rxscale_priority` | `5`           |

Order priority applies to the specific Shopify order. Patient priority is stored on the patient profile and can be reused across the patient's future activity.

<Note>
  Store priority values as plain integers. Values such as `high`, `urgent`, or empty strings are ignored instead of being converted to a priority.
</Note>

## Pharmacy Orders in the API

When you retrieve orders via the Management API, each order includes a `pharmacy_orders` array showing how the order is being fulfilled:

```json theme={null}
{
  "uid": "order-123",
  "status": "started",
  "pharmacy_orders": [
    {
      "uid": "po-456",
      "status": "waiting for pharmacy",
      "external_status": null,
      "name": "PO-A1B2-C3D4",
      "pharmacy": {
        "uid": "pharm-789",
        "display_name": "City Pharmacy"
      },
      "delivery_type": {
        "uid": "dt-001",
        "display_name": "Standard Shipping",
        "identifier": "standard_shipping"
      },
      "created_at": 1712000000,
      "updated_at": 1712000100
    }
  ]
}
```

Each pharmacy order represents a fulfillment attempt by a pharmacy. An order may have multiple pharmacy orders if it was reassigned to a different pharmacy.

<Note>
  `delivery_type` is resolved from the connected shop's fulfillment method (configured per shop), otherwise from the receiving pharmacy's default delivery type. It may be `null` when neither is set, so do not assume a delivery type is always present.
</Note>

### Pharmacy Order Statuses

| Status                 | What It Means                                                   |
| ---------------------- | --------------------------------------------------------------- |
| `init`                 | Pharmacy order has been created but not yet sent.               |
| `waiting for pharmacy` | Order has been sent to the pharmacy and is awaiting processing. |
| `in-progress`          | The pharmacy is actively processing the order.                  |
| `completed`            | The pharmacy has shipped the order.                             |
| `cancelled`            | The pharmacy order was cancelled.                               |

## Related Topics

* [Order Statuses](/help-center/order-statuses) -- Detailed explanation of all order statuses.
* [Prescription Statuses](/help-center/prescription-statuses) -- All prescription statuses and their meanings.
* [Order Lifecycle](/guides/order-lifecycle) -- Technical guide to order status transitions.
