0% found this document useful (0 votes)
5 views18 pages

Report Oop 1

The document outlines the design and implementation of a vaccine registration system using object-oriented programming principles. It details the classes involved, including 'Patient' and 'VaccinationProcess', along with their functionalities such as patient registration, vaccination processes, and data management. Additionally, it includes flow and class diagrams, source code snippets, and emphasizes the system's strengths in modularity and organization.

Uploaded by

Pemerhati Bebas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views18 pages

Report Oop 1

The document outlines the design and implementation of a vaccine registration system using object-oriented programming principles. It details the classes involved, including 'Patient' and 'VaccinationProcess', along with their functionalities such as patient registration, vaccination processes, and data management. Additionally, it includes flow and class diagrams, source code snippets, and emphasizes the system's strengths in modularity and organization.

Uploaded by

Pemerhati Bebas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

TABLE OF CONTENT

CONTENT PAGES
1.0 INTRODUCTION 2

2.0 CLASS EXPLAINATION 3

3.0 APPLICATION

3.0.1 FLOW DIAGRAM 4

3.0.2 CLASS DIAGRAM 5

3.0.3 SOURCES ARRANGEMENT 6-13

4.0 STRENGTH & UNIQUENESS 13-15

5.0 SAMPLE OUTPUT 15-18

1
1.0 INTRODUCTION

Efficient patient information management and vaccination registration are essential in


all aspects of healthcare and public health. Using the concepts of object-oriented
programming (OOP) provides an effective and extendable basis for the development of a
vaccine registration system.
The objectives of this system are to preserve patient records, simplify the registration
process, and enable smooth, dynamic updates. Our vaccine registration system utilizes
inheritance, constructors, destructors, classes, and dynamic pointers to fully utilize the power
of object-oriented programming. This structure improves the organization of the code and
makes it easier to scale, maintain, and extend.

2
2.0 CLASS EXPLANATION
‘Patient’ Class :

• This class represents a patient in the vaccination system.


• It has private member variables for patient details (name, age, vaccine type, etc.).
• The constructor ‘Patient’ initializes the patient's information when an object is created
• Getter methods are provided to access the private member variables.

‘VaccinationProcess’ Class:

• This class manages the vaccination process, including patient registration,


verification, vaccination, and data storage.
• It has private member variables for tracking total vials and vectors to store pre-
registered and new patients.
• The constructor initializes total vials and loads pre-registered data from a file.
• The destructor saves the registered data and deallocates memory for patient objects.
• Various methods handle patient registration, verification, vaccination, and data
manipulation.

Other Functions:

• There are also several functions outside the classes (‘displayStatistics’ ,


‘registerPreRegisteredPatient’ , etc.) that interact with the ‘VaccinationProcess’ class
to perform specific tasks.

3
3.0 EXPLANATION OF APPLICATION
3.0.1 FLOWCHART

START

Menu Display

Case 1

Case 2

Loop (Return to
Menu)
Case 3

User Chooses 6
(Exit Program)
Case 4

Save Data and Exit


Case 5

END
Case 6

4
3.0.2 CLASS DIAGRAM

Patient VaccinationProcess

-name : string -totalVialsPfizer


-age : int -totalVialsSinovac
-vaccineType : string
-totalVialsAstraZen
-phoneNumber : string
-preRegisteredPatient : vector<Patient*>
-icNumber : string
newRegistrations : vector<Patient*>
-homeAddress : string
-gender : string
+isPatientRegistered(name : string) : bool

+getName() : string +verifyPreRegisteredPatient(name : string) : bool

+getAge() : int +verifyDocuments() : void

+getVaccineType() : string +registeredNewPatient(name, age, vaccineType,


phoneNumber, icNumber, homeAddress, gender) :
+getPhoneNumber() : void
string
+performVaccination() : void
+getICNumber() : string
+getTotalPatients() : int
+getHomeAddress() :
string +getTotalPfizerVials() : int

+getGender() : () : string +getTotalSinovacVials() : int

+displayInfo() : void +getTotalAstraZenecaVials() : int

+isValidVaccineType(type : string) : bool

+saveRegisteredData() : void

+loadRegisteredData() : void

5
3.0.3 SOURCE ARRANGEMENT

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

