<?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.LymsXljcTracePushRecordMapper">
<select id="queryNeedPushRecords" resultType="com.lyms.talkonlineweb.domain.LymsXljcTracePushRecord">
select
archive.id as archId,
archive.pname,
hp.hname,
hp.dname as dpName,
doctor.dname,
result.diagnosis,
record.id as rid,
trace.id as traceId,
p.id as pid,
p.gzopenid,
trace.next_examine_date as nextExamineDate
from
lyms_xljc_record_trace trace
inner join lyms_xljc_record record on trace.rid = record.id
inner join lyms_xljc_record_result result on record.id = result.rid
inner join lyms_xljc_archive archive on record.arch_id = archive.id
inner join lyms_hdepart hp on record.examine_dpid = hp.did
inner join lyms_doctor doctor on record.examine_doctor = doctor.did
left join lyms_patient p on archive.idno = p.idno
where trace.next_examine_status = 0
and trace.yn = 1
and trace.next_examine_date >= DATE_SUB(CURDATE() ,INTERVAL 2 DAY)
and trace.next_examine_date <= DATE_ADD(CURDATE() ,INTERVAL 2 DAY)
and trace.next_examine_date != CURDATE()
</select>
</mapper>