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

/**
 * Repository class for PenghitunganKassaDanAlatOperasi
 * 
 */
@Repository("PenghitunganKassaDanAlatOperasiDao")
public interface PenghitunganKassaDanAlatOperasiDao extends PagingAndSortingRepository<PenghitunganKassaDanAlatOperasi, Integer> {
	
	@Query("select new map(a.noRec as noRec) " +
		 " from PenghitunganKassaDanAlatOperasi a " +
		 " left join a.pasienDaftar antrian " +
		 " where a.statusEnabled in ('true') and antrian.noRec=:noRec")
	List<Map<String, Object>> getListHitKassa(@Param("noRec") String noRec);
	
	@Query("select new map(a.noRec as noRec, " +
			" a.statusEnabled as statusEnabled) " +
			" from PenghitunganKassaDanAlatOperasi a " +
			" where a.statusEnabled in ('true') and a.noRec=:noRec")
	List<Map<String, Object>> getHitKassaByNoRec(@Param("noRec") String noRec);
	
	@Query("select new map(a.noRec as noRec, " +
			" a.kuantitas as kuantitas, " +
			" a.keterngan as keterngan, " +
			" a.statusEnabled as statusEnabled, " +
			" a.tambah1 as tambah1, " +
			" a.tambah2 as tambah2, " +
			" a.tambah3 as tambah3, " +
			" a.tambah4 as tambah4, " +
			" a.tambah5 as tambah5, " +
			" a.tambah6 as tambah6, " +
			" a.tambah7 as tambah7, " +
			" b.noRec as noRecHitKassa, " +
			" c.id as idProduk, " +
			" c.namaProduk as namaProduk) " +
			" from DetailAlatYangDigunakan a " +
			" left join a.penghitunganKassaDanAlatOperasi b " +
			" left join a.produk c where " +
			" a.statusEnabled in ('true') and b.noRec=:noRec")
	List<Map<String, Object>> getDetailAlatYangDigunakanByNoRec(@Param("noRec") String noRec);
	
	@Query("select new map(a.noRec as noRec, " +
			" a.kondisiSterilisasi as kondisiSterilisasi, " +
			" a.load as load, " +
			" a.tanggalSteril as tanggalSteril, " +
			" a.statusEnabled as statusEnabled, " +
			" a.ahliBedah.id as idAhliBedah, " +
			" a.ahliBedah.namaLengkap as nameAhliBedah, " +
			" a.asisten.id as idAsisten, " +
			" a.asisten.namaLengkap as nameAsisten, " +
			" a.perawatInstrumen.id as idPerawatInstrumen, " +
			" a.perawatInstrumen.namaLengkap as namePerawatInstrumen, " +
			" a.perawatSekuler.id as idPerawatSekuler, " +
			" a.perawatSekuler.namaLengkap as namePerawatSekuler, " +
			" a.perawatSirkuler.id as idPerawatSirkuler, " +
			" a.perawatSirkuler.namaLengkap as namePerawatSirkuler, " +
			" a.alat as alat, " +
			" b.noRec as noRecHitKassa)" +
			" from DetailDokterOperasi a " +
			" left join a.penghitunganKassaDanAlatOperasi b " +
			" where a.statusEnabled in ('true') and b.noRec=:noRec")
	List<Map<String, Object>> getDetailDokterOperasiByNoRec(@Param("noRec") String noRec);
}
