{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/affinityrx-com/json-schema/affinityrx-com-order-search-schema.json",
  "title": "OrderSearch",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/affinityrx-com-openapi.json#/components/schemas/OrderSearch",
  "type": "object",
  "properties": {
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100,
      "description": "Maximum records per page, from 1 to 100. Defaults to 25.",
      "default": 25
    },
    "startingAfter": {
      "type": "string",
      "maxLength": 2048,
      "description": "Page forward using the previous response's nextCursor. Keep the same filters, sort, organization and mode."
    },
    "externalOrderId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "description": "Match the external order ID exactly, including case. Combine with practiceId when your platform reuses IDs across practices."
    },
    "updatedAfter": {
      "type": "string",
      "format": "date-time",
      "description": "Return orders whose updatedAt is strictly later than this ISO 8601 timestamp. Sorting stays by creation time and ID unless sort is supplied. Keep this cutoff unchanged while paging."
    },
    "patientId": {
      "type": "string",
      "pattern": "^pat_[0-7][0-9a-hjkmnp-tv-z]{25}$",
      "description": "Limit results to the patient with this pat_ ID."
    },
    "practiceId": {
      "type": "string",
      "pattern": "^prac_[0-7][0-9a-hjkmnp-tv-z]{25}$",
      "description": "Limit results to the practice with this prac_ ID, within your authorized practices."
    },
    "query": {
      "type": "string",
      "maxLength": 120,
      "description": "Search saved order snapshots and tracking numbers: patient names, email, phone, date of birth (1985-03-02, 03/02/1985, 3/2/1985 or 03021985) and external ID; order external ID; prescriber name and NPI; medication names and brands; pharmacy name; each shipment's tracking number. Whole ord_ and pat_ IDs and six-character order numbers also match. Text matches ignore case and allow substrings, word prefixes and similar spellings for alphanumeric words of four or more characters. Every word containing letters or numbers must match, so each word narrows the list; punctuation-only words are ignored. An empty or punctuation-only query leaves the list unfiltered. Separate strength fields, practice names, prac_ IDs and rx_ IDs are not searched. Restart pagination when filters change."
    },
    "status": {
      "type": "string",
      "enum": [
        "awaiting_approval",
        "submitted",
        "processing",
        "shipped",
        "delivered",
        "cancelled",
        "failed"
      ],
      "description": "Return only orders with this status. Omit to include all statuses."
    },
    "cancelRequested": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "true returns only submitted or processing orders with a cancel the pharmacy has not confirmed yet (cancelRequestedAt set). false leaves those orders out. Omit to include both. Null counts as omitted."
    },
    "recentlyShipped": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "true returns only orders whose status is shipped and that shipped in the last 60 days; delivered orders are excluded. false leaves those orders out. Omit to include both. Null counts as omitted."
    },
    "sort": {
      "type": "string",
      "enum": [
        "patient",
        "patient_desc",
        "created",
        "created_desc"
      ],
      "description": "patient sorts the lowercase text firstName + space + lastName A to Z, then order ID; created sorts oldest first. A _desc suffix reverses the order. Defaults to created_desc. Restart pagination after changing sort."
    }
  },
  "additionalProperties": false
}