/*
 * File: settings.ts
 * Description: Settings and user profile type definitions
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */

// ============================================================================
// USER PROFILE TYPES
// ============================================================================

/**
 * UserProfile Interface
 * 
 * Purpose: Defines the complete user profile structure
 * 
 * Properties:
 * - Personal information (name, contact, demographics)
 * - Professional information (credentials, specialties)
 * - Hospital information (department, role, permissions)
 * - Preferences and settings
 */
export interface UserProfile {
  id: string;
  mrn: string;                    // Medical Record Number
  employeeId: string;             // Hospital Employee ID
  
  // Personal Information
  firstName: string;
  lastName: string;
  middleName?: string;
  email: string;
  phoneNumber: string;
  dateOfBirth: Date;
  gender: 'MALE' | 'FEMALE' | 'OTHER';
  address: Address;
  
  // Professional Information
  credentials: string[];          // MD, PhD, etc.
  specialties: string[];          // Emergency Medicine, Trauma, etc.
  boardCertifications: string[];  // Board certifications
  licenseNumber: string;          // Medical license number
  licenseExpiryDate: Date;
  yearsOfExperience: number;
  
  // Hospital Information
  department: string;             // Emergency Department, etc.
  role: ProfileUserRole;                 // Attending, Resident, etc.
  shiftPreference: 'DAY' | 'NIGHT' | 'FLEXIBLE';
  supervisor?: string;            // Direct supervisor
  permissions: UserPermissions;
  
  // Profile Settings
  profilePicture?: string;        // URL to profile picture
  emergencyContact: EmergencyContact;
  preferences: UserPreferences;
  
  // Metadata
  createdAt: Date;
  updatedAt: Date;
  lastLoginAt: Date;
  isActive: boolean;
}

/**
 * Address Interface
 * 
 * Purpose: Defines address structure for user profile
 */
export interface Address {
  street: string;
  city: string;
  state: string;
  zipCode: string;
  country: string;
}

/**
 * EmergencyContact Interface
 * 
 * Purpose: Defines emergency contact information
 */
export interface EmergencyContact {
  name: string;
  relationship: string;
  phoneNumber: string;
  email?: string;
  address?: Address;
}

/**
 * ProfileUserRole Type
 * 
 * Purpose: Defines different user roles in the hospital system for profile settings
 */
export type ProfileUserRole = 
  | 'ATTENDING_PHYSICIAN'
  | 'RESIDENT_PHYSICIAN'
  | 'FELLOW'
  | 'MEDICAL_STUDENT'
  | 'NURSE_PRACTITIONER'
  | 'PHYSICIAN_ASSISTANT'
  | 'ADMINISTRATOR'
  | 'RESEARCHER';

/**
 * UserPermissions Interface
 * 
 * Purpose: Defines user permissions and access levels
 */
export interface UserPermissions {
  canViewPatients: boolean;
  canEditPatients: boolean;
  canViewReports: boolean;
  canEditReports: boolean;
  canViewAlerts: boolean;
  canAcknowledgeAlerts: boolean;
  canManageUsers: boolean;
  canViewAnalytics: boolean;
  canExportData: boolean;
  canAccessAdminPanel: boolean;
}

// ============================================================================
// USER PREFERENCES TYPES
// ============================================================================

/**
 * UserPreferences Interface
 * 
 * Purpose: Defines user preferences and settings
 */
export interface UserPreferences {
  // Display Preferences
  theme: 'LIGHT' | 'DARK' | 'AUTO';
  fontSize: 'SMALL' | 'MEDIUM' | 'LARGE';
  language: string;               // ISO language code
  timezone: string;               // IANA timezone
  
  // Notification Preferences
  notifications: NotificationPreferences;
  
  // Clinical Preferences
  clinical: ClinicalPreferences;
  
  // Privacy Preferences
  privacy: PrivacyPreferences;
  
  // Accessibility Preferences
  accessibility: AccessibilityPreferences;
}

/**
 * NotificationPreferences Interface
 * 
 * Purpose: Defines notification settings
 */
export interface NotificationPreferences {
  pushNotifications: boolean;
  emailNotifications: boolean;
  smsNotifications: boolean;
  
  // Alert Types
  criticalAlerts: boolean;
  patientUpdates: boolean;
  scanResults: boolean;
  medicationReminders: boolean;
  shiftChanges: boolean;
  systemMaintenance: boolean;
  
  // Timing
  quietHours: {
    enabled: boolean;
    startTime: string;            // HH:MM format
    endTime: string;              // HH:MM format
  };
  
  // Sound and Vibration
  soundEnabled: boolean;
  vibrationEnabled: boolean;
  customSound?: string;           // Custom notification sound
}

/**
 * ClinicalPreferences Interface
 * 
 * Purpose: Defines clinical workflow preferences
 */
export interface ClinicalPreferences {
  // Default Views
  defaultDashboardView: 'LIST' | 'GRID' | 'TIMELINE';
  defaultPatientSort: 'PRIORITY' | 'NAME' | 'ADMISSION_TIME' | 'BED_NUMBER';
  showPatientPhotos: boolean;
  
