package com.ywt.outpatient.domain.entity.center;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface HisAddRegisteredFlagRepository extends JpaRepository<HisAddRegisteredFlag, Integer> {
    @Query(value = "select count(0) from his_add_registered_flag where his_patient_id = ? and hospital_id = 12 and status = 1 and deleted = 0;", nativeQuery = true)
    int countFlag(String hisPatientId);

    /**
     * 获取患者加号标识（太和医院）
     * @param hisPatientId
     * @return
     */
    @Query(value = "select * from his_add_registered_flag where his_patient_id = ? and hospital_id = 12 and status = 1 and deleted = 0 order by id desc limit 1;", nativeQuery = true)
    HisAddRegisteredFlag getFlag(String hisPatientId);
}
