<?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.lantone.security.mapper.MedoupMapper">
    <select id="getMedoupManage" resultType="com.lantone.security.dto.GetMedoupManageDTO">
        SELECT
            smp.id meduopId,
            smp.code,
            smp.name,
            sdm.dept_id,
            sd.hospital_id,
            sd.NAME deptName,
            srm.region_id,
            sr.NAME regionName,
            sr.hospital_id regionHospital
        FROM
            sys_medoup smp,
            sys_dept_medoup sdm,
            sys_dept sd,
            sys_region_medoup srm,
            sys_region sr
        WHERE
            smp.id = sdm.medoup_id
        AND sdm.is_deleted = 'N'
        AND smp.is_deleted = 'N'
        AND sr.is_deleted = 'N'
        AND srm.is_deleted = 'N'
        AND sd.is_deleted = 'N'
        AND sdm.dept_id = sd.id
        AND sd.hospital_id = 4
        AND smp.id = srm.medoup_id
        AND srm.region_id = sr.id
        AND sr.hospital_id = sd.hospital_id
        AND smp.id= #{id}
    </select>
</mapper>