Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

C++

PROJECT

Submitted By : RAVI

Class: XII A

Roll No :
TOPIC:

HOSPITAL
MANAGEMENT
CERTIFICATE

This is to certify that project entitled


“HOSPITAL MANAGEMENT”
is submitted by RAVI of class XII A
bearing roll no. . This project has been
completed under my guidance.

Ms. Vijaylaxmi
(PGT. Computer science)
CONTENTS
 Preface
 Acknowledgement
 Introduction
 Source code in C++
 Output
 Glossary
PREFACE

This project develops a basic idea on how


computers can be used to store and manage
a particular kind of data in an organization.
Through this project managing information
about the patients admitted into a hospital
will be more efficient, easy and convenient.
Records are easy to retrieve, manage and
update.

This project is able to add a new patient’s


record in the file, retrieve any existent
patient’s information etc.
ACKNOWLEDGEMENT

I am extremely grateful to my guide –

Ms.Vijaylaxmi for being a source of

inspiration and for her constant support in

the Design, Implementation and Evaluation

of the project. With utmost pleasure, I

would like to express my warm thanks to

her for her encouragement, co-operation

and consent without which I couldn’t be

able to complete this project.


INTRODUCTION
This project explains the basic blocks of HOSPITAL
MANAGEMENT system.

It defines :

* a structure for patient data


* a class for queue, which includes :
Member functions-
- add patient at the end
- add patient at the beginning
- get next patient
- output list
* The header files used are:
- iostream.h
- conio.h
- string.h
- stdlib.h
SOURCE CODE
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
// define maximum number of patients in a queue
#define MAXPATIENTS 100
// define structure for patient data
struct patient
{
charFirstName[50];
charLastName[50];
char ID[20];
};
// define class for queue
class queue
{
public:
queue (void);
intAddPatientAtEnd (patient p);
intAddPatientAtBeginning (patient p);
patientGetNextPatient (void);
voidOutputList (void);
charDepartmentName[50];
private:
intNumberOfPatients;
patient List[MAXPATIENTS];
};
// declare member functions for queue
queue::queue ()
{
// constructor
NumberOfPatients = 0;
}
int queue::AddPatientAtEnd (patient p)
{
// adds a normal patient to the end of the queue.
// returns 1 if successful, 0 if queue is full.
if (NumberOfPatients>= MAXPATIENTS)
{
// queue is full
return 0;
}
// put in new patient
else
List[NumberOfPatients] = p; NumberOfPatients++;
return 1;
}
int queue::AddPatientAtBeginning (patient p)
{
// adds a critically ill patient to the beginning of the queue.
// returns 1 if successful, 0 if queue is full.
int i;
if (NumberOfPatients>= MAXPATIENTS)
{
// queue is full
return 0;
}
// move all patients one position back in queue
for (i = NumberOfPatients-1; i >= 0; i--)
{
List[i+1] = List[i];
}
// put in new patient
List[0] = p; NumberOfPatients++;
return 1;
}
patient queue::GetNextPatient (void)
{
// gets the patient that is first in the queue.
// returns patient with no ID if queue is empty
int i; patient p;
if (NumberOfPatients == 0) {
// queue is empty
strcpy(p.ID,"");
return p;}
// get first patient
p = List[0];
// move all remaining patients one position forward in queue
NumberOfPatients--;
for (i=0; i<NumberOfPatients; i++)
{
List[i] = List[i+1];
}
// return patient
return p;
}

void queue::OutputList (void)


