drh_participant_metrics
Column |
Type |
tenant_id |
VARCHAR |
study_id |
TEXT |
participant_id |
TEXT |
cgm_start_date |
|
cgm_end_date |
|
mean_glucose |
|
number_of_days_cgm_worn |
|
percentage_active |
|
gmi |
|
coefficient_of_variation |
|
SQL DDL
CREATE VIEW drh_participant_metrics AS
SELECT
(
select
party_id
from
party
limit
1
) as tenant_id,
(
select
study_id
from
uniform_resource_study
limit
1
) as study_id,
participant_id,
MIN(Date_Time) AS cgm_start_date,
MAX(Date_Time) AS cgm_end_date,
ROUND(AVG(CGM_Value), 2) AS mean_glucose,
COUNT(DISTINCT DATE(Date_Time)) AS number_of_days_cgm_worn,
ROUND(
(COUNT(DISTINCT DATE(Date_Time)) /
ROUND((julianday(MAX(Date_Time)) - julianday(MIN(Date_Time)) + 1))
) * 100, 2) AS percentage_active,
ROUND(AVG(CGM_Value) * 0.155 + 95, 2) AS gmi,
ROUND((SQRT(AVG(CGM_Value * CGM_Value) - AVG(CGM_Value) * AVG(CGM_Value)) / AVG(CGM_Value)) * 100, 2) AS coefficient_of_variation
FROM
combined_cgm_tracing
GROUP BY
participant_id