2 // Copyright (C) 2011 Ken Chapple <ken@mi-squared.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 class NFQ_0421_Numerator1
implements CqmFilterIF
11 public function getTitle()
16 public function test( CqmPatient
$patient, $beginDate, $endDate )
18 // Flow of control loop
21 // See if BMI has been recorded between >=22kg/m2 and <30kg/m2 6 months before, or simultanious to the encounter
22 $query = "SELECT form_vitals.BMI " .
23 "FROM `form_vitals` " .
24 "LEFT JOIN `form_encounter` " .
25 "ON ( form_vitals.pid = form_encounter.pid ) " .
26 "LEFT JOIN `enc_category_map` " .
27 "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " .
28 "WHERE form_vitals.BMI IS NOT NULL " .
29 "AND form_vitals.BMI IS NOT NULL " .
30 "AND form_vitals.pid = ? AND form_vitals.BMI >= 22 AND form_vitals.BMI < 30 " .
31 "AND DATE( form_vitals.date ) >= DATE_ADD( form_encounter.date, INTERVAL -6 MONTH ) " .
32 "AND DATE( form_vitals.date ) <= DATE( form_encounter.date ) " .
33 "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' )";
34 $res = sqlStatement( $query, array( $patient->id
) );
35 $number = sqlNumRows($res);
41 // See if BMI has been recorded >=30kg/m2 6 months before, or simultanious to the encounter
42 // AND ÒCare goal: follow-up plan BMI managementÓ OR ÒCommunication provider to provider: dietary consultation orderÓ
43 $query = "SELECT form_vitals.BMI " .
44 "FROM `form_vitals` " .
45 "LEFT JOIN `form_encounter` " .
46 "ON ( form_vitals.pid = form_encounter.pid ) " .
47 "LEFT JOIN `enc_category_map` " .
48 "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " .
49 "WHERE form_vitals.BMI IS NOT NULL " .
50 "AND form_vitals.BMI IS NOT NULL " .
51 "AND form_vitals.pid = ? AND form_vitals.BMI >= 30 " .
52 "AND ( DATE( form_vitals.date ) >= DATE_ADD( form_encounter.date, INTERVAL -6 MONTH ) ) " .
53 "AND ( DATE( form_vitals.date ) <= DATE( form_encounter.date ) ) " .
54 "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' )";
55 $res = sqlStatement( $query, array( $patient->id
) );
56 $number = sqlNumRows($res);
58 ( Helper
::check( ClinicalType
::CARE_GOAL
, CareGoal
::FOLLOW_UP_PLAN_BMI_MGMT
, $patient ) ||
59 Helper
::check( ClinicalType
::COMMUNICATION
, Communication
::DIET_CNSLT
, $patient ) ) ) {
64 // See if BMI has been recorded <22kg/m2 6 months before, or simultanious to the encounter
65 // AND ÒCare goal: follow-up plan BMI managementÓ OR ÒCommunication provider to provider: dietary consultation orderÓ
66 $query = "SELECT form_vitals.BMI " .
67 "FROM `form_vitals` " .
68 "LEFT JOIN `form_encounter` " .
69 "ON ( form_vitals.pid = form_encounter.pid ) " .
70 "LEFT JOIN `enc_category_map` " .
71 "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " .
72 "WHERE form_vitals.BMI IS NOT NULL " .
73 "AND form_vitals.BMI IS NOT NULL " .
74 "AND form_vitals.pid = ? AND form_vitals.BMI < 22 " .
75 "AND ( DATE( form_vitals.date ) >= DATE_ADD( form_encounter.date, INTERVAL -6 MONTH ) ) " .
76 "AND ( DATE( form_vitals.date ) <= DATE( form_encounter.date ) ) " .
77 "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' )";
78 $res = sqlStatement( $query, array( $patient->id
) );
79 $number = sqlNumRows($res);
81 ( Helper
::check( ClinicalType
::CARE_GOAL
, CareGoal
::FOLLOW_UP_PLAN_BMI_MGMT
, $patient ) ||
82 Helper
::check( ClinicalType
::COMMUNICATION
, Communication
::DIET_CNSLT
, $patient ) ) ) {