{
// lists entire queue on screen
int i;
if (NumberOfPatients == 0)
{
cout<< "\nQueue is empty";
}
else
{
for (i=0; i<NumberOfPatients; i++)
{
cout<< "" << List[i].FirstName;
cout<< " " << List[i].LastName;
cout<< " " << List[i].ID;
}
}
}
// declare functions used by main:
patientInputPatient (void)
{
// this function asks user for patient data.
patient p;
cout<< "\nPlease enter data for new patient"<<" First name: ";
cin.getline(p.FirstName, sizeof(p.FirstName));
cout<< "\nLast name:\n ";
cin.getline(p.LastName, sizeof(p.LastName));
cout<< "\nSocial security number:\n ";
cin.getline(p.ID, sizeof(p.ID));
// check if data valid
if (p.FirstName[0]==0 || p.LastName[0]==0 || p.ID[0]==0)
{
// rejected
strcpy(p.ID,"");
cout<< "\nError: Data not valid. Operation cancelled.\n";
getch();
}
return p;
}
voidOutputPatient (patient * p)
{
// this function outputs patient data to the screen
if (p == NULL || p->ID[0]==0)
{
cout<< "\nNo patient";
return;
}
else
cout<< "\nPatient data:\n";
cout<< "\nFirst name: " << p->FirstName;
cout<< "\nLast name: " << p->LastName;
cout<< "\nSocial security number: " << p->ID;
}
intReadNumber()
{
// this function reads an integer number from the keyboard.
// it is used because input with cin>> doesn’t work properly!
char buffer[20];
cin.getline(buffer, sizeof(buffer));
returnatoi(buffer);
}
voidDepartmentMenu (queue * q)
{
// this function defines the user interface with menu for one
department
int choice = 0, success; patient p;
while (choice != 5)
{
// clear screen
clrscr();
// print menu
cout<< "\nWelcome to department: " << q->DepartmentName;
cout<< "\nPlease enter your choice:\n";
cout<< "\n1: Add normal patient\n";
cout<< "\n2: Add critically ill patient\n";
cout<< "\n3: Take out patient for operation\n";
cout<< "\n4: List queue\n";
cout<< "\n5: Change department or exit\n";
// get user choice
choice = ReadNumber();
// do indicated action
switch (choice)
{
case 1: // Add normal patient
p = InputPatient();
if (p.ID[0])
{
success = q->AddPatientAtEnd(p);
clrscr();
if (success)
{
cout<< "\nPatient added:";
}
else
{
// error
cout<< "\nError: The queue is full. Cannot add patient:";
}
OutputPatient(&p);
cout<< "\nPress any key\n";
getch();
}
break;
case 2: // Add critically ill patient
p = InputPatient();
if (p.ID[0])
{
success = q->AddPatientAtBeginning(p);
clrscr();
if (success)
{
cout<< "\nPatient added:";
}
else
{
// error
cout<< "\nError: The queue is full. Cannot add patient:";
}
OutputPatient(&p);
cout<< "\nPress any key\n";
getch();
}
break;
case 3: // Take out patient for operation
p = q->GetNextPatient();
clrscr();
if (p.ID[0])
{
cout<< "\nPatient to operate:";
OutputPatient(&p);}
else
{
cout<< "\nThere is no patient to operate.";
}
cout<< "\nPress any key";
getch();
break;

case 4: // List queue


clrscr();
q->OutputList();
cout<< "\nPress any key\n";
getch(); break;
}
}
}
// main function defining queues and main menu
void main ()
{
clrscr();
int i, MenuChoice = 0;
// define three queues
queue departments[3];
// set department names
strcpy (departments[0].DepartmentName, "Heart clinic\n");
strcpy (departments[1].DepartmentName, "Lung clinic\n");
strcpy (departments[2].DepartmentName, "Plastic surgery\n");
while (MenuChoice != 4)
{
// clear screen
clrscr();
// print menu
cout<< "\nWelcome to Software City Hospital";
cout<< "\nPlease enter your choice:";
for (i = 0; i < 3; i++)
{// write menu item for department i
cout<< "" << (i+1) << ": " << departments[i].DepartmentName;
}
cout<< "4: Exit\n";
// get user choice
MenuChoice = ReadNumber();
// is it a department name?
if (MenuChoice>= 1 &&MenuChoice<= 3)
{
// call submenu for department // (using pointer arithmeticshere:)
DepartmentMenu (departments + (MenuChoice-1));
}
}
getch();
}
OUTPUT
GLOSSARY

Definitions

CLASS: A class is way to bind the data describing an entity and its
associated functions together. In c++, class makes a data type that is
used to create objects of this type.
OBJECT: An instance of class is called object.
FILE: A bunch of byte stored on some storage device.
DATA ENCAPSULATION: Wrapping up of data and function into a
single unit.
DATA ABSTRACTION: It refers to the act of representing essential
features without including background details.
ARRAY: Named list of finite number of similar data elements.
CONSTANT: A data item that never changes its value during the
program run.
DATA TYPES: Means to identify the type of data and associated
functions of handling it.
VARIABLE: Named storage location whose value can be manipulated
during a program run.

You might also like