You are on page 1of 26

Table of Contents

CHAPTER 1: INTRODUCTION 2
1.1 Project Background 2
1.2 Objective 2
1.3 Scope 3
CHAPTER 2: METHODOLOGY 4
2.1 System Design 4
2.1.1 UML Class Diagram 4
2.1.2 Flowchart (result 7
CHAPTER 3: RESULTS AND DISCUSSION 12
3.1 Operation Menu / Welcome Message 12
3.2 Department Menu 14
3.3 Doctor Menu 16
3.3.1 Linked List and Algorithms 18
3.4 Get Patient List Using Vector 20
3.4.1 Search Patient Name in Vector 21
3.4.2 Sorting in Vector 22
3.4.3 Removing Elements in Vector 23
3.5 User Input Validation 24
CHAPTER 4: CONCLUSION 26

1
CHAPTER 1: INTRODUCTION
1.1 Project Background

As technology continue to advance, many systems have now involved automation and
high technology to solve real-life problem, so does medical field as well. With the technology
in medical field such as its equipment, computers, and software are constantly evolving, the
demand for medical services has increased; not because many people are unhealthy these days
but simply because the medical services have now become very convenient. Thus, many
software applications or systems and tools are appearing in medical field to provide solutions
in automating daily operations in a hospital, handling documentation task such as storing
personal information of patients and details of their disease and treatment. By using software
system to management hospital’s daily operation, we are able to reduce the pressure on the
doctors and nurses so they can focus on their task in treating patients instead of focusing on
administrative task.
Our Hospital Management System have the features of maintaining patients’ medical
records and personal details, name of the in-charged doctor for the patients. Our system also
able to track on the bill payments, append the patient data by updating the medical treatment
and condition, display personal information of patients to doctor while carried out diagnosis or
prognosis, and sort the queue based on the patient’s medical condition.
By digitizing all these information or documents and features into one system, the
doctors and the nurses do not need to analyse patient’s disease by manually searching through
‘paper-based’ database anymore, instead, they can now just go to the Hospital Management
System, type in patient’s name and view patient’s medical records such as disease and
treatments.
1.2 Objective

Hospital Management System purpose is to manage patients health care information into a
structured database and assist the workers in completing their job effectively and efficiently. It
is created to fulfil these following objectives :

1. To store the details of patient and workers to make a convenient and swift access for
later references.
2. To keep track of patient medical records for the appropriate specialization doctor or
emergency services.

2
3. To decrease the rate of human error and documentation work by using an efficient
system technology.
4. To track the bill payment that has been made by the patients.

1.3 Scope

Although a Hospital Management System has complicated system that is used to


manage all the departments such as laboratory, clinical, material, and etc, our system only
covers database management to store patients’ information such as their medical history, blood
type, severity of their medical condition, disease, and treatment; this system also able to act as
a finance system where it will display the amount to the patient and patients also allow to make
payment through this system. The aim for our system is mainly for recording patients’ medical
condition and treatment and generating the bills for the payment.

This system uses ‘txt.file’ as database thus, the number of patients that can be stored in
this Hospital Management System are depend on the memory capacity of the computer hard
disk. The memory size for each txt.file is 1KB, and our system is 289KB, thus, the computer
should have a minimum of memory capacity of hard disk of 16GB to store the patients’ data.
Figure 1.1 shows the total size of our Hospital Management System in Properties where the
folder consists of database (txt.file) and the program.

Figure 1.1 shows the size of the Hospital Managment Folder in Properties

The bill payment is limited to just adding patient to a ‘payment_database’ where it will
store the patients’ name and payment amount that have not been made. Once the patient makes
the payment, his or her name will be removed from the ‘payment_database’ but his or her

3
medical record will remain in the system. Detailed information of database will be discussed
in the latter chapter.

CHAPTER 2: METHODOLOGY
2.1 System Design

Throughout our project development process, UML Class diagram and flowchart are
used to design our system. This is to ensure we are able to control the scope of our project
throughout the development process. In this section, we will also discuss about how to set up
the database, header files for each class, data structures and the operation of each service
provided by the system. The definition of method in codes will be discussed in the latter
chapter which is Chapter 4 Results and Discussion.

2.1.1 UML Class Diagram


As mentioned previously, throughout the project development, UML diagram is used to
design our project. Figure 2.1 shows the Class Diagram of the Hospital Management System.

Figure 2.1 shows the Class Diagram of the Hospital Management System

4
In our Hospital Management System, we have implemented linked list, vector, and array
to manipulate the data using various algorithms such as searching, adding, sorting, and
removing. As mentioned previously, we have used text files or txt files as our database, thus
we have applied many built-in methods from ‘fstream’, ‘ofstream’, and ‘ifstream’ for file
handling. Based on the class diagram, we have used header files to construct our class, as well
as providing definition to the class’s methods. Header file is used because it allows the
programmer to read the codes easier as they are not cramped inside one file. As shown in
figure 2.1, we have constructed three header files, following are the name of header files:

• patient.h
• doctor_list.h
• application.h

patient.h is a header file that contains Patient class. It consists of the class’s methods
declaration and definition. doctor_list.h is a header file that contains doctor_list class and node
structure. It is used to construct linked list and add doctors into the linked list. application.h is
a header file that contains the declaration and definition of the driver program.

Database

To ensure the Hospital Management System runs smoothly, we have constructed two
folders to store departments and patients’ medical records respectively. Folder that stores
departments is named as ‘Departments’ and is used to store the queuing list of the patients
based on their desired doctors and departments whereas another folder named ‘Patient DB’ is
used to store patients’ medical records that are created as text files. Another database (text files)
named payment_list is to record the bill payment of patients. Figure 2.2 shows the database.
These databases regardless they are folder or text files, they must be located at the same
location to allow the program to open the file or folder. If they are placed separately, the full
path of the folders or files must be stated.

Figure 2.2 shows the databases that are used in Hospital Management System

5
patient.h or Patient Class

Based on the UML Class Diagram in figure 2.1, we can see that Patient class is used to
describe a patient in real life. Its instance variables are used to describe the attributes of a Patient
Object. From the Patient Class, we know that the Patient Object contains attributes of name,
age, medical history, treatment, blood type, phone number, department and doctor the patient
has assigned to, and the severity of his or her disease or medical condition. The Patient Class
consists of methods or functions to create their medical record in the database, assign doctors
to them based on departments, display information such as medical history and personal
information from the database, update information such as adding medical treatment into
database, sort the queue based on the patient’ severity, add patients’ names to payment database
and remove them from the database once they have made the payment. These behaviours can
be achieved by constructing the functions as per UML Class diagram in figure 2.1. The function
definition will be discussed in the latter chapter which is Chapter 3: Results and Discussion.

doctor_list.h or doctor_list Class and node struct

This header file contains doctor_list class and node struct. It is used to construct a linked
list and then add doctors as per their department to the linked list. This can be achieved by
constructing a node first and then use adding algorithm to add the doctors as per their
departments into the linked list. Thus, in the node struct, we will need to declare variable of
string named data, and a pointer named next to point to the next node. Then, we will need to
construct a class and declare the node struct in doctor_list class as instance variable, and set it
as null in the constructor.

Text file or txt file is created to store the names of the doctors as in figure 2.3. In figure
2.3, it shows the names of the doctors are stored inside a text file named Doctor DB and is
located inside a folder that named based on the doctors’ departments. For example, Dr. Mohd
Kamal and Dr. Ramar Omar are from General Department.

Other than having ‘add’ algorithm in the doctor_list class, we also have implemented
‘searching’ algorithm to validate user input. For example, Dr. Mohd Kamal and Ramar Omar
are displayed to the user as ‘Doctor Menu’, thus, initial assumption is user will enter the
doctor’s name based on the menu, however user might accidentally key in the wrong name.
Thus, searching algorithm is used to check if the user input exists in the linked list or not. If it
is not in the linked list, then the system will be able to inform the user.

6
Figure 2.3 shows the list of doctors in the department in text file

application.h

This header file is used to declare the prototype of functions that the system uses and
provide definition to them. As mentioned previously, header files able to enhance the
readability and code functionality instead of putting all the codes in one file that can increase
complexity and errors. The functions declared and defined in this header files are used to obtain
the patient list or the queue, remove patients from the patient list or the queue once he or she
has been brought to the doctor, display the doctor menu and department menu for the user to
choose. Figure 2.1 shows the required parameters to construct the functions mentioned.

2.1.2 Flowchart (result

Figure 2.4 shows the flowchart of Hospital Management System

Figure 2.4 shows the flowchart of our Hospital Management System (HMS) that can
provide five services to the user which are as follow:

7
• Provide Queue Number to Patient
• Bring Patient to Doctor
• Add Patient
• Search and Update Patient Data
• Update Patient Payment

In our HMS, the first message that user will be seeing is the operation menu. The operation
menu will display the five services listed as above and exit program for user to choose.

Provide Queue Number to Patient

This operation is used to provide the queue number to the patient according to their index
in the vector. When this operation, the program proceeds to show the department menu and
then doctor menu based on the user selection on department. Upon selecting which department
to visit, the program will go to the department folder and extract the Doctor DB text file and
put them in linked list to be displayed to the user. Then, after validating the user input to ensure
the name that entered by user exists in the linked list, program proceeds to look for the doctor’s
folder and access the text file named ‘patient_list’ to extract the patients’ name inside the files
and put them in the vector. Figure 2.5 and 2.6 shows the Departments folder and the patient_list
text files in the Dr. Yang folder respectively.

Figure 2.5 shows the types of Department in the HMS with different folder that
stores different doctors

Figure 2.6 shows the names of the patient in the patient_list text files that located in
the chosen Doctor folder

8
After program opens the patient_list text files, it will read the text file first to check whether
if it is empty or not. If it is empty, it will tell the user that the doctor has no patient at the
moment so no queue number will be generated; else, it will proceed to extract the patients’
names into vector and displayed them to the user for user to choose which patient the user
would like to generate the queue number to. Upon choosing which patient to generate the queue
number to, program will check if the input is correct or not based on the patient_list. This can
be done by using searching algorithm to the vector data structure since the patients’ names have
been stored as vector in the program. If the name cannot be found in the vector, then it will
display error message to the user and ask user to enter the correct name based on the patient
list displayed; else, it proceeds to generate the queue number based on the patient’s index in
the vector and displayed to the user. This also is done by using searching algorithm. After
generating the queue number, it will bring the user back to the operation menu.

Bring Patient to Doctor

When this operation is chosen, it is telling the program to remove the patient from the
patient_list text file. This can be done by using vector data structure and remove algorithm.
Similar process as the first operation discussed previously, department menu and doctor menu
will be displayed to the user for him or her to choose. Then it will proceed to check if there is
any patient in the list or not, in another words, the system will check if there is any patient
waiting in the queue or not. If there is not patient in the queue, then it will tell the user that the
doctor has no patient at the moment and bring user back to operation menu; else, it will display
the first element which is patient’s name in the vector and remove him or her from the vector
as this indicate that the user has been brought to visit the doctor. Next patient waiting in the
line will be displayed to the user. Finally, it will bring the user back to the operation menu.

Add Patient

This operation is used to add new patient into the HMS. Upon selecting this operation,
user will need to provide information to the system for it to be stored in the Patient DB as
discussed in the previous section. The personal information required for the system to store in
the medical record are as follow:

• Name of the Patient


• Age of the Patient
• Contact Number of the Patient

9
• Medical History of the Patient
• Blood Type of the Patient
• Severity of the Illness of the Patient

After entering all these information into the system by user, department menu will be
displayed to the user for him or her to choose and then proceed to display the doctor menu as
per the department selection. The department and the doctor chosen here will be recorded in
the medical record as well. After entering all the information and select the department, as well
as doctor, it will store the medical record in the Patient DB as discussed previously then print
successfully added to the database message to the user.

Search and Update Patient Data

This operation is mainly used by medical staff such as doctor to give medical treatment
such as medicine that will be prepared by the pharmacist after carried out diagnosis and
prognosis on the patient. In order to update the patient medical record, the user will need to
enter the patient’s name that he or she wishes to update. Then it will display the medical record
of the patient to the user after validating that the patient’s medical record exists in the database.
The system will ask the user whether he or she wishes to update the medical record or not. If
‘no’ is chose, then program will bring user back to operation menu; else, the medical staff will
need to enter the medical condition and treatment to the medical record.

Scenario for this operation is when doctor wishes to update the patient’s medical condition
and treatment during consultation with the patient. Then he or she proceeds to search the
patient’s medical record up in the database and view the patient’s medical record. He or she
choses ‘yes’ to update the medical record by adding medical condition that describe by the
patient after consulting the patient and then provide the medical treatment to the patient. Finally,
the consultation ended with the patient’s medical record updated to having medical condition
and treatment inside. Now the patient can proceed to hospital pharmacy to take medicine if
there is any based-on prescription or treatment given by the doctor. The pharmacist will then
search the patient’s medical record in the database and view the medical treatment entered by
doctor in charged. He or she will not update the medical record thus ‘no’ is chosen when
program asks whether he or she wanted to make any update on the medical record.

10
Update Patient Payment

This operation is used to update the payment_list text file after patient makes the payment.
This is done by using vector structure to extract the payment_list and remove the patient that
has made the payment from the list. A temp_list text file will be opened and write the new
vector into the file and renamed to the payment_list text file after removed the patient from the
vector. The user needs to key in the patient’s name first in order to remove the patient from the
payment_list textfile.

11
CHAPTER 3: RESULTS AND DISCUSSION
As mentioned in the Chapter Introduction, our HMS is a console application. Thus, in this
section, we will discuss about how the department menu, doctor menu, patient list and payment
list have been generated using data structure such as linked list and vector. We will also discuss
about how the system able to catch error that caused by user input.

3.1 Operation Menu / Welcome Message

Figure 3.1 shows the operation menu and welcome message to the user

In the figure above (3.1), there are 5 services provided by the system are put inside a menu
together with ‘Exit’. These services have their own functions to achieve the operation that has
been discussed in Chapter 2 Methodology. Figure 3.2 shows the menu appears again when user
try to enter number or selection that is not included in the menu which is ‘8’. Figure 3.3 shows
another error produced by the program when user key in character instead of integer.

Figure 3.2 shows the menu appears again when user enter an invalid number

12
Figure 3.3 shows error message produced when user key in character

This can be achieved by using do-while loop and as long as the user does not select 6, the
program will keeps running. If the user entered the correct input, then it will bring user to the
specific service or the operation that chosen by the user. While loop is implemented to validate
user input when it is not an integer data type. Following shows the fragment of code using do-
while loop:

Figure 3.4 shows the fragment of code to validate user input

13
3.2 Department Menu

Figure 3.5 shows the user select (1) in the operation menu

Figure 3.5 shows the snapshot of the console application of HMS after user select
operation (1) which is ‘Provide Queue Number to Patient’. The operation of this service has
been described and explained in previous chapter. Now, we will look more in depth on the
implementation side of the codes and errors that might be produced due to user input.

The department menu displayed in the console application as in figure 3.5 is done by using
function that is declared and defined in the application.h which is the header file for the driver
program. Figure 3.6 shows the snapshot of the declaration of the functions in Code::Block IDE.
Green arrow indicates the header file named application.h is used to store all the declaration or
prototype and definition of the functions in our HMS. This header file is mainly used in driver
program. The orange arrow indicates the prototype or declaration of the function that used to
display department at line 17. Figure 3.7 shows the function definition in the application.h file.

Figure 3.6 shows the function declaration in the application.h (header file)

14
Figure 3.7 shows the function definition

In the event of incorrect input such as user enters number that is not in the selection or
enters character instead of integer, the system will be able to capture it and display the error
message to the user. Figure 3.8 shows the error produced by the user when he or she entered
number that is out of the range of selection. Figure 3.9 shows the error produced by user
when he pr she entered a character ‘d’ instead of number.

Figure 3.8 shows the error message displayed to the user

15
Figure 3.8 shows the error message displayed to the user after he or she entered
character

The implementation is similar to the ‘Operation Menu / Welcome Message’ where do-
while loop and while loop are used to validate user input. If user did not enter any value that
is incorrect to the program by entering the correct number displayed in the above figure (3.8),
the program will proceed to display the doctor menu. Before we jump into the discussion of
doctor menu, we need to discuss how user select the department and affect the doctor menu
next. This can be achieved by using switch case to check which selection has been selected
by user, and then return the value of ‘department’ which is a string variable to be used to
open the folder to retrieve the Dcotor DB text file as discussed in the Chapter 2. The types of
department will be stored in an array. Figure 3.9 shows the doctor menu is displayed after
user entered the correct input and select (2) which is General department.

Figure 3.9 shows the doctor menu

3.3 Doctor Menu

The Doctor Menu is displayed by using linked list structure. First, we need to extract the
names of the doctor as per their department from the Doctor DB text file and then add them
into linked list by using add algorithm. Figure 3.10 shows the function named display_doctor
in the application.h that receive string as parameter to display the doctor menu to the user.

16
Figure 3.10 shows the doctor menu

At line 64 in the above figure (3.10), we used a function named add_doctor that receive
‘name’ variable as parameter to add the doctors’ name in the Doctor DB into linked list. It is
placed inside the while loop as this is to ensure the doctors’ names inside the Doctor DB text
file are all extracted and stored in linked list. To read the file, as discussed in Chapter 2, we
used ‘ifstream’ class in C++ to read file. This class can only be used for reading purpose,
writing behaviour is not allowed.

After adding doctors’ names to the linked list, it will be displayed by invoking a function
named display_doctor that accepts no parameters in doctor_list class as shown in figure 3.10
with black arrow pointing at line 70. The doctor_list class has been declared as object with the
name of ‘doctors’ as shown in figure 3.10 at line 55 with green arrow pointing at it. Finally,
validation must be carried out to prevent unwanted event such as program crashing from
happening due to user enters an incorrect input. Thus, at line 75 with yellow arrow pointing at
it, search function is called under the Doctors Object with ‘doc_name’ as the parameter which
is the variable to store user input. The search function will return Boolean data type thus, a
variable named ‘validate’ is declared with Boolean data type and used to store the return value
of the function. If ‘validate’ is false, then it will print the invalid message to the user and execute
the ‘again’ using goto keyword in c++.

17
3.3.1 Linked List and Algorithms

After discussing the functions in the application.h, now we can further discuss about the
algorithms that we used to manipulate the data in the linked list. The algorithms are all declared
and defined in the doctor_list class or doctor_list.h (header file). Figure 3.11 shows the
declaration of doctor_list class, instance functions and instance variables in the class, and node
struct in the doctor_list.h.

Figure 3.11 shows the declaration of doctor_list class and node struct

The node struct in the doctor_list.h acts as a node that contains data and pointer. The data
is declared as string data type as in the HMS, we are adding doctors’ names into the linked list.
The pointer is named as ‘next’ as shown in figure 3.11 and it is used to point to the next element
or in another words, the pointer will store the value of next node’s address. Figure 3.12 shows
the diagram of a linked list.
Head

address1

data Address2 data null

address1 address2

Figure 3.12 shows the achitecture of linked list

After declaring the node struct, we need to declare the doctor_list class by declaring
instance variables and functions. In the doctor_list class, we have declared a pointer named
head as pointer. All the instance functions in the class are declared as public so that other classes
and driver program can use. Figure 3.13 shows the functions definition for each function
displayed in figure 3.11 as prototype or declaration.

18
1
3

Figure 3.13 shows the definition of fucntions

In figure 3.13, we have broken the codes in four boxes based on their functionality. For
the first box, it is the constructor for doctor_list class. It is used to declare the head pointer to
null. The second box contains the definition of add_doctors that receive name as parameter. It
has the functionality of adding ‘names’ (parameter) to the node and connect the nodes together
to form a linked list. In the definition, first, we will need to construct a new node named
newNode as shown in figure 3.13, then we will need to check if the head pointer is null or not,
if it is null, the node that we constructed will be the first node and the head pointer will store
the address of our first node; else, we will need to create a temporary pointer named as last and
it will point to the existed node in the linked list, same as head. The while loop is used to
transverse the linked list to find the last node that points to null and the ‘last’ pointer will be
pointing as the last node and change the ‘next’ in the last node to the newNode’s address. Figure
3.14 show the sketches to illustrate how the temporary pointer named ‘last’ to find the last node
in the linked list using while loop, and the arrow shows in the figure is to indicate hat the ‘null’
value in the node will be changed to the value inside the newNode which is the address of the
newly added node.

19
Figure 3.14 shows the sketches of find the last node in the linked list

Box 3 in figure 3.13 contains display_doctor function. It is used to print the doctors’ names
in the linked list to the console application for user to choose which doctor. Finally, box 4 in
figure 3.14 contains function that use to validate user input using searching algorithm and
return Boolean value. This can be done by using while loop to transverse the linked list to find
if doctor’s name entered by the user exists in the linked list or not. If the program able to find
the name in the linked list, then it will return true; else it will return false.

3.4 Get Patient List Using Vector

Our HMS required to display patient list to user when the user select the operation (1)
which is to generate queue number to the patient based on their assigned department and doctor.
The user will need to select department first and then doctor using the same function discuss
previously. After user select the doctor, then the program will go to the database to look for the
doctor’s folder to retrieve the patients’ names in the patient_list text file and invoke a function
named getPatientList in the application.h. This function is used to read the file and retrieve the
lines in the text file and store them into vector. Figure 3.15 shows the definition of
getPatientList that accepts three parameters which are as follow:

• doc_name: Doctor Name from the Doctor Menu selection


• dept_name: Department Name from the Department Menu selection
• patient_vector: a vector to store the patients’ names in the patient_list

20
At line 25 in figure 3.15, a built-in function from fstream named peek( ) is used to check
whether the text file is empty or not. If it is empty then it will return false and program will tell
the user that the doctor has no patient at the moment; else, it will proceed to read the lines or
patients’ names in the text file and store it as vector. To store the names into vector as per the
sequence in the text files, a built-in function in the vector class named push_back is used. To
add the patients’ names into vector, we just put the patient names that we retrieve from the text
file into the push_back function as parameter.

Figure 3.15 shows the definition of getPatientList function

In the main.cpp file we store the return value of the getPatientList inside the result variable
where it is declared as Boolean. ‘patient_vect’ is declared as vector as well in the main.cpp file,
thus when the function is invoked, the patient_vec will store the patients’ names and to be
displayed to the user. Figure 3.16 shows the snapshot of console application after user entered
the correct doctor’s name.

Figure 3.16 shows the snapshot of the console application of displaying Patients
Names

3.4.1 Search Patient Name in Vector

Searching algorithm is used to validate user input when the program asks the user to give
the patient’s name based on the list given. If user entered incorrect name, system will be able
to capture it and produce error message to the user. This can be achieved by using searching

21
algorithm as well, but this time the searching algorithm will be applied on vector. Since we
have stored the patients’ names in the vector, we can now use a built-in method named find by
including algorithm header in C++. At line 59 (figure 3.17), an auto keyword is used by asking
the compiler to guess the type of the variable from the initialization. For example, without the
auto keyword shown in figure 3.17 at line 59, we will need to type out:

vector<string>::iterator results = find… …

Figure 3.16 shows the fragment of code to validate user input using find functions

Once the user input is validated and correct, it will proceed to the next block of code which
is generating the queue number based on the patient’s index in the vector. A built-in function
named distance is used. It shares the same concept as using ‘results’ minus patient_vec.begin( )
to obtain the index.

3.4.2 Sorting in Vector

Sorting algorithm is used when the severity of the patient’s medical condition is bad. This
will require the doctor to attend to the patient first. So, a sorting algorithm is used to place the
patient as the first element of the vector and then write to the patient_list text file.

Figure 3.17 shows the snapshot of console application of patient’s choosing B


indicate her/his medical condition is bad

22
The severity of the medical condition is asked by program when user choose (2) which is
add patient in the operation menu. Once all the information is entered, multiple functions will
be invoked which is used to create record, assigning patient to doctor, update payment record
and sorting the patient based on his or her medical condition’s severity. In this section, we will
be discussed more about the sorting algorithm.

To sort the patient in the patient list when the patient is having bad medical condition, first
we need to declare a temporary vector to store the patients’ names in the patient_list text file.
Then, we will use the search algorithm that discussed in the previous section to check if the
patient’s name exists in the vector. If the patient exists in the list, program will use the
push_back function to add the patient’s name into a new vector which is patient_vect. To avoid
duplicate data in the patient_vect, a function named pop_back is used. Since the patient is just
added to the patient_list text file, so when it is retrieved from the text file, it will be placed at
the end of the vector. After that, we use the for loop to insert the patients’ names in the
temp_vect to the patient_vect using push_back function to maintain the sequence. Figure 3.18
shows the fragment of code to carry out sorting if the medical condition of the patient is bad;
and adding temp_vect to the patient_vect without carry out any sorting when the patient’s
medical condition is normal.

Figure 3.18 shows the if-else-then logic to check if sorting is required

After carried out sorting, fstream is used to write the patient_vect vector to the file using
for loop.

3.4.3 Removing Elements in Vector

23
3.5 User Input Validation

To ensure the patient’s medical record contains valid information such as name should not
contains integer, phone number should not contain alphabets, and age should not contain
characters, two functions are declared and defined in the application.h.

Figure 3.18 shows the incorrect input by user captured by system and asks user to re-enter
again. To capture the input of entering alphabets, while loop is used. The user can only exit or
break the loop when he or she enters the correct input. To check for a name whether it contains
numbers or not, for loop is used. Figure 3.19 shows the function named check_userInput_str
that accepts variable that is string data type as parameter.

Figure 3.19 shows the snapshot of console application where user keeps entering the
incorrect input

Figure 3.20 shows the definition of Figure 3.21 shows the definition of
check_userInput_str to validate user input check_userInput_phone to validate user input

Another function is declared and defined in application.h as well which is used to validate
the phone number that entered by the user. This function is used to check whether the phone
number contains alphabets or not. Figure 3.21 shows the definition of the function named
check_userInput_phone which accepts phone number as parameter.

24
25
CHAPTER 4: CONCLUSION

26

You might also like