<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.web.work.mapper.PatientMapper">

    <select id="selectList" resultType="com.ruoyi.web.work.domain.Patient">
        select * from tb_patient
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="patId != null  and patId != ''"> and pat_id = #{patId}</if>
            <if test="patientCode != null  and patientCode != ''"> and patient_code = #{patientCode}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="birthDate != null  and birthDate != ''"> and birth_date = #{birthDate}</if>
            <if test="sex != null  and sex != ''"> and sex = #{sex}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="workPhone != null  and workPhone != ''"> and work_phone = #{workPhone}</if>
            <if test="marital != null  and marital != ''"> and marital = #{marital}</if>
            <if test="nation != null  and nation != ''"> and nation = #{nation}</if>
            <if test="career != null  and career != ''"> and career = #{career}</if>
            <if test="nationality != null  and nationality != ''"> and nationality = #{nationality}</if>
            <if test="eventTime != null  and eventTime != ''"> and event_time = #{eventTime}</if>
            <if test="eventType != null  and eventType != ''"> and event_type = #{eventType}</if>
            <if test="blh != null  and blh != ''"> and blh = #{blh}</if>
            <if test="brkh != null  and brkh != ''"> and brkh = #{brkh}</if>
            <if test="sfzh != null  and sfzh != ''"> and sfzh = #{sfzh}</if>
            <if test="yexh != null  and yexh != ''"> and yexh = #{yexh}</if>
            <if test="msgType != null  and msgId != ''"> and msg_Type = #{msgType}</if>
        </where>
    </select>

    <select id="getPatientCardByNameOrRoomOrEntity" resultType="com.ruoyi.web.work.domain.dto.PatientCardDto">

    </select>



    <select id="getPatientByDepartment" resultType="com.ruoyi.web.work.domain.dto.PatientCardDto">
        SELECT
            tb_pv1.department,
            tb_pv1.physician,
            tb_patient.`name`,
            tb_pv1.discharge_method,
            tb_pv1.discharge_time,
            tb_pv1.card_id
        FROM
            tb_pv1
                JOIN
            tb_patient ON tb_pv1.patient_id = tb_patient.id
        where tb_pv1.department=#{department}
    </select>



</mapper>
