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

/**
 * @author Shakato
 */
@Repository("SignOutOperationDao")
public interface SignOutOperationDao extends PagingAndSortingRepository<SignOutOperation, String> {
	/*
	 * Add show data to get header and detail
	 * add by iwankasan
	 * date : 27.10.2017
	 */
	@Query("select new map(signOutOperation.noRec as noRec, " +
			" antrian.noRec as noRecAntrian, " +
			" signOutOperation.statusperawatmembicarakantindakan as statusperawatmembicarakantindakan, " +
			" antrian.tglRegistrasi as tglRegistrasi, " +
			" kelas.id as idKelas, kelas.namaKelas as namaKelas, " +
			" ruangan.id as idRuangan, ruangan.namaRuangan as namaRuangan, " +
			" pegawai.id as idPegawai, pegawai.namaLengkap as namaPegawai, " +
			" pasien.jenisKelamin.jenisKelamin as jenisKelamin, " +
			" pasien.namaPasien as namaPasien, " +
			" pasien.noCm as noCm, alamats.alamatLengkap as alamatLengkap) " +
			" from SignOutOperation signOutOperation " +
			" left join signOutOperation.pasienDaftar antrian " +
			" left join antrian.ruangan ruangan " +
			" left join antrian.kelas as kelas " +
			" left join antrian.pegawai pegawai " +
			" left join antrian.pasienDaftar pasienDaftar " +
			" left join pasienDaftar.pasien pasien " +
			" left join pasien.alamats alamats where signOutOperation.noRec=:noRec")
	List<Map<String, Object>> getSignOutByNoRec(@Param("noRec") String noRec);
	
	@Query("select new map(signOutOperation.noRec as noRec, " +
			" antrian.noRec as noRecAntrian, " +
			" signOutOperation.statusperawatmembicarakantindakan as statusperawatmembicarakantindakan, " +
			" antrian.tglRegistrasi as tglRegistrasi, " +
			" kelas.id as idKelas, kelas.namaKelas as namaKelas, " +
			" ruangan.id as idRuangan, ruangan.namaRuangan as namaRuangan, " +
			" pegawai.id as idPegawai, pegawai.namaLengkap as namaPegawai, " +
			" pasien.jenisKelamin.jenisKelamin as jenisKelamin, " +
			" pasien.namaPasien as namaPasien, " +
			" pasien.noCm as noCm, alamats.alamatLengkap as alamatLengkap) " +
			" from SignOutOperation signOutOperation " +
			" left join signOutOperation.pasienDaftar antrian " +
			" left join antrian.ruangan ruangan " +
			" left join antrian.kelas as kelas " +
			" left join antrian.pegawai pegawai " +
			" left join antrian.pasienDaftar pasienDaftar " +
			" left join pasienDaftar.pasien pasien " +
			" left join pasien.alamats alamats where antrian.noRec=:noRec")
	List<Map<String, Object>> getSignOutByNoRecAntrian(@Param("noRec") String noRec);

 	@Query("select new map(cekKelengkapanAlkesDetail.noRec as noRec, " +
 			" cekKelengkapanAlkesDetail.keterangan as keterangan, " +
 			" signOutOperation.noRec as noRecSignOutOperation, " +
 			" cekKelengkapanAlkes.id as idCekKelengkapanAlkes, " +
 			" cekKelengkapanAlkes.name as nameCekKelengkapanAlkes, " +
 			" statusLengkapTidakLengkap.id as idStatusLengkapTidakLengkap, " +
 			" statusLengkapTidakLengkap.name as nameStatusLengkapTidakLengkap) " +
 			" from CekKelengkapanAlkesDetail cekKelengkapanAlkesDetail " +
 			" left join cekKelengkapanAlkesDetail.signOutOperation signOutOperation " +
 			" left join cekKelengkapanAlkesDetail.cekKelengkapanAlkes cekKelengkapanAlkes " +
 			" left join cekKelengkapanAlkesDetail.statusLengkapTidakLengkap statusLengkapTidakLengkap where " +
 			" statusLengkapTidakLengkap.statusEnabled in('true') and signOutOperation.noRec=:noRec")
 	List<Map<String, Object>> getCekKelengkapanalKesDetail(@Param("noRec") String noRec);
 	
 	
 	@Query("select new map(pemeriksaanJaringanCairanTubuhDetail.noRec as noRec, " +
 			" pemeriksaanJaringanCairanTubuhDetail.status as status, " +
 			" pemeriksaanJaringanCairanTubuhDetail.keterangan as keterangan, " +
 			" signOutOperation.noRec as noRecSignOutOperation, " +
 			" pemeriksaanJaringanCairanTubuh.id as idPemeriksaanJaringanCairanTubuh, " +
 			" pemeriksaanJaringanCairanTubuh.name as namePemeriksaanJaringanCairanTubuh) " +
 			" from PemeriksaanJaringanCairanTubuhDetail pemeriksaanJaringanCairanTubuhDetail " +
 			" left join pemeriksaanJaringanCairanTubuhDetail.signOutOperation signOutOperation " +
 			" left join pemeriksaanJaringanCairanTubuhDetail.pemeriksaanJaringanCairanTubuh pemeriksaanJaringanCairanTubuh " +
 			" where pemeriksaanJaringanCairanTubuhDetail.statusEnabled in('true') and signOutOperation.noRec=:noRec")
 	List<Map<String, Object>> getPemeriksaanJaringanCairanTubuhDetail(@Param("noRec") String noRec);

	
}
