Esempio n. 1
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     if (Helper::check(ClinicalType::COMMUNICATION, Communication::COUNS_NUTRITION, $patient, $beginDate, $endDate)) {
         return true;
     }
     return false;
 }
Esempio n. 2
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     if (Helper::check(ClinicalType::PHYSICAL_EXAM, PhysicalExam::FINDING_BMI_PERC, $patient, $beginDate, $endDate)) {
         return true;
     }
     return false;
 }
Esempio n. 3
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // Flow of control loop
     $return = false;
     do {
         // See if BMI has been recorded between >=22kg/m2 and <30kg/m2 6 months before, or simultanious to the encounter
         $query = "SELECT form_vitals.BMI " . "FROM `form_vitals` " . "LEFT JOIN `form_encounter` " . "ON ( form_vitals.pid = form_encounter.pid ) " . "LEFT JOIN `enc_category_map` " . "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " . "WHERE form_vitals.BMI IS NOT NULL " . "AND form_vitals.BMI IS NOT NULL " . "AND form_vitals.pid = ? AND form_vitals.BMI >= 22 AND form_vitals.BMI < 30 " . "AND DATE( form_vitals.date ) >= DATE_ADD( form_encounter.date, INTERVAL -6 MONTH ) " . "AND DATE( form_vitals.date ) <= DATE( form_encounter.date ) " . "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' )";
         $res = sqlStatement($query, array($patient->id));
         $number = sqlNumRows($res);
         if ($number >= 1) {
             $return = true;
             break;
         }
         // See if BMI has been recorded >=30kg/m2 6 months before, or simultanious to the encounter
         // AND ÒCare goal: follow-up plan BMI managementÓ OR ÒCommunication provider to provider: dietary consultation orderÓ
         $query = "SELECT form_vitals.BMI " . "FROM `form_vitals` " . "LEFT JOIN `form_encounter` " . "ON ( form_vitals.pid = form_encounter.pid ) " . "LEFT JOIN `enc_category_map` " . "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " . "WHERE form_vitals.BMI IS NOT NULL " . "AND form_vitals.BMI IS NOT NULL " . "AND form_vitals.pid = ? AND form_vitals.BMI >= 30 " . "AND ( DATE( form_vitals.date ) >= DATE_ADD( form_encounter.date, INTERVAL -6 MONTH ) ) " . "AND ( DATE( form_vitals.date ) <= DATE( form_encounter.date ) ) " . "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' )";
         $res = sqlStatement($query, array($patient->id));
         $number = sqlNumRows($res);
         if ($number >= 1 && (Helper::check(ClinicalType::CARE_GOAL, CareGoal::FOLLOW_UP_PLAN_BMI_MGMT, $patient) || Helper::check(ClinicalType::COMMUNICATION, Communication::DIET_CNSLT, $patient))) {
             $return = true;
             break;
         }
         // See if BMI has been recorded <22kg/m2 6 months before, or simultanious to the encounter
         // AND ÒCare goal: follow-up plan BMI managementÓ OR ÒCommunication provider to provider: dietary consultation orderÓ
         $query = "SELECT form_vitals.BMI " . "FROM `form_vitals` " . "LEFT JOIN `form_encounter` " . "ON ( form_vitals.pid = form_encounter.pid ) " . "LEFT JOIN `enc_category_map` " . "ON (enc_category_map.main_cat_id = form_encounter.pc_catid) " . "WHERE form_vitals.BMI IS NOT NULL " . "AND form_vitals.BMI IS NOT NULL " . "AND form_vitals.pid = ? AND form_vitals.BMI < 22 " . "AND ( DATE( form_vitals.date ) >= DATE_ADD( form_encounter.date, INTERVAL -6 MONTH ) ) " . "AND ( DATE( form_vitals.date ) <= DATE( form_encounter.date ) ) " . "AND ( enc_category_map.rule_enc_id = 'enc_outpatient' )";
         $res = sqlStatement($query, array($patient->id));
         $number = sqlNumRows($res);
         if ($number >= 1 && (Helper::check(ClinicalType::CARE_GOAL, CareGoal::FOLLOW_UP_PLAN_BMI_MGMT, $patient) || Helper::check(ClinicalType::COMMUNICATION, Communication::DIET_CNSLT, $patient))) {
             $return = true;
             break;
         }
     } while (false);
     return $return;
 }
