PHC
Vulnerable Population
Obesity
Calculated BMI
Obesity Screening
Obese Class 3
Providers population, age 18 and older, who are currently overweight or obese.
Based on and adapted from CIHI’s 2012 Indicator Technical Specifications (Nov 2012)
01-30-2018
All Active Patients
03-30-2021
SELECT
IF( COUNT(fin.patient) > 0,
SUM( IF( fin.bmi >= ${lowerLimit.obeseclass1} AND fin.bmi < ${upperLimit.obeseclass1}, 1, 0 ) )
,0 ) AS 'Obese Class 1',
IF( COUNT(fin.patient) > 0,
SUM( IF( fin.bmi >= ${lowerLimit.obeseclass2} AND fin.bmi < ${upperLimit.obeseclass2}, 1, 0 ) )
,0 ) AS 'Obese Class 2',
IF( COUNT(fin.patient) > 0,
SUM( IF( fin.bmi >= ${lowerLimit.obeseclass3}, 1, 0 ) )
,0 ) AS 'Obese Class 3',
IF( COUNT(fin.patient) > 0,
SUM( IF( fin.bmi < ${lowerLimit.bmi} AND fin.bmi > 0, 1, 0 ) )
,0 ) AS 'Under Weight',
IF( COUNT(fin.patient) > 0,
SUM( IF( fin.bmi >= ${lowerLimit.ideal} AND fin.bmi < ${upperLimit.ideal}, 1, 0 ) )
,0 ) AS 'Ideal Weight',
IF( COUNT(fin.patient) > 0,
SUM( IF( fin.bmi >= ${lowerLimit.overweight} AND fin.bmi < ${upperLimit.overweight}, 1, 0 ) )
,0 ) AS 'Over Weight',
IF( COUNT(fin.patient) > 0,
SUM( IF( fin.bmi = 0, 1, 0 ) )
,0 ) AS 'BMI Not Recorded'
FROM (
SELECT
d.demographic_no AS patient,
IFNULL( BMI.dataField, 0) AS bmi
FROM demographic d
-- BMI Screening
-- Look for BMI index of 30 or more
LEFT JOIN (
SELECT m1.id, m1.dataField, m1.demographicNo, m1.dateObserved
FROM measurements m1
RIGHT JOIN (
SELECT demographicNo, MAX(DateObserved) as dateObserved
FROM measurements
WHERE type = ${bmi}
AND demographicNo > 0
GROUP BY demographicNo
) m2
ON m1.dateObserved = m2.dateObserved
AND m1.demographicNo = m2.demographicNo
AND m1.type = ${bmi}
ORDER BY m1.id DESC
) BMI
ON (d.demographic_no = BMI.demographicNo)
-- get the heights so that they can be filtered out.
LEFT JOIN (
SELECT m1.id, m1.dataField, m1.demographicNo, m1.dateObserved
FROM measurements m1
RIGHT JOIN (
SELECT demographicNo, MAX(DateObserved) as dateObserved
FROM measurements
WHERE type = ${height}
AND demographicNo > 0
GROUP BY demographicNo
) m2
ON m1.dateObserved = m2.dateObserved
AND m1.demographicNo = m2.demographicNo
AND m1.type = ${height}
ORDER BY m1.id DESC
) HT
ON (d.demographic_no = HT.demographicNo)
-- get the weights so that they can be filtered out.
LEFT JOIN (
SELECT m1.id, m1.dataField, m1.demographicNo, m1.dateObserved
FROM measurements m1
RIGHT JOIN (
SELECT demographicNo, MAX(DateObserved) as dateObserved
FROM measurements
WHERE type = ${weight}
AND demographicNo > 0
GROUP BY demographicNo
) m2
ON m1.dateObserved = m2.dateObserved
AND m1.demographicNo = m2.demographicNo
AND m1.type = ${weight}
ORDER BY m1.id DESC
) WT
ON (d.demographic_no = WT.demographicNo)
-- exclude any patient that is pregnant (requires episodes)
LEFT JOIN (
SELECT demographicNo, `status`, startDate
FROM Episode
WHERE DATE(startDate) > ${lowerLimit.date}
GROUP BY demographicNo HAVING COUNT(demographicNo) > -1
) PREG
ON(PREG.demographicNo = d.demographic_no)
WHERE d.patient_status = ${pstatus}
AND provider_no = '${provider}'
AND d.demographic_no > 0
AND IFNULL( PREG.`status`, -1) NOT LIKE 'Current'
AND IFNULL( HT.dataField, ${lowerLimit.height}) BETWEEN ${lowerLimit.height} AND ${upperLimit.height}
AND ( FLOOR( ABS( DATEDIFF( DATE( CONCAT(d.year_of_birth,"-",d.month_of_birth,"-",d.date_of_birth) ),
NOW() ) ) / 365.25 ) >= ${lowerLimit.age} )
GROUP BY d.demographic_no HAVING COUNT(d.demographic_no) > -1
) fin
03-30-2021
SELECT
*
FROM demographic d
-- BMI Screening
-- Look for BMI index of 30 or more
LEFT JOIN (
SELECT m1.id, m1.dataField, m1.demographicNo, m1.dateObserved
FROM measurements m1
RIGHT JOIN (
SELECT demographicNo, MAX(DateObserved) as dateObserved
FROM measurements
WHERE type = ${bmi}
AND demographicNo > 0
GROUP BY demographicNo
) m2
ON m1.dateObserved = m2.dateObserved
AND m1.demographicNo = m2.demographicNo
AND m1.type = ${bmi}
ORDER BY m1.id DESC
) BMI
ON (d.demographic_no = BMI.demographicNo)
-- get the heights so that they can be filtered out.
LEFT JOIN (
SELECT m1.id, m1.dataField, m1.demographicNo, m1.dateObserved
FROM measurements m1
RIGHT JOIN (
SELECT demographicNo, MAX(DateObserved) as dateObserved
FROM measurements
WHERE type = ${height}
AND demographicNo > 0
GROUP BY demographicNo
) m2
ON m1.dateObserved = m2.dateObserved
AND m1.demographicNo = m2.demographicNo
AND m1.type = ${height}
ORDER BY m1.id DESC
) HT
ON (d.demographic_no = HT.demographicNo)
-- get the weights so that they can be filtered out.
LEFT JOIN (
SELECT m1.id, m1.dataField, m1.demographicNo, m1.dateObserved
FROM measurements m1
RIGHT JOIN (
SELECT demographicNo, MAX(DateObserved) as dateObserved
FROM measurements
WHERE type = ${weight}
AND demographicNo > 0
GROUP BY demographicNo
) m2
ON m1.dateObserved = m2.dateObserved
AND m1.demographicNo = m2.demographicNo
AND m1.type = ${weight}
ORDER BY m1.id DESC
) WT
ON (d.demographic_no = WT.demographicNo)
-- exclude any patient that is pregnant
LEFT JOIN (
SELECT demographicNo, `status`, startDate
FROM Episode
WHERE DATE(startDate) > ${lowerLimit.date}
GROUP BY demographicNo HAVING COUNT(demographicNo) > -1
) PREG
ON(PREG.demographicNo = d.demographic_no)
WHERE d.patient_status = ${pstatus}
AND provider_no = '${provider}'
AND d.demographic_no > 0
AND IFNULL( PREG.`status`, -1) NOT LIKE 'Current'
AND IFNULL( HT.dataField, ${lowerLimit.height}) BETWEEN ${lowerLimit.height} AND ${upperLimit.height}
AND ( FLOOR( ABS( DATEDIFF( DATE( CONCAT(d.year_of_birth,"-",d.month_of_birth,"-",d.date_of_birth) ),
NOW() ) ) / 365.25 ) >= ${lowerLimit.age} )
AND ( FLOOR( ABS( DATEDIFF( DATE( CONCAT(d.year_of_birth,"-",d.month_of_birth,"-",d.date_of_birth) ),
HT.dateObserved ) ) / 365.25 ) >= 18 )
AND (( BMI.dataField >= ${lowerLimit.obeseclass3} )
OR (IF(HT.dataField>0,ROUND(10000*WT.dataField/(HT.dataField*HT.dataField),2),0) >= ${lowerLimit.obeseclass3} ))
GROUP BY d.demographic_no HAVING COUNT(d.demographic_no) > -1