public function test(AmcPatient $patient, $beginDate, $endDate) { // Is smoking status recorded as structured data before the end date of the report if (exist_lifestyle_item($patient->id, 'tobacco', '', $endDate)) { return true; } else { return false; } }
/** * Function to check database filters and targets * * @param string $patient_id pid of selected patient. * @param array $filter array containing filter/target elements * @param array $interval array containing interval elements * @param string $dateTarget target date(format Y-m-d H:i:s). blank is current date. * @return boolean true if check passed, otherwise false */ function database_check($patient_id, $filter, $interval = '', $dateTarget = '') { $isMatch = false; //matching flag // Set date to current if not set $dateTarget = $dateTarget ? $dateTarget : date('Y-m-d H:i:s'); // Unpackage interval information // (Assume only one for now and only pertinent for targets) $intervalType = ''; $intervalValue = ''; if (!empty($interval)) { $intervalType = $interval[0]['value']; $intervalValue = $interval[0]['interval']; } foreach ($filter as $row) { // Row description // [0]=>special modes $temp_df = explode("::", $row['value']); if ($temp_df[0] == "CUSTOM") { // Row description // [0]=>special modes(CUSTOM) [1]=>category [2]=>item [3]=>complete? [4]=>number of hits comparison [5]=>number of hits if (exist_custom_item($patient_id, $temp_df[1], $temp_df[2], $temp_df[3], $temp_df[4], $temp_df[5], $intervalType, $intervalValue, $dateTarget)) { // Record the match $isMatch = true; } else { // If this is a required entry then return false if ($row['required_flag']) { return false; } } } else { if ($temp_df[0] == "LIFESTYLE") { // Row description // [0]=>special modes(LIFESTYLE) [1]=>column [2]=>status if (exist_lifestyle_item($patient_id, $temp_df[1], $temp_df[2], $dateTarget)) { // Record the match $isMatch = true; } else { // If this is a required entry then return false if ($row['required_flag']) { return false; } } } else { // Default mode // Row description // [0]=>special modes(BLANK) [1]=>table [2]=>column [3]=>value comparison [4]=>value [5]=>number of hits comparison [6]=>number of hits if (exist_database_item($patient_id, $temp_df[1], $temp_df[2], $temp_df[3], $temp_df[4], $temp_df[5], $temp_df[6], $intervalType, $intervalValue, $dateTarget)) { // Record the match $isMatch = true; } else { // If this is a required entry then return false if ($row['required_flag']) { return false; } } } } } // return results of check return $isMatch; }