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

Hospital Appointment Management System

INTRODUCTION:

A Hospital Appointment Management System (HAMS) is a software solution designed to


streamline the scheduling, tracking, and management of appointments within a healthcare
facility. It serves as a central platform for coordinating appointments between patients, doctors,
and administrative staff, facilitating efficient communication and organization within the
hospital.

The primary purpose of a HAMS is to optimize the appointment booking process, ensuring that
patients receive timely access to healthcare services while maximizing the utilization of medical
resources. By automating appointment-related tasks, such as scheduling, rescheduling, and
cancellations, the system reduces administrative workload and minimizes scheduling conflicts.

Functionalities:

Patient Module:

Allows patients to place appointments, cancel appointments, and view their information.

Patients provide their personal details and specify the type of disease they have when placing
an appointment.

The system assigns appointments with available doctors based on patient preferences.

Doctor Module:

Enables doctors to access their appointments, mark appointments as done, and change their
login credentials.

Doctors can view their scheduled appointments and update their login credentials as needed.

Admin Module:

1
Provides administrators with overall system management functionalities.

Admins can change the system's password, view appointments of doctors, and reset all
appointments if required.

Data Structures Used:

Linked lists are utilized to maintain patient records, allowing for efficient insertion and deletion
operations.

Dynamic memory allocation is employed to allocate memory for new patients as needed,
ensuring optimal resource utilization.

User Interface:

The program features a user-friendly interface with menu-driven options for easy navigation
and interaction.

Patients, doctors, and administrators are presented with intuitive menus tailored to their
respective roles, enhancing usability.

Objective:

The primary objective of the Hospital Appointment Management System is to improve the
efficiency of appointment scheduling and management processes within the hospital.

By automating appointment-related tasks and providing a centralized platform for stakeholders


to interact with, the system aims to streamline operations and enhance the overall quality of
healthcare services offered.

ELEMENTS USED IN THIS PROGRAM:

1. Header Files Inclusion:

The code begins by including necessary header files like< stdio.h>, <conio.h>,< stdlib.h>, and
<string.h>.

2. Structure Definitions:

Three structures are defined: patient, doctor, and admin. These structures hold information
related to patients, doctors, and administrators, respectively.

2
3. Global Variables Initialization:

Global variables such as first (pointer to the first patient record), res (result of disease
selection), count (array to track appointments for each doctor), and id and pwd (default admin
credentials) are initialized.

4. Function Prototypes:

Prototypes for all the functions used in the code are declared. This includes functions for role
selection (info()), patient actions (patient()), doctor actions (doctor()), admin actions (admin()),
utility functions, and appointment management.

5. Main Function:

The main() function initiates the program execution.

It calls the info() function to start the interaction with the user.

6. Role Selection Function (info()):

This function prompts the user to select their role: Patient, Doctor, Admin, or Exit.

Based on the user's choice, it directs the program flow to the corresponding role-specific
function.

7. Patient Function (patient()):

This function handles actions specific to patients, such as placing appointments, canceling
appointments, and viewing their information.

It prompts the user to input their choice and performs the corresponding action.

8. Doctor Function (doctor()):

This function handles actions specific to doctors, such as viewing appointments and marking
them as done.

It prompts the doctor to input their credentials for authentication and then presents a menu for
further actions.

9. Admin Function (admin()):

This function handles actions specific to admins, such as changing passwords and viewing
doctor appointments.

3
Similar to the doctor function, it prompts the admin to input credentials for authentication and
then presents a menu for further actions.

10. Utility Functions:

Several utility functions like disease(), cancelAppointment(), viewInformation(), chngepwd(),


and appointment_done() are defined to perform specific tasks related to appointment
management and authentication.

Source Code

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

#include<string.h>

#define MAX_NAME_LENGTH 20

void info();

void patient();

void doctor();

void admin();

int disease();

void chngepwd(int ch2);

4
void cancelAppointment();

void viewInformation();

void appointment_done();

struct patient

char name[20];

char contact[15];

char gen[10];

char address[50];

char id[20];

int appointment_time;

struct patient *next;

};

struct doctor

char id[20];

char pwd[20];

};

struct admin

char id[20];

5
char pwd[20];

};

struct patient *first=NULL;

int res=0,time;

int count[5]= {0,0,0,0,0};

char id[20]="admin",pwd[20]="1234";

int main()

struct patient *ns, *temp;

char ch;

info();

printf("\n Patient Info : ");

temp=first;

while(temp != NULL)

printf("\n name : %s is %s",temp->name,temp->gen);

temp=temp->next;

