package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.base.BaseMasterProduk;
import com.jasamedika.medifirst2000.helper.Caption;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import static javax.persistence.FetchType.LAZY;

/**
 * class Produk
 * 
 * @author Generator
 */
@Getter
@Setter
@Entity
@NoArgsConstructor
@Table(name = "Produk_M")
public class Produk extends BaseMasterProduk {
	public Produk(String kdProduk, String namaProduk, Integer id, SatuanStandar satuanStandar) {
		super();
		this.satuanStandar = satuanStandar;
		this.kdProduk = kdProduk;
		this.namaProduk = namaProduk;
		this.id = id;

	}

	public Produk(String kdProduk, String namaProduk, Integer id, SatuanStandar satuanStandar, Generik generik) {
		super();
		this.satuanStandar = satuanStandar;
		this.kdProduk = kdProduk;
		this.namaProduk = namaProduk;
		this.id = id;
		this.generik = generik;
	}

	public Produk(String kdProduk, String namaProduk, Integer id) {
		super();

		this.kdProduk = kdProduk;
		this.namaProduk = namaProduk;
		this.id = id;
	}

	public Produk(String kdProduk, String namaProduk, Integer id, BahanSample bahanSample) {
		super();

		this.kdProduk = kdProduk;
		this.bahanSample = bahanSample;
		this.namaProduk = namaProduk;
		this.id = id;
	}

	public Produk(String kdProduk, String namaProduk, Integer id, BahanSample bahanSample, String keterangan) {
		super();

		this.kdProduk = kdProduk;
		this.bahanSample = bahanSample;
		this.namaProduk = namaProduk;
		this.id = id;
		this.keterangan = keterangan;
	}

