package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonBackReference;
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 java.util.HashSet;
import java.util.Set;

import static javax.persistence.FetchType.LAZY;

@Getter
@Setter
@Entity
@Table(name = "PelayananPasien_T")
public class PelayananPasien extends MedicalRecordTransaction {
	private static final long serialVersionUID = -4641802074402049984L;

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

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

	@Caption(value = "statusOrder")
	@Column(name = "statusOrder")
	private Byte statusOrder;

	@Caption(value = "jasa")
	@Column(name = "jasa")
	private Double jasa;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "KelasFk")
	@Caption(value = "Produk")
	private Kelas kelas;

	@Column(name = "KelasFk", insertable = false, updatable = false)
	private Integer kelasId;

	@Caption(value = "Is Pasien")
	@Column(name = "isPasien")
	private Boolean isPasien;

	@Caption(value = "Is Pasien")
	@Column(name = "isObat")
	private Boolean isObat;

	@Caption(value = "Is Pasien")
	@Column(name = "isDosis")
	private Boolean isDosis;

	@Caption(value = "Is Pasien")
	@Column(name = "isRoute")
	private Boolean isRoute;

	@Caption(value = "Is Pasien")
	@Column(name = "isDokumentasi")
	private Boolean isDokumentasi;

	@Caption(value = "Is Pasien")
	@Column(name = "isWaktu")
	private Boolean isWaktu;

	@Caption(value = "Is Pasien")
	@Column(name = "isInformasi")
	private Boolean isInformasi;

	@Caption(value = "Is Benar")
	@Column(name = "isBenar")
	private Boolean isBenar;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "StrukFk")
	private StrukPelayanan strukPelayanan;

	@Column(name = "StrukFk", nullable = false, insertable = false, updatable = false)
	private String strukFk;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "StrukTerimaFk")
	private StrukPelayanan strukTerima;

	@Column(name = "StrukTerimaFk", insertable = false, updatable = false)
	private String strukTerimaId;

	@Caption(value = "nilaiKonversi")
	@Column(name = "nilaiKonversi")
	private Float nilaiKonversi;

	@Caption(value = "Status")
	@Column(name = "status")
	private String status;

	@Caption(value = "Tanggal Pelayanan")
	@Column(name = "TglPelayanan")
	private Date tglPelayanan;

	@Caption(value = "Harga Satuan")
	@Column(name = "hargaSatuan")
	private Double hargaSatuan;

	@Caption(value = "Harga Jual")
	@Column(name = "HargaJual")
	private Double hargaJual;

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

	@Caption(value = "Piutang Penjamin")
	@Column(name = "piutangPenjamin")
	private Double piutangPenjamin;

	@Caption(value = "Piutang Rumah Sakit")
	@Column(name = "piutangRumahSakit")
	private Double piutangRumahSakit;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "NoBatch")
	@Caption(value = "Struk Order")
	private StrukPelayananDNoBatch noBatch;

	@Column(name = "NoBatch", columnDefinition = "CHAR(32)", insertable = false, updatable = false)
	private String noBatchId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "satuanViewFK")
	@Caption(value = "satuanView")
	private SatuanStandar satuanView;

	@Column(name = "satuanViewFK", insertable = false, updatable = false)
	private Integer satuanViewId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "StrukOrderFk")
	@Caption(value = "Struk Order")
	private StrukOrder strukOrder;

	@Column(name = "StrukOrderFk", columnDefinition = "CHAR(32)", insertable = false, updatable = false)
	private String strukOrderId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "JenisObatFk")
	@Caption(value = "Jenis Obat")
	private JenisObat jenisObat;

	@Column(name = "JenisObatFk", insertable = false, updatable = false)
	private Integer jenisObatId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ProdukFk")
	@NotNull(message = "Produk Harus Diisi")
	@Caption(value = "Produk")
	private Produk produk;

	@Column(name = "ProdukFk", insertable = false, updatable = false)
	private Integer produkId;

	@Column(name = "Stock", nullable = false, length = 100)
	@Caption(value = "Stock")
	private Double stock;

	@Column(name = "Jumlah", nullable = false, length = 100)
	@Caption(value = "Jumlah")
	private Double jumlah;

	@Column(name = "AturanPakai", length = 100)
	@Caption(value = "AturanPakai")
	private String aturanPakai;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "RouteFk")
	@Caption(value = "Route")
	private RouteFarmasi route;

	@Column(name = "RouteFk", insertable = false, updatable = false)
	private Integer routeId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "KeteranganPakaiFk")
	@Caption(value = "Keterangan Pakai")
	private Stigma keteranganPakai;

	@Column(name = "KeteranganPakaiFk", insertable = false, updatable = false)
	private Integer keteranganPakaiId;

	@Column(name = "KeteranganPakai2", length = 100)
	@Caption(value = "KeteranganPakai2")
	private String keteranganPakai2;

	@ManyToOne(fetch = FetchType.LAZY)
	@Caption(value = "Kelompok Transaksi")
	@JoinColumn(name = "KdKelompokTransaksi")
	private KelompokTransaksi kelompokTransaksi;

	@Column(name = "KdKelompokTransaksi", insertable = false, updatable = false)
	private Integer kelompokTransaksiId;

	@Column(name = "KeteranganLain", length = 100)
	@Caption(value = "KeteranganLain")
	private String keteranganLain;

	@Caption(value = "Harga Discount")
	@Column(name = "hargaDiscount")
	private Double hargaDiscount;

	@Caption(value = "hargaNetto")
	@Column(name = "hargaNetto")
	private Double hargaNetto;

	@Caption(value = "dosis")
	@Column(name = "dosis")
	private Float dosis;

	@Caption(value = "NoRecTriger")
	@Column(name = "noRecTriger")
	private String noRecTriger;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "StrukResepFk")
	@Caption(value = "StrukResep")
	private StrukResep strukResep;

	@Column(name = "StrukResepFk", columnDefinition = "CHAR(32)", insertable = false, updatable = false)
	private String strukResepId;

	@ManyToOne(fetch = FetchType.LAZY)
	@Caption(value = "JenisKemasan")
	@JoinColumn(name = "JenisKemasanFK")
	private JenisKemasan jenisKemasan;

	@Column(name = "JenisKemasanFK", insertable = false, updatable = false)
	private Integer jenisKemasanId;

	@Column(name = "rKe")
	@Caption(value = "rKe")
	private String rKe;

	@JsonBackReference
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "pelayananPasien")
	private Set<PelayananPasienPetugas> pelayananPasienPetugasSet = new HashSet<>();

	@JsonBackReference
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "pelayananPasien")
	private Set<RacikanDetail> racikan = new HashSet<>();

	@JsonBackReference
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "pelayananPasien")
	private Set<PelayananPasienDetail> pelayananPasienDetailSet = new HashSet<>();

	@ManyToOne(fetch = FetchType.LAZY)
	@Caption(value = "Sayatan")
	@JoinColumn(name = "sayatan")
	private Sayatan sayatan;

	@Column(name = "sayatan", insertable = false, updatable = false)
	private Integer sayatanId;

	@ManyToOne(fetch = FetchType.LAZY)
	@Caption(value = "Voucher Paket")
	@JoinColumn(name = "voucherpaketfk")
	private VoucherPaket voucherPaket;

	@Column(name = "voucherpaketfk", columnDefinition = "CHAR(32)", insertable = false, updatable = false)
	private String voucherPaketId;

	private Boolean isPaket;

	private Boolean isSelisihPaket;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "aturanpakaifk")
	@Caption(value = "Aturan Pakai")
	private AturanPakai aturanPakaiReguler;

	@Column(name = "aturanpakaifk", columnDefinition = "CHAR(32)", insertable = false, updatable = false)
	private String aturanPakaiRegulerId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "aturanpakaisignafk")
	@Caption(value = "Aturan Pakai Signa")
	private AturanPakaiSigna aturanPakaiSigna;

	@Column(name = "aturanpakaisignafk", columnDefinition = "CHAR(32)", insertable = false, updatable = false)
	private String aturanPakaiSignaId;

	@Column(name = "persendiskonpegawai")
	@Caption(value = "Persentase Diskon Pegawai")
	private Double persenDiskonPegawai;

	@Column(name = "iscito")
	private Boolean isCito;

	@Column(name = "persencito")
	private Double persenCito;

}