{
  "openapi": "3.0.1",
  "info": {
    "title": "RxRelay Public API",
    "description": "Public partner API for clinic-scoped medication catalogs, order submission, order retrieval, and prescriber lookup.",
    "version": "v1"
  },
  "paths": {
    "/v1/orders": {
      "post": {
        "tags": [
          "ExternalOrders"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateOrderRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateOrderRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateOrderRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalCreateOrderResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalCreateOrderResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalCreateOrderResponse"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "patientId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalOrderId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalOrdersListResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalOrdersListResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalOrdersListResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/orders/{orderId}": {
      "get": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalCreateOrderResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalCreateOrderResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalCreateOrderResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/medications": {
      "get": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pharmacyId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalMedicationResponse"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalMedicationResponse"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalMedicationResponse"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/pharmacies": {
      "get": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalPharmacyResponse"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalPharmacyResponse"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalPharmacyResponse"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/prescribers": {
      "get": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PrescriberResponse"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PrescriberResponse"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PrescriberResponse"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/patients/{patientId}/addresses": {
      "get": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "patientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PatientAddressResponse"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PatientAddressResponse"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PatientAddressResponse"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "patientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalPatientAddressRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalPatientAddressRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalPatientAddressRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/patients": {
      "get": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "externalPatientId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientsListResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientsListResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientsListResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreatePatientRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreatePatientRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreatePatientRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/patients/{patientId}": {
      "get": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "patientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "patientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalUpdatePatientRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalUpdatePatientRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalUpdatePatientRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalPatientResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/patients/{patientId}/orders": {
      "get": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "patientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalOrdersListResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalOrdersListResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalOrdersListResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/patients/{patientId}/addresses/{addressId}": {
      "get": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "patientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "addressId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "patientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "addressId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/patients/{patientId}/addresses/{addressId}/default": {
      "post": {
        "tags": [
          "ExternalOrders"
        ],
        "parameters": [
          {
            "name": "patientId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "addressId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "clinicId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "externalClinicId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PatientAddressResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/clinic": {
      "get": {
        "tags": [
          "ExternalProvisioning"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/clinics": {
      "get": {
        "tags": [
          "ExternalProvisioning"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalClinicResponse"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalClinicResponse"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalClinicResponse"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "ExternalProvisioning"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateClinicRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateClinicRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateClinicRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/users": {
      "get": {
        "tags": [
          "ExternalProvisioning"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalClinicUserResponse"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalClinicUserResponse"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalClinicUserResponse"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "ExternalProvisioning"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateUserRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateUserRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateUserRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicUserResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicUserResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicUserResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/clinics/{clinicRef}/users": {
      "get": {
        "tags": [
          "ExternalProvisioning"
        ],
        "parameters": [
          {
            "name": "clinicRef",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalClinicUserResponse"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalClinicUserResponse"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ExternalClinicUserResponse"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "ExternalProvisioning"
        ],
        "parameters": [
          {
            "name": "clinicRef",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateUserRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateUserRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalCreateUserRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicUserResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicUserResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExternalClinicUserResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ExternalClinicResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "externalClinicId": {
            "type": "string",
            "nullable": true
          },
          "address1": {
            "type": "string",
            "nullable": true
          },
          "address2": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "state": {
            "type": "string",
            "nullable": true
          },
          "zip": {
            "type": "string",
            "nullable": true
          },
          "phoneNumber": {
            "type": "string",
            "nullable": true
          },
          "contactEmail": {
            "type": "string",
            "nullable": true
          },
          "isSandboxMode": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "ExternalClinicUserResponse": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "roles": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "npi": {
            "type": "string",
            "nullable": true
          },
          "joinedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "ExternalCreateClinicRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "externalClinicId": {
            "type": "string",
            "nullable": true
          },
          "address1": {
            "type": "string",
            "nullable": true
          },
          "address2": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "state": {
            "type": "string",
            "nullable": true
          },
          "zip": {
            "type": "string",
            "nullable": true
          },
          "phoneNumber": {
            "type": "string",
            "nullable": true
          },
          "contactEmail": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalCreateOrderRequest": {
        "type": "object",
        "properties": {
          "externalOrderId": {
            "type": "string",
            "nullable": true
          },
          "patient": {
            "$ref": "#/components/schemas/ExternalPatientRequest"
          },
          "shippingAddress": {
            "$ref": "#/components/schemas/ExternalShippingAddressRequest"
          },
          "shippingAddressId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "prescriberUserId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "prescriberNpi": {
            "type": "string",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalOrderItemRequest"
            },
            "nullable": true
          },
          "shippingMethod": {
            "type": "string",
            "nullable": true
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number",
                  "format": "double"
                },
                {
                  "type": "boolean"
                }
              ],
              "nullable": true
            },
            "nullable": true
          },
          "clinicId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "externalClinicId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalCreateOrderResponse": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "format": "uuid"
          },
          "externalOrderId": {
            "type": "string",
            "nullable": true
          },
          "patientId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number",
                  "format": "double"
                },
                {
                  "type": "boolean"
                }
              ],
              "nullable": true
            },
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalOrderItemResponse"
            },
            "nullable": true
          },
          "submissions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalOrderSubmissionResponse"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalCreatePatientRequest": {
        "type": "object",
        "properties": {
          "externalPatientId": {
            "type": "string",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "sex": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "defaultAddress": {
            "$ref": "#/components/schemas/ExternalPatientAddressRequest"
          }
        },
        "additionalProperties": false
      },
      "ExternalCreateUserRequest": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "roles": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "npi": {
            "type": "string",
            "nullable": true
          },
          "licenseState": {
            "type": "string",
            "nullable": true
          },
          "licenseNumber": {
            "type": "string",
            "nullable": true
          },
          "deaNumber": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalMedicationResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "strength": {
            "type": "string",
            "nullable": true
          },
          "form": {
            "type": "string",
            "nullable": true
          },
          "pharmacyName": {
            "type": "string",
            "nullable": true
          },
          "pharmacySku": {
            "type": "string",
            "nullable": true
          },
          "ingredients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MedicationIngredientResponse"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalOrderItemRequest": {
        "type": "object",
        "properties": {
          "medicationId": {
            "type": "string",
            "format": "uuid"
          },
          "medicationName": {
            "type": "string",
            "nullable": true
          },
          "quantity": {
            "type": "string",
            "nullable": true
          },
          "directions": {
            "type": "string",
            "nullable": true
          },
          "refills": {
            "type": "integer",
            "format": "int32"
          },
          "externalPrescriptionId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalOrderItemResponse": {
        "type": "object",
        "properties": {
          "orderItemId": {
            "type": "string",
            "format": "uuid"
          },
          "medicationId": {
            "type": "string",
            "format": "uuid"
          },
          "medicationName": {
            "type": "string",
            "nullable": true
          },
          "externalPrescriptionId": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalOrderSubmissionResponse": {
        "type": "object",
        "properties": {
          "submissionId": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "orderItemIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "nullable": true
          },
          "failureReason": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalOrderSummaryResponse": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "format": "uuid"
          },
          "externalOrderId": {
            "type": "string",
            "nullable": true
          },
          "patientId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number",
                  "format": "double"
                },
                {
                  "type": "boolean"
                }
              ],
              "nullable": true
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalOrderWebhookData": {
        "type": "object",
        "properties": {
          "order": {
            "$ref": "#/components/schemas/ExternalCreateOrderResponse"
          }
        },
        "additionalProperties": false
      },
      "ExternalOrderWebhookPayload": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "environment": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/ExternalOrderWebhookData"
          }
        },
        "additionalProperties": false
      },
      "ExternalOrdersListResponse": {
        "type": "object",
        "properties": {
          "orders": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalOrderSummaryResponse"
            },
            "nullable": true
          },
          "total": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "ExternalPatientAddressRequest": {
        "type": "object",
        "properties": {
          "address1": {
            "type": "string",
            "nullable": true
          },
          "address2": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "state": {
            "type": "string",
            "nullable": true
          },
          "zip": {
            "type": "string",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "ExternalPatientRequest": {
        "type": "object",
        "properties": {
          "patientId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "externalPatientId": {
            "type": "string",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "sex": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalPatientResponse": {
        "type": "object",
        "properties": {
          "patientId": {
            "type": "string",
            "format": "uuid"
          },
          "externalPatientId": {
            "type": "string",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "format": "date"
          },
          "sex": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "addresses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PatientAddressResponse"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalPatientsListResponse": {
        "type": "object",
        "properties": {
          "patients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalPatientResponse"
            },
            "nullable": true
          },
          "total": {
            "type": "integer",
            "format": "int32"
          },
          "limit": {
            "type": "integer",
            "format": "int32"
          },
          "offset": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "ExternalPharmacyResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "platform": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalShipmentResponse": {
        "type": "object",
        "properties": {
          "shipmentId": {
            "type": "string",
            "nullable": true
          },
          "carrier": {
            "type": "string",
            "nullable": true
          },
          "trackingNumber": {
            "type": "string",
            "nullable": true
          },
          "trackingUrl": {
            "type": "string",
            "nullable": true
          },
          "orderItemIds": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalShippingAddressRequest": {
        "type": "object",
        "properties": {
          "address1": {
            "type": "string",
            "nullable": true
          },
          "address2": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "state": {
            "type": "string",
            "nullable": true
          },
          "zip": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalTrackingOrderResponse": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "format": "uuid"
          },
          "externalOrderId": {
            "type": "string",
            "nullable": true
          },
          "patientId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number",
                  "format": "double"
                },
                {
                  "type": "boolean"
                }
              ],
              "nullable": true
            },
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalOrderItemResponse"
            },
            "nullable": true
          },
          "shipments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalShipmentResponse"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExternalTrackingWebhookData": {
        "type": "object",
        "properties": {
          "order": {
            "$ref": "#/components/schemas/ExternalTrackingOrderResponse"
          }
        },
        "additionalProperties": false
      },
      "ExternalTrackingWebhookPayload": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "environment": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/ExternalTrackingWebhookData"
          }
        },
        "additionalProperties": false
      },
      "ExternalUpdatePatientRequest": {
        "type": "object",
        "properties": {
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "dateOfBirth": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "sex": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "externalPatientId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "MedicationIngredientResponse": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "concentration": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "unit": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PatientAddressResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "patientId": {
            "type": "string",
            "format": "uuid"
          },
          "address1": {
            "type": "string",
            "nullable": true
          },
          "address2": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "state": {
            "type": "string",
            "nullable": true
          },
          "zip": {
            "type": "string",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean"
          },
          "isActive": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "PrescriberResponse": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "npi": {
            "type": "string",
            "nullable": true
          },
          "licenseState": {
            "type": "string",
            "nullable": true
          },
          "licenseNumber": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    }
  }
}