package cn.hnthyy.thmz.mapper.his.zy;

import cn.hnthyy.thmz.entity.his.zy.PatientMiSfz;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 身份证数据处理Mapper
 */
public interface PatientMiSfzMapper {

    /**
     * 根据主键查询身份证
     * @param patientId
     * @return
     */
    @Select("select * from patient_mi_sfz where patient_id=#{patientId} and sfz_image is not null ")
    List<PatientMiSfz> selectPatientMiSfzsByPatientId(@Param("patientId") String patientId);


    /**
     * 根据主键查询身份证
     * @param patientId
     * @return
     */
    @Select("select * from patient_mi_sfz where patient_id=#{patientId} and sfz_image is not null ")
    PatientMiSfz selectPatientMiSfzByPatientId(@Param("patientId") String patientId);

    /**
     * 根据门诊编号删除身份证记录
     * @param patientId
     * @return
     */
    @Delete("delete from patient_mi_sfz where patient_id=#{patientId}")
    int deletePatientMiSfzByPatientId(@Param("patientId") String patientId);

    /**
     * 新增身份证记录
     * @param patientMiSfz
     * @return
     */
    @Insert("INSERT INTO patient_mi_sfz(social_no, name, sex, nation, birth_day, address, agency, expirestart, expireend, tx_image, sfz_image, inpatient_no, patient_id) VALUES" +
            " (#{socialNo}, #{name}, #{sex}, #{nation}, #{birthDay}, #{address}, #{agency}, #{expirestart}, #{expireend}, #{txImage}, #{sfzImage}, #{inpatientNo},#{patientId}) ")
    int insertPatientMiSfz(PatientMiSfz patientMiSfz);

}
