<?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.LymsHisInfoMapper">
<resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsHisInfo">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="vccardno" column="vcCardNo" jdbcType="VARCHAR"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="sex" column="sex" jdbcType="VARCHAR"/>
<result property="birthday" column="birthday" jdbcType="VARCHAR"/>
<result property="phone" column="phone" jdbcType="VARCHAR"/>
<result property="idcard" column="idCard" jdbcType="VARCHAR"/>
<result property="dept" column="dept" jdbcType="VARCHAR"/>
<result property="hospitalId" column="hospitalId" jdbcType="VARCHAR"/>
<result property="diagnose" column="diagnose" jdbcType="VARCHAR"/>
<result property="doctor" column="doctor" jdbcType="VARCHAR"/>
<result property="upType" column="up_type" jdbcType="INTEGER"/>
<result property="upTime" column="up_time" jdbcType="TIMESTAMP"/>
<result property="created" column="created" jdbcType="TIMESTAMP"/>
<result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,vcCardNo,name,
sex,birthday,phone,
idCard,dept,hospitalId,diagnose,
doctor,up_type,up_time,created,
createdtime
</sql>
<select id="selectByOrder" resultMap="BaseResultMap">
SELECT
hi.*
FROM
lyms_his_info hi
LEFT JOIN lyms_patient p ON p.idno = hi.idCard
LEFT JOIN lyms_order o ON o.pid = p.id and o.`status`=1
WHERE
<![CDATA[hi.createdtime>#{startTime}]]> AND hi.up_type = 0 and
((<![CDATA[o.service_end_time>=#{endTime}]]> ) or
(hi.num >0))
</select>
<select id="selectOrderList" resultType="com.lyms.talkonlineweb.result.OrderDetailsResult">
SELECT
hi.up_time,hi.amount,hi.num
FROM
lyms_patient p
INNER JOIN lyms_his_info hi ON hi.idCard = p.idno
where p.id=#{pid}
and hi.up_type=1
</select>
</mapper>