  // Clinical Alerts
  autoAcknowledgeNonCritical: boolean;
  alertTimeoutMinutes: number;    // Auto-dismiss after X minutes
  
  // Documentation
  autoSaveInterval: number;       // Seconds
  defaultReportTemplate: string;
  enableVoiceNotes: boolean;
  
  // Patient Care
  showAllergiesProminently: boolean;
  showMedicationInteractions: boolean;
  enableClinicalDecisionSupport: boolean;
}

/**
 * PrivacyPreferences Interface
 * 
 * Purpose: Defines privacy and security settings
 */
export interface PrivacyPreferences {
  // Session Management
  sessionTimeoutMinutes: number;
  requireBiometricAuth: boolean;
  autoLockOnBackground: boolean;
  
  // Data Sharing
  allowAnalytics: boolean;
  allowCrashReporting: boolean;
  allowUsageStatistics: boolean;
  
  // Privacy Controls
  showPatientPhotos: boolean;
  enableScreenCapture: boolean;
  enableScreenshot: boolean;
}

/**
 * AccessibilityPreferences Interface
 * 
 * Purpose: Defines accessibility settings
 */
export interface AccessibilityPreferences {
  // Visual
  highContrastMode: boolean;
  reduceMotion: boolean;
  boldText: boolean;
  
  // Audio
  screenReaderEnabled: boolean;
  audioDescriptions: boolean;
  
  // Interaction
  largerTouchTargets: boolean;
  reduceTransparency: boolean;
}

// ============================================================================
// SETTINGS SCREEN TYPES
// ============================================================================

/**
 * SettingsSection Type
 * 
 * Purpose: Defines different sections in the settings screen
 */
export type SettingsSection = 
  | 'PROFILE'
  | 'NOTIFICATIONS'
  | 'CLINICAL'
  | 'PRIVACY'
  | 'ACCESSIBILITY'
  | 'ABOUT'
  | 'HELP'
  | 'LOGOUT';

/**
 * SettingsItem Interface
 * 
 * Purpose: Defines a single settings item
 */
export interface SettingsItem {
  id: string;
  title: string;
  subtitle?: string;
  icon: string;
  type: 'NAVIGATION' | 'TOGGLE' | 'SELECTION' | 'ACTION';
  value?: any;
  onPress?: () => void;
  disabled?: boolean;
  badge?: string;
}

/**
 * SettingsSection Interface
 * 
 * Purpose: Defines a settings section with items
 */
export interface SettingsSectionData {
  id: SettingsSection;
  title: string;
  items: SettingsItem[];
}

// ============================================================================
// PROFILE UPDATE TYPES
// ============================================================================

/**
 * ProfileUpdateData Interface
 * 
 * Purpose: Defines data structure for profile updates
 */
export interface ProfileUpdateData {
  firstName?: string;
  lastName?: string;
  middleName?: string;
  email?: string;
  phoneNumber?: string;
  address?: Partial<Address>;
  emergencyContact?: Partial<EmergencyContact>;
  specialties?: string[];
  boardCertifications?: string[];
  shiftPreference?: 'DAY' | 'NIGHT' | 'FLEXIBLE';
}

/**
 * ProfileUpdateRequest Interface
 * 
 * Purpose: Defines API request for profile updates
 */
export interface ProfileUpdateRequest {
  userId: string;
  updates: ProfileUpdateData;
  reason?: string;                // Reason for update
}

/**
 * ProfileUpdateResponse Interface
 * 
 * Purpose: Defines API response for profile updates
 */
export interface ProfileUpdateResponse {
  success: boolean;
  message: string;
  updatedProfile?: UserProfile;
  errors?: string[];
}

// ============================================================================
// PASSWORD AND SECURITY TYPES
// ============================================================================

/**
 * PasswordChangeRequest Interface
 * 
 * Purpose: Defines password change request
 */
export interface PasswordChangeRequest {
  currentPassword: string;
  newPassword: string;
  confirmPassword: string;
}

/**
 * SecuritySettings Interface
 * 
 * Purpose: Defines security-related settings
 */
export interface SecuritySettings {
  twoFactorEnabled: boolean;
  biometricEnabled: boolean;
  passwordExpiryDays: number;
  failedLoginAttempts: number;
  lastPasswordChange: Date;
  securityQuestions: SecurityQuestion[];
}

/**
 * SecurityQuestion Interface
 * 
 * Purpose: Defines security question structure
 */
export interface SecurityQuestion {
  id: string;
  question: string;
  answer: string;                 // Hashed answer
}

// ============================================================================
// EXPORT TYPES
// ============================================================================

export type {
  UserProfile,
  Address,
  EmergencyContact,
  ProfileUserRole,
  UserPermissions,
  UserPreferences,
  NotificationPreferences,
  ClinicalPreferences,
  PrivacyPreferences,
  AccessibilityPreferences,
  SettingsSection,
  SettingsItem,
  SettingsSectionData,
  ProfileUpdateData,
  ProfileUpdateRequest,
  ProfileUpdateResponse,
  PasswordChangeRequest,
  SecuritySettings,
  SecurityQuestion,
};

/*
 * End of File: settings.ts
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */ 