drh/api/daily-glcuose-profile/index.sql
-- not including shell
-- not including breadcrumbs from sqlpage_aide_navigation
-- not including page title from sqlpage_aide_navigation
SELECT 'json' AS component,
JSON_OBJECT(
'daily_glucose_profile', (
SELECT JSON_GROUP_ARRAY(
JSON_OBJECT(
'date_time', Date_Time,
'date', strftime('%Y-%m-%d', Date_Time),
'hour', strftime('%H', Date_Time),
'glucose', CGM_Value
)
)
FROM
combined_cgm_tracing
WHERE
participant_id = $participant_id
AND Date_Time BETWEEN $start_date AND $end_date
)
) AS contents;