package com.gnx.telemedicine.model;

import com.gnx.telemedicine.model.enums.CriticalityLevel;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;

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

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

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "lab_result_id", nullable = false)
    private LabResult labResult;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "patient_id", nullable = false)
    private Patient patient;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "doctor_id", nullable = false)
    private Doctor doctor;

    @Enumerated(EnumType.STRING)
    @Column(name = "criticality_level", nullable = false)
    private CriticalityLevel criticalityLevel;

    @Column(name = "test_name", nullable = false)
    private String testName;

    @Column(name = "result_value")
    private String resultValue;

    @Column(name = "reference_range")
    private String referenceRange;

    @Column(name = "clinical_significance", columnDefinition = "TEXT")
    private String clinicalSignificance;

    @Column(name = "acknowledgment_required")
    private Boolean acknowledgmentRequired = true;

    @Column(name = "acknowledged")
    private Boolean acknowledged = false;

    @Column(name = "acknowledged_at")
    private Instant acknowledgedAt;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "acknowledged_by")
    private UserModel acknowledgedBy;

    @Column(name = "acknowledgment_method")
    private String acknowledgmentMethod; // CALL, EMAIL, SMS, IN_PERSON

    @Column(name = "follow_up_required")
    private Boolean followUpRequired = true;

    @Column(name = "follow_up_status")
    private String followUpStatus;

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

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

