<?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.luowei.app_sb.mapper.Person_805Mapper">

    <!--    805-->
    <select id="selectPerson_805" resultType="com.luowei.app_sb.entity.Person_805Entity">
        SELECT * FROM person_805 WHERE sfz_id=#{sfz_id};
    </select>

    <insert id="insertPerson_805" parameterType="com.luowei.app_sb.entity.Person_805Entity">
        INSERT INTO person_805 (id,sfz_id,name,gender,emr,create_time,update_time)VALUES(#{id},#{sfz_id},#{name},#{gender},#{emr},#{create_time},#{update_time})
    </insert>
    <!--    编辑时不处理id与create_time-->
    <insert id="updatePerson_805" parameterType="com.luowei.app_sb.entity.Person_805Entity">
        UPDATE person_805 SET name=#{name},gender=#{gender},emr=#{emr},update_time=#{update_time} WHERE sfz_id=#{sfz_id}
    </insert>


    <insert id="insertPerson_health_805" parameterType="com.luowei.app_sb.entity.Person_health_805Entity">
        INSERT INTO person_health_805 (id,sfz_id,sbp,dbp,create_time,update_time)VALUES(#{id},#{sfz_id},#{sbp},#{dbp},#{create_time},#{update_time})
    </insert>

    <select id="selectPersonHealthVo" resultType="com.luowei.app_sb.vo.PersonHealthVo">
        SELECT t1.sfz_id,t1.name,t1.gender,t1.emr,t2.sbp,t2.dbp,t2.create_time,t2.update_time FROM person_805 AS t1 INNER JOIN person_health_805 AS t2 ON t1.sfz_id=t2.sfz_id WHERE t1.sfz_id=#{sfz_id} ORDER BY t2.update_time DESC LIMIT 0,1;
    </select>



</mapper>
