package com.yihu.jw.hospital.survey.dao;

import com.yihu.jw.entity.hospital.survey.WlyySurveyInspLabelInfoDO;
import com.yihu.jw.entity.hospital.survey.WlyySurveyUserAnswerDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

/**
 * Created by Trick on 2019/9/6.
 */
public interface SurveyUserAnswerDao extends PagingAndSortingRepository<WlyySurveyUserAnswerDO, String>, JpaSpecificationExecutor<WlyySurveyUserAnswerDO> {

    List<WlyySurveyUserAnswerDO> findBySurveyTempCodeAndPatient(String surveyTempCode,String patient);

    List<WlyySurveyUserAnswerDO> findBySurverUserId(String surverUserId);

    List<WlyySurveyUserAnswerDO> findByTempQuestionCode(String tempQuestionCode);
    @Query("From WlyySurveyUserAnswerDO c WHERE c.tempOptionCode = ?1 and c.surveyTempCode = ?2")
    List<WlyySurveyUserAnswerDO> findBytempOptionCode(String tempOptionCode,String surveyTempCode);

    @Query("SELECT DISTINCT c.patient from WlyySurveyUserAnswerDO c WHERE c.tempQuestionCode = ?1 and c.surveyTempCode = ?2")
    List<WlyySurveyUserAnswerDO> findByTempQuestionCodeDistinctPatient(String tempQuestionCode,String surveyTempCode );


}