Esempio n. 4
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // See if user has been a tobacco user before or simultaneosly to the encounter within two years (24 months)
     $date_array = array();
     foreach ($this->getApplicableEncounters() as $encType) {
         $dates = Helper::fetchEncounterDates($encType, $patient, $beginDate, $endDate);
         $date_array = array_merge($date_array, $dates);
     }
     // sort array to get the most recent encounter first
     $date_array = array_unique($date_array);
     rsort($date_array);
     // go through each unique date from most recent
     foreach ($date_array as $date) {
         // encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable
         $date = date('Y-m-d 23:59:59', strtotime($date));
         $beginMinus24Months = strtotime('-24 month', strtotime($date));
         $beginMinus24Months = date('Y-m-d 00:00:00', $beginMinus24Months);
         // this is basically a check to see if the patient is an reported as an active smoker on their last encounter
         if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_USER, $patient, $beginMinus24Months, $date)) {
             return true;
         } else {
             if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_NON_USER, $patient, $beginMinus24Months, $date)) {
                 return false;
             } else {
                 // nothing reported during this date period, so move on to next encounter
             }
         }
     }
     return false;
 }
Esempio n. 5
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     //Also exclude patients with a diagnosis of pregnancy during the measurement period.
     if (Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::PREGNANCY, $patient, $beginDate, $endDate)) {
         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)
 {
     $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)
 {
     $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;
 }
Esempio n. 9
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     $oneEncounter = array(Encounter::OPTION_ENCOUNTER_COUNT => 1);
     if (Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OUT_PCP_OBGYN, $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 = intval($patient->calculateAgeOnDate($beginDate));
     if ($age >= 3 && $age <= 11 && Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OUTPATIENT, $patient, $beginDate, $endDate, 1)) {
         return true;
     }
     return false;
 }
Esempio n. 11
0
 public function test(AmcPatient $patient, $beginDate, $endDate)
 {
     //Number of unique patients with office visits seen by the EP during the EHR reporting period
     $oneEncounter = array(Encounter::OPTION_ENCOUNTER_COUNT => 1);
     if (Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OFF_VIS, $patient, $beginDate, $endDate, $oneEncounter)) {
         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;
 }
Esempio n. 13
0
 public function test(AmcPatient $patient, $beginDate, $endDate)
 {
     //MEASURE STAGE 2: Number of unique patients who have had two or more office visits with the EP in the 24 months prior to the beginning of the EHR reporting period
     $twoEncounter = array(Encounter::OPTION_ENCOUNTER_COUNT => 2);
     if (Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OFF_VIS, $patient, $beginDate, $endDate, $twoEncounter)) {
         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)
 {
     $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;
 }
Esempio n. 16
0
 public function test(AmcPatient $patient, $beginDate, $endDate)
 {
     // Seen by the EP
     //  (basically needs an Office Visit within the report dates)
     $options = array(Encounter::OPTION_ENCOUNTER_COUNT => 1);
     if (Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OFF_VIS, $patient, $beginDate, $endDate, $options)) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 17
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     //Also exclude patients with a diagnosis of pregnancy during the measurement period.
     if (Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::PREGNANCY, $patient, $beginDate, $endDate)) {
         return true;
     }
     //Dialysis procedure exists exclude the patient
     $sql = "SELECT count(*) as cnt FROM procedure_order pr " . "INNER JOIN procedure_order_code prc ON pr.procedure_order_id = prc.procedure_order_id " . "WHERE pr.patient_id = ? " . "AND prc.procedure_code IN (' 108241001', '90937') " . "AND (pr.date_ordered BETWEEN ? AND ?)";
     $check = sqlQuery($sql, array($patient->id, $beginDate, $endDate));
     if ($check['cnt'] > 0) {
         return true;
     }
     return false;
 }
Esempio n. 18
0
 public function test(AmcPatient $patient, $beginDate, $endDate)
 {
     //MEASURE STAGE 2: Number of unique patients who have had two or more office visits with the EP in the 24 months prior to the beginning of the EHR reporting period
     // the begin date for encounter range is 2 years minus the above $beginDate
     $d1 = new DateTime($beginDate);
     $d2 = $d1->sub(new DateInterval('P2Y'));
     $beginDate_encounter = $d2->format('Y-m-d H:i:s');
     // the end date for encounter range is the above $beginDate
     $endDate_encounter = $beginDate;
     $twoEncounter = array(Encounter::OPTION_ENCOUNTER_COUNT => 2);
     if (Helper::check(ClinicalType::ENCOUNTER, Encounter::ENC_OFF_VIS, $patient, $beginDate_encounter, $endDate_encounter, $twoEncounter)) {
         return true;
     }
     return false;
 }
Esempio n. 19
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // Check for terminal illness within 6 months of encounter
     $dates = Helper::fetchEncounterDates(Encounter::ENC_OUTPATIENT, $patient, $beginDate, $endDate);
     foreach ($dates as $date) {
         $dateMinusSixMonths = strtotime('-6 month', strtotime($date));
         $dateMinusSixMonths = date('Y-m-d 00:00:00', $dateMinusSixMonths);
         if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TERMINAL_ILLNESS, $patient, $dateMinusSixMonths, $date)) {
             return true;
         }
     }
     if (Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::PREGNANCY, $patient, $beginDate, $endDate) || Helper::check(ClinicalType::PHYSICAL_EXAM, PhysicalExam::NOT_DONE_PATIENT, $patient, $beginDate, $endDate) || Helper::check(ClinicalType::PHYSICAL_EXAM, PhysicalExam::NOT_DONE_MEDICAL, $patient, $beginDate, $endDate) || Helper::check(ClinicalType::PHYSICAL_EXAM, PhysicalExam::NOT_DONE_SYSTEM, $patient, $beginDate, $endDate)) {
         return true;
     }
     return false;
 }
