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

@Repository("PapCatatanDao")
public interface PapCatatanDao extends PagingAndSortingRepository<PapCatatan, String> {

	@Query("select NEW Map ("
			+ "a.noRec as noRec,"
			+ "a.isNilai as isNilai,"
			+ "a.lainLain as lainLain,"
			+ "b.noRec as noRegistrasi, "
			+ "c.id as id) "
			+ "from PapCatatan a "
			+ "left join a.antrianPasienDiPeriksa b "
			+ "left join a.rujukan c "
			+ "where b.noRec=:noRec ")
	List<Map<String, Object>> findAllByNoRec(
			@Param("noRec") String noRec);
	
	@Query("select NEW Map ("
			+ "a.id as id, "
			+ "a.catatan as catatan) "
			+ "from Catatan a where a.id=:id")
	Map<String, Object> getCatatanMaster(
			@Param("id") Integer id);
	
	@Query("select NEW Map ("
			+ "a.noRec as noRec) "
			+ "from AntrianPasienDiPeriksa a "
			+ "where a.noRec=:noRec")
	Map<String, Object> getNoRegistrasi(
			@Param("noRec") String noRec);
}
