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 java.util.Set;

import static javax.persistence.FetchType.EAGER;
import static javax.persistence.FetchType.LAZY;
import static javax.persistence.TemporalType.DATE;

/**
 * @author salmanoe
 * @version 1.0.0
 * @since 12/06/2024
 */
@Getter
@Setter
@Entity
@Table(name = "persiapanoperasi_t")
public class PersiapanOperasi extends BaseTransaction implements Serializable {
	private static final long serialVersionUID = 4059228362398801137L;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "nocmfk")
	@NotNull(message = "Pasien tidak boleh kosong")
	@Caption(value = "Pasien")
	private Pasien pasien;

	@Column(name = "nocmfk", insertable = false, updatable = false, nullable = false)
	private Integer pasienId;

	@ElementCollection(fetch = EAGER)
	@CollectionTable(name = "diagnosispersiapan_t", joinColumns = @JoinColumn(name = "persiapantindakanoperasifk"))
	@Column(name = "diagnosis", length = 150)
	private Set<String> diagnosa;

	@ElementCollection(fetch = EAGER)
	@CollectionTable(name = "jenistindakanpersiapan_t", joinColumns = @JoinColumn(name = "persiapantindakanoperasifk"))
	@Column(name = "jenistindakan", length = 150)
	private Set<String> jenisTindakan;

	@Column(name = "tglrencanatindakan", nullable = false)
	@NotNull(message = "Tanggal rencana tindakan tidak boleh kosong")
	@Temporal(DATE)
	private Date tanggalRencanaTindakan;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "dpjpfk")
	@NotNull(message = "DPJP tidak boleh kosong")
	@Caption(value = "DPJP")
	private Pegawai dpjp;

	@Column(name = "dpjpfk", insertable = false, updatable = false, nullable = false)
	private Integer dpjpId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ruanganfk")
	@NotNull(message = "Ruangan tidak boleh kosong")
	@Caption(value = "Ruangan")
	private Ruangan ruangan;

	@Column(name = "ruanganfk", insertable = false, updatable = false, nullable = false)
	private Integer ruanganId;
}
