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

import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionEmrDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.Date;
import java.util.List;

/**
 * Created by wangzhinan on 2019/5/17.
 */
public interface PrescriptionEmrDao extends PagingAndSortingRepository<WlyyPrescriptionEmrDO, String>, JpaSpecificationExecutor<WlyyPrescriptionEmrDO> {

    @Query("select a from WlyyPrescriptionEmrDO a where a.prescriptionId = ?1 and a.del=1 ")
    List<WlyyPrescriptionEmrDO> findByPrescriptionId(String prescriptionId);

    @Query("select a from WlyyPrescriptionEmrDO a where a.prescriptionId = ?1 and a.del=1 ")
    WlyyPrescriptionEmrDO findEmrByPrescriptionId(String prescriptionId);


    @Modifying
    @Query("update WlyyPrescriptionEmrDO p set p.del=0 where p.prescriptionId=?1")
    void deleteByPrescriptionId(String prescriptionId);


}
