package com.jasamedika.medifirst2000.entities;

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

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

/**
 * class DokumenRekamMedis
 * 
 * @author Generator
 */
@Getter
@Setter
@Entity
@Table(name = "DokumenRekamMedis_T")
public class DokumenRekamMedis extends BaseTransaction {

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

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

	@ManyToOne
	@JoinColumn(name = "NoKirimFk")
	@Caption(value = "No Kirim")
	private StrukKirim noKirim;

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

	@ManyToOne
	@JoinColumn(name = "NoTerimaFk")
	@Caption(value = "No Terima")
	private StrukPelayanan noTerima;

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

	@ManyToOne
	@JoinColumn(name = "NoDokumenFk")
	@NotNull(message = "No Dokumen Harus Diisi")
	@Caption(value = "No Dokumen")
	private Dokumen noDokumen;

	@Column(name = "NoDokumenFk", insertable = false, updatable = false)
	private Integer noDokumenId;

	@ManyToOne
	@JoinColumn(name = "RuanganTujuanFk")
	@NotNull(message = "Ruangan Tujuan Harus Diisi")
	@Caption(value = "Ruangan Tujuan")
	private Ruangan ruanganTujuan;

	@Column(name = "RuanganTujuanFk", insertable = false, updatable = false)
	private Integer ruanganTujuanId;

	@ManyToOne
	@JoinColumn(name = "RuanganAsalFk")
	@NotNull(message = "Ruangan Asal Harus Diisi")
	@Caption(value = "Ruangan Asal")
	private Ruangan ruanganAsal;

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

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

	@JsonManagedReference
	@OneToMany(cascade = ALL, fetch = LAZY, mappedBy = "dokumenRekamMedis")
	private Set<MappingKirimDokumenPasien> mapKirimDokumenPasien = new HashSet<>();

	@ManyToOne
	@JoinColumn(name = "NoKirimReturnFk")
	@Caption(value = "No Kirim Return")
	private StrukKirim noKirim_Return;

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

}