Esempio n. 20
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     //Also exclude patients with a diagnosis of pregnancy during the measurement period.
     if (Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::PREGNANCY, $patient, $beginDate, $beginDate) || Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::END_STAGE_RENAL_DISEASE, $patient, $beginDate, $beginDate) || Helper::check(ClinicalType::DIAGNOSIS, Diagnosis::CHRONIC_KIDNEY_DISEASE, $patient, $beginDate, $beginDate)) {
         return true;
     }
     $procedure_code = implode(',', Codes::lookup(Procedure::DIALYSIS_SERVICE, 'SNOMED'));
     //Dialysis procedure exists exclude the patient
     $sql = "SELECT count(*) as cnt FROM procedure_order pr " . "INNER JOIN procedure_order_code prc ON pr.procedure_order_id = prc.procedure_order_id " . "WHERE pr.patient_id = ? " . "AND prc.procedure_code IN ({$procedure_code}) " . "AND (pr.date_ordered BETWEEN ? AND ?)";
     //echo $sql;
     $check = sqlQuery($sql, array($patient->id, $beginDate, $endDate));
     if ($check['cnt'] > 0) {
         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;
 }
Esempio n. 22
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // See if user has been a tobacco user before or simultaneosly to the encounter within two years (24 months)
     foreach ($this->getApplicableEncounters() as $encType) {
         $dates = Helper::fetchEncounterDates($encType, $patient, $beginDate, $endDate);
         foreach ($dates as $date) {
             // encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable
             $date = date('Y-m-d 23:59:59', strtotime($date));
             $beginMinus24Months = strtotime('-24 month', strtotime($date));
             $beginMinus24Months = date('Y-m-d 00:00:00', $beginMinus24Months);
             // this is basically a check to see if the patient's tobacco status has been evaluated in the two years previous to encounter.
             if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_USER, $patient, $beginMinus24Months, $date) || Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_NON_USER, $patient, $beginMinus24Months, $date)) {
                 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
         $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;
 }
Esempio n. 24
0
 public function test(CqmPatient $patient, $beginDate, $endDate)
 {
     // See if user has been counseled to stop smoking or been prescribed a smoking cessations medication within last 24 months
     foreach ($this->getApplicableEncounters() as $encType) {
         $dates = Helper::fetchEncounterDates($encType, $patient, $beginDate, $endDate);
         foreach ($dates as $date) {
             // encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable
             $date = date('Y-m-d 23:59:59', strtotime($date));
             $date = date("Y-m-d H:i:s", strtotime('+1 days', strtotime($date)));
             $beginMinus24Months = strtotime('-24 month', strtotime($date));
             $beginMinus24Months = date('Y-m-d 00:00:00', $beginMinus24Months);
             // this is basically a check to see if the patient is an reported as an active smoker on their last encounter
             if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_USER, $patient, $beginMinus24Months, $date)) {
                 //return true;
                 // encounters time stamp is always 00:00:00, so change it to 23:59:59 or 00:00:00 as applicable
                 $date = date("Y-m-d H:i:s", strtotime('+1 days', strtotime($date)));
                 $date = date('Y-m-d 23:59:59', strtotime($date));
                 $beginMinus24Months = strtotime('-24 month', strtotime($date));
                 $beginMinus24Months = date('Y-m-d 00:00:00', $beginMinus24Months);
                 $smoke_cess = sqlQuery("SELECT * FROM `rule_patient_data` " . "WHERE `category`='act_cat_inter' AND `item`='act_tobacco' AND `complete`='YES' " . "AND `pid`=? AND `date`>=? AND `date`<=?", array($patient->id, $beginMinus24Months, $date));
                 // this is basically a check to see if the patient's action has occurred in the two years previous to encounter.
                 // TODO: how to check for the smoking cessation medication types (can also just be a smoking cessation order, ie. prescription)
                 if (!empty($smoke_cess) || Helper::checkMed(Medication::SMOKING_CESSATION, $patient, $beginMinus24Months, $date) || Helper::checkMed(Medication::SMOKING_CESSATION_ORDER, $patient, $beginMinus24Months, $date)) {
                     return true;
                 }
             } else {
                 if (Helper::check(ClinicalType::CHARACTERISTIC, Characteristic::TOBACCO_NON_USER, $patient, $beginMinus24Months, $date)) {
                     return false;
                 } else {
                     // nothing reported during this date period, so move on to next encounter
                 }
             }
         }
     }
     return false;
 }