/**
 * Tipos para o módulo de Agendamentos
 */

export type AppointmentType = "presencial" | "telemedicina";

export type AppointmentStatus =
  | "requested"
  | "confirmed"
  | "checked_in"
  | "in_progress"
  | "completed"
  | "cancelled"
  | "no_show";

export interface Appointment {
  id: string;
  order_number: string; // APT-YYYY-NNNN (auto-gerado)
  patient_id: string;
  doctor_id: string;
  scheduled_at: string;
  duration_minutes: number;
  appointment_type: AppointmentType;
  status: AppointmentStatus;
  chief_complaint: string | null;
  patient_notes: string | null;
  notes: string | null;
  insurance_provider: string | null;
  checked_in_at: string | null;
  completed_at: string | null;
  cancelled_at: string | null;
  cancellation_reason: string | null;
  created_at: string;
  updated_at: string;
  created_by: string;
  updated_by: string | null;
}

export interface CreateAppointmentInput {
  patient_id: string;
  doctor_id: string;
  scheduled_at: string;
  duration_minutes?: number;
  appointment_type?: AppointmentType;
  chief_complaint?: string;
  patient_notes?: string;
  insurance_provider?: string;
  created_by?: string;
}

export interface UpdateAppointmentInput {
  scheduled_at?: string;
  duration_minutes?: number;
  status?: AppointmentStatus;
  chief_complaint?: string;
  notes?: string;
  patient_notes?: string;
  insurance_provider?: string;
  checked_in_at?: string;
  completed_at?: string;
  cancelled_at?: string;
  cancellation_reason?: string;
}

export interface AppointmentFilters {
  doctor_id?: string;
  patient_id?: string;
  status?: AppointmentStatus;
  scheduled_at?: string; // Use com operadores: gte.2025-10-10
  limit?: number;
  offset?: number;
  order?: string;
}

export interface GetAvailableSlotsInput {
  doctor_id: string;
  date: string; // YYYY-MM-DD format
}

export interface TimeSlot {
  time: string; // HH:MM format (e.g., "09:00")
  available: boolean;
}

export interface GetAvailableSlotsResponse {
  slots: TimeSlot[];
}
