<?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.bonus.boot.manager.task.dao.PhysicalResultTaskDao">
    <insert id="insertData" parameterType="com.bonus.boot.manager.task.entity.TaskBean">
    REPLACE into pm_physical_result(physical_id)
    select id from pm_base_physical where is_active = '1'
    </insert>
    <insert id="insertYear">
        insert into physical_result_hospital_year (year)values(#{year})
    </insert>
    <update id="updateStatusTask">
        update pm_base_phy_appont set
            appoint_status = '4'
        where user_id = #{id} and if_active = '1'
    </update>
    <select id="getIsExistThisYear" resultType="java.lang.String">
        select year from physical_result_hospital_year where year = #{year}
    </select>
    <select id="getNoUploadData" resultType="com.bonus.boot.manager.career.entity.CareerBean">
        select user_id as id from pm_base_phy_appont where appoint_status is null
    </select>
    <select id="getAllNoCheckPerson" resultType="com.bonus.boot.manager.career.entity.CareerBean">
        select
        pbp.hospital as hospitalName,
        pb.telep_number as phone,
        pb.phy_name as personName
        from pm_base_phy_appont p
        left join pm_base_hospital pbp on pbp.id = p.hospital_id and pbp.is_active = '1'
        left join pm_base_physical pb on pb.id = p.user_id and pb.is_active = '1'
        where p.phy_appont_time = #{date} and p.if_cancel = '2' and p.if_active = '1'
    </select>
    <select id="getNoCheckForAppointList" resultType="com.bonus.boot.manager.career.entity.CareerBean">
        select
            pb.phy_name as personName,
            pbp.hospital as hospitalName,
            pb.telep_number as phone
        from pm_base_phy_appont p
        left join pm_base_physical pb on pb.id = p.user_id and pb.is_active = '1'
        left join pm_base_hospital pbp on pbp.id = p.hospital_id and pbp.is_active = '1'
        where p.phy_appont_time = #{date} and p.if_cancel = '2' and p.if_active = '1' and p.appoint_status = '4'
    </select>
</mapper>