Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/FlasheyEstudi/Oasis-Liquido/llms.txt

Use this file to discover all available pages before exploring further.

Oasis Express is the home delivery arm of Oasis Liquido. Patients can convert any pharmacy purchase — including prescription fulfilments — into a delivery order. A driver is dispatched from the pharmacy, and both the patient and the pharmacy manager can follow the driver’s GPS position on a live map until the medicines arrive at the door. Every GPS waypoint the driver broadcasts is persisted in the DeliveryRoute model, giving a full breadcrumb trail for each order.

How Oasis Express works

1

Patient places an order

When checking out from a pharmacy, the patient sets is_delivery: true in the CreateSaleRequest and provides a delivery address with GPS coordinates. The sale is created and a linked DeliveryOrder is generated automatically with status pending.
2

Pharmacy prepares the order

The pharmacy manager reviews the incoming order in the Gestión de Pedidos screen, confirms the items are in stock, and packages them for collection.
3

Driver is assigned

The pharmacy manager (or system) calls PATCH /api/v1/delivery-orders/{id}/assign with a driver_id. The status advances to assigned and the driver receives a notification.
4

Driver picks up the package

The driver collects the order from the pharmacy and updates the status to picked_up, optionally broadcasting their current GPS coordinates.
5

Live GPS tracking in transit

As the driver travels, the app sends PATCH /api/v1/delivery-orders/{id}/status calls with updated current_lat and current_lng. Each broadcast creates a new DeliveryRoute waypoint and moves the pin on the patient’s live map view. Status is in_transit.
6

Delivery confirmed

On arrival, the driver marks the order delivered. A timestamp is recorded and the patient receives a confirmation. The full route breadcrumb is now queryable via GET /api/v1/delivery-orders/{id}/route.

Delivery status lifecycle

StatusWho sets itMeaning
pendingSystem (on sale creation)Order placed, no driver assigned yet
assignedPharmacy managerDriver accepted and confirmed
picked_upDriverPackage collected from pharmacy
in_transitDriver (GPS updates)En route to delivery address
deliveredDriverOrder received by patient
cancelledPatient, pharmacy, or adminOrder will not be fulfilled
export type DeliveryStatus =
  | 'pending'
  | 'assigned'
  | 'picked_up'
  | 'in_transit'
  | 'delivered'
  | 'cancelled';

DeliveryOrder fields

The DeliveryOrder record links the sale, the pharmacy, the driver, and both GPS endpoints.
export interface DeliveryOrder {
  id: string;
  pharmacy_id: string;           // Source pharmacy for this order
  patient_id?: string;           // Patient who placed the order
  delivery_driver_id?: string;   // Assigned driver (set on assign)
  status: DeliveryStatus;
  delivery_address: string;      // Human-readable delivery address
  delivery_lat: number;          // Patient's delivery latitude
  delivery_lng: number;          // Patient's delivery longitude
  pickup_address?: string;       // Pharmacy address (auto-populated)
  pickup_lat?: number;           // Pharmacy latitude
  pickup_lng?: number;           // Pharmacy longitude
  order_date: string;            // ISO datetime of order creation
  delivered_at?: string;         // ISO datetime of confirmed delivery
  notes?: string;                // Optional delivery instructions
  // Expanded relations (when requested)
  pharmacy?: Pharmacy;
  patient?: User;
  driver?: User;
  items?: DeliveryOrderItem[];
}

Creating a delivery order

Delivery orders are created implicitly when a sale is submitted with is_delivery: true. Call POST /api/v1/pharmacies/{pharmacyId}/sales.
export interface CreateSaleRequest {
  items: SaleItemRequest[];      // Medicines and quantities being purchased
  patient_id?: string;           // UUID of the patient (optional for walk-in)
  prescription_id?: string;      // Link to an active prescription if applicable
  is_delivery: boolean;          // Set to true to trigger a DeliveryOrder
  delivery_address?: string;     // Required when is_delivery is true
  delivery_lat?: number;         // Required when is_delivery is true
  delivery_lng?: number;         // Required when is_delivery is true
  notes?: string;                // Delivery instructions for the driver
}
Example: prescription-linked delivery order
{
  "items": [
    { "medicine_id": "clx2j4k0e0002abcdmnop", "quantity": 30, "unit_price": 25.50 }
  ],
  "patient_id": "clx2j4k0e0000abcd1234efgh",
  "prescription_id": "clx2j4k0e0004abcduvwx",
  "is_delivery": true,
  "delivery_address": "Reparto San Juan, Calle Los Robles 47, Managua",
  "delivery_lat": 12.1095,
  "delivery_lng": -86.2814,
  "notes": "Leave with the doorman if not home"
}
delivery_address, delivery_lat, and delivery_lng are required when is_delivery is true. The backend returns a 400 error if they are missing.

GPS waypoints and route replay

Every status update the driver sends with GPS coordinates is stored as a DeliveryRoute record.
// Schema: delivery_routes table
// deliveryOrderId  String  — parent order
// driverLat        Float   — latitude at moment of broadcast
// driverLng        Float   — longitude at moment of broadcast
// recordedAt       DateTime — server-side timestamp
Retrieve the complete route after delivery with:
GET /api/v1/delivery-orders/{id}/route
The response includes the total distance (metres), estimated duration (seconds), and the encoded geometry for rendering on MapLibre GL.
export interface DeliveryRoute {
  distance_meters: number;  // Total route length
  duration_seconds: number; // Estimated or actual travel time
  geometry: string;         // Encoded polyline or GeoJSON geometry
}

Assigning a driver

PATCH /api/v1/delivery-orders/{id}/assign
export interface AssignDriverRequest {
  driver_id: string; // UUID of an available delivery driver
}
Only pharmacy managers and admins can assign drivers. The driver must have is_available: true in their profile.
Reassigning a driver after the order is already picked_up or later will be rejected. Cancel and recreate the order if logistics need to change at that stage.

Filtering delivery orders

GET /api/v1/delivery-orders
Query parameterTypeDescription
statusDeliveryStatusFilter by current status
driver_idstringOrders assigned to a specific driver
pharmacy_idstringOrders originating from a specific pharmacy
date_fromstring (ISO date)Orders placed on or after this date
pagenumberPage number (default: 1)
limitnumberResults per page (default: 20)
Role scoping applies: patients see only their own orders, drivers see only their assigned orders, pharmacy managers see orders from their pharmacy, and admins see all.

Delivery orders API

Full endpoint reference for creating, assigning, and tracking delivery orders

Delivery driver role

How drivers receive assignments and broadcast GPS position updates

Build docs developers (and LLMs) love