<?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="MobileHospital">

	<select id="selectHospitalHoliday" parameterType="hashmap" resultType="hashmap">
		SELECT 'hospitalHoliday'                 AS dateType
			 , DATE_FORMAT(LOC_DATE, '%Y.%m.%d') AS locDate
		  FROM MU_HOSPITAL_HOLIDAY MH
		 WHERE MH.USE_YN = 'Y'
		   AND (
			 (MH.REPEAT_YN = 'Y')
				 OR
			 (MH.REPEAT_YN = 'N' AND DATE_FORMAT( MH.LOC_DATE, '%Y' ) >= DATE_FORMAT( CURDATE( ), '%Y' ))
			 )
		 UNION
		(
			SELECT 'publicHoliday'                   AS dateType
				 , DATE_FORMAT(LOC_DATE, '%Y.%m.%d') AS locDate
			  FROM MU_PUBLIC_HOLIDAY MPH
			  JOIN MU_HOSPITAL
			  ON PUBLIC_HOLIDAY_USE_YN='Y'
			 WHERE MPH.USE_YN = 'Y'
			   AND DATE_FORMAT( MPH.LOC_DATE, '%Y' ) >= DATE_FORMAT( CURDATE( ), '%Y' )
		)
	</select>

	<select id="selectHospitalWorkTime" parameterType="hashmap" resultType="hashmap">
		SELECT MH.MU_HOSPITAL_ID                                   AS "muHospitalId"
			 ,MH.HOSPITAL_NAME                                    AS "hospitalName"
			 ,MH.MON_OPEN_YN                                      AS "monOpenYn"
			 ,DATE_FORMAT(MH.MON_OPEN_START_TIME , '%H:%i')       AS "monOpenStartTime"
			 ,DATE_FORMAT(MH.MON_OPEN_END_TIME   , '%H:%i')       AS "monOpenEndTime"
			 ,MH.TUE_OPEN_YN                                      AS "tueOpenYn"
			 ,DATE_FORMAT(MH.TUE_OPEN_START_TIME , '%H:%i')       AS "tueOpenStartTime"
			 ,DATE_FORMAT(MH.TUE_OPEN_END_TIME   , '%H:%i')       AS "tueOpenEndTime"
			 ,MH.WED_OPEN_YN                                      AS "wedOpenYn"
			 ,DATE_FORMAT(MH.WED_OPEN_START_TIME , '%H:%i')       AS "wedOpenStartTime"
			 ,DATE_FORMAT(MH.WED_OPEN_END_TIME   , '%H:%i')       AS "wedOpenEndTime"
			 ,MH.THU_OPEN_YN                                      AS "thuOpenYn"
			 ,DATE_FORMAT(MH.THU_OPEN_START_TIME , '%H:%i')       AS "thuOpenStartTime"
			 ,DATE_FORMAT(MH.THU_OPEN_END_TIME   , '%H:%i')       AS "thuOpenEndTime"
			 ,MH.FRI_OPEN_YN                                      AS "friOpenYn"
			 ,DATE_FORMAT(MH.FRI_OPEN_START_TIME , '%H:%i')       AS "friOpenStartTime"
			 ,DATE_FORMAT(MH.FRI_OPEN_END_TIME   , '%H:%i')       AS "friOpenEndTime"
			 ,MH.SAT_OPEN_YN                                      AS "satOpenYn"
			 ,DATE_FORMAT(MH.SAT_OPEN_START_TIME , '%H:%i')       AS "satOpenStartTime"
			 ,DATE_FORMAT(MH.SAT_OPEN_END_TIME   , '%H:%i')       AS "satOpenEndTime"
			 ,MH.SUN_OPEN_YN                                      AS "sunOpenYn"
			 ,DATE_FORMAT(MH.SUN_OPEN_START_TIME , '%H:%i')       AS "sunOpenStartTime"
			 ,DATE_FORMAT(MH.SUN_OPEN_END_TIME   , '%H:%i')       AS "sunOpenEndTime"
			 ,MH.PUBLIC_HOLIDAY_USE_YN                            AS "publicHolidayUseYn"
		  FROM MU_HOSPITAL AS MH
		 WHERE MH.USE_YN        = 'Y'
		 LIMIT 0, 1
	</select>
</mapper>