public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     if ($patient->calculateAgeOnDate($beginDate) >= 65 && Helper::checkEncounter(Encounter::ENC_OUTPATIENT, $patient, $beginDate, $endDate)) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $age = $patient->calculateAgeOnDate($beginDate);
     if ($age >= 2 && $age <= 18) {
         //Children 2-18 years of age who had an outpatient or emergency department (ED) visit with a diagnosis of pharyngitis during the measurement period and an antibiotic ordered on or three days after the visit
         $pharyngitisArr = array('ICD9:034', 'ICD9:462', 'ICD9:463', 'ICD10:J02.0', 'ICD10:J02.8', 'ICD10:J02.9', 'ICD10:J03.80', 'ICD10:J03.81', 'ICD10:J03.90', 'ICD10:J03.91');
         $query = "SELECT l.title as drug FROM form_encounter fe " . "INNER JOIN openemr_postcalendar_categories opc ON fe.pc_catid = opc.pc_catid " . "INNER JOIN lists l ON l.type = 'medication' AND fe.pid = l.pid " . "WHERE opc.pc_catname = 'Office Visit' ";
         $pharyngitisStr = "(";
         $cnt = 0;
         foreach ($pharyngitisArr as $pharyngitisCode) {
             if ($cnt == 0) {
                 $pharyngitisStr .= " l.diagnosis LIKE '%" . $pharyngitisCode . "%' ";
             } else {
                 $pharyngitisStr .= " OR l.diagnosis LIKE '%" . $pharyngitisCode . "%' ";
             }
             $cnt++;
         }
         $pharyngitisStr .= ")";
         $query .= " AND " . $pharyngitisStr;
         $query .= " AND fe.pid = ? AND (fe.date BETWEEN ? AND ?)";
         $check = sqlQuery($query, array($patient->id, $beginDate, $endDate));
         if ($check['drug'] != "") {
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     if ($patient->calculateAgeOnDate($beginDate) > 65) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $encounterCount = array(Encounter::OPTION_ENCOUNTER_COUNT => 1);
     if ($patient->calculateAgeOnDate($beginDate) >= 18 && $patient->calculateAgeOnDate($beginDate) < 85 && (Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::HYPERTENSION, $patient, $beginDate, date('Y-m-d H:i:s', strtotime('+6 month', strtotime($beginDate)))) || Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::HYPERTENSION, $patient, $beginDate, $beginDate)) && (Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OUTPATIENT, $patient, $beginDate, $endDate, $encounterCount) || Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_NURS_FAC, $patient, $beginDate, $endDate, $encounterCount))) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $oneEncounter = array(Encounter::OPTION_ENCOUNTER_COUNT => 1);
     if ($patient->calculateAgeOnDate($beginDate) >= 65 && Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OFF_VIS, $patient, $beginDate, $endDate, $oneEncounter)) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $age = $patient->calculateAgeOnDate($beginDate);
     if ($age >= 18 && $age <= 65) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $twoCount = array(Encounter::OPTION_ENCOUNTER_COUNT => 2);
     if ($patient->calculateAgeOnDate($beginDate) >= 50 && (Helper::checkEncounter(Encounter::ENC_PRE_MED_SER_40_OLDER, $patient, $beginDate, $endDate, $twoCount) || Helper::checkEncounter(Encounter::ENC_PRE_MED_GROUP_COUNSEL, $patient, $beginDate, $endDate) || Helper::checkEncounter(Encounter::ENC_PRE_IND_COUNSEL, $patient, $beginDate, $endDate) || Helper::checkEncounter(Encounter::ENC_PRE_MED_OTHER_SERV, $patient, $beginDate, $endDate) || Helper::checkEncounter(Encounter::ENC_NURS_FAC, $patient, $beginDate, $endDate) || Helper::checkEncounter(Encounter::ENC_NURS_DISCHARGE, $patient, $beginDate, $endDate))) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $twoEncounters = array(Encounter::OPTION_ENCOUNTER_COUNT => 2);
     if ($patient->calculateAgeOnDate($beginDate) >= 18 && Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::HYPERTENSION, $patient, $beginDate, $endDate) && (Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OUTPATIENT, $patient, $beginDate, $endDate, $twoEncounters) || Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_NURS_FAC, $patient, $beginDate, $endDate, $twoEncounters))) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // Rs_Patient characteristic: birth dateÓ (age) >=1 year and <2 years to capture all Rs_Patients who will reach 2 years during the Òmeasurement periodÓ;
     $age = $patient->calculateAgeOnDate($beginDate);
     if ($age >= 1 && $age <= 2) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // Rs_Patient characteristic: birth date� (age) >=1 year and <2 years to capture all Rs_Patients who will reach 2 years during the �measurement period�;
     $age = $patient->calculateAgeOnDate($beginDate);
     if ($age >= 1 && $age <= 2 && Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OFF_VIS, $patient, $beginDate, $endDate, 1)) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // filter for Patient characteristic: birth date (age) >=2 and <=16 years
     $age = intval($patient->calculateAgeOnDate($beginDate));
     if ($age >= 3 && $age <= 11 && Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OUTPATIENT, $patient, $beginDate, $endDate, 1)) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $oneEncounter = array(Encounter::OPTION_ENCOUNTER_COUNT => 1);
     $twoEncounters = array(Encounter::OPTION_ENCOUNTER_COUNT => 2);
     if ($patient->calculateAgeOnDate($beginDate) >= 18 && (Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OFF_VIS, $patient, $beginDate, $endDate, $twoEncounters) || Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OPHTHAL, $patient, $beginDate, $endDate, $twoEncounters) || Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_HEA_AND_BEH, $patient, $beginDate, $endDate, $twoEncounters) || Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OCC_THER, $patient, $beginDate, $endDate, $twoEncounters) || Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_PSYCH_AND_PSYCH, $patient, $beginDate, $endDate, $twoEncounters) || Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_PRE_MED_SER_18_OLDER, $patient, $beginDate, $endDate, $oneEncounter) || Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_PRE_IND_COUNSEL, $patient, $beginDate, $endDate, $oneEncounter) || Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_PRE_MED_GROUP_COUNSEL, $patient, $beginDate, $endDate, $oneEncounter) || Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_PRE_MED_OTHER_SERV, $patient, $beginDate, $endDate, $oneEncounter))) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // filter for Patient characteristic: birth dateÓ (age) >=2 and <=16 years
     $age = $patient->calculateAgeOnDate($beginDate);
     if ($age >= 2 && $age <= 10) {
         return true;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     if ($patient->calculateAgeOnDate($beginDate) >= 64) {
         $endMinus1Year = date('Y-m-d 00:00:00', strtotime('-1 year', strtotime($endDate)));
         if (Helper::checkEncounter(Encounter::ENC_OUTPATIENT, $patient, $endMinus1Year, $endDate)) {
             return true;
         }
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $age = intval($patient->calculateAgeOnDate($beginDate));
     if ($age >= 18 && $age <= 64) {
         $oneEncounter = array(Encounter::OPTION_ENCOUNTER_COUNT => 1);
         if (Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OUTPATIENT, $patient, $beginDate, $endDate, $oneEncounter)) {
             return true;
         }
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $age = $patient->calculateAgeOnDate($beginDate);
     if ($age >= 18 && $age < 75 && Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OFF_VIS, $patient, $beginDate, $endDate)) {
         $diabetes_codes = array();
         foreach (Codes::lookup(Diagnosis::DIABETES, 'SNOMED-CT') as $code) {
             $diabetes_codes[] = "SNOMED-CT:" . $code;
         }
         $diabetes_codes = "'" . implode("','", $diabetes_codes) . "'";
         $query = "select count(*) cnt from form_encounter fe " . "inner join lists l on ( l.type='medical_problem' and l.pid = fe.pid )" . "where fe.pid = ? and fe.date between ? and ? " . "and l.diagnosis in ({$diabetes_codes}) and (l.begdate < ? or (l.begdate between ? and ? )) and (l.enddate is null or l.enddate > ? )";
         $sql = sqlQuery($query, array($patient->id, $beginDate, $endDate, $beginDate, $beginDate, $endDate, $endDate));
         if ($sql['cnt'] > 0) {
             return true;
         }
         return false;
     }
     return false;
 }
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $age = $patient->calculateAgeOnDate($beginDate);
     if ($age >= 2 && $age < 18) {
         //Children 2-18 years of age who had an outpatient or emergency department (ED) visit with a diagnosis of pharyngitis during the measurement period and an antibiotic ordered on or three days after the visit
         $antibiotics = implode(',', Codes::lookup(Medication::ANTIBIOTIC_FOR_PHARYNGITIS, 'RXNORM'));
         $query = "SELECT p.drug as drug FROM form_encounter fe " . "INNER JOIN openemr_postcalendar_categories opc ON fe.pc_catid = opc.pc_catid " . "INNER JOIN prescriptions p ON fe.pid = p.patient_id " . "WHERE opc.pc_catname = 'Office Visit' AND fe.pid = ? AND (fe.date BETWEEN ? AND ? ) " . " AND p.rxnorm_drugcode in ( {$antibiotics} ) AND DATEDIFF(fe.date,p.date_added) <= 3";
         $check = sqlQuery($query, array($patient->id, $beginDate, $endDate));
         if ($check['drug'] != "") {
             if (Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::ACUTE_PHARYNGITIS, $patient, $beginDate, $endDate) || Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::ACUTE_TONSILLITIS, $patient, $beginDate, $endDate)) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
     return false;
 }