Ankush Hospital Management System Report Java
Ankush Hospital Management System Report Java
Hospital Management
System
Submitted in Partial Fulfillment
of the Requirement
For The Third Semester of
MASTER OF COMPUTER
APPLICATION
Session 2024-25
Name – Ankush Name – Sunny Kumar
Roll No – 2306950140019 Roll No – 2306950140104
CERTIFICATE
0
I hereby declare that the Project entitled “Hospital Management
System” submitted to the Department of Computer Application,
Shri Ram Group of Colleges, Muzaffarnagar, in partial fulfillment
for the award of the Degree of MASTER IN COMPUTER
APPLICATION during the session 2024-2025 is a record of my own
work carried out under the guidance of Mr. Sanjay Kant Tyagi, and
that the Project has not previously formed the basis for the award
of any other degree.
This is to certify that the above statement made by me is correct
to the best of my knowledge.
Ankush
2306950140019
Sunny Kumar
2306950140104
1
DECLARATION
We, Ankush, Sunny Kumar hereby declare that the project report
titled “Hospital Management System ” is an original work carried
out by me under the supervision of Mr. Sanjay Kant Tyagi. I further
confirm that this work has not been submitted to any other
institute or university for the fulfilment of requirements for the
third semester of the Master of Computer Application program.
Ankush
2306950140019
Sunny Kumar
2306950140104
2
FORWARDING LETTER
Internal Guide
Mr. Sanjay Kant Tyagi
3
ACKNOWLEDGEMENT
4
Table of Contents
Abstract.................................................................................7
5. Introduction......................................................................8
6. Project Objective.............................................................10
5. Data Flow........................................................................11
Conclusion......................................................................11
CONTEXT LEVEL DFD HOSPITAL MANAGEMENT SYSTEM....0
ZERO LEVEL DFD....................................................................1
Hospital Management System..............................................1
DATA FLOWDIAGRAM-..........................................................2
1.1 REGISTATION A NEW PATIENT.........................................2
DATA FLOW DIAGRAM-.........................................................3
2.1 CHECK-IN OF A NEW PATIENT.........................................3
DATA FLOW DIAGRAM-.........................................................4
3.1 RECORD MODIFICATION.................................................4
DATAFLOWDIAGRAM-...........................................................5
4.1 CHECK-OUT OF CUSTOMER.............................................5
DATA FLOW DIAGRAM-.........................................................6
5.1 LISTING OF CUSTOMERS.................................................6
DATA FLOW DIAGRAM-.........................................................7
6.1 GENERATING BILL OF CUSTOMER...................................7
DATA FLOW DIAGRAM-.........................................................8
7.1 LIST OF ALL RECORDS......................................................8
5
7. Technology Stack...............................................................9
10. Database Design...........................................................14
11. Modules Description.....................................................17
12. GUI Implementation.....................................................20
Reception............................................................................26
Room...................................................................................38
Employee_info....................................................................48
patient_discharge...............................................................51
update_patient_details.......................................................55
Ambulance..........................................................................59
SearchRoom........................................................................62
DBMS SQL reate database hms;..........................................65
14. Challenges and Solutions..............................................72
15. Conclusion.....................................................................75
16. Future Enhancements...................................................75
17. References.....................................................................77
6
Abstract
7
5. Introduction
9
6. Project Objective
The Hospital Management System (HMS) project aims to provide an efficient, reliable, and
automated solution to manage the various operations of a hospital. The key objectives of the
project are designed to address the challenges hospitals face in their daily administration,
streamline processes, and improve the overall healthcare experience for both staff and patients. The
objectives of this project are as follows:
2. To Provide a Centralized Platform for Patient Data Management, Room Availability, Employee
Details, and Billing
The HMS project aims to create a centralized platform that integrates different aspects of hospital
management into one cohesive system. By using a single database to store patient information,
room availability, employee details, and billing information, the system simplifies data retrieval and
enhances coordination across departments.
Patient Data Management: The system stores all patient details in a central database,
including personal information, medical history, treatment details, and discharge
information. This makes it easier for healthcare providers to access relevant data and make
informed decisions regarding patient care.
Room Availability: The room allocation module tracks room availability in real-time, ensuring
that patients are allocated the appropriate room based on their needs and the hospital’s
capacity. It also tracks room status (vacant/occupied) and any special requirements like ICU
or maternity rooms.
Employee Information: A comprehensive database of hospital employees, including doctors,
nurses, administrative staff, and support personnel, is maintained within the system. This
allows the hospital to manage staff schedules, monitor shifts, and track performance and
payroll.
Billing and Payment: The HMS simplifies billing and payment processes by automatically
calculating costs based on services rendered, medications administered, and room charges.
10
5. Data Flow
Understanding how data flows through the system is crucial for designing an efficient
and effective HMS. The data flow involves:
Conclusion
11
12
CONTEXT LEVEL DFD HOSPITAL MANAGEMENT SYSTEM
REGISTRATION
Hospital
Managem
ent
System
CASR Login
RECORDS
Management
PATIENT
Management
ZERO LEVEL DFD
1.
REGISTRATI
2. Check-in
3. Record
modification
5. Listing of 6. generate
1 PATIENT DRUGS
DATA FLOWDIAGRAM-
1.1 REGISTATION A NEW PATIENT
Generating
PATIENT
new OPD
Display
Form
OPD ROOM
Process
Get
Update Table Details
customer Document
Open OPD
Update
2
PATIENT
Assigning a
Display
form
CHECKIN
Process
Update
Get Details
PATIENT
Details
Update Assigning
a Room
3
Read the
PATIENT OPD
USER number
DATAFLOWDIAGRAM-
4.1 CHECK-OUT OF CUSTOMER
PATIENT
PATIENT
Scan Record
Processing
Copy
Selected
Record Comput
e Total
Processing
Outpu
t
Select
Record
4
Generate
Comput
Total List
e Bill Final Output
DATA FLOW DIAGRAM-
6.1 GENERATING BILL OF CUSTOMER
CHECKOUT
MANAGE
Read room
EMENT number
Check for
check out of
PATIENT Update
Processing
Close
Databas
Comput
e Bill
Cash
PATIENT OUTPUT
UNIT
5
DATA FLOW DIAGRAM-
7.1 LIST OF ALL RECORDS
PATIENT
MANAG Select
Copy
Selected
Record
Copy
Selected
Record Compute
Total
Select Output
Processing Record
Generate
Total List
Final Output
To Screen/Printer
OUTPUT
UNIT
6
7. Technology Stack
In this section, we describe the key technologies used in the development of the Hospital Management
System (HMS). These technologies help in creating a robust, efficient, and scalable system for managing
hospital activities. Below is a detailed explanation of the technology stack used for this project:
7
Data Integrity and Security: MySQL supports features like ACID transactions (Atomicity,
Consistency, Isolation, Durability) that ensure data integrity, even in the event of system failures. It
also provides authentication and authorization mechanisms to secure sensitive hospital data.
In the Hospital Management System, MySQL is used to create and manage several key tables:
Patient Table: Stores personal details, medical history, and treatment information of patients.
Room Table: Tracks the availability and allocation of rooms to patients.
Employee Table: Stores employee details, including doctors, nurses, and administrative staff.
Billing Table: Manages billing information, including room charges, medical services, and payments.
Ambulance Table: Records ambulance usage for patient transport.
Using MySQL ensures that the system can store large amounts of data efficiently and can easily scale as the
hospital grows.
8
To ensure the efficient operation of the Hospital Management System (HMS), both hardware and software
requirements need to be met. The system's performance and functionality are optimized when these
requirements are fulfilled. Below are the specific system requirements for the HMS project.
Hardware Requirements:
1. Processor: Minimum 2 GHz
The processor should have a speed of at least 2 GHz. This ensures that the system can handle
multiple processes such as running the Java application, managing database queries, and processing
data efficiently. A multi-core processor is recommended for better performance during
simultaneous operations.
2. RAM: 4 GB
A minimum of 4 GB of Random Access Memory (RAM) is required for smooth operation of the
system, especially when handling multiple tasks like managing patient records, processing billing,
and displaying reports. Sufficient RAM ensures that the system can handle real-time processing
without slowing down.
3. Disk Space: 500 MB for Software and Database
The system needs at least 500 MB of free disk space for storing the software files, database, and any
logs or backups generated by the system. This space will also accommodate the MySQL database
that stores patient, employee, and billing data.
4. Display: Minimum 1024x768 Resolution
The system’s graphical user interface (GUI) is designed to be viewed on a display with a resolution of
1024x768 pixels or higher. This ensures that all elements of the user interface (such as tables,
buttons, and forms) are clearly visible and accessible without requiring scrolling or resizing.
Software Requirements:
1. Operating System: Windows 10 or Higher
The Hospital Management System is designed to run on Windows 10 or higher operating systems.
Windows is chosen for its wide compatibility with Java applications and its support for database
management systems like MySQL. However, the system can also run on other operating systems like
macOS or Linux with minimal adjustments.
2. JDK (Java Development Kit): Java 8 or Higher
The system is built using Java, so the Java Development Kit (JDK) version 8 or higher is required to
compile and run the project. Java 8 introduces key features like lambda expressions, streams, and
default methods that improve the performance and readability of the code. Ensure that the JDK is
installed and correctly configured on the system.
3. Database: MySQL 5.6 or Higher
The backend of the system uses MySQL to manage and store hospital data. MySQL version 5.6 or
higher is required to ensure compatibility with the features used in the project, such as transaction
management, stored procedures, and data integrity. It is essential to install and configure MySQL
properly for the system to interact with the database.
4. IDE (Integrated Development Environment): Eclipse, NetBeans, or IntelliJ IDEA
An IDE is necessary to write, debug, and manage the Java code. The following IDEs are
recommended for development:
o Eclipse: A popular open-source IDE with comprehensive Java support and plugins.
o NetBeans: Another open-source IDE that is beginner-friendly and provides excellent support
for Java Swing and MySQL integration.
9
o IntelliJ IDEA: A robust IDE with advanced features for Java development, offering code9.
System Design
Architecture
The system follows a Layered Architecture with three distinct layers: Presentation Layer, Business Logic
Layer, and Database Layer. Each layer is responsible for specific functionality, ensuring clear separation of
concerns, easier maintenance, and scalability.
1. Presentation Layer:
o This layer is responsible for the user interface and interactions. The GUI is developed using
Java Swing, providing a user-friendly and responsive design.
o The interface includes various forms and dialogs for adding new patients, searching for
available rooms, managing employee records, etc.
o Key components:
Login Page: For authentication of users (staff or administrators).
Patient Information: Displays and allows the management of patient details.
Room Management: Allows searching for available rooms and allocating them to
patients.
Employee Management: Allows the viewing and updating of employee records.
2. Business Logic Layer:
o This layer is responsible for processing the core logic of the system, such as managing
patients, rooms, employees, and their interactions.
o Key functionalities:
Patient Management: Handles the addition, modification, and discharge of patients.
Room Management: Includes logic to check room availability, allocate rooms to
patients, and manage room details.
Employee Management: Handles the addition and management of employee
records, including doctors, nurses, and administrative staff.
Ambulance Management: Logic for managing ambulance requests for patient
transportation.
Search Functions: Search functionality for finding specific patients, rooms, or
employees.
3. Database Layer:
o This layer is responsible for managing the database and handling data persistence.
o MySQL Database is used to store all relevant data, including:
Patient Details: Name, age, medical condition, room assigned, etc.
Room Details: Room number, availability status, capacity, etc.
Employee Details: Name, designation, shift information, etc.
o Database Operations:
CRUD (Create, Read, Update, Delete) operations are implemented for managing
patients, rooms, and employees.
Data consistency and integrity are ensured using relational tables and foreign key
relationships.
UML Diagrams
1. Use Case Diagram:
o The Use Case Diagram captures the interactions between different users (e.g., hospital staff,
administrators) and the system. Major use cases include:
10
Login: Allows users to authenticate.
Add/Update Patient: Allows users to add new patients or modify patient details.
Search Room: Enables searching for available rooms based on specific criteria.
Allocate Room: Assigns a room to a patient.
Manage Employees: View and update employee information.
2. Class Diagram:
o The Class Diagram defines the structure of the system, representing the various classes
involved and their relationships. Key classes include:
Patient: Attributes include patientID, name, age, roomNo, etc.
Room: Attributes include roomNo, capacity, availability.
Employee: Attributes include employeeID, name, designation, etc.
Ambulance: Attributes include ambulanceNo, status, etc.
DatabaseConnection: Class to manage MySQL database connections and queries.
3. Sequence Diagram:
o The Sequence Diagram demonstrates the flow of operations for key interactions within the
system.
Example: Adding a New Patient
User enters patient details in the UI.
The system validates the information and stores it in the database.
The system checks room availability and assigns a room if available.
Confirmation message is shown to the user.
11
10. Database Design
The Hospital Management System requires an organized database to store and manage information
related to patients, rooms, employees, and ambulances. Below is a detailed explanation of the database
tables, their attributes, relationships, sample queries, and the normalization process applied to ensure
efficient database management.
Sample Queries
Here are some SQL queries for data retrieval:
1. Fetch Patient Details by Patient_ID:
sql
Copy code
SELECT * FROM Patient WHERE Patient_ID = 101;
This query retrieves all details for the patient with Patient_ID = 101.
2. Check Room Availability:
sql
Copy code
SELECT * FROM Room WHERE Status = 'Available';
This query fetches all rooms that are currently available.
3. Get All Employees in the 'Cardiology' Department:
sql
Copy code
SELECT Name, Role FROM Employee WHERE Department = 'Cardiology';
This query retrieves the names and roles of all employees in the Cardiology department.
4. Get Room Details Assigned to a Patient (for Patient_ID = 101):
sql
Copy code
SELECT r.Room_ID, r.Room_Type, r.Status, r.Capacity FROM Room r
JOIN Patient p ON r.Room_ID = p.Room_ID
WHERE p.Patient_ID = 101;
This query retrieves the room details for the patient with Patient_ID = 101.
5. Get Ambulance Availability:
sql
Copy code
SELECT * FROM Ambulance WHERE Availability = 'Available';
This query retrieves all ambulances that are available for patient transport.
Normalization Process
Normalization is the process of organizing data in the database to reduce redundancy and dependency. This
ensures data integrity, faster queries, and better performance.
1. First Normal Form (1NF):
o 1NF ensures that each column contains atomic (indivisible) values, meaning no multi-valued
attributes.
13
o In the Patient Table, each attribute (e.g., Name, Age, Phone) holds a single value per patient.
2. Second Normal Form (2NF):
o 2NF ensures that the database is in 1NF and that all non-key attributes are fully dependent
on the primary key.
o In the Patient Table, the Room_ID and Admission_Date depend entirely on the Patient_ID
and not on any part of the key.
3. Third Normal Form (3NF):
o 3NF ensures that the database is in 2NF and that there are no transitive dependencies,
meaning non-key attributes do not depend on other non-key attributes.
o In the Employee Table, the Salary and Shift attributes depend directly on the Employee_ID
and not on other attributes like Department.
14
11. Modules Description
In the Hospital Management System, various modules work together to manage different aspects of the
system, such as patient information, ambulance assignments, employee management, and user
authentication. Below is a detailed explanation of each module, including its functionality, key methods,
and how it interacts with the database.
1. ALL_Patient_Info.java
Functionality:
The ALL_Patient_Info.java module is responsible for managing patient records. It allows the hospital staff
to view, add, and update patient details. This module provides a user interface to access and modify patient
data, making it essential for maintaining patient records throughout their stay in the hospital.
Key Methods:
viewPatientInfo(): Displays the list of all patients in the system.
addPatientInfo(Patient patient): Adds a new patient record to the database.
updatePatientInfo(Patient patient): Updates the details of an existing patient, such as address,
phone number, or room assignment.
deletePatientInfo(int patientId): Deletes a patient's record from the system.
Database Interaction:
The module interacts with the Patient Table in the database for all CRUD (Create, Read, Update,
Delete) operations.
SQL queries are used to retrieve, insert, or modify patient data. For example:
sql
Copy code
INSERT INTO Patient (Name, Age, Address, Phone, Room_ID, Admission_Date)
VALUES (?, ?, ?, ?, ?, ?);
This query is executed when a new patient is added to the system.
2. Ambulance.java
Functionality:
The Ambulance.java module handles ambulance assignments and checks the availability of ambulances.
This module is used by hospital staff to ensure that ambulances are dispatched as needed for patient
transportation. It tracks the status of each ambulance (whether it is available or currently in use).
Key Methods:
checkAvailability(): Checks if any ambulances are available for immediate use.
assignAmbulance(int ambulanceId, String location): Assigns a specific ambulance to a patient and
updates the ambulance's location.
updateAmbulanceStatus(int ambulanceId, String status): Updates the availability status of an
ambulance (e.g., from "Available" to "Not Available").
Database Interaction:
The module interacts with the Ambulance Table to check and update the availability of ambulances.
SQL queries are executed to retrieve and modify the status of ambulances. For example:
sql
Copy code
SELECT * FROM Ambulance WHERE Availability = 'Available';
This query retrieves all ambulances that are available for use.
15
3. conn.java
Functionality:
The conn.java module is responsible for establishing and managing the database connection using JDBC
(Java Database Connectivity). It provides the functionality to connect to the MySQL database, handle any
exceptions, and close the connection when it is no longer needed.
Key Methods:
getConnection(): Establishes a connection to the database.
closeConnection(): Closes the database connection after completing the necessary operations.
executeQuery(String query): Executes a SQL query to interact with the database.
Database Interaction:
This module interacts with the database through JDBC to manage the database connection.
It uses JDBC URL, username, and password to establish the connection to the MySQL database.
Example of establishing a connection:
java
Copy code
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/hospital_db", "root",
"password");
4. Department.java
Functionality:
The Department.java module manages hospital departments, assigns employees to departments, and
tracks department resources. It ensures that each department has the necessary employees and resources
to operate efficiently.
Key Methods:
addDepartment(String departmentName): Adds a new department to the system.
assignEmployeeToDepartment(int employeeId, int departmentId): Assigns an employee to a specific
department.
viewDepartmentInfo(): Displays details of all departments and their employees.
Database Interaction:
The module interacts with the Department Table and Employee Table in the database.
SQL queries are used to insert, update, and retrieve department information. For example:
sql
Copy code
INSERT INTO Department (Department_Name)
VALUES (?);
This query is used to add a new department to the database.
5. Employee_info.java
Functionality:
The Employee_info.java module manages employee details such as name, role, salary, and department
assignments. It provides functionality to add, view, and update employee information, allowing the hospital
to maintain a record of all its staff.
Key Methods:
addEmployee(Employee employee): Adds a new employee to the system.
updateEmployeeInfo(Employee employee): Updates an existing employee’s information, such as
role or salary.
viewEmployeeInfo(): Displays a list of all employees and their roles.
16
Database Interaction:
This module interacts with the Employee Table in the database to add or update employee
information.
SQL queries are executed to manage employee data. For example:
sql
Copy code
INSERT INTO Employee (Name, Role, Department, Salary, Shift)
VALUES (?, ?, ?, ?, ?);
6. Login.java
Functionality:
The Login.java module handles user authentication and authorization. It ensures that only authorized users
(such as admins, nurses, and doctors) can access specific parts of the system based on their roles. It checks
the user's credentials and grants access accordingly.
Key Methods:
validateUser(String username, String password): Validates the login credentials against the stored
data in the database.
authorizeRole(String username): Checks the role of the logged-in user (admin, nurse, or doctor).
logout(): Logs the user out of the system.
Database Interaction:
This module interacts with the User Table (if exists) in the database to verify user credentials.
SQL query for validating login:
sql
Copy code
SELECT * FROM User WHERE Username = ? AND Password = ?;
This query checks whether the entered username and password match the stored credentials.
7. NEW_PATIENT.java
Functionality:
The NEW_PATIENT.java module registers new patients by collecting their details such as name, age,
address, and phone number. It ensures that new patients are added to the system with all necessary
information.
Key Methods:
registerPatient(Patient patient): Registers a new patient and adds their details to the database.
collectPatientDetails(): Collects patient details through a GUI interface.
validatePatientDetails(Patient patient): Validates the provided patient details before submission.
Database Interaction:
The module interacts with the Patient Table in the database to insert a new patient’s details.
SQL query to insert a new patient:
sql
Copy code
INSERT INTO Patient (Name, Age, Address, Phone, Room_ID, Admission_Date)
VALUES (?, ?, ?, ?, ?, ?);
8. patient_discharge.java
Functionality:
17
The patient_discharge.java module manages the discharge process for patients. It generates the final bill
for the patient and updates the patient’s status to "discharged." This module is responsible for generating a
discharge summary and handling the billing process.
In the Hospital Management System, the graphical user interface (GUI) is developed using Java Swing,
which is a part of Java's standard library that allows for building rich, interactive, and responsive desktop
applications. The GUI is designed to provide a user-friendly interface for hospital staff to interact with the
system, managing patients, rooms, and employees.
The system uses several Java Swing components to build the interface. Below is a discussion of the key
Swing components used and their functionality, followed by descriptions of the key screens.
18
Copy code
JTextField usernameField = new JTextField(20);
JTextField passwordField = new JPasswordField(20);
4. JLabel:
o Purpose: JLabel is used to display static text, which can guide users in filling out fields or
provide information about actions.
o Usage: Labels are used for indicating fields like "Username", "Password", "Name", "Age",
etc., to help users understand what data they need to input.
java
Copy code
JLabel usernameLabel = new JLabel("Username");
JLabel passwordLabel = new JLabel("Password");
5. JPasswordField:
o Purpose: JPasswordField is used to securely input passwords. It hides the entered characters
(typically displayed as asterisks) for privacy.
o Usage: This component is used in the login screen to ensure that the password entered by
the user is not visible.
java
Copy code
JPasswordField passwordField = new JPasswordField(20);
6. JComboBox:
o Purpose: JComboBox is used for drop-down selection lists, allowing users to choose from
predefined options.
o Usage: In the patient registration and room allocation screens, JComboBox can be used to
select room types or departments.
java
Copy code
JComboBox roomTypeComboBox = new JComboBox(new String[]{"General", "VIP", "ICU"});
7. JTextArea:
o Purpose: JTextArea is used for multi-line text input, such as entering detailed patient
information or a discharge summary.
o Usage: It can be used for fields that require longer inputs, such as an address field or patient
history.
java
Copy code
JTextArea addressArea = new JTextArea(5, 20);
8. JTable:
o Purpose: JTable is used to display tabular data, such as patient records, employee details, or
room availability.
o Usage: This is useful for displaying large sets of data in a structured format, allowing users to
scroll through the information.
java
Copy code
JTable patientTable = new JTable(data, columnNames);
20
JButton submitButton = new JButton("Register Patient");
submitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name = nameField.getText();
String age = ageField.getText();
String roomType = (String) roomTypeComboBox.getSelectedItem();
// Code to add patient details to the database
}
});
Sample Screenshot Description: The registration screen will include input fields for patient information
(name, age, address) and a drop-down list to select the room type, along with a submit button to save the
details.
21
Login
package hospital.management.system;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
JTextField textField;
JPasswordField jPasswordField;
JButton b1,b2;
Login(){
JLabel nameLable=new JLabel("Username");
nameLable.setBounds(40,20,100,30);
nameLable.setFont(new Font("Tahoma",Font.BOLD,16));
nameLable.setForeground(Color.black);
add(nameLable);
textField=new JTextField();
textField.setBounds(150,20,150,30);
textField.setFont(new Font("Tahoma",Font.PLAIN,15));
textField.setBackground(new Color(255,179,0));
add(textField);
jPasswordField=new JPasswordField();
jPasswordField.setBounds(150,70,150,30);
jPasswordField.setFont(new Font("TAhoma",Font.PLAIN,15));
jPasswordField.setBackground(new Color(255,179,0));
add(jPasswordField);
b1=new JButton("Login");
b1.setBounds(40,140,120,30);
b1.setFont(new Font("Serife",Font.BOLD,15));
b1.setBackground(Color.BLACK);
b1.setForeground(Color.white);
b1.addActionListener(this);
add(b1);
b2=new JButton("Cancel");
b2.setBounds(180,140,120,30);
b2.setFont(new Font("Serife",Font.BOLD,15));
b2.setBackground(Color.BLACK);
b2.setForeground(Color.white);
b2.addActionListener(this);
add(b2);
getContentPane().setBackground(new Color(109,164,170));
setSize(750,300);
setLocation(400,270);
setLayout(null);
setVisible(true);
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==b1){
try{
conn c= new conn();
String user=textField.getText();
String Pass=jPasswordField.getText();
}
else {
JOptionPane.showMessageDialog(null,"Invalid");
}
23
} catch (Exception E) {
E.printStackTrace();
}
}
else {
System.exit(10);
}
}
24
Reception
package hospital.management.system;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
panel.setBounds(5,160,1525,670);
panel.setBackground(new Color(109,164,170));
add(panel);
25
ImageIcon i1=new ImageIcon(ClassLoader.getSystemResource("icon/dr.png"));
Image image=i1.getImage().getScaledInstance(250,250,Image.SCALE_DEFAULT);
ImageIcon i2= new ImageIcon(image);
JLabel label= new JLabel(i2);
label.setBounds(1300,0,250,250);
panel1.add(label);
}
});
}
});
26
JButton btn3=new JButton("Department");
btn3.setBounds(30,100,200,30);
btn3.setBackground(new Color(246,215,118));
panel1.add(btn3);
btn3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new Department();
}
});
}
});
}
});
}
});
}
});
}
});
}
});
28
JButton btn10=new JButton("Log Out");
btn10.setBounds(750,15,200,30);
btn10.setBackground(new Color(246,215,118));
panel1.add(btn10);
btn10.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
}
});
setSize(1950,1090);
setLayout(null);
getContentPane().setBackground(Color.white);
setVisible(true);
}
public static void main(String[] args) {
new Reception();
}
}
29
NEW_PATIE
NT
package hospital.management.system;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.util.Date;
NEW_PATIENT(){
r1 = new JRadioButton("Male");
r1.setFont(new Font("Tahoma",Font.BOLD,14));
r1.setForeground(Color.white);
r1.setBackground(new Color(109, 164, 170));
r1.setBounds(271,191,80,15);
panel.add(r1);
r2 = new JRadioButton("Female");
r2.setFont(new Font("Tahoma",Font.BOLD,14));
r2.setForeground(Color.white);
31
r2.setBackground(new Color(109, 164, 170));
r2.setBounds(350,191,80,15);
panel.add(r2);
c1 = new Choice();
try {
conn c = new conn();
ResultSet resultSet = c.statement.executeQuery("select * from Room");
while (resultSet.next()){
c1.add(resultSet.getString("room_no"));
}
}catch (Exception e){
e.printStackTrace();
}
c1.setBounds(271,274,150,20);
c1.setFont(new Font("Tahoma", Font.BOLD, 14));
c1.setForeground(Color.WHITE);
c1.setBackground(new Color(3,45,48));
panel.add(c1);
32
labelDeposite.setForeground(Color.white);
panel.add(labelDeposite);
b1 = new JButton("ADD");
b1.setBounds(100,430,120,30);
b1.setForeground(Color.WHITE);
b1.setBackground(Color.black);
b1.addActionListener(this);
panel.add(b1);
b2 = new JButton("Back");
b2.setBounds(260,430,120,30);
b2.setForeground(Color.WHITE);
b2.setBackground(Color.black);
b2.addActionListener(this);
panel.add(b2);
setUndecorated(true);
setSize(850,550);
setLayout(null);
setLocation(300,250);
setVisible(true);
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b1){
conn c = new conn();
String radioBTN = null;
if (r1.isSelected()){
radioBTN = "Male";
}else if (r2.isSelected()){
radioBTN = "Female";
}
String s1 = (String)comboBox.getSelectedItem();
String s2 = textFieldNumber.getText();
String s3 = textName.getText();
String s4 = radioBTN;
String s5 = textFieldDisease.getText();
String s6 = c1.getSelectedItem();
String s7 = date.getText();
String s8 = textFieldDeposite.getText();
try {
33
c.statement.executeUpdate(q);
c.statement.executeUpdate(q1);
JOptionPane.showMessageDialog(null, "added Successfully");
setVisible(false);
}catch (Exception E) {
E.printStackTrace();
}
}else {
setVisible(false);
}
34
35
Room
package hospital.management.system;
import net.proteanit.sql.DbUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
try{
36
}
setUndecorated(true);
setSize(900,600);
setLayout(null);
setLocation(300,230);
setVisible(true);
37
}
}
38
39
Departme
nt
package hospital.management.system;
import net.proteanit.sql.DbUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
try{
conn c = new conn();
String q = "select * from department";
ResultSet resultSet = c.statement.executeQuery(q);
table.setModel(DbUtils.resultSetToTableModel(resultSet));
}catch (Exception e){
e.printStackTrace();
40
}
// setUndecorated(true);
setSize(700,500);
setLayout(null);
setLocation(350,250);
setVisible(true);
}
public static void main(String[] args) {
new Department();
}
}
41
42
ALL_Patient_Info
package hospital.management.system;
import net.proteanit.sql.DbUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
ALL_Patient_Info(){
JPanel panel = new JPanel();
panel.setBounds(5,5,890,590);
panel.setBackground(new Color(90, 156, 163));
panel.setLayout(null);
add(panel);
try{
conn c = new conn();
String q = "select * from Patient_Info";
ResultSet resultSet = c.statement.executeQuery(q);
table.setModel(DbUtils.resultSetToTableModel(resultSet));
setUndecorated(true);
setSize(900,600);
setLayout(null);
setLocation(300,200);
setVisible(true);
}
public static void main(String[] args) {
new ALL_Patient_Info();
44
}
}
45
Employee_info
package hospital.management.system;
import net.proteanit.sql.DbUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
try{
conn c = new conn();
String q = "select * from EMP_INFO";
ResultSet resultSet = c.statement.executeQuery(q);
table.setModel(DbUtils.resultSetToTableModel(resultSet));
}catch (Exception e){
e.printStackTrace();
}
46
JLabel label3 = new JLabel("Phone Number");
label3.setBounds(350,9,150,20);
label3.setFont(new Font("Tahoma",Font.BOLD,14));
panel.add(label3);
setUndecorated(true);
setSize(1000,600);
setLocation(350,230);
setLayout(null);
setVisible(true);
}
public static void main(String[] args) {
new Employee_info();
}
}
47
48
patient_discharge
package hospital.management.system;
import javax.swing.*;
import java.awt.*;
import java.util.Date;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
patient_discharge(){
try{
conn c = new conn();
ResultSet resultSet = c.statement.executeQuery("select * from Patient_Info");
while (resultSet.next()){
choice.add(resultSet.getString("number"));
}
49
}
50
c.statement.executeUpdate("delete from Patient_Info where number =
'"+choice.getSelectedItem()+"'");
c.statement.executeUpdate("update room set Availability = 'Available' where room_no =
'"+RNo.getText()+"'");
JOptionPane.showMessageDialog(null,"Done");
setVisible(false);
}catch (Exception E){
E.printStackTrace();
}
}
});
setUndecorated(true);
51
setSize(800,400);
setLayout(null);
setLocation(400,250);
setVisible(true);
}
public static void main(String[] args) {
new patient_discharge();
}
52
update_patient_details
package hospital.management.system;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
try {
conn c= new conn();
ResultSet resultSet = c.statement.executeQuery("select * from Patient_Info");
53
while (resultSet.next()){
choice.add(resultSet.getString("Name"));
}
54
check.setBackground(Color.black);
check.setForeground(Color.white);
panel.add(check);
check.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String id = choice.getSelectedItem();
String q = "select * from Patient_Info where Name = '"+id+"'";
try{
conn c = new conn();
ResultSet resultSet = c.statement.executeQuery(q);
while (resultSet.next()){
textFieldR.setText(resultSet.getString("Room_Number"));
textFieldINTIme.setText(resultSet.getString("Time"));
textFieldAmount.setText(resultSet.getString("Deposite"));
}
55
E.printStackTrace();
}
}
});
setUndecorated(true);
setSize(950,500);
setLayout(null);
setLocation(400,250);
setVisible(true);
}
public static void main(String[] args) {
new update_patient_details();
}
}
56
Ambulance
package hospital.management.system;
import net.proteanit.sql.DbUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
Ambulance(){
JPanel panel = new JPanel();
panel.setBounds(5,5,890,590);
panel.setBackground(new Color(90, 156, 163));
panel.setLayout(null);
add(panel);
try{
conn c = new conn();
String q = "select * from Ambulance";
ResultSet resultSet = c.statement.executeQuery(q);
table.setModel(DbUtils.resultSetToTableModel(resultSet));
57
JLabel label3 = new JLabel("Car name");
label3.setBounds(366,11,100,14);
label3.setFont(new Font("Tahoma",Font.BOLD,14));
panel.add(label3);
setUndecorated(true);
setSize(900,600);
setLayout(null);
setLocation(300,200);
setVisible(true);
}
public static void main(String[] args) {
new Ambulance();
}
}
58
59
SearchRoom
package hospital.management.system;
import net.proteanit.sql.DbUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
60
try {
conn c = new conn();
String q = "select * from room";
ResultSet resultSet = c.statement.executeQuery(q);
table.setModel(DbUtils.resultSetToTableModel(resultSet));
61
}
});
setUndecorated(true);
setSize(700,500);
setLayout(null);
setLocation(450,250);
setVisible(true);
}
public static void main(String[] args) {
new SearchRoom();
}
62
DBMS SQL reate database hms;
USE hms;
63
64
65
66
);
Test Cases
1. Test Case 1: Patient Registration
o Objective: Verify that the system successfully registers a new patient and stores their details
in the database.
o Test Input:
Name: John Doe
Age: 45
Address: 123 Main Street, City
Phone: 1234567890
Room Type: General
o Expected Output:
A new patient record should be created in the database.
The system should display a confirmation message that the patient has been
registered successfully.
o Test Steps:
1. Open the patient registration screen.
2. Enter the above details into the respective fields.
3. Click on the "Register Patient" button.
o Actual Output:
A patient record is created successfully in the database, and a confirmation message
is displayed.
o Result: Pass
o Remarks: The system correctly registers the patient and stores the information in the
database.
2. Test Case 2: Room Allocation
o Objective: Verify that the system allocates a room to a patient based on the selected room
type.
o Test Input:
Patient Name: John Doe
Room Type: VIP
o Expected Output:
The system should allocate a VIP room from the available rooms and display a
confirmation message.
o Test Steps:
1. Go to the room allocation screen.
2. Select the patient's name and room type.
67
3. Click on the "Allocate Room" button.
o Actual Output:
The system allocates a VIP room (Room 201) and updates the room status in the
database.
o Result: Pass
o Remarks: The system correctly allocated the room and updated the room status as
"Occupied."
3. Test Case 3: Patient Discharge
o Objective: Verify that the system processes the discharge of a patient and generates the
final bill.
o Test Input:
Patient Name: John Doe
Discharge Date: 2024-12-28
o Expected Output:
The patient's discharge details should be updated in the system.
A final bill should be generated based on the patient's room type and stay duration.
The room status should be updated to "Available."
o Test Steps:
1. Go to the patient discharge screen.
2. Select the patient to be discharged.
3. Enter the discharge date.
4. Click on the "Generate Bill" and "Discharge" buttons.
o Actual Output:
The patient’s record is updated, and a final bill is generated. The room status is
updated to "Available."
o Result: Pass
o Remarks: The discharge process works correctly, and the system updates all records
accordingly.
4. Test Case 4: Login Authentication
o Objective: Verify that the system correctly authenticates users based on their roles (Admin,
Nurse, Doctor).
o Test Input:
Username: admin
Password: admin123
Role: Admin
o Expected Output:
The system should validate the credentials and grant access to the Admin dashboard.
o Test Steps:
1. Open the login screen.
2. Enter the username and password.
3. Click the "Login" button.
o Actual Output:
The system grants access to the Admin dashboard.
o Result: Pass
o Remarks: The login functionality works as expected, and role-based access is correctly
implemented.
5. Test Case 5: Search Patient Record
68
o Objective: Verify that the system can search for a patient by name and display their details.
o Test Input:
Patient Name: John Doe
o Expected Output:
The system should display the details of John Doe, including the room number, age,
and other relevant information.
o Test Steps:
1. Go to the patient search screen.
2. Enter "John Doe" in the search field.
3. Click on the "Search" button.
o Actual Output:
The system displays the patient details for John Doe, including room information and
status.
o Result: Pass
o Remarks: The patient search functionality works correctly, and the system retrieves the
appropriate patient record.
Testing Results
1. Login Authentication:
o All user roles (Admin, Nurse, Doctor) were tested, and the system correctly handled login
attempts based on role-specific access rights. No issues were encountered.
2. Patient Registration:
o The registration process was thoroughly tested with different patient details (name, age,
contact information). The system successfully saved the records in the database and
displayed a confirmation message each time.
3. Room Allocation:
o Multiple room types (General, VIP, ICU) were tested for allocation. The system correctly
assigned the room based on the room type selected and updated the room status to
"Occupied." The allocation process worked without errors.
4. Patient Discharge:
o The discharge process worked well, including the generation of bills and updating the room
availability. The room status was correctly updated, and the patient record was marked as
discharged.
5. Error Handling:
o During testing, some minor errors were encountered with incorrect patient ID entries during
patient search, but these were resolved by validating input fields and providing error
messages when invalid data was entered.
During the development of the Hospital Management System (HMS), several challenges were encountered
across different aspects of the project, including database integration, GUI design, and system
performance. Below is a discussion of these challenges and the solutions implemented to overcome them.
70
Challenge:
Tracking room availability posed a challenge due to the dynamic nature of room allocations (patients could
be admitted or discharged at any time). Ensuring that the system correctly updated the room status after
each allocation or discharge was critical. Initially, there were issues with the system not reflecting real-time
changes in room availability.
Solution:
To handle room availability efficiently:
We implemented a room status table in the database, where each room’s status
(Occupied/Available) was updated after patient admission or discharge.
Triggers and stored procedures were used in MySQL to automatically update room availability when
a patient was registered or discharged. This ensured real-time updates in the system.
On the application side, a refresh mechanism was introduced, where the room availability status
was rechecked before any allocation attempt was made.
5. Performance Optimization
Challenge:
As the system grew with more patients, room details, and employees in the database, performance began
to degrade, especially when querying large datasets or generating reports.
Solution:
To improve system performance:
Indexes were created on frequently queried fields in the database, such as patient names and room
types, which significantly reduced query time.
Pagination was implemented in areas with large data sets (e.g., patient lists, employee records),
ensuring that only a subset of records was displayed at any time.
For complex operations, such as generating the final bill or fetching patient details, stored
procedures were used to perform heavy computations directly in the database, offloading the logic
from the application.
71
15. Conclusion
The Hospital Management System (HMS) successfully meets the objectives of automating and streamlining
the complex tasks involved in hospital administration. By incorporating advanced technologies such as Java
Swing for the frontend and MySQL for the backend, the system provides an efficient solution for managing
patient records, room allocations, employee details, and ambulance services. The project has been
designed to automate key hospital functions, reducing manual workload and minimizing human errors.
Project Outcomes
The HMS offers a centralized platform for hospital staff to efficiently manage critical tasks. Some of the key
outcomes of the system include:
Efficient Patient Management: The system allows for quick registration, viewing, and updating of
patient details. It also tracks the patient's room allocation and discharge status, making the process
seamless and error-free.
Room Allocation Management: With real-time room availability tracking, hospital staff can quickly
allocate rooms based on patient needs, avoiding conflicts and delays.
Employee Management: The system helps in managing employee details, roles, and departments,
improving administrative efficiency and enabling proper resource allocation.
Automated Billing and Discharge Process: The discharge process is automated, with accurate billing
generation based on room type and stay duration, reducing manual effort and errors.
User Role Management: With role-based access, the system ensures that only authorized personnel
can access sensitive information, improving data security and compliance.
Impact on Hospital Management
The implementation of the Hospital Management System has a profound impact on hospital operations. By
replacing manual methods with an automated system, hospitals can achieve significant improvements in
both operational efficiency and patient satisfaction. Some notable impacts include:
Faster Decision-Making: Automation speeds up processes like patient registration, room allocation,
and billing, allowing hospital staff to make quicker decisions and provide better care.
Improved Accuracy: By reducing the reliance on manual data entry, the system minimizes human
errors, ensuring that patient records, room allocations, and billing details are accurate.
Resource Optimization: The system optimizes the use of hospital resources, such as rooms and
staff, ensuring that they are efficiently utilized without overburdening the hospital staff.
Better Data Management: With a centralized database, hospital administrators can easily access
and manage vast amounts of data, making it easier to track and analyze performance metrics,
patient outcomes, and resource usage.
While the current Hospital Management System (HMS) provides a comprehensive solution for hospital
administration, there are several opportunities to enhance its capabilities and provide even more value to
hospital management. Below are some potential future enhancements:
1. Mobile Application Integration
Integrating a mobile application with the Hospital Management System would provide users (doctors,
nurses, and patients) with greater accessibility and flexibility.
Patient Access: Patients could view their appointment schedules, medical records, test results, and
communicate with doctors directly from their smartphones.
72
Doctor Access: Doctors could manage patient information, update prescriptions, and check room
availability while on the move, improving efficiency and enabling real-time updates.
Admin Access: Hospital administrators could manage hospital operations and resources from
anywhere, ensuring quick decision-making and improved management.
2. Cloud Deployment
Moving the system to the cloud would significantly enhance scalability, security, and accessibility. Cloud
deployment would allow for:
Data Accessibility: Hospital staff could access the system from anywhere in the world, enabling
better management of remote clinics and multiple hospital branches.
Scalability: The system would be able to scale easily to accommodate growing hospital operations
and more data without requiring significant infrastructure upgrades.
Cost Reduction: Cloud storage and computing services reduce the need for expensive on-site
hardware and IT maintenance.
3. AI for Patient Data Analysis
Integrating artificial intelligence (AI) to analyze patient data could bring numerous benefits:
Predictive Analytics: AI algorithms could predict potential health risks based on patient history and
other data, helping doctors identify conditions early and provide preventive care.
Personalized Medicine: By analyzing vast amounts of medical data, AI could assist in developing
personalized treatment plans, ensuring better outcomes for patients.
Efficient Resource Allocation: AI can help optimize hospital resources, such as staff, room
allocations, and medical equipment, based on historical data and real-time patient needs.
4. Electronic Health Records (EHR) Integration
Integrating with a national or global Electronic Health Record (EHR) system could allow for seamless
sharing of patient data across healthcare providers. This would:
Enhance Continuity of Care: Patients could receive consistent and coordinated care even when they
visit different hospitals or healthcare providers.
Improved Decision-Making: Doctors would have access to comprehensive patient histories,
reducing the likelihood of treatment errors and improving overall patient care.
5. Telemedicine Integration
The increasing use of telemedicine presents an opportunity for enhancing the system:
Remote Consultations: Patients could consult with doctors via video calls, reducing the need for in-
person visits, particularly for follow-ups or non-urgent conditions.
Virtual Health Monitoring: Integration with wearable health devices could allow doctors to monitor
patients' vitals remotely, improving preventive care.
6. Advanced Reporting and Analytics
While the current system provides basic data management features, advanced reporting tools could offer
deeper insights into hospital performance. These could include:
Real-Time Dashboards: Visual dashboards displaying key performance indicators (KPIs) such as
patient occupancy rates, staff performance, and resource utilization.
Predictive Reports: Advanced analytics tools to predict trends, such as seasonal spikes in certain
diseases or staffing needs, helping hospital administrators prepare in advance.
73
17. References
This section includes the sources of information and resources that were used during the development of
the Hospital Management System project. It covers books, websites, online articles, and any other
resources referenced throughout the course of research, design, and implementation.
Books:
1. Java: The Complete Reference (10th Edition) by Herbert Schildt
o This book was essential for understanding core Java programming, particularly in areas
related to JDBC, Swing, and object-oriented principles used in the project.
2. Head First Java (2nd Edition) by Kathy Sierra and Bert Bates
o This resource provided foundational knowledge on Java programming, including GUI
development with Swing and concepts of object-oriented programming.
3. Database System Concepts (6th Edition) by Abraham Silberschatz, Henry F. Korth, and S. Sudarshan
o This textbook helped in understanding database design principles, SQL queries, and
normalization, which were key to the MySQL database design of the project.
Websites and Online Resources:
1. Oracle Java Documentation
o URL: https://docs.oracle.com/en/java/
o The official Java documentation was referred to for understanding core Java classes, Swing
components, and JDBC connectivity.
2. MySQL Documentation
o URL: https://dev.mysql.com/doc/
o This website provided essential information on MySQL database setup, query syntax, and
optimization techniques used in the backend development of the project.
3. GeeksforGeeks
o URL: https://www.geeksforgeeks.org/
o A helpful website for learning Java, Swing, and JDBC programming concepts, and for
troubleshooting issues encountered during development.
4. Stack Overflow
o URL: https://stackoverflow.com/
o Stack Overflow was an invaluable resource for debugging and finding solutions to
programming issues, particularly when working with Java Swing and MySQL.
5. W3Schools (SQL Tutorials)
o URL: https://www.w3schools.com/sql/
o W3Schools provided tutorials and examples on SQL queries, helping in the creation of
efficient queries for the project’s database.
1. MySQL Workbench
o URL: https://www.mysql.com/products/workbench/
o MySQL Workbench was used for database design, query development, and management of
the MySQL database.
2. Java SE Development Kit (JDK 8)
o URL: https://www.oracle.com/java/technologies/javase-jdk8-downloads.html
o The JDK was used to compile and run the Java code, providing the necessary libraries and
tools for development.
74