package com.jasamedika.medifirst2000.dao;

import java.util.List;
import java.util.Map;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.jasamedika.medifirst2000.entities.PegawaiSKAsuransi;

@Repository("PegawaiSKAsuransiDao")
public interface PegawaiSKAsuransiDao extends PagingAndSortingRepository<PegawaiSKAsuransi, Integer>{
	@Query("select new Map(model.id as pegawaiSkAsuransiId,"
			+"suratkeputusan.id as suratKeputusanId,"
			+"suratkeputusan.noSK as noSuratKeputusan,"
			+"suratkeputusan.namaSK as namaSuratKeputusan,"
			+"suratkeputusan.tglBerlakuAwal as tglBerlakuAwal,"
			+"suratkeputusan.tglBerlakuAkhir as tglBerlakuAkhir,"
			+"ruangan.id as ruanganId,"
			+"ruangan.namaRuangan as namaRuangan,"
			+"rekanan.id as rekananPenjaminAsuransiId,"
			+"rekanan.namaRekanan as namaRekananPenjaminAsuransi,"
			+"komponenharga.id as komponenHargaId,"
			+"komponenharga.komponenHarga as namaKomponenHarga,"
			+"model.persenHargaSatuanPremi as persenPremi,"
			+"model.hargaSatuanPremi as hargaSatuanPremi,"
			+"model.factorRate as factorRate,"
			+"model.operatorFactorRate as operatorFactorRatePremi,"
			+"model.totalFactorRatePremi as totalFactorRatePremi,"
			+"model.isByMonth as isByMonth,"
			+"model.isByYear as isByYear"
			+") from PegawaiSKAsuransi model "
			+"left join model.noSK suratkeputusan "
			+"left join suratkeputusan.ruangan ruangan "
			+"left join model.rekanan rekanan "
			+"left join model.komponenHarga komponenharga "
			+ "where model.id =:idPegawaiSkAsuransi")
	Map<String,Object> get(@Param("idPegawaiSkAsuransi") Integer idPegawaiSkAsuransi);
	
	@Query("select new Map(model.id as pegawaiSkAsuransiId,"
		+"suratkeputusan.id as suratKeputusanId,"
		+"suratkeputusan.noSK as noSuratKeputusan,"
		+"suratkeputusan.namaSK as namaSuratKeputusan,"
		+"suratkeputusan.tglBerlakuAwal as tglBerlakuAwal,"
		+"suratkeputusan.tglBerlakuAkhir as tglBerlakuAkhir,"
		+"ruangan.id as ruanganId,"
		+"ruangan.namaRuangan as namaRuangan,"
		+"rekanan.id as rekananPenjaminAsuransiId,"
		+"rekanan.namaRekanan as namaRekananPenjaminAsuransi,"
		+"komponenharga.id as komponenHargaId,"
		+"komponenharga.komponenHarga as namaKomponenHarga,"
		+"model.persenHargaSatuanPremi as persenPremi,"
		+"model.hargaSatuanPremi as hargaSatuanPremi,"
		+"model.factorRate as factorRate,"
		+"model.operatorFactorRate as operatorFactorRatePremi,"
		+"model.totalFactorRatePremi as totalFactorRatePremi,"
		+"model.isByMonth as isByMonth,"
		+"model.isByYear as isByYear,"
		+ "model.statusEnabled as statusEnabled "
		+") from PegawaiSKAsuransi model "
		+"left join model.noSK suratkeputusan "
		+"left join suratkeputusan.ruangan ruangan "
		+"left join model.rekanan rekanan "
		+"left join model.komponenHarga komponenharga")
	List<Map<String,Object>> getAll();

}
