package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.base.BaseMaster;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

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

import static javax.persistence.FetchType.LAZY;
import static javax.persistence.GenerationType.SEQUENCE;

@Getter
@Setter
@Entity
@Table(name = "Diagnosa_M")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class Diagnosa extends BaseMaster {

	@NotNull(message = "Kd Diagnosa tidak boleh kosong")
	@Column(name = "KdDiagnosa", nullable = false, length = 10)
	@Caption(value = "Kode Diagnosa")
	private String kdDiagnosa;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectJenisKelaminFk")
	@Caption(value = "Object Jenis Kelamin")
	private JenisKelamin jenisKelamin;

	@Column(name = "ObjectJenisKelaminFk", insertable = false, updatable = false)
	private Integer jenisKelaminId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectKategoryDiagnosaFk")
	@Caption(value = "Object Kategory Diagnosa")
	private KategoryDiagnosa kategoryDiagnosa;

	@Column(name = "ObjectKategoryDiagnosaFk", insertable = false, updatable = false)
	private Integer kategoryDiagnosaId;

	@NotNull(message = "Nama Diagnosa tidak boleh kosong")
	@Column(name = "NamaDiagnosa", nullable = false, length = 150)
	@Caption(value = "Nama Diagnosa")
	private String namaDiagnosa;

	@NotNull(message = "QDiagnosa tidak boleh kosong")
	@Column(name = "QDiagnosa", nullable = false)
	@Caption(value = "QDiagnosa")
	private Integer qDiagnosa;

	@Id
	@GeneratedValue(strategy = SEQUENCE, generator = "public.diagnosa_m_id_seq")
	@SequenceGenerator(name = "public.diagnosa_m_id_seq", sequenceName = "public.diagnosa_m_id_seq", allocationSize = 1)
	@Column(name = "id")
	protected Integer id;

}