package com.jasamedika.medifirst2000.entities;

import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

import static javax.persistence.FetchType.LAZY;

/**
 * @author salmanoe
 * @version 1.0.0
 * @since 15/02/2024
 */
@Getter
@Setter
@Entity
@Table(name = "obattindakan_t")
public class ObatLayananTindakan extends BaseTransaction implements Serializable {

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "tindakanpasienfk", nullable = false)
	@NotNull(message = "Tindakan pasien Tidak boleh Kosong")
	@Caption(value = "Tindakan Pasien")
	private PelayananPasien tindakanPasien;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "obatfk", nullable = false)
	@NotNull(message = "Obat tidak boleh kosong")
	@Caption(value = "Obat")
	private Produk obat;

	@Column(nullable = false, columnDefinition = "numeric(6,2)")
	@NotNull(message = "Jumlah obat tidak boleh kosong")
	private Double jumlahObat;

	@Column(updatable = false, columnDefinition = "timestamp default current_date")
	private Date tanggalDibuat;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "dibuat_pegawai_id")
	@Caption(value = "Dibuat oleh pegawai")
	private Pegawai dibuatOleh;

	@Column(insertable = false)
	private Date tanggalDiubah;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "diubah_pengguna_id")
	@Caption(value = "Diubah oleh pegawai")
	private Pegawai diubahOleh;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ruanganfarmasifk", nullable = false)
	@NotNull(message = "Ruangan farmasi Tidak boleh Kosong")
	@Caption(value = "Ruangan Farmasi")
	private Ruangan ruanganFarmasi;
}
