package com.jasamedika.medifirst2000.dao;

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

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

import com.jasamedika.medifirst2000.entities.StrukPelayananPenjamin;

@Repository("StrukPelayananPenjaminDao")
public interface StrukPelayananPenjaminDao extends JpaRepository<StrukPelayananPenjamin, String> {
		
	@Query("select new Map(p.id as id, p.nipPns AS NIP, p.namaLengkap AS namaLengkap, mapPegawai.jabatan.namaJabatan AS jabatan) "
			+ "from MapPegawaiJabatanToUnitKerja mapPegawai left join mapPegawai.pegawai p "
			+ "where mapPegawai.isPrimary is true and mapPegawai.statusEnabled is true and p.id in (select cast(sdf.nilaiField as int) from SettingDataFixed sdf where sdf.namaField like '%VerifikasiPelayananPenjamin%')")
	public List<Map<String, Object>> findPegawaiVerikatorStrukPelayananPenjamin();
	
	// untuk surat pernyataan
	@Query("select new Map(spp.totalBiaya as jumlahBiaya, "
			+ "spp.totalSudahDibayar as telahDibayar, "
			+ "spp.totalSisaHarusDibayar as sisaYangBelumDibayar) from StrukPelayananPenjamin spp "
			+ "join spp.noStruk sp "
			+ "join sp.noregistrasi pd "
			+ "where pd.noRegistrasi=:noRegistrasi")
	Map<String, Object> findOneByNoRegistrasi(@Param("noRegistrasi") String noRegistrasi);
	
}
