export type ConditionCategory =
  | 'cardiovascular'
  | 'respiratory'
  | 'neurological'
  | 'ophthalmologic'
  | 'musculoskeletal'
  | 'endocrine'
  | 'gastrointestinal'
  | 'dermatological'
  | 'urological'
  | 'reproductive'
  | 'hematological'
  | 'immunological'
  | 'otological';

export type Severity = 'mild' | 'moderate' | 'severe';

export type EventType = 'appointments' | 'prescriptions' | 'labs' | 'vitals' | 'vaccinations' | 'imaging';

export type LabStatus = 'normal' | 'warning' | 'critical';

export interface Patient {
  id: string;
  name: string;
  dateOfBirth: string;
  age: number;
  gender: string;
  bloodType: string;
  height: string;
  weight: string;
}

export interface Condition {
  id: number;
  sourceDiagnosisId?: string;
  code: string;
  name: string;
  category: ConditionCategory;
  position: { x: number; y: number; z: number } | null;
  severity: Severity;
  diagnosedDate: string;
  description: string;
  notes: string;
  bodyRegion?: string;
}

export interface Appointment {
  id: string;
  date: string;
  time: string;
  type: 'appointments';
  doctor: string;
  specialty: string;
  reason: string;
  diagnosis: string;
  treatment: string;
  notes: string;
  severity?: Severity;
}

export interface Medication {
  id: string;
  name: string;
  date: string;
  dosage: string;
  frequency: string;
  type: 'prescriptions';

  //prescribedDate: string;
  prescribedBy: string;
  indication: string;
  sideEffects: string;
  instructions: string;
  refills: number;
  nextRefill: string;
  startDate: string;
  endDate: string;
}

export interface LabTest {
  id: string;
  name: string;
  value: number;
  unit: string;
  range: string;
  status: LabStatus;
}

export interface LabResult {
  id: string;
  date: string;
  time: string;
  type: 'labs';
  orderingPhysician: string;
  testName: string;
  results: LabTest[];
}

export interface ImagingEvent {
  id: string;
  date: string;
  time: string;
  type: 'imaging';
  name: string;
  hospital: string;
  explanation: string;
  imageUrl?: string;
}

export interface VitalSign {
  id: string;
  date: string;
  time: string;
  type: 'vitals';
  bloodPressure: { systolic: number; diastolic: number };
  heartRate: number;
  temperature: number;
  respiratoryRate: number;
  oxygenSaturation: number;
  weight: number;
  bmi: number;
}

export interface TrendDataPoint {
  date: string;
  value: number;
  unit: string;
  status?: LabStatus;
}

export interface HealthMetric {
  id: string;
  name: string;
  type: 'lab' | 'wearable';
  color: string;
  data: TrendDataPoint[];
  unit: string;
}

export interface MedicalData {
  patient: Patient;
  conditions: Condition[];
  appointments: Appointment[];
  medications: Medication[];
  labResults: LabResult[];
  vitals: VitalSign[];
  healthTrends: HealthMetric[];
}

export interface VaccinationEvent {
  id: string;
  date: string;
  time: string;
  type: 'vaccinations';
  name: string;
  administrationPlace: string;
}

export type TimelineEvent = Appointment | Medication | LabResult | VitalSign | VaccinationEvent | ImagingEvent;

// --- Graph Types ---
export interface GraphDataset {
  id: string;
  instanceId?: string;
  name: string;
  type: 'medication' | 'line';
  unit: string;
  color: string;
  data: Array<{
    date: string;
    value: number;
    unit?: string;
    refMin?: number;
    refMax?: number;
  }>;
  lineStyle?: 'solid' | 'dashed' | 'dotted';
  pointStyle?: 'circle' | 'square' | 'none';
  sourceTestIds?: string[];
  // Reference range for normalization
  refMin?: number;
  refMax?: number;
}

// --- Widget Types ---
import {
  Activity,
  Pill,
  TestTube,
  Watch,
  History,
  CalendarDays,
} from 'lucide-react';

export type WidgetType =
  | 'recent-blood-work'
  | 'current-medications'
  | 'vital-signs'
  | 'device-summary'
  | 'recent-history'
  | 'upcoming-schedule';

export interface WidgetDefinition {
  id: WidgetType;
  title: string;
  icon: any;
  color: string; // Tailwind color class prefix (e.g., 'blue', 'red')
}

export const WIDGET_DEFINITIONS: Record<WidgetType, WidgetDefinition> = {
  'recent-blood-work': { id: 'recent-blood-work', title: 'Recent Blood Work', icon: TestTube, color: 'red' },
  'current-medications': { id: 'current-medications', title: 'Current Prescriptions', icon: Pill, color: 'blue' },
  'vital-signs': { id: 'vital-signs', title: 'Vital Signs', icon: Activity, color: 'green' },
  'device-summary': { id: 'device-summary', title: 'Wearable Data', icon: Watch, color: 'teal' },
  'recent-history': { id: 'recent-history', title: 'Recent History', icon: History, color: 'emerald' },
  'upcoming-schedule': { id: 'upcoming-schedule', title: 'Upcoming Schedule', icon: CalendarDays, color: 'indigo' },
};
