package com.jasamedika.medifirst2000.entities;

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 java.util.HashSet;
import java.util.Set;

import static javax.persistence.FetchType.LAZY;

@Getter
@Setter
@Entity
@Table(name = "PasienDaftar_T")
public class PasienDaftar extends BaseTransaction {
	private static final long serialVersionUID = -603798112476936636L;

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

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

	@Caption(value = "Total Biaya")
	@Column(name = "totalBiaya")
	private Double totalBiaya;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectStatusKeluarFk")
	@Caption(value = "Object Status Keluar")
	private StatusKeluar statusKeluar;

	@Column(name = "ObjectStatusKeluarFk", insertable = false, updatable = false)
	private Integer statusKeluarId;

	@Column(name = "statusKasusPenyakit", nullable = false)
	@Caption(value = "Status Kasus Penyakit")
	private Boolean statusKasusPenyakit;

	@Column(name = "IsKajianAwal", nullable = false, length = 100)
	@Caption(value = "Kajian Awal")
	private Boolean isKajianAwal;

	@Column(name = "noRegistrasi", nullable = false, length = 200)
	@NotNull(message = "No Registrasi Harus Diisi")
	@Caption(value = "No registrasi ")
	private String noRegistrasi;

	@NotNull(message = "Is On Site Service tidak boleh kosong")
	@Column(name = "isOnSiteService", nullable = false)
	@Caption(value = "Is On Site Service")
	private Byte isOnSiteService;

	@NotNull(message = "Is Registrasi Lengkap tidak boleh kosong")
	@Column(name = "isRegistrasiLengkap", nullable = false)
	@Caption(value = "Is Registrasi Lengkap")
	private Byte isRegistrasiLengkap;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectKasusPenyakitLastFk")
	@Caption(value = "Object Kasus Penyakit Last")
	private KasusPenyakit kasusPenyakit;

	@Column(name = "ObjectKasusPenyakitLastFk", insertable = false, updatable = false)
	private Integer kasusPenyakitId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectPegawaiFk")
	@Caption(value = "Penanggung Jawab pasien")
	private Pegawai dokterPenanggungJawab;

	@Column(name = "ObjectPegawaiFk", insertable = false, updatable = false)
	private Integer dokterPenanggungJawabId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectKelompokPasienLastFk")
	@NotNull(message = "Kd Kelompok Pasien Last tidak boleh kosong")
	@Caption(value = "Object Kelompok Pasien Last")
	private KelompokPasien kelompokPasien;

	@Column(name = "ObjectKelompokPasienLastFk", insertable = false, updatable = false, nullable = false)
	private Integer kelompokPasienId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectRuanganLastFk")
	@Caption(value = "Object Ruangan Last")
	private Ruangan ruangan;

	@Column(name = "ObjectRuanganLastFk", insertable = false, updatable = false)
	private Integer ruanganId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectRuanganAsalFk")
	@Caption(value = "Object Ruangan Asal")
	private Ruangan ruanganAsal;

