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

@Repository("RehabilitasiAsesmenDao")
public interface RehabilitasiAsesmenDao extends PagingAndSortingRepository<RehabilitasiAsesmen, String> {
	
	@Query("select new map (rehab.aktivitas as aktivitas, "+
			"rehab.beratBadan as beratBadan, "+
			"rehab.diagnosaRehabilitasi as diagnosaRehabilitasi, "+
			"rehab.fungsiDefekasi as fungsiDefekasi, "+
			"rehab.fungsiKomunikasi as fungsiKomunikasi, "+
			"rehab.fungsiMenelan as fungsiMenelan, "+
			"rehab.fungsiMotorik as fungsiMotorik, "+
			"rehab.kardiorespirasi as kardiorespirasi, "+
			"rehab.lingkarKepala as lingkarKepala, "+
			"rehab.pemeriksaanTambahan as pemeriksaanTambahan, "+
			"rehab.protokolTerapi as protokolTerapi, "+
			"rehab.riwayatPenyakitDahulu as riwayatPenyakitDahulu, "+
			"rehab.riwayatPenyakitSekarang as riwayatPenyakitSekarang, "+
			"rehab.sensoriMotor as sensoriMotor, "+
			"rehab.tglInput as tglInput, "+
			"rehab.tinggiBadan as tinggiBadan, "+
			"rehab.noRec as noRec, "+
			"antrian.noRec as norecAntrian, "+
			"pasienDaftar.noRec as noRecPasienDaftar, "+
			"pasien.id as idPasien) "+
			"from RehabilitasiAsesmen rehab "+
			"left join rehab.pasienDaftar antrian "+
			"left join antrian.pasienDaftar pasienDaftar "+
			"left join pasienDaftar.pasien pasien "+
			"where antrian.noRec = :noRec")
	List<Map<String,Object>> getListRehabilitasiAsesmen(@Param("noRec") String noRec);
	
	@Query("select new map (rehab.aktivitas as aktivitas, "+
			"rehab.beratBadan as beratBadan, "+
			"rehab.diagnosaRehabilitasi as diagnosaRehabilitasi, "+
			"rehab.fungsiDefekasi as fungsiDefekasi, "+
			"rehab.fungsiKomunikasi as fungsiKomunikasi, "+
			"rehab.fungsiMenelan as fungsiMenelan, "+
			"rehab.fungsiMotorik as fungsiMotorik, "+
			"rehab.kardiorespirasi as kardiorespirasi, "+
			"rehab.lingkarKepala as lingkarKepala, "+
			"rehab.pemeriksaanTambahan as pemeriksaanTambahan, "+
			"rehab.protokolTerapi as protokolTerapi, "+
			"rehab.riwayatPenyakitDahulu as riwayatPenyakitDahulu, "+
			"rehab.riwayatPenyakitSekarang as riwayatPenyakitSekarang, "+
			"rehab.sensoriMotor as sensoriMotor, "+
			"rehab.tglInput as tglInput, "+
			"rehab.tinggiBadan as tinggiBadan, "+
			"rehab.noRec as noRec, "+
			"antrian.noRec as norecAntrian, "+
			"pasienDaftar.noRec as noRecPasienDaftar, "+
			"pasien.id as idPasien) "+
			"from RehabilitasiAsesmen rehab "+
			"left join rehab.pasienDaftar antrian "+
			"left join antrian.pasienDaftar pasienDaftar "+
			"left join pasienDaftar.pasien pasien "+
			"where rehab.noRec = :noRec")
	Map<String,Object> getRehabilitasiAsesmen(@Param("noRec") String noRec);

}
