package com.gnx.telemedicine.model;

import com.gnx.telemedicine.model.enums.BreachStatus;
import com.gnx.telemedicine.model.enums.BreachType;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.Instant;
import java.time.LocalDate;
import java.util.UUID;

@Getter
@Setter
@Entity
@Table(name = "breach_notifications")
public class BreachNotification {
    @Id
    @GeneratedValue(strategy = GenerationType.UUID)
    @Column(name = "id")
    private UUID id;

    @Column(name = "incident_date", nullable = false)
    private LocalDate incidentDate;

    @Column(name = "discovery_date", nullable = false)
    private LocalDate discoveryDate;

    @Enumerated(EnumType.STRING)
    @Column(name = "breach_type", nullable = false)
    private BreachType breachType;

    @Column(name = "affected_patients_count")
    private Integer affectedPatientsCount;

    @Column(name = "description", nullable = false, columnDefinition = "TEXT")
    private String description;

    @Column(name = "mitigation_steps", columnDefinition = "TEXT")
    private String mitigationSteps;

    @Column(name = "notified_at")
    private Instant notifiedAt;

    @Enumerated(EnumType.STRING)
    @Column(name = "status")
    private BreachStatus status = BreachStatus.INVESTIGATING;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "created_by", nullable = false)
    private UserModel createdBy;

    @Column(name = "created_at", nullable = false, updatable = false)
    private Instant createdAt = Instant.now();

    @UpdateTimestamp
    @Column(name = "updated_at", nullable = false)
    private Instant updatedAt = Instant.now();
}

