if ($measure_id == "") { $measure_count++; continue; } if (count($range_list) == 0) { # Not a numeric field $measure_count++; continue; } foreach ($range_list as $range_entry) { $range_lower = $range_entry[0]; $range_upper = $range_entry[1]; $age_min = $range_entry[2]; $age_max = $range_entry[3]; $gender_option = $range_entry[4]; $ref_range = new ReferenceRangeGlobal(); $ref_range->measureId = $measure_id; $ref_range->ageMin = $age_min; $ref_range->ageMax = $age_max; $ref_range->sex = $gender_option; $ref_range->rangeLower = $range_lower; $ref_range->rangeUpper = $range_upper; $ref_range->addToDb($_SESSION['user_id']); } $measure_count++; } # Remove measure entries marked for deletion #foreach($measures_to_delete as $measure_id) #{ # Disabled for version 0.8.4. # TODO: Check existing result values before deleting a measure
public static function getByAgeAndSex($age, $sex, $measure_id, $user_id) { # Fetches the reference range based on supplied age and sex values $saved_db = DbUtil::switchToGlobal(); $query_string = "SELECT * FROM reference_range_global WHERE measure_id={$measure_id} AND user_id={$user_id}"; $retval = null; $resultset = query_associative_all($query_string, $row_count); if ($resultset == null || count($resultset) == 0) { return $retval; } foreach ($resultset as $record) { $ref_range = ReferenceRangeGlobal::getObject($record); if ($ref_range->ageMin == 0 && $ref_range->ageMax == 0) { # No agewise split if ($ref_range->sex == "B" || strtolower($ref_range->sex) == strtolower($sex)) { return $ref_range; } } else { if ($ref_range->ageMin <= $age && $ref_range->ageMax >= $age) { # Age wise split exists if ($ref_range->sex == "B" || strtolower($ref_range->sex) == strtolower($sex)) { return $ref_range; } } } } DbUtil::switchRestore($saved_db); }