class Patient {
protected:
string name;
int age;
string vaccineType;
string phoneNumber;
string icNumber;
string homeAddress;
string gender;

public:
Patient(const string& n, int a, const string& v, const string& phone, const string& ic,
const string& address, const string& g)
: name(n), age(a), vaccineType(v), phoneNumber(phone), icNumber(ic),
homeAddress(address), gender(g) {
cout << "\nPatient registered.\n";
}

~Patient() {
cout << "\nPatient removed from the system.\n";
}

string getName() const {


return name;
}

int getAge() const {


return age;
}

string getVaccineType() const {


return vaccineType;
}

string getPhoneNumber() const {


return phoneNumber;
}

string getICNumber() const {


return icNumber;
}

string getHomeAddress() const {


return homeAddress;
}

6
string getGender() const {
return gender;
}

void displayInfo() const {


cout << "Name: " << name << "\nAge: " << age << "\nVaccine Type: " <<
vaccineType
<< "\nPhone Number: " << phoneNumber << "\nIC Number: " << icNumber
<< "\nHome Address: " << homeAddress << "\nGender: " << gender << "\n";
}
};

class VaccinationProcess {
private:
int totalVialsPfizer;
int totalVialsSinovac;
int totalVialsAstraZeneca;
vector<Patient*> preRegisteredPatients;
vector<Patient*> newRegistrations;

public:
VaccinationProcess()
: totalVialsPfizer(0), totalVialsSinovac(0), totalVialsAstraZeneca(0) {
loadRegisteredData();
}

~VaccinationProcess() {
saveRegisteredData();

for (Patient* p : preRegisteredPatients) {


delete p;
}
for (Patient* p : newRegistrations) {
delete p;
}
preRegisteredPatients.clear();
newRegistrations.clear();
}

bool isPatientRegistered(const string& patientName) const {


for (const Patient* p : preRegisteredPatients) {
if (p->getName() == patientName) {
return true;
}
}
return false;
}

bool verifyPreRegisteredPatient(const string& patientName) const {


for (const Patient* p : preRegisteredPatients) {
if (p->getName() == patientName) {
cout << " " << patientName << " is pre-registered patient.\n";
return true;
}
}

7
cout << " " << patientName << " is not pre-registered patient.\n";
return false;
}

void verifyDocuments() {
cout << "\nVerifying documents for pre-registered patients...\n";
string patientName;
cout << "\nEnter patient name for verification: \n";
cin.ignore();
getline(cin, patientName);

if (verifyPreRegisteredPatient(patientName)) {
cout << "Verification SUCCESSFULL for patient " << patientName << ".\n";
// Add patient to new registrations
for (const Patient* p : preRegisteredPatients) {
if (p->getName() == patientName) {
newRegistrations.push_back(new Patient(*p));
break;
}
}
} else {
cout << "Verification FAILED for patient " << patientName << ". Patient not
found.\n";
}
}

void registerNewPatient(const string& name, int age, const string& vaccineType,


const string& phoneNumber, const string& icNumber,
const string& homeAddress, const string& gender) {
Patient* newPatient = new Patient(name, age, vaccineType, phoneNumber,
icNumber, homeAddress, gender);
newRegistrations.push_back(newPatient);
}

void performVaccination() {
verifyDocuments();

for (const Patient* p : newRegistrations) {


if (p->getVaccineType() == "Pfizer") {
totalVialsPfizer++;
} else if (p->getVaccineType() == "Sinovac") {
totalVialsSinovac++;
} else if (p->getVaccineType() == "AstraZeneca") {
totalVialsAstraZeneca++;
}
}

displayVaccinatedPatients();

cout << "Total Pfizer vials consumed: " << totalVialsPfizer << "\n";
cout << "Total Sinovac vials consumed: " << totalVialsSinovac << "\n";
cout << "Total AstraZeneca vials consumed: " << totalVialsAstraZeneca << "\n";
}

void addPreRegisteredPatient(const string& name, int age, const string& vaccineType,

8
const string& phoneNumber, const string& icNumber,
const string& homeAddress, const string& gender) {
Patient* preRegisteredPatient = new Patient(name, age, vaccineType,
phoneNumber, icNumber, homeAddress, gender);
preRegisteredPatients.push_back(preRegisteredPatient);
}

void displayVaccinatedPatients() const {


cout << "\nList of vaccinated patients:\n";
for (const Patient* p : newRegistrations) {
p->displayInfo();
cout << "-----------------------\n";
}
}

int getTotalPatients() const {


return preRegisteredPatients.size() + newRegistrations.size();
}

int getTotalPfizerVials() const {


return totalVialsPfizer;
}

int getTotalSinovacVials() const {


return totalVialsSinovac;
}

int getTotalAstraZenecaVials() const {


return totalVialsAstraZeneca;
}

bool isValidVaccineType(const string& type) const {


return (type == "Pfizer" || type == "Sinovac" || type == "AstraZeneca");
}

void saveRegisteredData() const {


ofstream outFile("vaccination_data.txt");
if (outFile.is_open()) {
for (const Patient* p : preRegisteredPatients) {
outFile << p->getName() << "," << p->getAge() << "," << p->getVaccineType()
<< "," << p->getPhoneNumber() << "," << p->getICNumber()
<< "," << p->getHomeAddress() << "," << p->getGender() << "\n";
}
for (const Patient* p : newRegistrations) {
outFile << p->getName() << "," << p->getAge() << "," << p->getVaccineType()
<< "," << p->getPhoneNumber() << "," << p->getICNumber()
<< "," << p->getHomeAddress() << "," << p->getGender() << "\n";
}
outFile.close();
cout << "\nData saved successfully.\n";
} else {
cout << "\nUnable to save data to file.\n";
}
}

9
void loadRegisteredData() {
ifstream inFile("vaccination_data.txt");
if (inFile.is_open()) {
string name, age, vaccineType, phoneNumber, icNumber, homeAddress, gender;
while (getline(inFile, name, ',')) {
getline(inFile, age, ',');
getline(inFile, vaccineType, ',');
getline(inFile, phoneNumber, ',');
getline(inFile, icNumber, ',');
getline(inFile, homeAddress, ',');
getline(inFile, gender, '\n');

int patientAge = stoi(age);


addPreRegisteredPatient(name, patientAge, vaccineType, phoneNumber,
icNumber, homeAddress, gender);
}
inFile.close();

} else {
cout << "\nNo existing data file found.\n";
}
}
};