	@JsonBackReference
	@OneToMany(cascade = CascadeType.ALL, fetch = LAZY, mappedBy = "produk")
	private Set<ProdukDetailLaboratorium> produkDetail = new HashSet<>();

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "BahanSampleFk")
	@Caption(value = "Bahan Sample")
	private BahanSample bahanSample;

	@Column(name = "BahanSampleFk", insertable = false, updatable = false)
	private Integer bahanSampleId;

	@Caption(value = "Deskripsi Produk")
	@Column(name = "DeskripsiProduk", length = 300)
	private String deskripsiProduk;

	@Caption(value = "Is Produk Intern")
	@Column(name = "isProdukIntern")
	private Byte isProdukIntern;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectAccountFk")
	@Caption(value = "Object Account")
	private ChartOfAccount account;

	@Column(name = "ObjectAccountFk", insertable = false, updatable = false)
	private Integer accountId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectBahanProdukFk")
	@Caption(value = "Object Bahan Produk")
	private BahanProduk bahanProduk;

	@Column(name = "ObjectBahanProdukFk", insertable = false, updatable = false)
	private Integer bahanProdukId;

	@Caption(value = "Keterangan")
	@Column(name = "Keterangan", length = 50)
	private String keterangan;
	@Caption(value = "Kode Barcode")
	@Column(name = "KdBarcode", length = 50)
	private String kdBarcode;

	@ManyToOne(fetch = LAZY)
	@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
	@JoinColumn(name = "ObjectBentukProdukFk")
	@Caption(value = "Object Bentuk Produk")
	private BentukProduk bentukProduk;

	@Column(name = "ObjectBentukProdukFk", insertable = false, updatable = false)
	private Integer bentukProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectDepartemenFk")
	@Caption(value = "Object Departemen")
	private Departemen departemen;

	@Column(name = "ObjectDepartemenFk", insertable = false, updatable = false)
	private Integer departemenId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectDetailGolonganProdukFk")
	@Caption(value = "Object Detail Golongan Produk")
	private DetailGolonganProduk detailGolonganProduk;

	@Column(name = "ObjectDetailGolonganProdukFk", insertable = false, updatable = false)
	private Integer detailGolonganProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectDetailJenisProdukFk")
	@Caption(value = "Object Detail Jenis Produk")
	private DetailJenisProduk detailJenisProduk;

	@Column(name = "ObjectDetailJenisProdukFk", insertable = false, updatable = false)
	private Integer detailJenisProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectFungsiProdukFk")
	@Caption(value = "Object Fungsi Produk")
	private FungsiProduk fungsiProduk;

	@Column(name = "ObjectFungsiProdukFk", insertable = false, updatable = false)
	private Integer fungsiProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectGolonganProdukFk")
	@Caption(value = "Object Golongan Produk")
	private GolonganProduk golonganProduk;

	@Column(name = "ObjectGolonganProdukFk", insertable = false, updatable = false)
	private Integer golonganProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectGProdukFk")
	@Caption(value = "Object G Produk")
	private GeneralProduk gProduk;

	@Column(name = "ObjectGProdukFk", insertable = false, updatable = false)
	private Integer gProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectJenisPeriksaPenunjangFk")
	@Caption(value = "Object JenisPeriksaPenunjang")
	private JenisPeriksaPenunjang jenisPeriksaPenunjang;

	@Column(name = "ObjectJenisPeriksaPenunjangFk", insertable = false, updatable = false)
	private Integer jenisPeriksaPenunjangId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectKategoryProdukFk")
	@Caption(value = "Object Kategory Produk")
	private KategoryProduk kategoryProduk;

	@Column(name = "ObjectKategoryProdukFk", insertable = false, updatable = false)
	private Integer kategoryProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectLevelProdukFk")
	@Caption(value = "Object Level Produk")
	private LevelProduk levelProduk;

	@Column(name = "ObjectLevelProdukFk", insertable = false, updatable = false)
	private Integer levelProdukId;

	@Caption(value = "Kode Produk")
	@Column(name = "KdProduk", length = 6)
	private String kdProduk;

	@Caption(value = "Spesifikasi")
	@Column(name = "Spesifikasi", length = 1000)
	private String spesifikasi;

	@Caption(value = "KodeBMN")
	@Column(name = "KodeBMN", length = 25)
	private String kodeBmn;

	@Caption(value = "Kode Produk Intern")
	@Column(name = "KdProdukIntern", length = 15)
	private String kdProdukIntern;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectProdusenProdukFk")
	@Caption(value = "Object Produsen Produk")
	private ProdusenProduk produsenProduk;

	@Column(name = "ObjectProdusenProdukFk", insertable = false, updatable = false)
	private Integer produsenProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectSatuanBesarFk")
	@Caption(value = "Object Satuan Besar")
	private SatuanBesar satuanBesar;

	@Column(name = "ObjectSatuanBesarFk", insertable = false, updatable = false)
	private Integer satuanBesarId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectSatuanKecilFk")
	@Caption(value = "Object Satuan Kecil")
	private SatuanKecil satuanKecil;

	@Column(name = "ObjectSatuanKecilFk", insertable = false, updatable = false)
	private Integer satuanKecilId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectSatuanStandarFk")
	@Caption(value = "Object Satuan Standar")
	private SatuanStandar satuanStandar;

	@Column(name = "ObjectSatuanStandarFk", insertable = false, updatable = false)
	private Integer satuanStandarId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectStatusProdukFk")
	@Caption(value = "Object Status Produk")
	private StatusProduk statusProduk;

	@Column(name = "ObjectStatusProdukFk", insertable = false, updatable = false)
	private Integer statusProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectTypeProdukFk")
	@Caption(value = "Object Type Produk")
	private TypeProduk typeProduk;

	@Column(name = "ObjectTypeProdukFk", insertable = false, updatable = false)
	private Integer typeProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectUnitLaporanFk")
	@Caption(value = "Object Unit Laporan")
	private UnitLaporan unitLaporan;

	@Column(name = "ObjectUnitLaporanFk", insertable = false, updatable = false)
	private Integer unitLaporanId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectWarnaProdukFk")
	@Caption(value = "Object Warna Produk")
	private WarnaProduk warnaProduk;

	@Column(name = "ObjectWarnaProdukFk", insertable = false, updatable = false)
	private Integer warnaProdukId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectKelompokProdukBPJSFk")
	@Caption(value = "Object KelompokProdukBPJS")
	private KelompokProdukBPJS kelompokProdukBPJS;

	@Column(name = "ObjectKelompokProdukBPJSFk", insertable = false, updatable = false)
	private Integer kelompokProdukBPJSId;

	@Caption(value = "Kekuatan")
	@Column(name = "Kekuatan", length = 20)
	private String kekuatan;

	@Caption(value = "Nama Produk")
	@Column(name = "NamaProduk", length = 150)
	private String namaProduk;

	@Caption(value = "Nilai Normal")
	@Column(name = "NilaiNormal")
	private Short nilaiNormal;

	@Caption(value = "QProduk")
	@Column(name = "QProduk")
	private Integer qProduk;

	@Caption(value = "Qty Jual Terkecil")
	@Column(name = "QtyJualTerkecil")
	private Double qtyJualTerkecil;

	@Caption(value = "Qty Kalori")
	@Column(name = "QtyKalori")
	private Double qtyKalori;

	@Caption(value = "Qty Karbohidrat")
	@Column(name = "QtyKarbohidrat")
	private Double qtyKarbohidrat;

	@Caption(value = "Qty Lemak")
	@Column(name = "QtyLemak")
	private Double qtyLemak;

	@Caption(value = "Qty Porsi")
	@Column(name = "QtyPorsi")
	private Double qtyPorsi;

	@Caption(value = "Qty Protein")
	@Column(name = "QtyProtein")
	private Double qtyProtein;

	@Caption(value = "Qty Satu Kemasan")
	@Column(name = "QtySatuKemasan")
	private Integer qtySatuKemasan;

	@Caption(value = "Qty Terkecil")
	@Column(name = "QtyTerkecil")
	private Double qtyTerkecil;

	@Caption(value = "Tanggal Produksi")
	@Column(name = "TglProduksi", insertable = false, updatable = false)
	private Date tglProduksi;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectGenerikFk")
	@Caption(value = "Object Generik")
	private Generik generik;

	@Column(name = "ObjectGenerikFk", insertable = false, updatable = false)
	private Integer generikId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectSediaanFk")
	@Caption(value = "Object Sediaan")
	private Sediaan sediaan;

	@Column(name = "ObjectSediaanFk", insertable = false, updatable = false)
	private Integer sediaanId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectDetailObatFk")
	@Caption(value = "Object Detail Obat")
	private DetailObat detailObat;

	@Column(name = "ObjectDetailObatFk", insertable = false, updatable = false)
	private Integer detailObatId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectStatusBarangFk")
	@Caption(value = "Object Detail Obat")
	private StatusBarang statusBarang;

	@Column(name = "ObjectStatusBarangFk", insertable = false, updatable = false)
	private Integer statusBarangId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectRekananFk")
	@Caption(value = "Object Rekanan")
	private Rekanan rekanan;

	@Column(name = "ObjectRekananFk", insertable = false, updatable = false)
	private Integer rekananId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectMerkProdukFk")
	@Caption(value = "Object Merk Produk")
	private MerkProduk merkProduk;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "golonganDarahFk")
	@Caption(value = "Golongan Darah")
	private GolonganDarah golonganDarah;

	@Column(name = "GolonganDarahFk", insertable = false, updatable = false)
	private Integer golonganDarahId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "rhesusFk")
	@Caption(value = "Rhesus")
	private Rhesus rhesus;

	@Column(name = "RhesusFk", insertable = false, updatable = false)
	private Integer rhesusId;

	@Column(name = "ObjectMerkProdukFk", insertable = false, updatable = false)
	private Integer merkProdukId;

	// add by Arya
	@Caption(value = "Status")
	@Column(name = "Status")
	private String status;

	@Column(name = "verifikasiAnggaran")
	private Boolean verifikasiAnggaran;

	// add by susy

	@Column(name = "isnarkotika")
	private Boolean isNarkotika;

	@Column(name = "ispsikotropika")
	private Boolean isPsikotropika;

	@Column(name = "kode_kptl")
	private String kptl;
}