	@Column(name = "ObjectRuanganAsalFk", insertable = false, updatable = false)
	private Integer ruanganAsalId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "RuanganNextSchedule")
	@Caption(value = "RuanganNextSchedule")
	private Ruangan ruanganNextSchedule;

	@Column(name = "RuanganNextSchedule", insertable = false, updatable = false)
	private Integer ruanganNextScheduleId;

	@Column(name = "StatusSchedule", length = 40)
	@Caption(value = "StatusSchedule")
	private String statusSchedule;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "NoCMFk")
	@NotNull(message = "No C M Harus Diisi")
	@Caption(value = "No C M")
	private Pasien pasien;

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

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "NoRegistrasiFk")
	@Caption(value = "No Registrasi")
	private PenanggungJawabPasien penanggungJawabPasien;

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

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

	@NotNull(message = "Tgl Registrasi tidak boleh kosong")
	@Column(name = "TglRegistrasi", nullable = false)
	@Caption(value = "Tanggal Registrasi")
	private Date tglRegistrasi;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectStatusPulangFk")
	@Caption(value = "Object Status Pulang")
	private StatusPulang statusPulang;

	@Column(name = "ObjectStatusPulangFk", insertable = false, updatable = false)
	private Integer statusPulangId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectKondisiPasienFk")
	@Caption(value = "Object Kondisi Pasien")
	private KondisiPasien kondisiPasien;

	@Column(name = "ObjectKondisiPasienFk", insertable = false, updatable = false)
	private Integer kondisiPasienId;

	@Column(name = "TglPulang")
	@Caption(value = "Tanggal Pulang")
	private Date tglPulang;

	@Column(name = "TglMeninggal")
	@Caption(value = "Tanggal Meninggal")
	private Date tanggalMeninggal;

	@Column(name = "JenisPelayanan", length = 40)
	@Caption(value = "Jenis Pelayanan")
	private String jenisPelayanan;

	@Column(name = "NamaLengkapAmbilPasien", length = 40)
	@Caption(value = "Nama Lengkap Ambil Pasien")
	private String namaLengkapAmbilPasien;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectHubunganKeluargaAmbilPasienFk")
	@Caption(value = "Object Hubungan Keluarga Ambil Pasien")
	private HubunganKeluarga hubunganKeluarga;

	@Column(name = "ObjectHubunganKeluargaAmbilPasienFk", insertable = false, updatable = false)
	private Integer hubunganKeluargaId;

	@OneToMany(fetch = LAZY, mappedBy = "pasienDaftar")
	private Set<AntrianPasienDiPeriksa> antrianPasienDiPeriksaSet = new HashSet<>();

	@OneToMany(fetch = LAZY, mappedBy = "pasienDaftar")
	private Set<BatalRegistrasi> batalRegistrasiSet = new HashSet<>();

	@OneToMany(fetch = LAZY, mappedBy = "pasienDaftar")
	private Set<DiputuskanDetail> diputuskanDetailSet = new HashSet<>();

	@OneToMany(fetch = LAZY, mappedBy = "pasienDaftar")
	private Set<PemakaianAsuransi> pemakaianAsuransiSet = new HashSet<>();

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectKelasFk")
	@Caption(value = "Object Kelas")
	private Kelas kelas;

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

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectPenyebabKematianFk")
	@Caption(value = "Penyebab Kematian")
	private PenyebabKematian penyebabKematian;

	@Column(name = "ObjectPenyebabKematianFk", insertable = false, updatable = false)
	private Integer penyebabKematianId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectDokterPemeriksaFk")
	@Caption(value = "Dokter Pemeriksa")
	private Pegawai dokterPemeriksa;

	@Column(name = "ObjectDokterPemeriksaFk", insertable = false, updatable = false)
	private Integer dokterPemeriksaId;

	@OneToMany(fetch = LAZY, mappedBy = "pasienDaftar")
	private Set<MapPasienDpjpToPasienDaftar> mapPasienDpjpToPasienDaftar = new HashSet<>();

	@Caption(value = "emergensi")
	@Column(name = "Emergensi")
	private Boolean emergensi;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "NoStrukLastFk")
	@Caption(value = "No Struk Last")
	private StrukPelayanan strukPelayanan;

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

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "NoSbmLastFk")
	@Caption(value = "No SBM Last")
	private StrukBuktiPenerimaan strukBuktiPenerimaan;

	@Column(name = "NoSbmLastFk", insertable = false, updatable = false)
	private String strukBuktiPenerimaanId;

	@Caption(value = "Kode Status Diskon Pegawai")
	@Column(name = "diskonpegawai")
	private Integer diskonPegawai;

	@ManyToOne(fetch = 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 isBatalPaket;

	@ManyToOne(fetch = LAZY)
	@Caption(value = "DPJP")
	@JoinColumn(name = "dpjpfk")
	private DpjpPasien dpjpPasien;
}