// Function to display real-time statistics


void displayStatistics(const VaccinationProcess& vaccinationProcess) {
cout << "\n===== Vaccination Statistics =====\n";
cout << "Total number of patients: " << vaccinationProcess.getTotalPatients() << "\n";
cout << "Total Pfizer vials consumed: " << vaccinationProcess.getTotalPfizerVials() <<
"\n";
cout << "Total Sinovac vials consumed: " << vaccinationProcess.getTotalSinovacVials()
<< "\n";
cout << "Total AstraZeneca vials consumed: " <<
vaccinationProcess.getTotalAstraZenecaVials() << "\n";
cout << "==================================\n";
}

void registerPreRegisteredPatient(VaccinationProcess& vaccinationProcess) {


string name, vaccineType, phoneNumber, icNumber, homeAddress, gender;
int age;

cout << "Enter patient name: ";


cin.ignore();
getline(cin, name);

cout << "Enter patient age: ";


cin >> age;

cout << "Enter vaccine type (Pfizer, Sinovac, AstraZeneca): ";


cin >> vaccineType;

cout << "Enter phone number: ";


cin >> phoneNumber;

cout << "Enter IC number: ";

10
cin >> icNumber;

cout << "Enter home address: ";


cin.ignore();
getline(cin, homeAddress);

cout << "Enter gender: ";


cin >> gender;

vaccinationProcess.addPreRegisteredPatient(name, age, vaccineType, phoneNumber,


icNumber, homeAddress, gender);
cout << "\nPre-registered patient added successfully.\n";
}

void registerNewPatient(VaccinationProcess& vaccinationProcess) {


string name, vaccineType, phoneNumber, icNumber, homeAddress, gender;
int age;

cout << "Enter patient name: ";


cin.ignore();
getline(cin, name);

cout << "Enter patient age: ";


cin >> age;

cout << "Enter vaccine type (Pfizer, Sinovac, AstraZeneca): ";


cin >> vaccineType;

cout << "Enter phone number: ";


cin >> phoneNumber;

cout << "Enter IC number: ";


cin >> icNumber;

cout << "Enter home address: ";


cin.ignore();
getline(cin, homeAddress);

cout << "Enter gender: ";


cin >> gender;

vaccinationProcess.registerNewPatient(name, age, vaccineType, phoneNumber,


icNumber, homeAddress, gender);
cout << "New patient registered successfully.\n";
}

void performVaccination(VaccinationProcess& vaccinationProcess) {


vaccinationProcess.verifyDocuments();
vaccinationProcess.performVaccination();
}

void viewTotalPatients(const VaccinationProcess& vaccinationProcess) {


cout << "Total number of patients: " << vaccinationProcess.getTotalPatients() << "\n";
}

11
void viewStatistics(const VaccinationProcess& vaccinationProcess) {
displayStatistics(vaccinationProcess);
}

void displayMenu() {
cout << "\n===== VACCINE REGISTRATION SYSTEM =====\n";
cout << "\n1. Register Pre-Registered Patient\n";
cout << "\n2. Register New Patient\n";
cout << "\n3. Perform Vaccination\n";
cout << "\n4. View Total Number of Patients\n";
cout << "\n5. View Real-time Statistics\n";
cout << "\n6. Exit\n";
cout << "=======================================\n";
}

