/*
 * File: src/main/java/reports/model/sales/Prescriptions.java
 * Description: This model represents the Prescriptions entity, capturing details
 * related to medical prescriptions. It includes relationships with patients and doctors
 * and tracks prescription items associated with each prescription. The model stores
 * metadata such as creation, update, and deletion timestamps.
 */

package com.nebula.erp.reports.model.sales;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import jakarta.persistence.*;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Data
@Entity
@Table(name = "prescriptions")
@Setter
@Getter
public class Prescriptions {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false)
    private String patient_id;

    @Column(nullable = false)
    private String doctor_id;

    @Column(nullable = false)
    private String encounter_id;

    @Column(nullable = false)
    private String custom_encounter_id;

    @Column(nullable = false)
    private Date date;

    private String created_by;

    private String tenant;

    @OneToMany(mappedBy = "prescription", cascade = CascadeType.ALL, orphanRemoval = true)
    @JsonManagedReference
    private List<PrescriptionItem> prescription_items;

    private LocalDateTime created_at = LocalDateTime.now();
    private LocalDateTime updated_at = LocalDateTime.now();
    private LocalDateTime deleted_at = null;

}