The veterinary reporting system allows veterinarians to create detailed health assessments for animals, track their mood/condition over time, and monitor nutrition compliance. All reports require the vet_reports-create, vet_reports-edit, or vet_reports-view permissions.
This is used on public pages to show current animal health:
// In HealthStateReport modelpublic function getLatestByAnimalId($animalId){ $sql = "SELECT hsr.*, ag.animal_name, s.specie_name, c.category_name, h.habitat_name, u.username AS checked_by_username, r.role_name FROM health_state_reports hsr JOIN animal_full af ON hsr.id_full_animal = af.id_full_animal JOIN animal_general ag ON af.animal_g_id = ag.id_animal_g LEFT JOIN specie s ON ag.specie_id = s.id_specie LEFT JOIN category c ON s.category_id = c.id_category LEFT JOIN habitats h ON af.habitat_id = h.id_habitat LEFT JOIN users u ON hsr.checked_by = u.id_user LEFT JOIN roles r ON u.role_id = r.id_role WHERE hsr.id_full_animal = :animal_id ORDER BY hsr.review_date DESC, hsr.updated_at DESC LIMIT 1"; $stmt = $this->db->prepare($sql); $stmt->execute([':animal_id' => $animalId]); return $stmt->fetch(PDO::FETCH_OBJ);}
When viewing feeding logs, the system compares actual feeding to the nutrition plan:
// In feeding logs query$sql = "SELECT fl.*, ag.animal_name, af.nutrition_id, n.food_type AS plan_food_type, n.food_qtty AS plan_food_qtty, n.nutrition_type, u.username AS fed_by_username FROM feeding_logs fl JOIN animal_full af ON fl.animal_f_id = af.id_full_animal JOIN animal_general ag ON af.animal_g_id = ag.id_animal_g LEFT JOIN nutrition n ON af.nutrition_id = n.id_nutrition LEFT JOIN users u ON fl.user_id = u.id_user WHERE fl.animal_f_id = :animal_id ORDER BY fl.food_date DESC";
This allows veterinarians to see:
Planned food type vs. actual food type
Planned quantity vs. actual quantity
Feeding frequency and consistency
Discrepancies between planned and actual feeding can indicate issues that may affect the animal’s health state.
if ($result && is_numeric($result)) { header('Location: /vreports/gest/start?msg=saved'); exit();} else { // Log detailed error error_log("Failed to save health report. Parameters: full_animal_id=$fullAnimalId, state=$state"); // Provide specific error messages $errorMsg = "Failed to save health report."; if (is_array($result) && isset($result['error'])) { $dbError = $result['error']; if (strpos($dbError, 'foreign key') !== false) { $errorMsg = "The selected animal or user does not exist."; } elseif (strpos($dbError, 'Duplicate entry') !== false) { $errorMsg = "A report with this information already exists."; } } header('Location: /vreports/gest/create?msg=error&error=' . urlencode($errorMsg)); exit();}