int getMenuChoice() {
int choice;
cout << "\nEnter your choice (1-6): ";
cin >> choice;
return choice;
}

void processMenuChoice(int choice, VaccinationProcess& vaccinationProcess) {


switch (choice) {
case 1:
registerPreRegisteredPatient(vaccinationProcess);
break;
case 2:
registerNewPatient(vaccinationProcess);
break;
case 3:
performVaccination(vaccinationProcess);
break;
case 4:
viewTotalPatients(vaccinationProcess);
break;
case 5:
viewStatistics(vaccinationProcess);
break;
case 6:
cout << "\nExiting the program.\n";
break;
default:
cout << "\nInvalid choice. Please enter a number between 1 and 6.\n";
}
}

int main() {
VaccinationProcess vaccinationProcess;

do {
displayMenu();
int choice = getMenuChoice();
processMenuChoice(choice, vaccinationProcess);

12
// Break out of the loop if the user chose option 6
if (choice == 6) {
break;
}

} while (true);

return 0;
}

4.0 STRENGTH AND UNIQUENESS


4.0.1 STRENGTHS

Modularity and Organization:

• The code is organized into well-defined classes ‘Patient’ and ‘VaccinationProcess’,


promoting modularity and ease of maintenance.
Constructor and Destructor Usage:

• Constructors and destructors are appropriately utilized in the Patient and


‘VaccinationProcess’ classes, enhancing object initialization and cleanup.
Dynamic Memory Allocation:

• Dynamic memory allocation is employed for patient objects using new in the
‘VaccinationProcess’ class, and memory is properly deallocated in the destructor.
Inheritance and Polymorphism:

• The use of inheritance is not explicitly present in the current code, but there is
potential for extending classes and leveraging polymorphism.
File I/O:

• File I/O operations are implemented for saving and loading patient data,
demonstrating persistence and data management.
Encapsulation:

• Data members in the Patient class are encapsulated with private access modifiers,
ensuring controlled access to class properties.
User Input Handling:

• User input is appropriately handled using cin and ‘getline’, considering potential
issues with input buffer.

13
Error Handling:

• Some basic error handling is present, such as checking if the file is open during data
loading and providing feedback for invalid user choices.

Code Reusability:

• Functions are used to perform specific tasks, promoting code reusability and
maintainability.
Real-time Statistics Display:

• A function is dedicated to displaying real-time statistics, providing a snapshot of the


current system status.
Clear User Interface:

• The menu-driven user interface is clear and user-friendly, making it easy for users to
interact with the program.
Resource Management:

• Proper resource management is demonstrated, ensuring the release of dynamically


allocated memory in the destructor.
Persistence:

• Patient data is saved to a file, allowing for the persistence of information between
program executions.
Flexibility:

• The code structure allows for easy addition of new features or modifications to
existing functionality.

4.0.2 UNIQUENNESS:

Patient Class:

• The Patient class encapsulates essential patient information and employs a


constructor and destructor to handle the initialization and cleanup processes. It
includes a range of patient details such as name, age, vaccine type, phone number,
IC number, home address, and gender.

Dynamic Memory Management:

• The code employs dynamic memory allocation for patient objects using new to create
instances dynamically. It also ensures proper memory deallocation using delete in
the destructor to prevent memory leaks.

14
VaccinationProcess Class:

• The ‘VaccinationProcess’ class manages the vaccination process and maintains


counts of Pfizer, Sinovac, and AstraZeneca vials. It also handles pre-registered and
new patient data using vectors of pointers to Patient objects.

Persistence of Data:

• The code demonstrates the persistence of patient data by saving and loading
information from a file (vaccination_data.txt). This ensures that patient records are
retained across program executions.

Verification and Registration Process:

• The system includes a patient verification process, allowing the identification of pre-
registered patients and their subsequent registration for vaccination. It also supports
the registration of entirely new patients.

Real-Time Statistics:

• The system provides real-time statistics, displaying the total number of patients and
the consumption of Pfizer, Sinovac, and AstraZeneca vials.

Menu-Driven User Interface:

• The main function implements a menu-driven user interface, allowing users to


interactively choose various options such as patient registration, vaccination, and
viewing statistics.

Input Handling:

• The code incorporates proper input handling, utilizing ‘getline’ to handle string inputs
and ‘cin.ignore()’ to clear the input buffer when needed.

Structured Menu and Choice Processing:

• The menu and choice processing functions are well-structured, offering a clear and
organized way for users to interact with the system.

Polymorphism and Inheritance:

• Although not explicitly highlighted, the code structure supports potential future
extensions with polymorphism and inheritance, as the Patient class can be further
extended to accommodate different types of patients or additional functionalities.
OUTPUT

15
16
17
18

You might also like