/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.patient;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.yihu.wlyy.entity.patient.PatientReservation;

public interface PatientReservationDao extends PagingAndSortingRepository<PatientReservation, Long>, JpaSpecificationExecutor<PatientReservation> {

	PatientReservation findById(Long id);

	PatientReservation findByCode(String code);

	List<PatientReservation> findByPatient(String patient, Pageable page);

	List<PatientReservation> findByPatientAndAdminTeamCode(String patient,Long teamCode,Pageable page);

	List<PatientReservation> findByDoctor(String doctor,Pageable page);

	@Query("select count(1) from PatientReservation a where a.doctor = ?1 and a.patient=?2 ")
	Long  countReservationByDoctorForPatient(String doctor,String patient);
}
