{
  "openapi": "3.0.1",
  "info": {
    "title": "Prescription Management",
    "description": "This portion of the API provides endpoints for managing prescriptions.",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.ezyvet.com",
      "description": "ezyVet production environment"
    },
    {
      "url": "https://api.trial.ezyvet.com",
      "description": "ezyVet trial environment"
    }
  ],
  "security": [],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://api.ezyvet.com/v1/oauth/access_token",
            "scopes": {
              "read-prescription": "Read prescription resources",
              "read-prescriptionitem": "Read prescription item resources",
              "read-therapeutic": "Read therapeutic resources",
              "write-externalprescription": "Create and update external prescription resources",
              "write-prescription": "Create and update prescription resources",
              "write-prescriptionitem": "Create and update prescription item resources"
            }
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad Request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/BadRequest"
            }
          }
        }
      },
      "InternalError": {
        "description": "Internal error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "500"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "An internal server error occurred"
                },
                "detail": {
                  "type": "string",
                  "example": "An error occured, please contact API support with the id, status and code provided with the response."
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Not Found",
        "content": {
          "text/html": {
            "schema": {
              "type": "string",
              "example": "No input file specified."
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Too Many Requests",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "429"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "Too Many Requests"
                },
                "detail": {
                  "type": "string",
                  "example": "Too Many Requests"
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "messages": {
                  "type": "array",
                  "items": {
                    "properties": {
                      "level": {
                        "type": "string",
                        "example": "error"
                      },
                      "type": {
                        "type": "string",
                        "example": "InvalidRequestException"
                      },
                      "text": {
                        "type": "string",
                        "example": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the \\\"access token\\\" parameter."
                      },
                      "fields": {
                        "type": "array",
                        "example": [],
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "UnprocessableEntity": {
        "description": "Unprocessable Entity",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_5JBMuXC69QQoPpKDFoBow"
                },
                "status": {
                  "type": "string",
                  "example": "422"
                },
                "code": {
                  "type": "string",
                  "example": ""
                },
                "title": {
                  "type": "string",
                  "example": "Unprocessable Entity"
                },
                "detail": {
                  "type": "string",
                  "example": "Unprocessable Entity"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "BadRequest": {
        "description": "Bad Request",
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "properties": {
                "id": {
                  "type": "string",
                  "example": "error_3YLvb0V7eXcHqgGauTjDy"
                },
                "status": {
                  "type": "string",
                  "example": "400"
                },
                "code": {
                  "type": "string",
                  "example": "100001"
                },
                "title": {
                  "type": "string",
                  "example": "The authorization grant type is not supported by the authorization server."
                },
                "detail": {
                  "type": "string",
                  "example": "The authorization grant type is not supported by the authorization server."
                }
              }
            }
          }
        }
      },
      "ExternalPrescriptionPatchRequestv1": {
        "type": "object",
        "properties": {
          "prescription_uid": {
            "type": "string"
          },
          "animal_id": {
            "type": "number"
          },
          "consult_id": {
            "type": "number"
          },
          "contact_id": {
            "type": "number"
          },
          "prescribing_vet_user_id": {
            "type": "number"
          },
          "date_of_prescription": {
            "description": "Depreciated.",
            "deprecated": true,
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ]
          },
          "date_of_lastdispense": {
            "deprecated": true,
            "description": "Depreciated from root - Should be included in the prescriptionitem. Applied only to items that do not have their own `date_of_lastdispense`. Items that already provide `date_of_lastdispense` are not overwritten.",
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ]
          },
          "external_reference": {
            "type": "string"
          },
          "total_price": {
            "type": "number"
          },
          "external_prescription_item_list": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "external_product_name": {
                  "type": "string"
                },
                "external_product_reference": {
                  "type": "string"
                },
                "external_link": {
                  "type": "string"
                },
                "instructions": {
                  "type": "string"
                },
                "price": {
                  "type": "number"
                },
                "qty": {
                  "type": "number",
                  "description": "The quantity dispensed in this specific dispense event — i.e. the amount the pet owner physically receives at this fill."
                },
                "remaining": {
                  "type": "number",
                  "description": "The quantity still authorized to be dispensed against the prescription after this fill."
                },
                "date_of_lastdispense": {
                  "deprecated": true,
                  "description": "The last dispense date of the externally prescribed item in Epoch time.",
                  "example": "1764277366",
                  "oneOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "string"
                    }
                  ]
                },
                "status": {
                  "type": "string",
                  "nullable": true,
                  "enum": [
                    "CANCELLED_DR",
                    "DECLINED_DR",
                    "CANCELLED_CLIENT",
                    "DECLINED_CLIENT",
                    "PENDING",
                    "CURRENT"
                  ],
                  "description": "The status of the prescribed item. Use `CANCELLED` when meds have been dispensed previously and `DECLINED` when no meds have been dispensed, referencing DR or CLIENT based on who made the change. `PENDING` will be auto-assigned when no `date_of_lastdispense` is provided. If no item provides a status, at least one item must provide `date_of_lastdispense`"
                },
                "status_date": {
                  "type": "number",
                  "example": 1764277366,
                  "description": "The date and time the status is set in Epoch time. Required and numeric when status is `DECLINED` or `CANCELLED`."
                }
              },
              "required": [
                "external_product_name",
                "external_product_reference",
                "price",
                "qty"
              ]
            }
          }
        },
        "required": [
          "prescription_uid",
          "animal_id",
          "prescribing_vet_user_id",
          "date_of_lastdispense",
          "external_reference",
          "total_price",
          "external_prescription_item_list"
        ]
      },
      "ExternalPrescriptionPatchResponsev1": {
        "type": "object",
        "properties": {
          "meta": {
            "type": "object",
            "properties": {
              "transaction_id": {
                "type": "string"
              },
              "timestamp": {
                "type": "string"
              }
            },
            "required": [
              "transaction_id",
              "timestamp"
            ]
          },
          "items": {
            "type": "array",
            "items": {}
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "level": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "text": {
                  "type": "string"
                },
                "fields": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "required": [
                "level",
                "type",
                "text",
                "fields"
              ]
            }
          }
        },
        "required": [
          "meta",
          "items",
          "messages"
        ]
      },
      "PrescriptionItemv1": {
        "type": "object",
        "properties": {
          "product_id": {
            "type": "string",
            "description": "Refers to the ID of the Product."
          },
          "qty": {
            "type": "string",
            "description": "The quantity of the product prescribed."
          }
        },
        "required": [
          "product_id",
          "qty"
        ]
      }
    }
  },
  "paths": {
    "/v1/externalprescription": {
      "patch": {
        "summary": "Patch an external prescription",
        "operationId": "update-externalprescription",
        "tags": [
          "External Prescription"
        ],
        "security": [
          {
            "bearerAuth": [
              "write-externalprescription"
            ]
          }
        ],
        "requestBody": {
          "description": "Data to update the external prescription",
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalPrescriptionPatchRequestv1"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPrescriptionPatchResponsev1"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "summary": "Post an external prescription",
        "description": "Create a new external prescription record.",
        "operationId": "create-externalprescription",
        "tags": [
          "External Prescription"
        ],
        "security": [
          {
            "bearerAuth": [
              "write-externalprescription"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "animal_id": {
                    "type": "number"
                  },
                  "consult_id": {
                    "type": "number"
                  },
                  "contact_id": {
                    "type": "number"
                  },
                  "prescribing_vet_user_id": {
                    "type": "number"
                  },
                  "date_of_prescription": {
                    "description": "The prescription date of the External Prescription in Epoch time.",
                    "oneOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      }
                    ]
                  },
                  "date_of_lastdispense": {
                    "deprecated": true,
                    "description": "Depreciated from root - Should be included in the prescriptionitem. Applied only to items that do not have their own `date_of_lastdispense`. Items that already provide `date_of_lastdispense` are not overwritten.",
                    "oneOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      }
                    ]
                  },
                  "external_reference": {
                    "type": "string"
                  },
                  "total_price": {
                    "type": "number"
                  },
                  "external_prescription_item_list": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "external_product_name": {
                          "type": "string"
                        },
                        "external_product_reference": {
                          "type": "string"
                        },
                        "external_link": {
                          "type": "string"
                        },
                        "instructions": {
                          "type": "string"
                        },
                        "date_of_lastdispense": {
                          "deprecated": true,
                          "description": "The last dispense date of the externally prescribed item in Epoch time.",
                          "example": "1764277366",
                          "oneOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "string"
                            }
                          ]
                        },
                        "price": {
                          "type": "number"
                        },
                        "qty": {
                          "type": "number",
                          "description": "The quantity dispensed in this specific dispense event — i.e., the amount the pet owner physically receives at this fill."
                        },
                        "remaining": {
                          "type": "number",
                          "description": "The quantity still authorized to be dispensed against the prescription after this fill."
                        }
                      },
                      "required": [
                        "external_product_name",
                        "external_product_reference",
                        "price",
                        "qty"
                      ]
                    }
                  }
                },
                "required": [
                  "animal_id",
                  "prescribing_vet_user_id",
                  "date_of_prescription",
                  "external_reference",
                  "total_price",
                  "external_prescription_item_list"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {}
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "level": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          },
                          "fields": {
                            "type": "object",
                            "properties": {
                              "prescription_uid": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "summary": "Delete an external prescription",
        "operationId": "delete-externalprescription",
        "tags": [
          "External Prescription"
        ],
        "description": "Deactivates an External Prescription record and the corresponding prescription and prescription items. Third parties can only deactivate external prescriptions that they created.",
        "security": [
          {
            "bearerAuth": [
              "write-externalprescription"
            ]
          }
        ],
        "parameters": [
          {
            "name": "prescription_uid",
            "in": "query",
            "description": "The Uid of the prescription that associates with the External Prescription.",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "transaction_id": {
                          "type": "string"
                        },
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {}
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "level": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          },
                          "fields": {
                            "type": "object",
                            "properties": {
                              "prescription_uid": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/prescription": {
      "post": {
        "summary": "Creates a Prescription",
        "description": "Creates a [`Prescription`](#get-prescription). A [`Prescription`](#get-prescription) contain [`PrescriptionItem`](#get-prescriptionitem)s within the `POST` data, which will result in new [`PrescriptionItem`](/#get-prescriptionitem)s also being created through this endpoint.\n\nPrescriptions created using this endpoint will impact stock levels. External pharmacy/home delivery platforms should use\nthe [`ExternalPrescription`](/#create-externalprescription) endpoint.",
        "operationId": "create-prescription",
        "tags": [
          "Prescription"
        ],
        "security": [
          {
            "bearerAuth": [
              "write-prescription"
            ]
          }
        ],
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "animal_id": {
                    "type": "string",
                    "description": "Refers to the ID of the [`Animal`](#animal)."
                  },
                  "consult_id": {
                    "type": "string",
                    "description": "Refers to the ID of the [`Consult`](#consult) where the [`Prescription`](#prescription) is attached."
                  },
                  "contact_id": {
                    "type": "string",
                    "description": "Refers to the [`Contact`](#contact) ID of the [`Animal`](#animal)."
                  },
                  "prescribing_vet_user_id": {
                    "type": "string",
                    "description": "Refers to the ID of the [`User`](#user) that is prescribing the medication."
                  },
                  "date_of_prescription": {
                    "type": "string",
                    "description": "The epoch time when the [`Prescription`](#prescription) was issued. This is not necessarily when the [`Prescription`](#prescription) record was created."
                  },
                  "prescription_item_list": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "product_id": {
                          "type": "string",
                          "description": "Product ID"
                        },
                        "qty": {
                          "type": "string",
                          "description": "Quantity of the product"
                        }
                      }
                    },
                    "description": "Contains a list of [`PrescriptionItem`](#prescriptionitem) objects."
                  }
                },
                "required": [
                  "animal_id",
                  "prescribing_vet_user_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response with created Prescription",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "prescription": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "description": "The ID number used by the system to uniquely identify a [`Prescription`](#prescription)."
                              },
                              "active": {
                                "type": "string",
                                "description": "If **true**, the [`Prescription`](#prescription) is active and usable in ezyVet."
                              },
                              "created_at": {
                                "type": "string",
                                "description": "The epoch time when the [`Prescription`](#prescription) was created."
                              },
                              "modified_at": {
                                "type": "string",
                                "description": "The epoch time when the [`Prescription`](#prescription) was last modified."
                              },
                              "animal_id": {
                                "type": "string",
                                "description": "Refers to the ID of the [`Animal`](#animal)."
                              },
                              "consult_id": {
                                "type": "string",
                                "description": "Refers to the ID of the [`Consult`](#consult) where the [`Prescription`](#prescription) is attached."
                              },
                              "prescribing_vet_user_id": {
                                "type": "string",
                                "description": "Refers to the ID of the [`User`](#user) that is prescribing the medication."
                              },
                              "date_of_prescription": {
                                "type": "string",
                                "description": "The epoch time when the [`Prescription`](#prescription) was issued. This is not necessarily when the [`Prescription`](#prescription) record was created."
                              },
                              "prescription_item_list": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "description": "Contains a list of [`PrescriptionItem`](#prescriptionitem) IDs."
                              },
                              "contact_id": {
                                "type": "string",
                                "description": "Refers to the [`Contact`](#contact) ID of the [`Animal`](#animal)."
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "get": {
        "summary": "Fetch a list of Prescriptions",
        "operationId": "get-prescription",
        "security": [
          {
            "bearerAuth": [
              "read-prescription"
            ]
          }
        ],
        "tags": [
          "Prescription"
        ],
        "description": "Fetches a list containing Prescriptions (up to 10).",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The ID number used by the system to uniquely identify a Prescription."
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "If true, the Prescription is active and usable in ezyVet."
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the Prescription was created."
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the Prescription was last modified."
          },
          {
            "name": "animal_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The name of the Animal to which the Prescription was issued."
          },
          {
            "name": "consult_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The name of the Consult to which the Prescription was issued."
          },
          {
            "name": "prescribing_vet_user",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The name of the User (a vet) who issued the Prescription."
          },
          {
            "name": "date_of_prescription",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "The epoch time when the Prescription was issued. This is not necessarily when the Prescription record was created."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "prescription": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "animal_id": {
                                "type": "string"
                              },
                              "consult_id": {
                                "type": "string"
                              },
                              "prescribing_vet_user_id": {
                                "type": "string"
                              },
                              "date_of_prescription": {
                                "type": "string"
                              },
                              "prescription_item_list": {
                                "type": "array",
                                "items": {
                                  "type": "number"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/prescription/{id}": {
      "patch": {
        "summary": "Update a Prescription",
        "operationId": "update-prescription",
        "tags": [
          "Prescription"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The ID number used by the system to uniquely identify a Prescription."
          },
          {
            "name": "consult_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Refers to the ID of the Consult where the Prescription is attached."
          },
          {
            "name": "animal_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Refers to the ID of the Animal."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "type": "object",
                "properties": {
                  "animal_id": {
                    "type": "string",
                    "description": "Refers to the ID of the Animal."
                  },
                  "consult_id": {
                    "type": "string",
                    "description": "Refers to the ID of the Consult where the Prescription is attached."
                  },
                  "contact_id": {
                    "type": "string",
                    "description": "Refers to the Contact ID of the Animal."
                  },
                  "prescribing_vet_user_id": {
                    "type": "string",
                    "description": "Refers to the ID of the User that is prescribing the medication."
                  },
                  "date_of_prescription": {
                    "type": "string",
                    "description": "The epoch time when the Prescription was issued."
                  },
                  "prescription_item_list": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/PrescriptionItemv1"
                    },
                    "default": [],
                    "description": "Contains a list of PrescriptionItem objects."
                  }
                },
                "required": [
                  "animal_id",
                  "prescribing_vet_user_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful update",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "prescription": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "description": "The ID number used by the system to uniquely identify a Prescription."
                              },
                              "active": {
                                "type": "string",
                                "description": "If true, the Prescription is active and usable in ezyVet."
                              },
                              "created_at": {
                                "type": "string",
                                "description": "The epoch time when the Prescription was created."
                              },
                              "modified_at": {
                                "type": "string",
                                "description": "The epoch time when the Prescription was last modified."
                              },
                              "animal_id": {
                                "type": "string",
                                "description": "Refers to the ID of the Animal."
                              },
                              "consult_id": {
                                "type": "string",
                                "description": "Refers to the ID of the Consult where the Prescription is attached."
                              },
                              "prescribing_vet_user_id": {
                                "type": "string",
                                "description": "Refers to the ID of the User that is prescribing the medication."
                              },
                              "date_of_prescription": {
                                "type": "string",
                                "description": "The epoch time when the Prescription was issued."
                              },
                              "prescription_item_list": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "default": [],
                                "description": "Contains a list of PrescriptionItem IDs."
                              },
                              "contact_id": {
                                "type": "string",
                                "description": "Refers to the Contact ID of the Animal."
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      },
                      "default": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-prescription"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Delete a Prescription",
        "operationId": "delete-prescription",
        "tags": [
          "Prescription"
        ],
        "description": "Deletes a Prescription. You cannot delete a Prescription if there is a linked Invoice. Remove the linked invoice line first before deleting.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The ID of the Prescription to delete",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "description": "Bearer token for authentication",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful deletion of the Prescription",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_matched": {
                          "type": "number"
                        },
                        "items_processed": {
                          "type": "number"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {}
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-prescription"
            ]
          }
        ]
      }
    },
    "/v1/prescriptionitem": {
      "get": {
        "summary": "Fetches a list of PrescriptionItems",
        "operationId": "get-prescriptionitem",
        "tags": [
          "Prescription Item"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "description": "The ID number used by the system to uniquely identify an PrescriptionItem.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "description": "If true, the PrescriptionItem is active and usable in ezyVet.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "description": "The epoch time when the PrescriptionItem was created.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "description": "The epoch time when the PrescriptionItem was last modified.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "prescription_id",
            "in": "query",
            "description": "Refers to the ID of the Prescription to which the PrescriptionItem belongs.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "description": "Refers to the ID of the Product added to the Prescription as a PrescriptionItem.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "qty",
            "in": "query",
            "description": "The amount of the PrescriptionItem prescribed.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "remaining",
            "in": "query",
            "description": "The amount of the PrescriptionItem remaining from the prescription.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "instructions",
            "in": "query",
            "description": "Instructions on how to use the PrescriptionItem.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date_start",
            "in": "query",
            "description": "The epoch time when the PrescriptionItem must start being taken.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "serial_number",
            "in": "query",
            "description": "The serial number for PrescriptionItem.",
            "schema": {
              "type": "string",
              "nullable": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A list of PrescriptionItems with meta information.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "prescriptionitem": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "prescription_id": {
                                "type": "string"
                              },
                              "product_id": {
                                "type": "string"
                              },
                              "qty": {
                                "type": "string"
                              },
                              "remaining": {
                                "type": "string"
                              },
                              "instructions": {
                                "type": "string"
                              },
                              "date_start": {
                                "type": "string"
                              },
                              "serial_number": {
                                "type": "string",
                                "nullable": true
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-prescriptionitem"
            ]
          }
        ]
      },
      "post": {
        "summary": "Creates a PrescriptionItem",
        "operationId": "create-prescriptionitem",
        "description": "Creates a prescription item for a prescription.\n\nPrescription items created using this endpoint will impact stock levels. External pharmacy/home delivery platforms should use\nthe [`ExternalPrescription`](/#create-externalprescription) endpoint.",
        "tags": [
          "Prescription Item"
        ],
        "security": [
          {
            "bearerAuth": [
              "write-prescriptionitem"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "prescription_id": {
                    "type": "string",
                    "description": "Refers to the ID Prescription to which the PrescriptionItem belongs."
                  },
                  "product_id": {
                    "type": "string",
                    "description": "Refers to the ID Product added to the Prescription as a PrescriptionItem."
                  },
                  "qty": {
                    "type": "string",
                    "description": "The amount of the PrescriptionItem prescribed."
                  },
                  "remaining": {
                    "type": "string",
                    "description": "The amount of the PrescriptionItem remaining from the prescription."
                  },
                  "instructions": {
                    "type": "string",
                    "description": "Instructions on how to use the PrescriptionItem."
                  },
                  "date_start": {
                    "type": "string",
                    "description": "The epoch time when the PrescriptionItem must start being taken."
                  }
                },
                "required": [
                  "prescription_id",
                  "product_id",
                  "qty",
                  "remaining",
                  "date_start"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A JSON object containing the created PrescriptionItem.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "prescriptionitem": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "description": "The ID number used by the system to uniquely identify an PrescriptionItem."
                              },
                              "active": {
                                "type": "string",
                                "description": "If true, the PrescriptionItem is active and usable in ezyVet."
                              },
                              "created_at": {
                                "type": "string",
                                "description": "The epoch time when the PrescriptionItem was created."
                              },
                              "modified_at": {
                                "type": "string",
                                "description": "The epoch time when the PrescriptionItem was last modified."
                              },
                              "prescription_id": {
                                "type": "string"
                              },
                              "product_id": {
                                "type": "string"
                              },
                              "qty": {
                                "type": "string"
                              },
                              "remaining": {
                                "type": "string"
                              },
                              "instructions": {
                                "type": "string"
                              },
                              "date_start": {
                                "type": "string"
                              },
                              "serial_number": {
                                "type": "string",
                                "description": "The serial number for PrescriptionItem."
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/v1/prescriptionitem/{id}": {
      "patch": {
        "summary": "Update a PrescriptionItem",
        "operationId": "update-prescriptionitem",
        "tags": [
          "Prescription Item"
        ],
        "description": "Updates a PrescriptionItem. You cannot update a PrescriptionItem if there is a linked Invoice. Remove the linked invoice line first before updating.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "prescription_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "qty",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "remaining",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "instructions",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date_start",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "serial_number",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "PrescriptionItem data to update",
          "content": {
            "application/merge-patch+json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active": {
                    "type": "string"
                  },
                  "prescription_id": {
                    "type": "string"
                  },
                  "product_id": {
                    "type": "string"
                  },
                  "qty": {
                    "type": "string"
                  },
                  "remaining": {
                    "type": "string"
                  },
                  "instructions": {
                    "type": "string"
                  },
                  "date_start": {
                    "type": "string"
                  },
                  "serial_number": {
                    "type": "string"
                  }
                },
                "required": [
                  "prescription_id",
                  "product_id",
                  "qty",
                  "remaining",
                  "date_start"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "prescriptionitem": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "prescription_id": {
                                "type": "string"
                              },
                              "product_id": {
                                "type": "string"
                              },
                              "qty": {
                                "type": "string"
                              },
                              "remaining": {
                                "type": "string"
                              },
                              "instructions": {
                                "type": "string"
                              },
                              "date_start": {
                                "type": "string"
                              },
                              "serial_number": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "write-prescription"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Deletes a PrescriptionItem",
        "operationId": "delete-prescriptionitem",
        "security": [
          {
            "bearerAuth": [
              "write-prescription"
            ]
          }
        ],
        "tags": [
          "Prescription Item"
        ],
        "description": "Deletes a [`PrescriptionItem`](#prescriptionitem).\n\nYou cannot delete a [`PrescriptionItem`](#prescriptionitem) if there is a linked [`Invoice`](#invoice). Remove the linked invoice line first before deleting.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "ID of the PrescriptionItem to delete",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "authorization",
            "in": "header",
            "description": "Bearer token for authorization",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content. The PrescriptionItem was successfully deleted."
          },
          "403": {
            "description": "Forbidden. Cannot delete the PrescriptionItem if there is a linked Invoice."
          },
          "404": {
            "description": "Not Found. The specified PrescriptionItem ID does not exist."
          }
        }
      }
    },
    "/v1/therapeutic": {
      "get": {
        "summary": "Fetch a Therapeutic list",
        "operationId": "get-therapeutics",
        "tags": [
          "Therapeutic"
        ],
        "description": "Fetches a list containing Therapeutic(s). (up to 10)",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "created_at",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "modified_at",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "default_template_id",
            "in": "query",
            "schema": {
              "type": "string",
              "default": 0
            }
          },
          {
            "name": "department_ids",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "meta": {
                      "type": "object",
                      "properties": {
                        "timestamp": {
                          "type": "string"
                        },
                        "items_page": {
                          "type": "string"
                        },
                        "items_page_total": {
                          "type": "string"
                        },
                        "items_page_size": {
                          "type": "string"
                        },
                        "items_total": {
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "therapeutic": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "active": {
                                "type": "string"
                              },
                              "created_at": {
                                "type": "string"
                              },
                              "modified_at": {
                                "type": "string"
                              },
                              "name": {
                                "type": "string"
                              },
                              "default_template_id": {
                                "type": "string"
                              },
                              "department_ids": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "messages": {
                      "type": "array",
                      "items": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        },
        "security": [
          {
            "bearerAuth": [
              "read-therapeutic"
            ]
          }
        ]
      }
    }
  }
}
