<?php
// =============================================================
//  GET /api/v1/reference/specialties
//
//  Read-only reference data — see departments.php's header comment for
//  why this stays read-only here (management stays on the desktop app).
// =============================================================

require_once __DIR__ . '/../_bootstrap.php';

if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
    Api::error(405, 'MethodNotAllowed', 'Use GET');
}

api_authenticate();

$result = $conn->query("
    SELECT id, name, description, status
    FROM specialty
    WHERE status = 'Active'
    ORDER BY name
");

Api::success(['specialties' => $result->fetch_all(MYSQLI_ASSOC)]);
