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.PasienDaftar;

@Repository("pasienMeninggalDao")
public interface PasienMeninggalDao extends PagingAndSortingRepository<PasienDaftar, String>{

	@Query("select NEW Map("
			+ "b.id as id, "
			+ "b.namaLengkap as namaDokter) "
			+ "from PegawaiJadwalKerjaDokterD a "
			+ "left join a.pegawai b "
			+ "left join a.ruangan c where c.id=("
			+ "select e.id as ruanganId "
			+ "from RegistrasiPelayananPasien d "
			+ "left join d.ruangan e "
			+ "left join d.pasien f"
			+ " where f.noCm=:noCm)")
	List<Map<String, Object>> getDokterPemeriksa(
			@Param("noCm") String noCm);
	
	@Query("select NEW Map("
			+ "a.id as id, "
			+ "a.kdPenyebabKematian as kdPenyebabKematian, "
			+ "a.penyebabKematian as penyebabKematian) "
			+ "from PenyebabKematian a")
	List<Map<String, Object>> getPenyebabKematian();
}