printf("\n");

6
}

void info()

int ch1;

printf("\n\n\n * Hospital Appointment Management *");

printf("\n\nWho are you? ");

printf("\n1. Patient");

printf("\n2. Doctor");

printf("\n3. Admin"); printf("\

n4. Exit");

// Check if input is an integer

if (scanf("%d", &ch1) != 1)

// Clear the input buffer

while (getchar() != '\n');

printf("\n Invalid input. Please enter a number.");

info(); // Recursive call to prompt again

return;

switch(ch1)

7
case 1:

patient();

break;

case 2:

doctor();

break;

case 3:

admin();

break;

case 4:

exit(0);

default:

printf("\n Invalid Choice");

info();

8
}

void patient()

int ch1;

printf("\n\n**Patient Menu**"); printf("\

n1. Place Appointment"); printf("\n2.

Cancel Appointment"); printf("\n3. All

Patients Information"); printf("\nEnter

your choice = "); scanf("%d",&ch1);

switch(ch1)

case 1:

struct patient *ns,*temp;

ns=(struct patient*) malloc(sizeof(struct patient));

printf("\n\n Enter name = ");

scanf("%s",ns->name);

printf("\n Enter gender = ");

scanf("%s",ns->gen);

printf("\n Enter contact number = ");

scanf("%s", ns->contact);

9
printf("\n Enter address = ");

scanf("%s", ns->address);

ns->next=NULL;

if(first==NULL)

first=ns;

else

temp=first;

while(temp->next!=NULL)

temp=temp->next;

temp->next=ns;

printf("\n What disease do you have?");

res=disease();

switch (res)

10
case 1:

count[0]++; time=(10+count[0])

%13;

printf("\n You have an appointment with Dr. Abhijeet at %d number at %


d:00",count[0],time);

break;

case 2:

count[1]++; time=(10+count[1])

%13;

printf("\n You have an appointment with Dr. Viraj at %d number at %


d:00",count[1],time);

break;

case 3:

count[2]++; time=(10+count[2])

%13;

printf("\n You have an appointment with Dr. Samrudhi at %d number at %


d:00",count[2],time);

break;

case 4:

count[3]++; time=(10+count[3])

%13;

printf("\n You have an appointment with Dr. Sayli at %d number at %


d:00",count[3],time);

break;

case 5:

count[4]++;

11
time=(10+count[4])%13;

printf("\n You have an appointment with Dr. Shravni at %d number at %


d:00",count[4],time);

break;

default:

printf("\n Invalid doctor.");

return;

break;

case 2:

cancelAppointment();

break;

case 3:

viewInformation();

break;

default:

printf("\n Invalid Choice");

break;

12
}

struct patient *temp = first;

while(temp != NULL)

printf("\nPatient's Name: %s", temp->name);

printf("\nContact no.: %s", temp->contact);

printf("\nGender: %s", temp->gen); printf("\

nAddress: %s", temp->address); temp=temp-

>next;

info(); // Go back to the main menu after performing the chosen action

void doctor()

// Doctor's functionality

char id[20],pwd[20];

int ch2,count8=3,countt=3,flag=1,ch,counttt=0;

struct doctor doc[5];

if(counttt==0)

13
strcpy(doc[0].id, "Abhijeet");

strcpy(doc[0].pwd, "1234");

strcpy(doc[1].id, "Viraj");

strcpy(doc[1].pwd, "5678");

strcpy(doc[2].id, "Samrudhi");

strcpy(doc[2].pwd, "abcd");

strcpy(doc[3].id, "Sayli");

strcpy(doc[3].pwd, "efgh");

strcpy(doc[4].id, "Shravni");

strcpy(doc[4].pwd, "ijkl");

counttt++;

printf("\n 1. Doctor 1\n (Heart specialist)"); printf("\

n\n 2. Doctor 2\n (neurological)"); printf("\n\n 3.

Doctor 3\n (general disease)"); printf("\n\n 4. Doctor

4\n (ear & eye specialist)"); printf("\n\n 5. Doctor 5\n

(dentist)");

printf("\n\n Enter who are you = ");

// Check if input is an integer

if (scanf("%d", &ch2) != 1)

// Clear the input buffer

14
while (getchar() != '\n');

printf("\n Invalid input. Please enter a

number."); doctor(); // Recursive call to prompt

again return;

do

printf("\n Enter id = ");

scanf("%s",id);

printf("\n Enter password = ");

scanf("%s",pwd);

if(strcmp(id,doc[ch2-1].id)==0 && strcmp(pwd,doc[ch2-1].pwd)==0)

flag=2;

break;

count8--;

printf("\n Incorrect id or password. Please try again.");

printf("\n Chance remaining : %d",count);

} while(count8>0);

if(flag==2)

15
printf("\n -----Welcome--- -");

printf("\n 1. see appointments ");

printf("\n 2. Appointment done ");

printf("\n Enter your choice : ");

scanf("%d",&ch);

switch(ch)

case 1:

printf("\n you have %d appointments",count[ch2-1]);

break;

case 2:

appointment_done();

break;

default:

printf("\n Invalid Choice");

break;

else

16
{

printf("\n Too many incorrect attempts");

info();

void admin()

// Admin's functionality

struct admin a[5];

struct doctor doc[5];

char id2[20],pwd2[20];

int count6=3,ch, ch2;

do

printf("\n Enter id = ");

scanf("%s",id2);

printf("\n Enter password = ");

scanf("%s",pwd2);

if(strcmp(id2,id)==0 && strcmp(pwd2,pwd)==0)

break;

17
count6--;

printf("\n Incorrect id or password. Please try again.");

printf("\n Chance remaining : %d",count6);

} while(count6>0);

if(count6==0)

printf("\n Too many incorrect attempt");

else

printf("\n -----welcome--- -");

printf("\n\n 1. change password = ");

printf("\n 2. See appointments of doctor");

printf("\n 3.Reset all appointments");

printf("\n\n Enter your choice = ");

scanf("%d",&ch);

switch(ch)

case 1:

printf("\n Enter new id = ");

scanf("%s",id);

printf("\n Enter new password = ");

18
scanf("%s",pwd);

info();

break;

case 2:

printf("\n 1. Abhijeet\n (Heart specialist)");

printf("\n\n 2. Viraj\n (neurological)"); printf("\n\

n 3. Samruddhi\n (general diseases)"); printf("\n\

n 4. Sayli\n (ear & eye specialist)"); printf("\n\n

5. Shravni\n (dentist)");

printf("\n\n Enter doctor = ");

scanf("%d",&ch2);

strcpy(doc[0].id, "Abhijeet");

strcpy(doc[1].id, "Viraj");

strcpy(doc[2].id, "Samrudhi");

strcpy(doc[3].id, "Sayli");

strcpy(doc[4].id, "Shravni");

printf("\n %s have %d appointments ",doc[ch2-1].id,count[ch2-1]);

break;

case 3:

19
// Reset all appointments

for (int i = 0; i < 5; i++)

count[i] = 0;

printf("\nAll appointments have been reset.");

break;

default:

printf("\n Invlaid choice");

int disease()

int ch;

do

printf("\n\n\t 1. Heart disease");

20
printf("\n\t 2. Neurological problem");

printf("\n\t 3. General disease");

printf("\n\t 4. Ear or eye disease");

printf("\n\t 5. Dental problem");

printf("\n\n\n\t Enter your choice = ");

scanf("%d",&ch);

} while(ch>=5 && ch<=1);

return ch;

void cancelAppointment()

char name[20];

printf("\nEnter your name to cancel the appointment: ");

scanf("%s", name);

struct patient *current = first;

struct patient *prev = NULL;

while (current != NULL)

if (strcmp(current->name, name) == 0)

if (prev == NULL)

21
{

first = current->next;

else

prev->next = current->next;

free(current);

printf("\nAppointment canceled successfully.");

return;

prev = current;

current = current->next;

printf("\nAppointment not found for the given name.");

void viewInformation()

struct patient *temp = first;

if (temp == NULL)

printf("\nNo patients registered yet.\n");

22
return;

printf("\nPatients Information:\n");

while (temp != NULL)

printf("\nName: %s", temp->name); printf("\

nContact no.: %s", temp->contact); printf("\

nGender: %s", temp->gen); printf("\

nAddress: %s", temp->address);

printf("\nAppointment Time: %d:00 \n\n", temp->appointment_time); // Assuming


appointment_time is set

printf("\n");

temp = temp->next;

void appointment_done()

char name[20];

printf("\nEnter patient's name to mark appointment as done: ");

scanf("%s", name);

struct patient *current = first;

struct patient *prev = NULL;

23
while (current != NULL)

if (strcmp(current->name, name) == 0)

// Remove the patient from the appointment list

if (prev == NULL)

first = current->next;

} else

prev->next = current->next;

free(current);

printf("\nAppointment for %s has been marked as done.", name);

return;

prev = current;

current = current->next;

printf("\nAppointment not found for the given patient's name.");

24
THANK U!!!!

25

You might also like