package com.jasamedika.medifirst2000.entities;

import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.etl.pasien.constant.StatusMigrasi;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import static com.jasamedika.medifirst2000.etl.pasien.constant.StatusMigrasi.BELUM_KIRIM;
import static javax.persistence.EnumType.STRING;
import static javax.persistence.FetchType.LAZY;

/**
 * @author Salman
 * @version 1.0.0
 * @since 06/11/2023
 */
@Getter
@Setter
@Entity
@Table(name = "migrasipasien_t", uniqueConstraints = @UniqueConstraint(columnNames = "pasienfk"))
public class MigrasiPasien extends BaseTransaction {

	private static final long serialVersionUID = 8936798143770665885L;

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

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

	@Column(length = 30, nullable = false, columnDefinition = "varchar(30) default 'BELUM_KIRIM'")
	@Enumerated(STRING)
	@NotNull(message = "Status migrasi tidak boleh kosong")
	@Size(max = 30, message = "Status migrasi maksimal {max} karakter")
	@Caption(value = "Status Migrasi")
	private StatusMigrasi statusMigrasi = BELUM_KIRIM;

}
