package com.jasamedika.medifirst2000.dao;
 

import java.util.Date;
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.StrukVerifikasi;

@Repository("StrukVerifikasiDao")
public interface StrukVerifikasiDao extends PagingAndSortingRepository<StrukVerifikasi, String> {

	@Query("select model from StrukVerifikasi model where model.noRec=:noRec")
	StrukVerifikasi findByNoRecStrukVerifikasi(@Param("noRec") String noRec);
	
	@Query("select new map (loginUser.id as idLoginUser, "+
			"loginUser.namaUser as namaUser, "+
			"pegawai.id as id, "+
			"pegawai.namaLengkap as namaLengkap) "+
			"from StrukVerifikasi strukverifikasi "+
			"left join strukverifikasi.loginUser loginUser "+
			"left join loginUser.pegawai pegawai "+
			"where strukverifikasi.noRec=:noRec")
	Map<String,Object> findStrukVerifikasiByNoRec(@Param("noRec") String noRec);
	
	@Query(" select model.noRec"+
			" from StrukVerifikasi model"+
			" left join model.ruangan ruangan"+
			" where ruangan.id = :idRuangan and model.tglverifikasi = :tglverifikasi")
	public String findNoRecByIdRuanganAndTanggalAndPegawai(@Param("idRuangan") Integer idRuangan,@Param("tglverifikasi") Date tglverifikasi);
}
