import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  BeforeInsert,
} from 'typeorm';
import { randomUUID } from 'crypto';

@Entity('questionnaire_form_data')
export class QuestionnaireFormData {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'uuid', unique: true })
  uuid: string;

  @Column({ type: 'varchar', length: 100 })
  first_name: string;

  @Column({ type: 'varchar', length: 50, nullable: true })
  phone_number: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  ophthalmologist_name: string;

  @Column({ type: 'int', nullable: true })
  age: number;

  @Column({ type: 'varchar', length: 20, nullable: true })
  gender: string;

  @Column({ type: 'date', nullable: true })
  next_injection_date: Date;

  @Column({ type: 'varchar', length: 255, nullable: true })
  medication: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  injection_duration: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  injection_frequency: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  injection_eyes: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  missed_appointment: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  dmla_threat: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  dmla_interference: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  dmla_limitation: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  vision_loss_fear: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  treatment_need: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  close_follow_up_need: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  injection_pain: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  clinic_experience: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  daily_activity_interference: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  financial_affordability: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  appointment_memory: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  injection_problems: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  injection_frequency_practical: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  general_health_limitation: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  transport_problem: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  injection_stress: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  vision_stabilization: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  lesion_minimization: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  daily_activity_effect: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  follow_up_usefulness: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  close_person_vision_loss: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  close_person_injection: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  ophthalmologist_encouragement: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  media_information: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  recent_vision_loss: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  education: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  travel_time: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  insurance_coverage: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  daily_medications: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  vision_impact: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  ophthalmologist_satisfaction: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  clinic_contact_difficulty: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  accompaniment_support: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  mood_impact: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  age_related: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  continuous_follow_up: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  abnormal_vessels: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  irreversible_loss: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  all_patients_need: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  edema_thickness_exam: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  glasses_correction: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  injection_timing: string;

  @Column({ type: 'varchar', length: 255, nullable: true })
  total_vision_recovery: string;

  @Column({ type: 'text', nullable: true })
  additional_comments: string;

  @Column({ type: 'varchar', length: 150, default: '' })
  center: string;

  @CreateDateColumn()
  created_at: Date;

  @UpdateDateColumn()
  updated_at: Date;

  @BeforeInsert()
  generateUuid(): void {
    if (!this.uuid) {
      this.uuid = randomUUID();
    }
  }
}
