Skip to content

Pet Module Documentation

Jack Turner edited this page Apr 7, 2025 · 1 revision

Pet Module Documentation - Veterinary Management System

Overview

The pets.cpp and pets.hpp files form the Pet Management module of the Veterinary Management System (VMS). This module handles all operations related to pet records, including creation, viewing, updating, deletion, search, filtering, and import/export.

Files Included

• pets.cpp: Implements the logic for all pet-related operations.

• pets.hpp: Declares function prototypes and includes necessary headers.

Goals of Each Step (cpp & hpp)

Basic Structure Setup

Goal: Create a function to display the Pet Menu and connect the file with the system. Explanation: This sets up the user interface portion of the pet module. It ensures users can access pet functions from the menu.

Add New Pet

Goal: Allow users to input new pet details and insert them into the database. Explanation: Gathers user input for name, breed, age, etc., and uses VMSDatabase::addRecord() to store it.

View All Pets

Goal: Display all pets stored in the database. Explanation: Uses VMSDatabase::printTable() to show the entire pet table.

Delete a Pet

Goal: Enable the deletion of a pet record by Pet ID. Explanation: Prompts user for Pet ID and removes the entry using VMSDatabase::deleteRecord().

Update Pet Details

Goal: Allow the user to update existing pet records. Explanation: Pulls all pets using getData(), finds the right one by ID, and prompts for updated fields before calling addRecord().

Search Pet by ID

Goal: Search for a pet based on Pet ID. Explanation: Iterates over the result of getData("pets") to find and display the correct record.

Import/Export CSV

Goal: Allow exporting pet data to a CSV file and importing from a CSV file. Explanation: Uses file streams to write all records to a file or load them into the database.

Header File (pets.hpp)

Function Prototypes

void addPet();
void viewPet();
void updatePet();
void removePet();
void viewAppointmentHistory();
void savePetsToFile();
void loadPetsFromFile();

Header Structure

• Includes <iostream>, <vector>, <string>, <fstream>, and your vms_database.hpp.

• Uses #pragma once to prevent duplicate inclusions.

Integration with VMS

The pet menu is integrated with main.cpp using a simple switch-based loop that allows the user to access it from the main dashboard. Once selected, displayPetMenu() is launched, which loops until the user exits.

Notes

• All database interaction is handled via the VMSDatabase class.

• All user input is validated with basic type checking.

• CSV export is written in plain text with , delimiters.

Clone this wiki locally