package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
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.util.Date;

import static javax.persistence.CascadeType.ALL;
import static javax.persistence.FetchType.LAZY;

@Getter
@Setter
@Entity
@Table(name = "LkkIdentifikasiKorban_T")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class LkkIdentifikasiKorban extends BaseTransaction {

	@ManyToOne(fetch = LAZY)
	@Caption(value = "LkkIdentifikasiKejadian")
	@JoinColumn(name = "ObjectLkkIdentifikasiKejadianFk")
	private LkkIdentifikasiKejadian lkkIdentifikasiKejadian;

	@Column(name = "ObjectLkkIdentifikasiKejadianFk", insertable = false, updatable = false)
	private String lkkIdentifikasiKejadianId;

	@NotNull(message = "Nama Korban tidak boleh kosong")
	@Caption(value = "Nama Korban")
	@Column(name = "NamaKorban", nullable = false, length = 100)
	private String namaKorban;

	@Caption(value = "N.I Kependudukan")
	@Column(name = "NiKependudukan", length = 50)
	private String niKependudukan;

	@Caption(value = "Tempat Lahir")
	@Column(name = "TempatLahir", length = 50)
	private String tempatLahir;

	@Caption(value = "Tgl Lahir")
	@Column(name = "TglLahir")
	private Date tglLahir;

	@NotNull(message = "Jenis Kelamin tidak boleh kosong")
	@Caption(value = "Jenis Kelamin")
	@Column(name = "JenisKelamin", nullable = false, length = 20)
	private String jenisKelamin;

	@Caption(value = "Status Pekerjaan")
	@Column(name = "StatusPekerjaan")
	private String statusPekerjaan;

	@Caption(value = "Status Jabatan")
	@Column(name = "StatusJabatan")
	private String statusJabatan;

	@ManyToOne(fetch = LAZY)
	@Caption(value = "Unit Ruangan")
	@JoinColumn(name = "ObjectUnitRuanganFk")
	private Ruangan unitRuangan;

	@JsonBackReference
	@OneToOne(cascade = ALL, fetch = LAZY, mappedBy = "lkkIdentifikasiKorban")
	private LkkRencanaTindakLanjut lkkRencanaTindakLanjut;

	@JsonBackReference
	@OneToOne(cascade = ALL, fetch = LAZY, mappedBy = "lkkIdentifikasiKorban")
	private LkkPerkiraanKerugian lkkPerkiraanKerugian;

}
