<?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.talkonlineweb.mapper.LymsIllnessMapper">

    <resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsIllness">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="pcid" column="pcid" jdbcType="INTEGER"/>
            <result property="iid" column="iid" jdbcType="INTEGER"/>
            <result property="iname" column="iname" jdbcType="VARCHAR"/>
            <result property="createdby" column="createdby" jdbcType="INTEGER"/>
            <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
            <result property="updatedby" column="updatedby" jdbcType="INTEGER"/>
            <result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,pcid,iid,
        createdby,createdtime,updatedby,
        updated_time
    </sql>

    <select id="queryPatientHasIllnessCode" resultType="java.lang.Integer">
       select count(1)
       from lyms_pcase pcase,
            lyms_illness i
       where pcase.pcid = i.pcid
       and pcase.pid = #{pid}
       and pcase.hid = #{hid}
       and i.iid = #{illCode}
    </select>
    <select id="queryMayPregnant" resultType="com.lyms.talkonlineweb.domain.PregnantResult">
        select p.id as pid,
               p.idno,
               pcase.pcid,
               ill.id as illID,
               ill.iname
        from
            lyms_patient p,
            lyms_pcase pcase,
            lyms_illness ill
        where p.id = pcase.pid
            and pcase.pcid = ill.pcid
            and ill.iname like '%孕%'
            and ill.iname like '%周%'
    </select>
</mapper>
