<?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.openhis.web.doctorstation.mapper.DoctorStationChineseMedicalAppMapper">

    <select id="getTcmEncounterDiagnosis" resultType="com.openhis.web.doctorstation.dto.DiagnosisQueryDto">
        SELECT T1.id AS encounter_diagnosis_id,
               T1.condition_id,
               T1.syndrome_group_no,
               T2.definition_id,
               T3.source_enum,
               T3.NAME,
               T1.maindise_flag,
               T1.diag_srt_no,
               T1.med_type_code,
               T2.verification_status_enum,
               T2.yb_no
        FROM adm_encounter_diagnosis AS T1
                 LEFT JOIN cli_condition AS T2 ON T2.ID = T1.condition_id
            AND T2.delete_flag = '0' AND T2.tcm_flag = 1
                 LEFT JOIN cli_condition_definition AS T3 ON t3.ID = T2.definition_id
            AND T3.delete_flag = '0'
        WHERE T1.delete_flag = '0'
          AND T1.tcm_flag = 1
          AND T1.encounter_id = #{encounterId}
        ORDER BY T1.diag_srt_no
    </select>

</mapper>