/**
 * Created by Djidjelly Siclait on 11/26/2016.
 */
package com.evapps.Repository;

import com.evapps.Entity.History;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface HistoryRepository extends JpaRepository<History, String> {

    History findByHistoryId(String historyId);

    @Query("select h from History h where h.patient.patientId = :id and h.consultationReference = :reference")
    History findByPatientIdAndConsultationReference(@Param("id") String patientId, @Param("reference") String consultationReference);

    @Query("select h from History h where h.patient.patientId = :id" )
    List<History> findByPatientId(@Param("id") String patientId);

    @Query("select h from History h where h.surgeryType = :surgeryType" )
    List<History> findBySurgeryType(@Param("surgeryType") String surgeryType);

}

@@ -291,31 +291,8 @@
 m;%0A%0A
-import java.util.List;%0A
 %0Apub
@@ -461,500 +461,82 @@
 e h.
-patient.patientId = :id and h.consultationReference = :reference%22)%0A    History findByPatientIdAndConsultationReference(@Param(%22id%22) String patientId, @Param(%22reference%22) String consultationReference);%0A%0A    @Query(%22select h from History h where h.patient.patientId = :id%22 )%0A    List%3CHistory%3E findByPatientId(@Param(%22id%22) String patientId);%0A%0A    @Query(%22select h from History h where h.surgeryType = :surgeryType%22 
+user.email = :email%22
 )%0A    
-List%3C
 History
-%3E
  findBy
-SurgeryType(@Param(%22surgeryType%22) String surgeryType
+User(@Param(%22email%22) String email
 );%0A
-%0A
 %7D%0A

Refactor History Repository