// API Types for Normogen Backend

// Base Types
export interface ApiResponse<T> {
  data?: T;
  error?: string;
  message?: string;
}

export interface PaginatedResponse<T> {
  items: T[];
  total: number;
  page: number;
  pageSize: number;
}

// Authentication Types
export interface User {
  user_id: string;
  username: string;
  email: string;
  role: 'patient' | 'provider' | 'admin';
  profile_id?: string;
  created_at?: string;
  updated_at?: string;
}

export interface Claims {
  sub: string;
  username: string;
  email: string;
  role: string;
  exp: number;
  iat: number;
}

export interface AuthTokens {
  token: string;
  user_id: string;
  username: string;
}

export interface LoginRequest {
  email: string;
  password: string;
}

export interface RegisterRequest {
  username: string;
  email: string;
  password: string;
  role?: 'patient' | 'provider' | 'admin';
}

// Medication Types
export enum PillSize {
  Tiny = 'tiny',
  ExtraSmall = 'extra_small',
  Small = 'small',
  Medium = 'medium',
  Large = 'large',
  ExtraLarge = 'extra_large',
  Custom = 'custom'
}

export enum PillShape {
  Round = 'round',
  Oval = 'oval',
  Oblong = 'oblong',
  Capsule = 'capsule',
  Tablet = 'tablet',
  OvalCaplet = 'oval_caplet',
  OvalScored = 'oval_scored',
  RoundScored = 'round_scored',
  Rectangular = 'rectangular',
  Square = 'square',
  Triangular = 'triangular',
  Diamond = 'diamond',
  Hexagonal = 'hexagonal',
  Octagonal = 'octagonal',
  Other = 'other'
}

export enum PillColor {
  White = 'white',
  Blue = 'blue',
  Red = 'red',
  Yellow = 'yellow',
  Green = 'green',
  Orange = 'orange',
  Purple = 'purple',
  Pink = 'pink',
  Brown = 'brown',
  Gray = 'gray',
  Black = 'black',
  Beige = 'beige',
  Clear = 'clear',
  MultiColor = 'multi_color',
  Other = 'other'
}

export interface PillIdentification {
  size?: PillSize;
  shape?: PillShape;
  color?: PillColor;
  custom_size?: string;
  custom_shape?: string;
  custom_color?: string;
}

export interface Medication {
  medication_id?: string;
  user_id: string;
  name: string;
  dosage: string;
  frequency: string;
  start_date?: string;
  end_date?: string;
  instructions?: string;
  active: boolean;
  pill_identification?: PillIdentification;
  created_at?: string;
  updated_at?: string;
}

export interface CreateMedicationRequest {
  name: string;
  dosage: string;
  frequency: string;
  start_date?: string;
  end_date?: string;
  instructions?: string;
  pill_identification?: PillIdentification;
}

export interface UpdateMedicationRequest {
  name?: string;
  dosage?: string;
  frequency?: string;
  start_date?: string;
  end_date?: string;
  instructions?: string;
  active?: boolean;
  pill_identification?: PillIdentification;
}

// Drug Interaction Types (Phase 2.8)
export enum InteractionSeverity {
  Mild = 'mild',
  Moderate = 'moderate',
  Severe = 'severe',
  Unknown = 'unknown'
}

export interface DrugInteraction {
  medications: string[];
  severity: InteractionSeverity;
  description: string;
  disclaimer: string;
}

export interface CheckInteractionRequest {
  medications: string[];
}

export interface CheckNewMedicationRequest {
  name: string;
  dosage: string;
}

// Health Statistics Types
export enum HealthStatType {
  Weight = 'weight',
  Height = 'height',
  BloodPressure = 'blood_pressure',
  HeartRate = 'heart_rate',
  BloodSugar = 'blood_sugar',
  Temperature = 'temperature',
  OxygenSaturation = 'oxygen_saturation',
  Cholesterol = 'cholesterol',
  Other = 'other'
}

export interface HealthStat {
  stat_id?: string;
  user_id: string;
  stat_type: HealthStatType;
  value: number;
  unit: string;
  measured_at: string;
  notes?: string;
  created_at?: string;
  updated_at?: string;
}

export interface CreateHealthStatRequest {
  stat_type: HealthStatType;
  value: number;
  unit: string;
  measured_at: string;
  notes?: string;
}

export interface TrendData {
  stat_type: HealthStatType;
  average: number;
  min: number;
  max: number;
  trend: 'up' | 'down' | 'stable';
  data_points: HealthStat[];
}

// Lab Results Types
export interface LabResult {
  lab_id?: string;
  user_id: string;
  test_name: string;
  test_type: string;
  result_value: string;
  reference_range?: string;
  is_abnormal: boolean;
  test_date: string;
  notes?: string;
  created_at?: string;
}

// Dose Log Types
export interface DoseLog {
  log_id?: string;
  medication_id: string;
  scheduled_time: string;
  taken_time?: string;
  status: 'scheduled' | 'taken' | 'skipped' | 'missed';
  notes?: string;
}

// Error Types
export interface ApiError {
  message: string;
  code?: string;
  details?: any;
}
