Skip to main content
GET
/
patients
/
search
curl -X GET "/patients/search?uid=doctor_uid_123&query=john" \
  -H "Authorization: Bearer your_jwt_token_here"
{
  "success": true,
  "data": [
    {
      "_id": "65f8a1b2c3d4e5f6789012ab",
      "doctor_id": "doctor_uid_123",
      "firstName": "John",
      "lastName": "Doe",
      "dateOfBirth": "1985-06-15",
      "address": {
        "street": "123 Main St",
        "city": "New York",
        "state": "NY",
        "zipCode": "10001"
      },
      "insurance": {
        "provider": "Blue Cross",
        "policyNumber": "BC123456"
      },
      "medicalHistory": "No significant medical history",
      "currentMedications": "None",
      "contact": {
        "phone": "+1234567890",
        "email": "[email protected]"
      }
    }
  ]
}

Overview

Search for patients by first name or last name within the current doctor’s patient list. If no search query is provided, returns all patients for the doctor.

Authentication

Authorization
string
required
Bearer token for authenticated access
Authorization: Bearer your_jwt_token_here

Query Parameters

uid
string
required
Doctor’s user ID (validated by authentication middleware)
query
string
Search query to filter patients by first name or last name (case-insensitive). If not provided, returns all patients for the doctor.

Response

success
boolean
Whether the request was successful
data
array
Array of patient objects matching the search criteria (limited to 10 results when searching)
error
string
Error message (only present when success is false)

Example Requests

curl -X GET "/patients/search?uid=doctor_uid_123&query=john" \
  -H "Authorization: Bearer your_jwt_token_here"
curl -X GET "/patients/search?uid=doctor_uid_123" \
  -H "Authorization: Bearer your_jwt_token_here"

Example Response

{
  "success": true,
  "data": [
    {
      "_id": "65f8a1b2c3d4e5f6789012ab",
      "doctor_id": "doctor_uid_123",
      "firstName": "John",
      "lastName": "Doe",
      "dateOfBirth": "1985-06-15",
      "address": {
        "street": "123 Main St",
        "city": "New York",
        "state": "NY",
        "zipCode": "10001"
      },
      "insurance": {
        "provider": "Blue Cross",
        "policyNumber": "BC123456"
      },
      "medicalHistory": "No significant medical history",
      "currentMedications": "None",
      "contact": {
        "phone": "+1234567890",
        "email": "[email protected]"
      }
    }
  ]
}

Error Responses

{
  "success": false,
  "error": "Doctor UID is missing or was not validated."
}
{
  "success": false,
  "error": "Failed to search patients"
}