package com.jasamedika.medifirst2000.dao;

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

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

import com.jasamedika.medifirst2000.entities.DataPesertaPerusahanYangBekerjaSama;

public interface DataPesertaPerusahanYangBekerjaSamaDao extends PagingAndSortingRepository<DataPesertaPerusahanYangBekerjaSama, String>,
																JpaSpecificationExecutor<DataPesertaPerusahanYangBekerjaSama>{
	
	@Query("select p from DataPesertaPerusahanYangBekerjaSama p where p.dataPerusahaanYangBekerjaSamaId=:noRec")
	public List<DataPesertaPerusahanYangBekerjaSama> getDataPesertaByDataPerusahaan(@Param("noRec") String noRec);

	@Query("select new map ("
			+ "p.dataPerusahaanYangBekerjaSamaId as dataPerusahaanYangBekerjaSamaId,"
			+ "p.namaPeserta as namaPeserta,"
			+ "p.jenisKelaminId as jenisKelaminId,"
			+ "p.jumlahKeluarga as jumlahKeluarga,"
			+ "p.plafonYangDijamin as plafonYangDijamin,"
			+ "p.alamat as alamat,"
			+ "p.noTlp as noTlp,"
			+ "p.noRec as noRec"
			+ ") from DataPesertaPerusahanYangBekerjaSama p "
			+ "where p.dataPerusahaanYangBekerjaSama.rekanan.jenisRekananId = 7 "
			+ "and p.statusEnabled is true")
	public List<Map<String, Object>> getDataPesertaRumahSakitYangBekerjaSama();
	
	@Query("select new map ("
			+ "p.dataPerusahaanYangBekerjaSamaId as dataPerusahaanYangBekerjaSamaId,"
			+ "p.namaPeserta as namaPeserta,"
			+ "p.jenisKelaminId as jenisKelaminId,"
			+ "p.jumlahKeluarga as jumlahKeluarga,"
			+ "p.plafonYangDijamin as plafonYangDijamin,"
			+ "p.alamat as alamat,"
			+ "p.noTlp as noTlp,"
			+ "p.noRec as noRec"
			+ ") from DataPesertaPerusahanYangBekerjaSama p "
			+ "where p.dataPerusahaanYangBekerjaSama.rekanan.jenisRekananId = 2 "
			+ "and p.statusEnabled is true") //Penjamin Pasien
	public List<Map<String, Object>> getDataPesertaAsuransiYangBekerjaSama();
	
	@Query("select new map("
			+ "p.rekananId as rekananId,"
			+ "p.rekanan.namaRekanan as namaRekanan,"
			+ "p.jangkaAwal as jangkaAwal,"
			+ "p.jangkaAkhir as jangkaAkhir,"
			+ "p.noRec as noRec) "
			+ "from DataPerusahaanYangBekerjaSama p "
			+ "where p.rekanan.jenisRekananId = 7"
			+ "and p.statusEnabled is true")
	public List<Map<String, Object>> getDataRumahSakitYangBekerjaSama();
	
	@Query("select new map("
			+ "p.rekananId as rekananId,"
			+ "p.rekanan.namaRekanan as namaRekanan,"
			+ "p.jangkaAwal as jangkaAwal,"
			+ "p.jangkaAkhir as jangkaAkhir,"
			+ "p.noRec as noRec) from DataPerusahaanYangBekerjaSama p "
			+ "where p.rekanan.jenisRekananId = 2"
			+ "and p.statusEnabled is true") //Penjamin Pasien
	public List<Map<String, Object>> getDataAsuransiYangBekerjaSama();

}
