|
|
|
@ -218,134 +218,134 @@
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="select_timeline" resultClass="dataMap" parameterClass="dataMap">
|
|
|
|
|
SELECT
|
|
|
|
|
DATE_FORMAT(b.reg_dt, '%Y-%m-%d') as reg_date,
|
|
|
|
|
DATE_FORMAT(b.reg_dt, '%H:%i %p') as hour_min,
|
|
|
|
|
ifnull(DATEDIFF(b.reg_dt, LAG(b.reg_dt) OVER (ORDER BY b.reg_dt)),'0') as day_diff,
|
|
|
|
|
ifnull(DATE_FORMAT(TIMEDIFF(b.reg_dt, LAG(b.reg_dt) OVER (ORDER BY b.reg_dt) ), '%H:%i'), '00:00') as time_diff,
|
|
|
|
|
c.title,
|
|
|
|
|
b.dn_no,
|
|
|
|
|
c.cd_no,
|
|
|
|
|
LPAD(c.val_1, 2, '0') as val_1,
|
|
|
|
|
(select color_cd from tbl_code_item ts where ts.val_1 = c.cd_no) as color_cd,
|
|
|
|
|
CASE
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_1' THEN
|
|
|
|
|
(select concat(ifnull(eat_qty,0), 'ml')
|
|
|
|
|
from tbl_bf_daily_nutrition_1 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_2' THEN
|
|
|
|
|
(select
|
|
|
|
|
case when tn1.milk_tp = 87 then ifnull(concat(ifnull(tn.prd_nm,''), ' ', eat_qty, 'ml'),'')
|
|
|
|
|
else ifnull(concat('유축수유', ' ', eat_qty, 'ml'),'')
|
|
|
|
|
end
|
|
|
|
|
from tbl_bf_daily_nutrition_2 tn1
|
|
|
|
|
left outer join tbl_db_nutrient tn ON tn1.db_dn_no = tn.dn_no and tn1.milk_tp = 87
|
|
|
|
|
WHERE tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_3' THEN
|
|
|
|
|
(select
|
|
|
|
|
concat(
|
|
|
|
|
case
|
|
|
|
|
when tn1.db_dn_tp = 'bf' then ifnull(tb.prd_nm, '')
|
|
|
|
|
when tn1.db_dn_tp = 'sf' then ifnull(tc.prd_nm, '')
|
|
|
|
|
end
|
|
|
|
|
,' '
|
|
|
|
|
,tn1.eat_qty, 'ml 섭취'
|
|
|
|
|
)
|
|
|
|
|
from tbl_bf_daily_nutrition_3 tn1
|
|
|
|
|
left outer join tbl_db_nutrient tb on tn1.db_dn_no = tb.dn_no
|
|
|
|
|
left outer join tbl_db_sf_commerce tc on tn1.db_dn_no = tc.dbc_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_5' THEN
|
|
|
|
|
(select concat( ifnull(sleep_h,0), '시 ', ifnull(sleep_m,0), '분')
|
|
|
|
|
from tbl_bf_daily_nutrition_5 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_6' THEN
|
|
|
|
|
(select tn2.title
|
|
|
|
|
from tbl_bf_daily_nutrition_6 tn1
|
|
|
|
|
inner join tbl_code_item_str tn2 on tn2.cg_cd = 'BF_FECES_QTY' and tn1.rest_qty = tn2.val_1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_7' THEN
|
|
|
|
|
(
|
|
|
|
|
SELECT ifnull(tv.dv_disease,'')
|
|
|
|
|
FROM tbl_bf_daily_nutrition_7 tn1
|
|
|
|
|
INNER JOIN tbl_db_vac_schedule tn2 on tn1.db_dvs_no = tn2.dvs_no
|
|
|
|
|
INNER JOIN tbl_db_vac tv on tn2.dv_no = tv.dv_no
|
|
|
|
|
WHERE tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_9' THEN
|
|
|
|
|
(select
|
|
|
|
|
concat(
|
|
|
|
|
case
|
|
|
|
|
when tn1.db_dhb_tp = 'sf' then ifnull(tb.name, '')
|
|
|
|
|
when tn1.db_dhb_tp = 'bf' then ifnull(tc.name, '')
|
|
|
|
|
end
|
|
|
|
|
,
|
|
|
|
|
tn1.eat_qty, 'ml 섭취'
|
|
|
|
|
)
|
|
|
|
|
from tbl_bf_daily_nutrition_9 tn1
|
|
|
|
|
left outer join tbl_db_home_sf tb on tn1.db_dhb_no = tb.dhb_no
|
|
|
|
|
left outer join tbl_db_home_bf tc on tn1.db_dhb_no = tc.dhb_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_10' THEN
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
concat(
|
|
|
|
|
case
|
|
|
|
|
when tn1.db_dbc_tp = 'sf' then ifnull(tb.prd_nm, '')
|
|
|
|
|
when tn1.db_dbc_tp = 'bf' then ifnull(tc.prd_nm, '')
|
|
|
|
|
end , tn1.eat_qty, 'ml 섭취' )
|
|
|
|
|
FROM tbl_bf_daily_nutrition_10 tn1
|
|
|
|
|
LEFT OUTER JOIN tbl_db_sf_commerce tb on tn1.db_dbc_no = tb.dbc_no
|
|
|
|
|
LEFT OUTER JOIN tbl_db_bf_commerce tc on tn1.db_dbc_no = tc.dbc_no
|
|
|
|
|
WHERE tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_11' THEN
|
|
|
|
|
(select
|
|
|
|
|
concat(ifnull(hosp_nm,''), ' 의사:', doctor_nm, ', 증상: ', checkup)
|
|
|
|
|
from tbl_bf_daily_nutrition_11 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_12' THEN
|
|
|
|
|
(select
|
|
|
|
|
daily_life
|
|
|
|
|
from tbl_bf_daily_nutrition_12 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_13' THEN
|
|
|
|
|
(select
|
|
|
|
|
achievement
|
|
|
|
|
from tbl_bf_daily_nutrition_13 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_14' THEN
|
|
|
|
|
(select
|
|
|
|
|
concat(ifnull(blq + brq,0), 'ml')
|
|
|
|
|
from tbl_bf_daily_nutrition_14 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_15' THEN
|
|
|
|
|
(select
|
|
|
|
|
concat(ifnull(etc_symptom,''), ' ', ifnull(temperature,''))
|
|
|
|
|
from tbl_bf_daily_nutrition_15 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
END AS time_val
|
|
|
|
|
FROM tbl_bf_family_match a
|
|
|
|
|
SELECT ifnull(DATEDIFF(XA.reg_dt, LAG(XA.reg_dt) OVER (ORDER BY b.reg_dt)), '0') as day_diff,
|
|
|
|
|
ifnull(DATE_FORMAT(TIMEDIFF(XA.reg_dt, LAG(XA.reg_dt) OVER (ORDER BY XA.reg_dt)), '%H:%i'),'00:00') as time_diff,
|
|
|
|
|
XA.reg_date,
|
|
|
|
|
XA.hour_min,
|
|
|
|
|
XA.title,
|
|
|
|
|
XA.dn_no,
|
|
|
|
|
XA.cd_no,
|
|
|
|
|
XA.val_1,
|
|
|
|
|
XA.color_cd,
|
|
|
|
|
XA.time_val
|
|
|
|
|
FROM (
|
|
|
|
|
SELECT DATE_FORMAT(b.reg_dt, '%Y-%m-%d') as reg_date,
|
|
|
|
|
DATE_FORMAT(b.reg_dt, '%H:%i %p') as hour_min,
|
|
|
|
|
c.title,
|
|
|
|
|
b.dn_no,
|
|
|
|
|
c.cd_no,
|
|
|
|
|
b.reg_dt,
|
|
|
|
|
LPAD(c.val_1, 2, '0') as val_1,
|
|
|
|
|
(select color_cd from tbl_code_item ts where ts.val_1 = c.cd_no) as color_cd,
|
|
|
|
|
CASE
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_1' THEN
|
|
|
|
|
(select concat(ifnull(eat_qty, 0), 'ml') from tbl_bf_daily_nutrition_1 tn1 where tn1.dn_no = b.dn_no)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_2' THEN
|
|
|
|
|
(select case
|
|
|
|
|
when tn1.milk_tp = 87 then ifnull(concat(ifnull(tn.prd_nm, ''), ' ', eat_qty, 'ml'), '')
|
|
|
|
|
else ifnull(concat('유축수유', ' ', eat_qty, 'ml'), '')
|
|
|
|
|
end
|
|
|
|
|
from tbl_bf_daily_nutrition_2 tn1
|
|
|
|
|
left outer join tbl_db_nutrient tn ON tn1.db_dn_no = tn.dn_no and tn1.milk_tp = 87
|
|
|
|
|
WHERE tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_3' THEN
|
|
|
|
|
(select concat(
|
|
|
|
|
case
|
|
|
|
|
when tn1.db_dn_tp = 'bf' then ifnull(tb.prd_nm, '')
|
|
|
|
|
when tn1.db_dn_tp = 'sf' then ifnull(tc.prd_nm, '')
|
|
|
|
|
end
|
|
|
|
|
, ' '
|
|
|
|
|
, tn1.eat_qty, 'ml 섭취'
|
|
|
|
|
)
|
|
|
|
|
from tbl_bf_daily_nutrition_3 tn1
|
|
|
|
|
left outer join tbl_db_nutrient tb on tn1.db_dn_no = tb.dn_no
|
|
|
|
|
left outer join tbl_db_sf_commerce tc on tn1.db_dn_no = tc.dbc_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_5' THEN
|
|
|
|
|
(select concat(ifnull(sleep_h, 0), '시 ', ifnull(sleep_m, 0), '분')
|
|
|
|
|
from tbl_bf_daily_nutrition_5 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_6' THEN
|
|
|
|
|
(select tn2.title
|
|
|
|
|
from tbl_bf_daily_nutrition_6 tn1
|
|
|
|
|
inner join tbl_code_item_str tn2
|
|
|
|
|
on tn2.cg_cd = 'BF_FECES_QTY' and tn1.rest_qty = tn2.val_1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_7' THEN
|
|
|
|
|
(
|
|
|
|
|
SELECT ifnull(tv.dv_disease, '')
|
|
|
|
|
FROM tbl_bf_daily_nutrition_7 tn1
|
|
|
|
|
INNER JOIN tbl_db_vac_schedule tn2 on tn1.db_dvs_no = tn2.dvs_no
|
|
|
|
|
INNER JOIN tbl_db_vac tv on tn2.dv_no = tv.dv_no
|
|
|
|
|
WHERE tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_9' THEN
|
|
|
|
|
(select concat(
|
|
|
|
|
case
|
|
|
|
|
when tn1.db_dhb_tp = 'sf' then ifnull(tb.name, '')
|
|
|
|
|
when tn1.db_dhb_tp = 'bf' then ifnull(tc.name, '')
|
|
|
|
|
end
|
|
|
|
|
,
|
|
|
|
|
tn1.eat_qty, 'ml 섭취'
|
|
|
|
|
)
|
|
|
|
|
from tbl_bf_daily_nutrition_9 tn1
|
|
|
|
|
left outer join tbl_db_home_sf tb on tn1.db_dhb_no = tb.dhb_no
|
|
|
|
|
left outer join tbl_db_home_bf tc on tn1.db_dhb_no = tc.dhb_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_10' THEN
|
|
|
|
|
(
|
|
|
|
|
SELECT concat(
|
|
|
|
|
case
|
|
|
|
|
when tn1.db_dbc_tp = 'sf' then ifnull(tb.prd_nm, '')
|
|
|
|
|
when tn1.db_dbc_tp = 'bf' then ifnull(tc.prd_nm, '')
|
|
|
|
|
end, tn1.eat_qty, 'ml 섭취')
|
|
|
|
|
FROM tbl_bf_daily_nutrition_10 tn1
|
|
|
|
|
LEFT OUTER JOIN tbl_db_sf_commerce tb on tn1.db_dbc_no = tb.dbc_no
|
|
|
|
|
LEFT OUTER JOIN tbl_db_bf_commerce tc on tn1.db_dbc_no = tc.dbc_no
|
|
|
|
|
WHERE tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_11' THEN
|
|
|
|
|
(select concat(ifnull(hosp_nm, ''), ' 의사:', doctor_nm, ', 증상: ', checkup)
|
|
|
|
|
from tbl_bf_daily_nutrition_11 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_12' THEN
|
|
|
|
|
(select daily_life
|
|
|
|
|
from tbl_bf_daily_nutrition_12 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_13' THEN
|
|
|
|
|
(select achievement
|
|
|
|
|
from tbl_bf_daily_nutrition_13 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_14' THEN
|
|
|
|
|
(select concat(ifnull(blq + brq, 0), 'ml')
|
|
|
|
|
from tbl_bf_daily_nutrition_14 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_15' THEN
|
|
|
|
|
(select concat(ifnull(etc_symptom, ''), ' ', ifnull(temperature, ''))
|
|
|
|
|
from tbl_bf_daily_nutrition_15 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
END AS time_val
|
|
|
|
|
FROM tbl_bf_family_match a
|
|
|
|
|
INNER JOIN tbl_bf_daily_nutrition b on a.smc_no = b.smc_no
|
|
|
|
|
INNER JOIN tbl_code_item_str c on b.nutirition_cd_no = c.cd_no
|
|
|
|
|
WHERE
|
|
|
|
|
a.member_id = #member_id#
|
|
|
|
|
and a.smc_no = #smc_no#
|
|
|
|
|
and b.reg_dt between date_add(now(),interval -1 month ) and now()
|
|
|
|
|
and b.nutirition_cd_no != ''
|
|
|
|
|
ORDER BY b.reg_dt
|
|
|
|
|
</select>
|
|
|
|
|
WHERE a.member_id = #member_id#
|
|
|
|
|
and a.smc_no = #smc_no#
|
|
|
|
|
and b.reg_dt between date_add(now(), interval -1 month ) and now()
|
|
|
|
|
and b.nutirition_cd_no != ''
|
|
|
|
|
) XA
|
|
|
|
|
WHERE XA.time_val is not NULL
|
|
|
|
|
ORDER BY XA.reg_dt
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="select_timeline_color_cd" resultClass="dataMap" parameterClass="dataMap">
|
|
|
|
|
SELECT
|
|
|
|
|