<?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.PatientServiceMapper">
<resultMap id="PatientServiceResultMap" type="com.lyms.platform.permission.model.PatientService">
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="parentid" property="parentid" jdbcType="VARCHAR" />
<result column="pid" property="pid" jdbcType="VARCHAR" />
<result column="ser_type" property="serType" jdbcType="INTEGER" />
<result column="ser_doct" property="serDoct" jdbcType="VARCHAR" />
<result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
<result column="create_user_name" property="createUserName" jdbcType="VARCHAR" />
<result column="create_user" property="createUser" jdbcType="VARCHAR" />
<result column="ser_status" property="serStatus" jdbcType="INTEGER" />
<result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
<result column="update_user_name" property="updateUserName" jdbcType="VARCHAR" />
<result column="update_user" property="updateUser" jdbcType="VARCHAR" />
<result column="hospital_id" property="hospitalId" jdbcType="VARCHAR" />
</resultMap>
<insert id="addPatientService" parameterType="com.lyms.platform.permission.model.PatientService">
insert into patient_service (id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id) values (#{id},#{parentid},#{pid},#{serType},#{serDoct},#{createDate},#{createUserName},#{createUser},#{serStatus},#{updateDate},#{updateUserName},#{updateUser},#{hospitalId})
</insert>
<update id="updatePatientService" parameterType="com.lyms.platform.permission.model.PatientService">
update patient_service <set><if test="parentid != null and parentid != ''">
parentid = #{parentid,jdbcType=VARCHAR},
</if>
<if test="pid != null and pid != ''">
pid = #{pid,jdbcType=VARCHAR},
</if>
<if test="serType != null and serType >= 0">
ser_type = #{serType,jdbcType=INTEGER},
</if>
<if test="serDoct != null and serDoct != ''">
ser_doct = #{serDoct,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
create_date = #{createDate,jdbcType=TIMESTAMP},
</if>
<if test="createUserName != null and createUserName != ''">
create_user_name = #{createUserName,jdbcType=VARCHAR},
</if>
<if test="createUser != null and createUser != ''">
create_user = #{createUser,jdbcType=VARCHAR},
</if>
<if test="serStatus != null and serStatus >= 0">
ser_status = #{serStatus,jdbcType=INTEGER},
</if>
<if test="updateDate != null">
update_date = #{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="updateUserName != null and updateUserName != ''">
update_user_name = #{updateUserName,jdbcType=VARCHAR},
</if>
<if test="updateUser != null and updateUser != ''">
update_user = #{updateUser,jdbcType=VARCHAR},
</if>
<if test="hospitalId != null and hospitalId != ''">
hospital_id = #{hospitalId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<delete id="deletePatientService" parameterType="java.lang.String">
delete from patient_service where id = #{id,jdbcType=VARCHAR}
</delete>
<select id="getPatientService" resultMap="PatientServiceResultMap" parameterType="java.lang.String">
select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id
from patient_service 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="PatientServiceCondition">
<where>
1 = 1
<if test="id != null and id != ''">
and id = #{id,jdbcType=VARCHAR}
</if>
<if test="parentid != null and parentid != ''">
and parentid = #{parentid,jdbcType=VARCHAR}
</if>
<if test="pid != null and pid != ''">
and pid = #{pid,jdbcType=VARCHAR}
</if>
<if test="serType != null and serType >= 0">
and ser_type = #{serType,jdbcType=INTEGER}
</if>
<if test="serDoct != null and serDoct != ''">
and ser_doct = #{serDoct,jdbcType=VARCHAR}
</if>
<if test="createDate != null">
and create_date = #{createDate,jdbcType=TIMESTAMP}
</if>
<if test="createUserName != null and createUserName != ''">
and create_user_name = #{createUserName,jdbcType=VARCHAR}
</if>
<if test="createUser != null and createUser != ''">
and create_user = #{createUser,jdbcType=VARCHAR}
</if>
<if test="serStatus != null and serStatus >= 0">
and ser_status = #{serStatus,jdbcType=INTEGER}
</if>
<if test="updateDate != null">
and update_date = #{updateDate,jdbcType=TIMESTAMP}
</if>
<if test="updateUserName != null and updateUserName != ''">
and update_user_name = #{updateUserName,jdbcType=VARCHAR}
</if>
<if test="updateUser != null and updateUser != ''">
and update_user = #{updateUser,jdbcType=VARCHAR}
</if>
<if test="hospitalId != null and hospitalId != ''">
and hospital_id = #{hospitalId,jdbcType=VARCHAR}
</if>
</where>
</sql>
<select id="queryPatientService" resultMap="PatientServiceResultMap" parameterType="com.lyms.platform.permission.model.PatientServiceQuery">
select id,parentid,pid,ser_type,ser_doct,create_date,create_user_name,create_user,ser_status,update_date,update_user_name,update_user,hospital_id
from patient_service
<include refid="PatientServiceCondition" />
<include refid="orderAndLimit" />
</select>
<select id="queryPatientServiceCount" resultType="int" parameterType="com.lyms.platform.permission.model.PatientServiceQuery">
select count(1) from patient_service
<include refid="PatientServiceCondition" />
</select>
</mapper>