<?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.lyms.platform.permission.dao.master.PatientMarkHospitalLogMapper">
    <resultMap id="PatientMarkHospitalLogResultMap" type="com.lyms.platform.permission.model.PatientMarkHospitalLog">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="patient_make_hos_id" property="patientMakeHosId" jdbcType="VARCHAR"/>
        <result column="patient_id" property="patientId" jdbcType="VARCHAR"/>
        <result column="rem_result" property="remResult" jdbcType="INTEGER"/>
        <result column="make_date" property="makeDate" jdbcType="TIMESTAMP"/>
        <result column="make_failure" property="makeFailure" jdbcType="INTEGER"/>
        <result column="make_remark" property="makeRemark" jdbcType="VARCHAR"/>
        <result column="marke_doctor" property="markeDoctor" jdbcType="VARCHAR"/>
        <result column="marke_date" property="markeDate" jdbcType="TIMESTAMP"/>
        <result column="marke_type" property="markeType" jdbcType="INTEGER"/>
        <result column="hospital_id" property="hospitalId" jdbcType="VARCHAR"/>
    </resultMap>
    <insert id="addPatientMarkHospitalLog" parameterType="com.lyms.platform.permission.model.PatientMarkHospitalLog">
insert into patient_mark_hospital_log (id,patient_make_hos_id,patient_id,rem_result,make_date,make_failure,make_remark,marke_doctor,marke_date,marke_type,hospital_id) values (#{id},#{patientMakeHosId},#{patientId},#{remResult},#{makeDate},#{makeFailure},#{makeRemark},#{markeDoctor},#{markeDate},#{markeType},#{hospitalId})
</insert>
    <update id="updatePatientMarkHospitalLog" parameterType="com.lyms.platform.permission.model.PatientMarkHospitalLog">
        update patient_mark_hospital_log
        <set>
            <if test="patientMakeHosId != null and patientMakeHosId != ''">
                patient_make_hos_id = #{patientMakeHosId,jdbcType=VARCHAR},
            </if>
            <if test="patientId != null and patientId != ''">
                patient_id = #{patientId,jdbcType=VARCHAR},
            </if>
            <if test="remResult != null and remResult >= 0">
                rem_result = #{remResult,jdbcType=INTEGER},
            </if>
            <if test="makeDate != null">
                make_date = #{makeDate,jdbcType=TIMESTAMP},
            </if>
            <if test="makeFailure != null and makeFailure >= 0">
                make_failure = #{makeFailure,jdbcType=INTEGER},
            </if>
            <if test="makeRemark != null and makeRemark != ''">
                make_remark = #{makeRemark,jdbcType=VARCHAR},
            </if>
            <if test="markeDoctor != null and markeDoctor != ''">
                marke_doctor = #{markeDoctor,jdbcType=VARCHAR},
            </if>
            <if test="markeDate != null">
                marke_date = #{markeDate,jdbcType=TIMESTAMP},
            </if>
            <if test="markeType != null and markeType >= 0">
                marke_type = #{markeType,jdbcType=INTEGER},
            </if>
            <if test="hospitalId != null and hospitalId != ''">
                hospital_id = #{hospitalId,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=VARCHAR}
    </update>
    <delete id="deletePatientMarkHospitalLog" parameterType="java.lang.String">
delete from patient_mark_hospital_log where id = #{id,jdbcType=VARCHAR}
</delete>
    <select id="getPatientMarkHospitalLog" resultMap="PatientMarkHospitalLogResultMap" parameterType="java.lang.String">
select id,patient_make_hos_id,patient_id,rem_result,make_date,make_failure,make_remark,marke_doctor,marke_date,marke_type,hospital_id
 from patient_mark_hospital_log where id = #{id,jdbcType=VARCHAR}
</select>
    <sql id="orderAndLimit">
        <if test="sort != null and sort != '' ">
            order by ${sort}
            <if test="need != null">
                limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
            </if>
        </if>
    </sql>
    <sql id="PatientMarkHospitalLogCondition">
        <where>
            1 = 1
            <if test="id != null and id != ''">
                and id = #{id,jdbcType=VARCHAR}
            </if>
            <if test="patientMakeHosId != null and patientMakeHosId != ''">
                and patient_make_hos_id = #{patientMakeHosId,jdbcType=VARCHAR}
            </if>
            <if test="patientId != null and patientId != ''">
                and patient_id = #{patientId,jdbcType=VARCHAR}
            </if>
            <if test="remResult != null and remResult >= 0">
                and rem_result = #{remResult,jdbcType=INTEGER}
            </if>
            <if test="makeDate != null">
                and make_date = #{makeDate,jdbcType=TIMESTAMP}
            </if>
            <if test="makeFailure != null and makeFailure >= 0">
                and make_failure = #{makeFailure,jdbcType=INTEGER}
            </if>
            <if test="makeRemark != null and makeRemark != ''">
                and make_remark = #{makeRemark,jdbcType=VARCHAR}
            </if>
            <if test="markeDoctor != null and markeDoctor != ''">
                and marke_doctor = #{markeDoctor,jdbcType=VARCHAR}
            </if>
            <if test="markeDate != null">
                and marke_date = #{markeDate,jdbcType=TIMESTAMP}
            </if>
            <if test="markeType != null and markeType >= 0">
                and marke_type = #{markeType,jdbcType=INTEGER}
            </if>
            <if test="hospitalId != null and hospitalId != ''">
                and hospital_id = #{hospitalId,jdbcType=VARCHAR}
            </if>
        </where>
    </sql>
    <select id="queryPatientMarkHospitalLog" resultMap="PatientMarkHospitalLogResultMap"
            parameterType="com.lyms.platform.permission.model.PatientMarkHospitalLogQuery">
        select
        id,patient_make_hos_id,patient_id,rem_result,make_date,make_failure,make_remark,marke_doctor,marke_date,marke_type,hospital_id
        from patient_mark_hospital_log
        <include refid="PatientMarkHospitalLogCondition"/>
        <include refid="orderAndLimit"/>
    </select>
    <select id="queryPatientMarkHospitalLogCount" resultType="int"
            parameterType="com.lyms.platform.permission.model.PatientMarkHospitalLogQuery">
        select count(1) from patient_mark_hospital_log
        <include refid="PatientMarkHospitalLogCondition"/>
    </select>
</mapper>