We are currently updating the OP Help Center content for the release of OP 14.19 or OP 19. OP 19 is a member of the certified OP 14 family of products (official version is 14.19.1), which you may see in your software (such as in Help > About) and in the Help Center tabs labeled 14.19. You may also notice that the version number in content and videos may not match the version of your software, and some procedural content may not match the workflow in your software. We appreciate your patience and understanding as we make these enhancements.

SQL: Active Patients with Obesity

About

This SQL shows all active patients with BMI greater than the 95th percentile for age.

A sample image of this SQL report run in the Database Viewer is shown below:

Caveats

This will show you all active patients whose BMI is greater than 95%.

Notes:

  • The SQL only pulls patients whose status is ACTIVE.
  • It only pulls patients ages 2 and up, since younger children don't have a BMI defined.
  • It pulls patients whose BMI is GREATER than 95, not GREATER THAN OR EQUAL to 95.   
  • It looks at the patient’s most recent BMI.  So, if a child's BMI is currently under 95 even though the patient's previous three BMIs were over 95, the patient won't appear in the grid.

Code

To highlight and copy the code below to your clipboard, simply click the Copy button.

select p.* , pc.bmi_percent from
(
 (select patno, max(date1) as most_recent from physical_chart group by patno) p
left outer join physical_chart pc on pc.patno = p.patno and pc.date1 = p.most_recent
)
inner join register on register.patno = p.patno
where status_pat = 'ACTIVE' and bmi_percent > 95