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.DiagnosaTindakans;
import com.jasamedika.medifirst2000.entities.RehabilitasiFormulirKlaim;

@Repository("RehabilitasiFormulirKlaimDao")
public interface RehabilitasiFormulirKlaimDao extends PagingAndSortingRepository<RehabilitasiFormulirKlaim, String> {
	
	@Query("select new map (rehab.anamnesa as anamnesa, "+
			"rehab.anjuran as anjuran, "+
			"rehab.noRec as noRec, "+
			"rehab.evaluasi as evaluasi, "+
			"rehab.hubunganKeluarga as hubunganKeluarga, "+
			"rehab.pemeriksaanFisik as pemeriksaanFisik, "+
			"rehab.pemeriksaanPenunjang as pemeriksaanPenunjang, "+
			"rehab.tglInput as tglInput) "+
			"from RehabilitasiFormulirKlaim rehab "+
			"left join rehab.pasienDaftar antrian "+
			"where antrian.noRec = :noRec")
	List<Map<String,Object>> getListRehabilitasiFormulirKlaim(@Param("noRec") String noRec);
	
	@Query("select new map (rehab.anamnesa as anamnesa, "+
			"rehab.anjuran as anjuran, "+
			"rehab.noRec as noRec, "+
			"rehab.evaluasi as evaluasi, "+
			"rehab.hubunganKeluarga as hubunganKeluarga, "+
			"rehab.pemeriksaanFisik as pemeriksaanFisik, "+
			"rehab.pemeriksaanPenunjang as pemeriksaanPenunjang, "+
			"rehab.tglInput as tglInput) "+
			"from RehabilitasiFormulirKlaim rehab "+
			"left join rehab.pasienDaftar antrian "+
			"where rehab.noRec = :noRec")
	Map<String,Object> getRehabilitasiFormulirKlaim(@Param("noRec") String noRec);
	
	@Query("select new map (diagnosis.namaDiagnosaTindakan as namaDiagnosaTindakan,diagnosis.id as id) from DiagnosaTindakans diagnosa left join diagnosa.diagnosaTindakan diagnosis left join diagnosa.rehabilitasiFormulirKlaim rehab where rehab.noRec = :noRec and "+
			"diagnosa.diagnosisMedis is true")
	List<DiagnosaTindakans> getDiagnosaMedis(@Param("noRec") String noRec);
	
	@Query("select new map ( diagnosis.namaDiagnosaTindakan as namaDiagnosaTindakan,diagnosis.id as id) from DiagnosaTindakans diagnosa left join diagnosa.diagnosaTindakan diagnosis left join diagnosa.rehabilitasiFormulirKlaim rehab where rehab.noRec = :noRec and "+
			"diagnosa.diagnosisFungsi is true")
	List<DiagnosaTindakans> getDiagnosaFungsi(@Param("noRec") String noRec);
	
	@Query("select new map ( diagnosis.namaDiagnosaTindakan as namaDiagnosaTindakan,diagnosis.id as id) from DiagnosaTindakans diagnosa left join diagnosa.diagnosaTindakan diagnosis left join diagnosa.rehabilitasiFormulirKlaim rehab where rehab.noRec = :noRec and "+
			"diagnosa.tataLaksanaKFR is true")
	List<DiagnosaTindakans> getDiagnostataLaksanaKFR(@Param("noRec") String noRec);

}
