0% found this document useful (0 votes)
11 views111 pages

Reort Final

The document outlines the development of a Hospital Management System aimed at automating and streamlining hospital operations using Java. It includes objectives such as enhancing patient care, improving efficiency, and ensuring data security, along with detailed descriptions of modules like patient management and billing. The document also discusses future enhancements, testing methodologies, and provides coding examples for the system's interface.

Uploaded by

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

Reort Final

The document outlines the development of a Hospital Management System aimed at automating and streamlining hospital operations using Java. It includes objectives such as enhancing patient care, improving efficiency, and ensuring data security, along with detailed descriptions of modules like patient management and billing. The document also discusses future enhancements, testing methodologies, and provides coding examples for the system's interface.

Uploaded by

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

INDEX

Topics Page No.

1.Title
2: Introduction & Objective
;. Tools/Platform, Hardware and Software Requirement
4. Analysis
-ER Diagram
-DFD
-Data Dictionary
5. Modules
Process logic of each modules

6. Screen
-Input
-Reports
7. Coding

8. Validation Checks

9.Testing

10.Conclusion

11.Future Scope

12.Bibliography
TITLE

HOSPITAL
MANAGEMENT
SYSTEM
INTRODUCTION & OBJECTIVE
INTRODUCTION
The Hospital Management System is a comprehensive software solution designed to
streamline and automate various administrative and operational tasks within a hospital
or healthcare facility. This project aims to develop a user-friendly and efficient system
using Java programming language, which will provide hospitals with a centralized
platform to manage their daily operations effectively.

OBJECTIVE
This main objective of the system is to computerize the maintenance of the patient
details and billing section in the hospital. It also includes the details about the laboratory
checkups. The primary objective of the HOSPITAL MANAGEMENT SYSTEM are as
follows:

1.Streamline Hospital Operations: The primary objective is to streamline and


optimize hospital operations by automating manual processes.

2.Enhance Patient Care: The project aims to improve the overall quality of patient care
by providing healthcare professionals with easy access to accurate and up-to-date
patient information.

3.Improve Efficiency and Productivity: The Hospital Management System aims to


enhance the efficiency and productivity of hospital staff by eliminating redundant tasks and
automating routine processes.

4.Optimize Resource Utilization: The project objective is to optimize the utilization of


hospital resources, including doctors, nurses, equipment, and medications.

5.Ensure Data Security and Privacy: Data security and patient privacy are paramount
in healthcare systems.
6.Provide Comprehensive Reporting and Analytics: The Hospital Management
System project aims to provide comprehensive reporting and analytics capabilities.
TOOLS AND PLATFORMS

Programming Language Used: - JAVA


Database Management System: - MySQL
Development Environment: - Apache NetBeans IDE 23
Operating System: - Compatible with Windows, mac OS, or Linux
SOFTWARE & HARDWAR REQUIREMENTS

Software Requirements

Operating system: - Window 8 or above


Tools: - NetBeans, MYSQL
Language: - Java
Framework: - NA

Hardware Requirements

The application will run on a Windows operating system with the following
specifications:
-

PROCESSOR: - Intel core i3 or above


RAM: - 4GB or above.
DFDs

1. ZERO LEVEL DFD

Hospital
User Management System Cloud Side
2. FIRST LEVEL DFD

Hospital Management System


Manageall
activities/Get
User records of
successful or
unsuccessful
transactions
ER - Diagram:
MODULES AND THEIR DESCRIPTION

The Hospital Expense Management System project consists of several interconnected


modules that work together to provide a comprehensive and efficient expense
management solution. Each module serves a specific purpose and contributes to the
overall functionality of the system. Let's explore the key modules in detail:

1.User Authentication and Access Control Module: This module


handles user authentication and access control, ensuring that only authorized
personnel can access the system. It includes features such as login, registration,
and password management.

2.Patient Management Module: The Patient Management module


allows hospital staff to manage patient information effectively. It includes
functionalities like patient registration, storing demographic details, medical
history, allergies, and contact information

3.Appointment Scheduling Module: This module enables patients


to schedule appointments with doctors based on their availability. It also
allows doctors and administrators to view and manage the appointment
schedule, reschedule appointments, and send notifications to patients.
4.Doctor Management Module: The Doctor Management module
allows administrators to maintain a database of doctors working at the hospital. It
includes functionalities like adding new doctors, updating their profiles,
managing their availability, and assigning them to specific departments or
clinics.

5.Pharmacy and Inventory Management Module: This module handles


the management of medicines, medical supplies, and inventory control. . It
includes features like stock management, automatic reordering, tracking
expiry dates, generating purchase orders, and maintaining a record of received
and consumed items.

6.Billing and Invoicing Module: The Billing and Invoicing


module automates the billing process for hospital services. It generates accurate
invoices based on services provided, procedures conducted, medications
administered, and
other charges.
7.Laboratory Management Module: The Laboratory Management module
integrates the hospital's laboratory with the system.

8.Reporting and Analytics Module: The Reporting and Analytics module


generates comprehensive reports and provides insights into various aspects
of hospital operations.

9.System Administration Module: The System Administration


module allows administrators to manage system settings, user roles, and
permissions.
Future Scope
The Hospital Management System project based on Java offers a solid foundation
for further enhancements and expansions. Here are some potential areas for
future development:

1.Integration with Electronic Health Records (EHR): EHR integration


can enable seamless sharing of patient data across different healthcare facilities
and systems, promoting continuity of care and interoperability.

2.Mobile Application: Developing a mobile application for the Hospital


Management System can allow patients to access their medical records,
schedule appointments, and receive notifications on their
smartphones, enhancing convenience and engagement

3.Telemedicine Integration: Integrating telemedicine capabilities into


the system enable virtual consultations, remote monitoring, and telehealth
services, providing accessible healthcare to patients regardless of their location.

4.Artificial Intelligence (AI) and Machine Learning (ML):


Implementing AI and ML algorithms can help automate certain tasks, such as
medical record classification, predictive analytics for patient outcomes, and
personalized treatment recommendations.

5.Internet of Things (IOT) Integration: Connecting medical devices,


wearables, and sensors to the system can facilitate real-time data collection,
remote monitoring of patients, and proactive healthcare interventions.

6.Expansion to Multiple Locations: Scaling the system to


accommodate multiple hospital branches or healthcare facilities can provide
centralized management and data sharing while maintaining local customization.

7.Enhancing Data Security: Strengthening the system's security measures,


such as implementing encryption, access controls, and regular vulnerability
assessments, is crucial to safeguard patient data and protect against cyber threats.
CONCLUSION

The Hospital Management System project significant benefits in terms of


streamlining hospital operations, improving patient care, and enhancing overall efficiency.
By automating various administrative and operational tasks, the system eliminates
manual processes, reduces paperwork, and minimizes errors. It provides a centralized
platform for managing patient records, appointments, billing, inventory, and
communication among different departments.

The project's successful implementation can result in improved patient satisfaction, as


it enables efficient appointment scheduling, timely access to medical records, and
accurate billing. It also facilitates better coordination among healthcare professionals,
leading to enhanced collaboration and patient care. The reporting and analytics
capabilities of the system provide valuable insights for informed decision-making and
resource optimization.
TESTING

INTRODUCTION
Testing is the process of executing a program with the intent of finding errors. It
is a major quality measure employed during software development. During testing,
the program is executed with a set of conditions known as test cases, and the
output is evaluated to determine whether the program is performing as expectation the
programmer. Testing is the process of executing a program with the intent of finding
errors.

TESTING OBJECTIVES

• Testing is the process of executing a program with the intent of finding an error.
• A successful test uncovers a yet undiscovered error.
• A good test case has a high probability of finding errors if it exists.
• The tests are inadequate to detect possibly present errors.

• The software more or less confirms different perspectives on the quality


and reliability standards.

LEVELS OF TESTING
To uncover the errors, present in different phases we have the concept of levels
of things. The basic levels of testing are

TESTING TECHNIQUE USED (TYPES OF TESTING)


1. UNIT TESTING
• Unit Testing is done on individual modules as they are completed and
become executable.
• It is confined only to the designer’srequirements.
• Each module can be tested using the following two strategies.
2. BLACK BOX TESTING
• In this strategy some test cases are generated as the input conditions that
fully execute all the functional requirements for the program. This testing has
been used to find errors in the following categories:
• Incorrect or missing function

• Interface errors
• Errors in a data structure or external database access
• Performance errors
• Initialization and termination errors.
• In this testing only output is checked for correctness. The logical flow of data
is not checked.
3. WHITE BOX TESTING
In this the test cases are generated on the logic of each module by drawing flow
• graphs of that module and logical decisions are tested on all the cases.
• It has been used to generate the testcases in the following cases:
• Guarantee that all independent paths have been executed.
• Execute all logical decisions on their true and false sides.
• Execute all loops at their boundaries and within their operational bounds.
• Execute internal data structure to ensure their validity.
4. INTEGRATION TESTING
Integration testing ensures that the software and the subsystems work together as a
whole. It tests the interface of the entire module to make sure that the modules behave
properly
when integrated.

5. SYSTEM TESTING
System testing involves in-house testing of the entire system before delivery to the user.
It aims to satisfy the user that the system meets all requirements of the
client’s specifications.

6. USER ACCEPTANCE TESTING


User acceptance of a system is the key factor to the success of any system. The
system under study is tested for user acceptance by constantly keeping in touch
with the prospective system users at the time of developing and making changes
whenever required.
It is pre-delivery testing in which the entire system is tested at the client’s site
on real-world data to find errors.
7. VALIDATION TESTING
The system has been tested and implemented successfully and thus ensured that all
the requirements as listed in the software required specification are completely
fulfilled. In case of erroneous input, corresponding error messages are displayed.

8. OUTPUT TESTING
After performing validation testing, the nextstep is output testing of the proposed system
since no system could be useful if it does not produce the required specified format.. The
output format on the screen is found to be correct as the format was designed in the system
design phase according to the user’s needs. For the hard copy also output comes as the
specified requirements by the users. Hence output testing does not result in any corrections in
the system.
Bibliography

• www.w3 schools. com


• www.tutioralspoint.com
• www.youtube.com
Coding

Indexpage.java
package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class index extends JFrame implements


ActionListener {
JFrame f;
JLabel l1,l2,l3,l4;
JButton bt1,bt2,bt3,bt4;

index()
{
f=new JFrame ("Index page");
f.setBackground(Color.WHITE);
f.setLayout(null);

l1=new JLabel ();


l1.setBounds(0,0,800,570);
l1.setLayout(null);

ImageIcon img = new


ImageIcon(ClassLoader.getSystemResource("hospital/hms/image
4.jpg")); Image
il=img.getImage().getScaledInstance(800,570,Image.SCALE_SMOOTH);
ImageIcon img4=new ImageIcon(il);
l1.setIcon(img4);
f.add(l1);

l3=new JLabel("Provide best quality Healthcare for


you"); l3.setBounds(90,350,500,40);
l3.setFont(new Font("Airal",Font.BOLD,15));
l3.setForeground(Color.BLACK);
l1.add(l3);

bt1=new JButton("Doctor");
bt1.setBounds(50,390,150,40);
bt1.setBackground(Color.BLACK);
bt1.setForeground(Color.white);
l1.add(bt1);

bt2=new JButton("Patient");
bt2.setBounds(220,390,150,40);
bt2.setBackground(Color.BLACK);
bt2.setForeground(Color.white);
l1.add(bt2);

bt3=new JButton("Receptionist");
bt3.setBounds(50,450,150,40);
bt3.setBackground(Color.BLACK);
bt3.setForeground(Color.white);
l1.add(bt3);

bt4=new JButton("Admin");
bt4.setBounds(220,450,150,40);
bt4.setBackground(Color.BLACK);
bt4.setForeground(Color.white);
l1.add(bt4);

bt1.addActionListener(this);
bt2.addActionListener(this);
bt3.addActionListener(this);
bt4.addActionListener(this);

l2=new JLabel("TrustCare Medical Group");


l2.setBounds(80,320,500,35);
l2.setFont(new Font("Arial",Font.ITALIC,35));
l2.setForeground(Color.BLACK);
l1.add(l2);

f.setSize(800,570);
f.setLocation(300,100);
f.setVisible(true);
f.setResizable(false);

}
public void actionperformed (ActionEvent ae)
{
if(ae.getSource()==bt1)
{
f.setVisible(false);
new loginpage();
}
if(ae.getSource()==bt2)
{
f.setVisible(false);
new loginpage();
}
if(ae.getSource()==bt3)
{
f.setVisible(false);
new loginpage();
}
if(ae.getSource()==bt4)
{
f.setVisible(false);
new loginpage();
}
}
public static void main(String[] args)
{
new index();
}
Loginpage.java
package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;

public class loginpage extends JFrame implements


ActionListener {

JFrame f;
JPanel panel;
JLabel l1, l2, l3, l4;
JTextField tf;
JPasswordField pf;
JButton bt1, bt2;

loginpage() {
f = new JFrame("loginpage");
f.setBackground(Color.WHITE);
f.setLayout(null);

l1 = new JLabel();
l1.setBounds(0, 0, 580, 350);
l1.setLayout(null);

ImageIcon img = new


ImageIcon(ClassLoader.getSystemResource("hospital/hms/admin
login 1.jpg"));
Image i = img.getImage().getScaledInstance(580, 350,
Image.SCALE_SMOOTH);
ImageIcon img1 = new ImageIcon(i);
l1.setIcon(img1);

l2 = new JLabel("Login page");


l2.setBounds(198, 35, 500, 50);
l2.setFont(new Font("Airal", Font.BOLD, 30));
l2.setForeground(Color.BLACK);
l1.add(l2);
f.add(l1);

l3 = new JLabel("Username:");
l3.setBounds(180, 120, 150, 30);
l3.setFont(new Font("Airal", Font.BOLD, 20));
l3.setForeground(Color.BLACK);
l1.add(l3);

l4 = new JLabel("Password:");
l4.setBounds(180, 170, 150, 30);
l4.setFont(new Font("Airal", Font.BOLD, 20));
l4.setForeground(Color.BLACK);
l1.add(l4);

tf = new JTextField();
tf.setBounds(310, 120, 150, 30);
l1.add(tf);

pf = new JPasswordField();
pf.setBounds(310, 170, 150, 30);
l1.add(pf);

bt1 = new JButton("Login");


bt1.setBackground(Color.BLACK);
bt1.setForeground(Color.WHITE);
bt1.setBounds(130, 220, 150, 40);
l1.add(bt1);

bt2 = new JButton("Back");


bt2.setBackground(Color.BLACK);
bt2.setForeground(Color.WHITE);
bt2.setBounds(310, 220, 150, 40);
l1.add(bt2);

bt1.addActionListener(this);
bt2.addActionListener(this);

f.setVisible(true);
f.setSize(580, 350);
f.setLocation(300, 100);
f.setResizable(false);
}

public void actionperformed (ActionEvent ae)


{
if(ae.getSource()==bt1)
{
try
{
connectionclass obj=new connectionclass();
String name=tf.getText();
String pass=pf.getText();
String q="select * from admin where
(username='"+name+"'and password='"+pass+"')";
ResultSet rs=obj.stm.executeQuery(q);

if(rs.next())
{
// System.out.println("login");
String adminname=rs.getString("name");
new adminhomepage(adminname).setVisible(true);
f.setVisible(false);
}
else
{
JOptionPane.showMessageDialog(null,"you have entered
wrong username and password !");
f.setVisible(false);
f.setVisible(true);
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
if(ae.getSource()==bt2)
{
this.f.setVisible(false);
new index();

}
public static void main(String[] args)
{
new loginpage();
}
}
Adminhomepage.java

package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;

public class adminhomepage extends JFrame implements


ActionListener
{
JLabel l1;
Font f,f1,f2;

adminhomepage(String adminname)
{
super("admin homepage");
setLocation(0,0);
setSize(1500,730);

ImageIcon img = new


ImageIcon(ClassLoader.getSystemResource("hospital/hms/
adminhome page.jpg"));
Image i= img.getImage().getScaledInstance(1500, 730,
Image.SCALE_SMOOTH);
ImageIcon img1 = new ImageIcon(i);
l1=new JLabel(img);

f=new Font ("Lucida Fax",Font.BOLD,20);


f2=new Font ("Gadugi",Font.BOLD,35);
f1=new Font ("MS UI Gothic",Font.BOLD,18);

JMenuBar m1=new JMenuBar();


JMenu men1=new JMenu("Doctor");
JMenuItem ment1=new JMenuItem ("Add Doctor");
JMenuItem ment2=new JMenuItem ("View
Doctor");

JMenu men2=new JMenu("Patient");


JMenuItem ment3=new JMenuItem ("Add Patient");
JMenuItem ment4=new JMenuItem ("View
Patient");

JMenu men3=new JMenu("Receptionist");


JMenuItem ment5=new JMenuItem ("Add Receptionist");
JMenuItem ment6=new JMenuItem ("View
Receptionist");

JMenu men4=new JMenu("Appointment");


JMenuItem ment7=new JMenuItem ("Add Appointment");
JMenuItem ment8=new JMenuItem ("View
Appointment");
JMenu men5=new JMenu("Hi,Admin("+adminname+")");
JMenuItem ment9=new JMenuItem ("My Profile");
JMenuItem ment10=new JMenuItem ("Change Password");

JMenu men8=new JMenu ("Exit");


JMenuItem ment14=new JMenuItem ("Exit");

men1.add(ment1);
men1.add(ment2);
men2.add(ment3);
men2.add(ment4);
men3.add(ment5);
men3.add(ment6);
men4.add(ment7);
men4.add(ment8);
men5.add(ment9);
men5.add(ment10);
men8.add(ment14);

m1.add(men1);
m1.add(men2);
m1.add(men3);
m1.add(men4);
m1.add(men5);
m1.add(men8);

men1.setFont(f);
men2.setFont(f);
men3.setFont(f);
men4.setFont(f);
men5.setFont(f);
men8.setFont(f);

ment1.setFont(f1);
ment2.setFont(f1);
ment3.setFont(f1);
ment4.setFont(f1);
ment5.setFont(f1);
ment6.setFont(f1);
ment7.setFont(f1);
ment8.setFont(f1);
ment9.setFont(f1);
ment10.setFont(f1);
ment14.setFont(f1);

m1.setBackground(Color.BLACK);

men1.setForeground(Color.GRAY);
men2.setForeground(Color.GRAY);
men3.setForeground(Color.GRAY);
men4.setForeground(Color.GRAY);
men5.setForeground(Color.GRAY);
men8.setForeground(Color.RED);

ment1.setForeground(Color.YELLOW);
ment3.setForeground(Color.YELLOW);
ment5.setForeground(Color.YELLOW);
ment7.setForeground(Color.YELLOW);
ment9.setForeground(Color.YELLOW);
ment14.setForeground(Color.ED);

ment1.setBackground(Color.BLACK);
ment3.setBackground(Color.BLACK);
ment5.setBackground(Color.BLACK);
ment7.setBackground(Color.BLACK);
ment9.setBackground(Color.BLACK);
ment14.setBackground(Color.BLACK);

ment1.addActionListener(this);
ment2.addActionListener(this);
ment3.addActionListener(this);
ment4.addActionListener(this);
ment5.addActionListener(this);
ment6.addActionListener(this);
ment7.addActionListener(this);
ment8.addActionListener(this);
ment9.addActionListener(this);
ment10.addActionListener(this);
ment14.addActionListener(this);

setJMenuBar (m1);
add (m1);
}

public void actionperformed (ActionEvent ae)


{
String comnd =ae.getActionCommand();
if(comnd.equals("Add Doctor"))
{
new AddDoctor();
}
elseif(comnd.equals("view doctor"))
{
new viewdoctor().setVisible(true);
}
elseif (comnd.equals("Exist"))
{
this.setVisible(false);
new index();
}
}

}
AddDoctor.java

package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
;
import java.util.Random;

public class AddDoctor extends JFrame implements


ActionListener {
JFrame f;
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16;
JTextField t1,t2,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
JPasswordField t3;
JButton bt1,bt2;

AddDoctor()
{
f = new JFrame("Add Doctor");
f.setBackground(Color.WHITE);
f.setLayout(null);

l1=new JLabel();
l1.setBounds(0, 0, 900, 600);
l1.setLayout(null);

ImageIcon img = new


ImageIcon(ClassLoader.getSystemResource("hospital/hms/
adddoctor.j pg"));
Image i1 = img.getImage().getScaledInstance(900, 600,
Image.SCALE_SMOOTH);
ImageIcon img1 = new ImageIcon(i1);
l1.setIcon(img1);

l2=new JLabel("Add Doctor Details");


l2.setBounds(280,30,500,50);
l2.setFont(new Font("Airal",Font.BOLD,30));
l2.setForeground(Color.BLACK);
l1.add(l2);
f.add(l1);

l3=new JLabel ("Name");


l3.setBounds(50,150,150,30);
l3.setFont(new Font("Airal",Font.BOLD,20));
l3.setForeground(Color.BLACK);
l1.add(l3);
t1=new JTextField();
t1.setBounds(200,150,150,30);
l1.add(t1);

l4=new JLabel ("UserName");


l4.setBounds(450,150,200,30);
l4.setFont(new Font("Airal",Font.BOLD,20));
l4.setForeground(Color.BLACK);
l1.add(l4);

t2=new JTextField();
t2.setBounds(600,150,150,30);
l1.add(t2);

l5=new JLabel ("Password");


l5.setBounds(50,200,100,30);
l5.setFont(new
Font("Airal",Font.BOLD,20));
l5.setForeground(Color.BLACK);
l1.add(l5);

t3=new JPasswordField();
t3.setBounds(200,200,150,30);
l1.add(t3);

l6=new JLabel ("Date ofBirth");


l6.setBounds(450,200,200,30);
l6.setFont(new
Font("Airal",Font.BOLD,20));
l6.setForeground(Color.BLACK);
l1.add(l6);

t4=new JTextField();
t4.setBounds(600,200,150,30);
l1.add(t4);

l7=new JLabel ("Address");


l7.setBounds(50,250,100,30);
l7.setFont(new
Font("Airal",Font.BOLD,20));
l7.setForeground(Color.BLACK);
l1.add(l7);

t5=new JTextField();
t5.setBounds(200,250,150,30);
l1.add(t5);

l8=new JLabel ("Phone");


l8.setBounds(450,250,100,30);
l8.setFont(new
Font("Airal",Font.BOLD,20));
l8.setForeground(Color.BLACK);
l1.add(l8);
t6=new JTextField();
t6.setBounds(600,250,150,30);
l1.add(t6);

l9=new JLabel ("Emailid");


l9.setBounds(50,300,100,30);
l9.setFont(new
Font("Airal",Font.BOLD,20));
l9.setForeground(Color.BLACK);
l1.add(l9);

t7=new JTextField();
t7.setBounds(200,300,150,30);
l1.add(t7);

l10=new JLabel ("City");


l10.setBounds(450,300,100,30);
l10.setFont(new
Font("Airal",Font.BOLD,20));
l10.setForeground(Color.BLACK);
l1.add(l10);

t8=new JTextField();
t8.setBounds(600,300,150,30);
l1.add(t8);

l11=new JLabel ("Gender");


l11.setBounds(50,350,100,30);
l11.setFont(new
Font("Airal",Font.BOLD,20));
l11.setForeground(Color.BLACK);
l1.add(l11);

t9=new JTextField();
t9.setBounds(200,350,150,30);
l1.add(t9);

l12=new JLabel ("Blood Group");


l12.setBounds(450,350,140,30);
l12.setFont(new Font("Airal",Font.BOLD,20));
l12.setForeground(Color.BLACK);
l1.add(l12);

t10=new JTextField();
t10.setBounds(600,350,150,30);
l1.add(t10);

l13=new JLabel ("Age");


l13.setBounds(450,400,100,30);
l13.setFont(new
Font("Airal",Font.BOLD,20));
l13.setForeground(Color.BLACK);
l1.add(l13);
t11=new JTextField();
t11.setBounds(600,400,150,30);
l1.add(t11);

l14=new JLabel ("Clinic Number");


l14.setBounds(450,450,150,30);
l14.setFont(new Font("Airal",Font.BOLD,20));
l14.setForeground(Color.BLACK);
l1.add(l14);

t12=new JTextField();
t12.setBounds(600,450,120,30);
l1.add(t12);

l15=new JLabel ("Joining Date");


l15.setBounds(50,400,120,30);
l15.setFont(new
Font("Airal",Font.BOLD,20));
l15.setForeground(Color.BLACK);
l1.add(l15);

t13=new JTextField();
t13.setBounds(200,400,150,30);
l1.add(t13);

l16=new JLabel ("Spcialization");


l16.setBounds(50,450,140,30);
l16.setFont(new
Font("Airal",Font.BOLD,20));
l16.setForeground(Color.BLACK);
l1.add(l16);

t14=new JTextField();
t14.setBounds(200,450,150,30);
l1.add(t14);

bt1=new JButton("Submit");
bt1.setBackground(Color.BLACK);
bt1.setForeground(Color.white);
bt1.setBounds(250,500,150,40);
l1.add(bt1);

bt2=new JButton("Cancel");
bt2.setBackground(Color.BLACK);
bt2.setForeground(Color.WHITE);
bt2.setBounds(450,500,150,40);
l1.add(bt2);

bt1.addActionListener(this);
bt2.addActionListener(this);
f.setVisible(true);
f.setSize(900,600);
f.setLocation(300, 100);

}
public void actionperformed (ActionEvent e)
{
if(e.getSource()==bt1)
{
String name=t1.getText();
String username=t2.getText();
String password=t3.getText();
String dob=t4.getText();
String address=t5.getText();
String phone=t6.getText();
String email=t7.getText();
String city=t8.getText();
String gender=t9.getText();
String blood=t10.getText();
String age=t11.getText();
String clinic=t12.getText();
String jod=t13.getText();
String splz=t14.getText();
String avl="yes";
Random r= new Random();
String doc_l1=""+Math.abs(r.nextInt() % 100000);

try
{
connectionclass obj = new connectionclass();
String q = "insert into doctor
values('"doc_l1"',"+name+"','"+username+"','"+password"','"+dob+"','"
+address+"','"+phone+"','"+email"','"+city+"','"+gender+"','"+blood"','"
+age+"','"+clinic+"','"+jod+"','"+splz+"','"+avl")";
obj.stm.executeUpdate(q);
JOptionPane . showMessageDialog(null,"Details
Successfully Inserted");
f.setVisible(false);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
if(e.getSource()==bt2)
{
f.setVisible(false);
}
}
public static void main(String[] args)
{
new AddDoctor();
}
}
Viewdoctor.java
package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
public class viewdoctor extends JFrame
implements ActionListener
{
String x[]={"Name"
,"Username","DOB","ADDRESS","PHONE","EMAIL",
"CITY","GENDER","BLOOD GROUP","AGE","CLINIC
NO.",
"JOINING
DATE","SPCIALIZATION","AVAILABILITY"};
JButton bt,bt1;
Stringy[][]=new String[20][14];
inti=0,j=0;
JTablet;
JLabell1,l2;
JTextField tf1;
JPanel p1,p2,p3;
Font f,f1;

viewdoctor()
{
super("Doctor Information");
setSize(1500,400);
setLocation(1,1);

f=new Font("MS UI Gothic",Font.BOLD,15);

try
{
connectionclass obj=new connectionclass();
String q="Select * from doctor";
ResultSet rest=obj.stm.executeQuery(q);
while(rest.next())
{
y[i][j++]=rest.getString("name");
y[i][j++]=rest.getString("username");
y[i][j++]=rest.getString("dob");
y[i][j++]=rest.getString("address");
y[i][j++]=rest.getString("phone");
y[i][j++]=rest.getString("email");
y[i][j++]=rest.getString("city");
y[i][j+
+]=rest.getString("gender"); y[i]
[j++]=rest.getString("blood");
y[i][j++]=rest.getString("age");
y[i][j++]=rest.getString("clinic_no");
y[i][j++]=rest.getString("joining_date");
y[i][j++]=rest.getString("specialization");
y[i][j++]=rest.getString("availability");

i++;
j=0;
}
t=new JTable(y,x);
t.setFont(f);
t.setBackground(Color.BLACK);
t.setForeground(Color.WHITE);

}
catch(Exception ex)
{
ex.printStackTrace();
}
JScrollPane sp=new JScrollPane(t);

f1=new Font("Lucida Fax",Font.BOLD,25);


l1=new JLabel ("Doctor Username");
l2=new JLabel ("Delete or Edit any
Doctor?");
l2.setHorizontalAlignment(JLabel.CENTER);

l1.setForeground(Color.GRAY);
l2.setForeground(Color.YELLOW);
l1.setFont(f);
l2.setFont(f1);

bt=new JButton("Delete Doctor");


bt1=new JButton("Edit Doctor
Record"); bt.addActionListener(this);
bt1.addActionListener(this);

bt.setBackground(Color.BLACK);
bt1.setBackground(Color.BLACK);

bt.setForeground(Color.WHITE);
bt1.setForeground(Color.WHITE);

tf1=new JTextField();
tf1.setFont(f);

p1=new JPanel();
p1.setLayout(new GridLayout(1,1,10,10));
p1.add(l2);

p2=new JPanel();
p2.setLayout(new GridLayout(1,4,10,10));
p2.add(l1);
p2.add(tf1);
p2.add(bt);
p2.add(bt1);

p3=new JPanel();
p3.setLayout(new GridLayout(2,1,10,10));
p3.add(p1);
p3.add(p2);

p1.setBackground(Color.BLACK);
p2.setBackground(Color.BLACK);
p3.setBackground(Color.BLACK);

add(p3,"South");

add(sp);

}
public void actionPerformed(ActionEvent ae)
{
String username=tf1.getText();
if(ae.getSource()==bt)
{
try
{
connectionclass obj1=new connectionclass();
String q="delete from doctor
where username='"+username+"'";
obj1.stm.executeUpdate(q);
String q2="update appointment
set appointment_ststus='cancel'where
doctor
_username='"+username+"'and appointment_status='open'";

obj1.stm.executeUpdate(q);

setVisible(false);
}
}
catch(Exception e)
{
e.printStackTrace();
}
if(ae.getSource()==bt1)
{
if(username.isEmpty())
{
JOptionPane.showMessageDialog(null, "Please fill
the doctor username !");
}
else
{
setVisible(false);
new EditDoctor(username).setVisible(true);
}
}
}
public static void main(String[] args)
{
new viewdoctor().setVisible(true);
}
}
output
EditDoctor.java

package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;

public class EditDoctor extends JFrame implements


ActionListener
{
JFrame f;
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16;
JTextField t1,t2,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
JPasswordField t3;
JButton bt1,bt2;

EditDoctor(String username)
{
try
{
connectionclass obj= new connectionclass();
String q="select * from doctor where
username='"+username+"'";
ResultSet rest=obj.stm.executeQuery(q);

if(rest0.next())
{
f = new JFrame("Edit Doctor");
f.setBackground(Color.WHITE);
f.setLayout(null);

l1=new JLabel();
l1.setBounds(0, 0, 900, 600);
l1.setLayout(null);

ImageIcon img = new


ImageIcon(ClassLoader.getSystemResource("hospital/hms/
add doctor.jpg"));
Image i1 = img.getImage().getScaledInstance(900,
600, Image.SCALE_SMOOTH);
ImageIcon img1 = new ImageIcon(i1);
l1.setIcon(img1);

l2=new JLabel("Edit Doctor Details");


l2.setBounds(280,30,500,50);
l2.setFont(new Font("Airal",Font.BOLD,30));
l2.setForeground(Color.BLACK);
l1.add(l2);
f.add(l1);

l3=new JLabel ("Name");


l3.setBounds(50,150,150,30);
l3.setFont(new Font("Airal",Font.BOLD,20));
l3.setForeground(Color.BLACK);
l1.add(l3);

l4=new JLabel ("UserName");


l4.setBounds(450,150,200,30);
l4.setFont(new Font("Airal",Font.BOLD,20));
l4.setForeground(Color.BLACK);
l1.add(l4);

l5=new JLabel ("Password");


l5.setBounds(50,200,100,30);
l5.setFont(new
Font("Airal",Font.BOLD,20));
l5.setForeground(Color.BLACK);
l1.add(l5);

l6=new JLabel ("Date ofBirth");


l6.setBounds(450,200,200,30);
l6.setFont(new
Font("Airal",Font.BOLD,20));
l6.setForeground(Color.BLACK);
l1.add(l6);

l7=new JLabel ("Address");


l7.setBounds(50,250,100,30);
l7.setFont(new
Font("Airal",Font.BOLD,20));
l7.setForeground(Color.BLACK);
l1.add(l7);

l8=new JLabel ("Phone");


l8.setBounds(450,250,100,30);
l8.setFont(new
Font("Airal",Font.BOLD,20));
l8.setForeground(Color.BLACK);
l1.add(l8);

l9=new JLabel ("Emailid");


l9.setBounds(50,300,100,30);
l9.setFont(new
Font("Airal",Font.BOLD,20));
l9.setForeground(Color.BLACK);
l1.add(l9);
l10=new JLabel ("City");
l10.setBounds(450,300,100,30);
l10.setFont(new
Font("Airal",Font.BOLD,20));
l10.setForeground(Color.BLACK);
l1.add(l10);

l11=new JLabel ("Gender");


l11.setBounds(50,350,100,30);
l11.setFont(new
Font("Airal",Font.BOLD,20));
l11.setForeground(Color.BLACK);
l1.add(l11);

l12=new JLabel ("Blood Group");


l12.setBounds(450,350,140,30);
l12.setFont(new
Font("Airal",Font.BOLD,20));
l12.setForeground(Color.BLACK);
l1.add(l12);

l13=new JLabel ("Age");


l13.setBounds(450,400,100,30);
l13.setFont(new
Font("Airal",Font.BOLD,20));
l13.setForeground(Color.BLACK);
l1.add(l13);

l14=new JLabel ("Clinic Number");


l14.setBounds(450,450,150,30);
l14.setFont(new
Font("Airal",Font.BOLD,20));
l14.setForeground(Color.BLACK);
l1.add(l14);

l15=new JLabel ("Joining Date");


l15.setBounds(50,400,120,30);
l15.setFont(new
Font("Airal",Font.BOLD,20));
l15.setForeground(Color.BLACK);
l1.add(l15);
l16=new JLabel ("Spcialization");
l16.setBounds(50,450,140,30);
l16.setFont(new Font("Airal",Font.BOLD,20));
l16.setForeground(Color.BLACK);
l1.add(l16);

try
{
connectionclass obj= new connectionclass();
String q="select * from doctor
where username='"+username+"'";
ResultSet rest()=obj.stm.executeQuery(q);
while(rest.next())
{
t1=new JTextField();
t1.setBounds(200,150,150,30);
t1.setText(rest.getString("name"));
l1.add(t1);

t2=new JTextField();
t2.setBounds(600,150,150,30);
t2.setText(rest.getString("username"));
t2.setEditable(false);
l1.add(t2);

t3=new JPasswordField();
t3.setBounds(200,200,150,30);
t3.setText(rest.getString("password"));
t3.setEditable(false);
l1.add(t3);

t4=new JTextField();
t4.setBounds(600,200,150,30);
t4.setText(rest.getString("dob"));
l1.add(t4);

t5=new JTextField();
t5.setBounds(200,250,150,30);
t5.setText(rest.getString("address"));
l1.add(t5);

t6=new JTextField();
t6.setBounds(600,250,150,30);
t6.setText(rest.getString("phone"));
l1.add(t6);

t7=new JTextField();
t7.setBounds(200,300,150,30);
t7.setText(rest.getString("email"));
l1.add(t7);

t8=new JTextField();
t8.setBounds(600,300,150,30);
t8.setText(rest.getString("city"));
l1.add(t8);

t9=new JTextField();
t9.setBounds(200,350,150,30);
t9.setText(rest.getString("gender"));
l1.add(t9);

t10=new JTextField();
t10.setBounds(600,350,150,30);
t10.setText(rest.getString("blood"));
l1.add(t10);

t11=new JTextField();
t11.setBounds(600,400,150,30);
t11.setText(rest.getString("age"));
l1.add(t11);

t12=new JTextField();
t12.setBounds(600,450,120,30);
t12.setText(rest.getString("clinic_n0"));
l1.add(t12);

t13=new JTextField();
t13.setBounds(200,400,150,30);
t13.setText(rest.getString("joiningP_date"))
; l1.add(t13);

t14=new JTextField();
t14.setBounds(200,450,150,30);
t14.setText(rest.getString("specialization"))
; l1.add(t14);

}
}
catch(Exception ee)
{
ee.printStackTrace();
}
bt1=new JButton("Update");
bt1.setBackground(Color.BLACK);
bt1.setForeground(Color.white);
bt1.setBounds(250,500,150,40);
l1.add(bt1);

bt2=new JButton("Cancel");
bt2.setBackground(Color.BLACK);
bt2.setForeground(Color.WHITE);
bt2.setBounds(450,500,150,40);
l1.add(bt2);

bt1.addActionListener(this);
bt2.addActionListener(this);

f.setVisible(true);
f.setSize(900,600);
f.setLocation(300, 100);

}
else
{
JOptionPane.showMessageDialog(null,"record not
found,please fill the right doctor username!");
this.setVisible(false);
}
}
catch(Exception exx)
{
exx.printStackTrace();
}
}
public void actionperformed (ActionEvent e)
{
if(e.getSource()==bt1)
{
String name=t1.getText();
String username=t2.getText();
String dob=t4.getText();
String address=t5.getText();
String phone=t6.getText();
String email=t7.getText();
String city=t8.getText();
String gender=t9.getText();
String blood=t10.getText();
String age=t11.getText();
String clinic=t12.getText();
String jod=t13.getText();
String splz=t14.getText();

try
{
connectionclass obj = new
connectionclass() String q2="update doctor set
name='"+name+"',dob='"+dob+"',address='"+address+"',phone
='"+phone+"',email='"+email"',city='"+city+"',gender='"+gende
r+"',blood='"+blood"',age='"+age+"',clinic_no='"+clinic+"',join
ing_date='"+jod+"',specialization='"+splz+"',availablity='"+avl
+"' where username='"+username+"'";
obj.stm.executeUpdate(q2);
JOptionPane . showMessageDialog(null,"Details
Successfully updated");
f.setVisible(false);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
if(e.getSource()==bt2)
{
f.setVisible(false);
}
• Add Patient
addpatient.java

package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

import java.sql.*;
import java.util.Random;

public class addpatient extends JFrame implements ActionListener

{
JFrame f;
JLabell1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16;

JTextField t1,t2,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
JPasswordField t3;

JButton bt1,bt2;

addpatient()

{
f = new JFrame("Add Patient");

f.setBackground(Color.WHITE);
f.setLayout(null);

l1=new JLabel();
l1.setBounds(0, 0, 900, 600);

l1.setLayout(null);

ImageIcon img = new


ImageIcon(ClassLoader.getSystemResource("hospital/hms/addpatient2.jpg"));
Image i1 = img.getImage().getScaledInstance(900, 600, Image.SCALE_SMOOTH);
ImageIcon img1 = new ImageIcon(i1);

l1.setIcon(img1);

l2=new JLabel("Add Patient Details");

l2.setBounds(280,30,500,50);
l2.setFont(new Font("Airal",Font.BOLD,30));

l2.setForeground(Color.BLACK);
l1.add(l2);

f.add(l1);

l3=new JLabel ("Name");


l3.setBounds(50,150,150,30);
l3.setFont(new Font("Airal",Font.BOLD,20));

l3.setForeground(Color.BLACK);
l1.add(l3);

t1=new JTextField();
t1.setBounds(200,150,150,30);

l1.add(t1);

l4=new JLabel ("UserName");

l4.setBounds(450,150,200,30);
l4.setFont(new Font("Airal",Font.BOLD,20));

l4.setForeground(Color.BLACK);
l1.add(l4);

t2=new JTextField();
t2.setBounds(600,150,150,30);

l1.add(t2);
l5=new JLabel ("Password");

l5.setBounds(50,200,100,30);
l5.setFont(new Font("Airal",Font.BOLD,20));

l5.setForeground(Color.BLACK);
l1.add(l5);

t3=new JPasswordField();
t3.setBounds(200,200,150,30);

l1.add(t3);

l6=new JLabel ("Email");


l6.setBounds(450,200,200,30);
l6.setFont(new Font("Airal",Font.BOLD,20));

l6.setForeground(Color.BLACK);
l1.add(l6);

t4=new JTextField();
t4.setBounds(600,200,150,30);

l1.add(t4);

l7=new JLabel ("Father Name");

l7.setBounds(50,250,150,30);
l7.setFont(new Font("Airal",Font.BOLD,20));
l7.setForeground(Color.BLACK);

l1.add(l7);

t5=new JTextField();
t5.setBounds(200,250,150,30);

l1.add(t5);
l8=new JLabel ("Phone");
l8.setBounds(450,250,100,30);
l8.setFont(new Font("Airal",Font.BOLD,20));
l8.setForeground(Color.BLACK);

l1.add(l8);

t6=new JTextField();
t6.setBounds(600,250,150,30);

l1.add(t6);

l9=new JLabel ("Material Status");

l9.setBounds(50,300,150,30);
l9.setFont(new Font("Airal",Font.BOLD,20));

l9.setForeground(Color.BLACK);
l1.add(l9);

t7=new JTextField();
t7.setBounds(200,300,150,30);

l1.add(t7);

l10=new JLabel ("City");


l10.setBounds(450,300,100,30);
l10.setFont(new Font("Airal",Font.BOLD,20));

l10.setForeground(Color.BLACK);
l1.add(l10);

t8=new JTextField();
t8.setBounds(600,300,150,30);

l1.add(t8);
l11=new JLabel ("Gender");
l11.setBounds(50,350,100,30);
l11.setFont(new Font("Airal",Font.BOLD,20));

l11.setForeground(Color.BLACK);
l1.add(l11);

t9=new JTextField();
t9.setBounds(200,350,150,30);

l1.add(t9);

l12=new JLabel ("Blood Group");

l12.setBounds(450,350,140,30);
l12.setFont(new Font("Airal",Font.BOLD,20));

l12.setForeground(Color.BLACK);
l1.add(l12);

t10=new JTextField();
t10.setBounds(600,350,150,30);

l1.add(t10);

l13=new JLabel ("Age");


l13.setBounds(450,400,100,30);
l13.setFont(new Font("Airal",Font.BOLD,20));
l13.setForeground(Color.BLACK);

l1.add(l13);

t11=new JTextField();
t11.setBounds(600,400,150,30);

l1.add(t11);
l14=new JLabel ("Deceased");

l14.setBounds(450,450,150,30);
l14.setFont(new Font("Airal",Font.BOLD,20));
l14.setForeground(Color.BLACK);

l1.add(l14);

t12=new JTextField();
t12.setBounds(600,450,120,30);

l1.add(t12);

l15=new JLabel ("Address");

l15.setBounds(50,400,120,30);
l15.setFont(new Font("Airal",Font.BOLD,20));

l15.setForeground(Color.BLACK);
l1.add(l15);

t13=new JTextField();
t13.setBounds(200,400,150,30);

l1.add(t13);

l16=new JLabel ("Date ofBirth");

l16.setBounds(50,450,140,30);
l16.setFont(new Font("Airal",Font.BOLD,20));

l16.setForeground(Color.BLACK);
l1.add(l16);

t14=new JTextField();
t14.setBounds(200,450,150,30);

l1.add(t14);
bt1=new JButton("Submit");
bt1.setBackground(Color.BLACK);

bt1.setForeground(Color.white);
bt1.setBounds(250,500,150,40);

l1.add(bt1);

bt2=new JButton("Cancel");
bt2.setBackground(Color.BLACK);

bt2.setForeground(Color.WHITE);
bt2.setBounds(450,500,150,40);
l1.add(bt2);

bt1.addActionListener(this);

bt2.addActionListener(this);

f.setVisible(true);

f.setSize(900,600);
f.setLocation(300, 100);

}
public void actionPerformed (ActionEvent e)

{
if(e.getSource()==bt1)

{
String name=t1.getText();
String username=t2.getText();

String password=t3.getText();
String email=t4.getText();
String fname=t5.getText();

String phone=t6.getText();
String material_status=t7.getText();

String city=t8.getText();
String gender=t9.getText();
String blood=t10.getText();
String age=t11.getText();
String deceased=t12.getText();

String address=t13.getText();
String dob=t14.getText();

Random r= new Random();


String pat_id=""+Math.abs(r.nextInt() % 100000);

try

{
connectionclass obj = new connectionclass();
String q = "insert into patient
values('"+pat_id+"','"+name+"','"+username+"','"+password"','"+email+"','"+fname+"','"+pho
ne+"','"+material_status"','"+city+"','"+gender+"','"+blood"','"+age+"','"+deceased+"','"+addre
ss+"','"+dob+"')";
obj.stm.executeUpdate(q);
JOptionPane . showMessageDialog(null,"Patient Details Successfully Inserted");

f.setVisible(false);
}
catch(Exception ex)

{
ex.printStackTrace();

}
}
if(e.getSource()==bt2)

{
f.setVisible(false);
}

}
public static void main(String[] args)
{
new addpatient();
}

}
Viewpatient.java
package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;

public class viewpatient extends JFrame implements


ActionListener
{

String x[]={"Name" ,"Username","Email","Father


Name","Phone","Material Status",
"City","Gender","Blood group","Address","Deceased",
"Date ofBirth","Age"};
JButton bt,bt1;
Stringy[][]=new String[20][13];
inti=0,j=0;
JTablet;
JLabell1,l2;
JTextField tf1;
JPanel p1,p2,p3;
Font f,f1;

viewpatient()
{
super("Patient Information");
setSize(1500,400);
setLocation(1,1);

f=new Font("MS UI Gothic",Font.BOLD,15);

try
{
connectionclass obj=new connectionclass();
String q="Select * from patient";
ResultSet
rest=obj.stm.executeQuery(q);
while(rest.next())
{
y[i][j++]=rest.getString("name");
y[i][j++]=rest.getString("username");
y[i][j++]=rest.getString("email");
y[i][j++]=rest.getString("father_name");
y[i][j++]=rest.getString("phone");
y[i][j++]=rest.getString("material_status");
y[i][j++]=rest.getString("city");
y[i][j++]=rest.getString("gender");
y[i][j++]=rest.getString("blood");
y[i][j++]=rest.getString("age");
y[i][j++]=rest.getString("dob");
y[i][j+
+]=rest.getString("deceased"); y[i]
[j++]=rest.getString("address");

i++;
j=0;
}
t=new JTable(y,x);
t.setFont(f);
t.setBackground(Color.BLACK)
;
t.setForeground(Color.WHITE);

}
catch(Exception ex)
{
ex.printStackTrace();
}
JScrollPane sp=new JScrollPane(t);

f1=new Font("Lucida Fax",Font.BOLD,25);


l1=new JLabel ("Patient Username");
l2=new JLabel ("Delete or Edit any
Patient?");
l2.setHorizontalAlignment(JLabel.CENTER);

l1.setForeground(Color.GRAY);
l2.setForeground(Color.YELLOW);
l1.setFont(f);
l2.setFont(f1);

bt=new JButton("Delete Patient");


bt1=new JButton("Edit Patient Record");
bt.addActionListener(this);
bt1.addActionListener(this);

bt.setBackground(Color.BLACK);
bt1.setBackground(Color.BLACK);

bt.setForeground(Color.WHITE);
bt1.setForeground(Color.WHITE)
;

tf1=new JTextField();
tf1.setFont(f);
p1=new JPanel();
p1.setLayout(new GridLayout(1,1,10,10));
p1.add(l2);

p2=new JPanel();
p2.setLayout(new GridLayout(1,4,10,10));
p2.add(l1);
p2.add(tf1);
p2.add(bt);
p2.add(bt1);

p3=new JPanel();
p3.setLayout(new GridLayout(2,1,10,10));
p3.add(p1);
p3.add(p2);

p1.setBackground(Color.BLACK);
p2.setBackground(Color.BLACK);
p3.setBackground(Color.BLACK);

add(p3,"South");

add(sp);

}
public void actionPerformed(ActionEvent ae)
{
String username=tf1.getText();
if(ae.getSource()==bt)
{
try
{
connectionclass obj1=new connectionclass();
String q="delete from patient
where username='"+username+"'";
obj1.stm.executeUpdate(q);

setVisible(false);
}

catch(Exception e)
{
e.printStackTrace();
}
}
if(ae.getSource()==bt1)
{
if(username.isEmpty())
{
JOptionPane.showMessageDialog(null,
"Please fill the patient username !");
}
else
{
setVisible(false);
new Editpatient(username).setVisible(true);
}
}
}
public static void main(String[]
args) {
new viewpatient().setVisible(true);
}
}

}
}
ACKNOWLEDGEMENT

We started this project as apart of the curriculum of BCA “ VIDYA INSTITUTE


OF CREATIVE TEACHING ’’ assigned to us. It was very exciting for us to work on the
project “Hospital Management System” . We take this opportunity to express our heartfelt
gratitude to all the people from our college for inspiring us to go to the depth of the
subject through
theoretical and practical approaches in every stage of our training.

We are sincerely indebted to Ms. ADITI who extended valuable guidance, constant
encouragement and help through various difficult stages for the completion of the project.
Thankyou for introducing add on subject which made our work even easier. We would
also thank our faculty members without whom this project would have been distant reality.
At
end, we want to thank our family, friends and relatives for their positive criticism and
needful support
CERTIFICATE
This is to certify that the project report on
“HOSPITAL MANAGEMENT SYSTEM”

Is a bonafide work and it is submitted to


Vidya Institute of Creative Teaching

By

For partial fulfillment of the final year


Computer Application
Fifth Semester

During the Academic year


2024-2025
Under the Guidance of
Prof.
Guide

Department of BCA
Vidya Institute of Creative Teaching

2024-2025
Editpatient.java
package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

import java.sql.*;

public class Editpatient extends JFrame implements ActionListener

{
JFrame f;
JLabell1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16;

JTextField t1,t2,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
JPasswordField t3;

JButton bt1,bt2;

Editpatient(String username)

{
try

{
connectionclass obj= new connectionclass();
String q="select * from patient where username='"+username+"'";

ResultSet rest0=obj.stm.executeQuery(q);

if(rest0.next())

{
f = new JFrame("Edit Patient");

f.setBackground(Color.WHITE);
f.setLayout(null);
l1=new JLabel();
l1.setBounds(0, 0, 900, 600);

l1.setLayout(null);

ImageIcon img = new


ImageIcon(ClassLoader.getSystemResource("hospital/hms/adddpatient2.jpg"));
Image i1 = img.getImage().getScaledInstance(900, 600, Image.SCALE_SMOOTH);

ImageIcon img1 = new ImageIcon(i1);


l1.setIcon(img1);

l2=new JLabel("Edit Patient Details");

l2.setBounds(280,30,500,50);
l2.setFont(new Font("Airal",Font.BOLD,30));

l2.setForeground(Color.BLACK);
l1.add(l2);

f.add(l1);

l3=new JLabel ("Name");


l3.setBounds(50,150,150,30);
l3.setFont(new Font("Airal",Font.BOLD,20));
l3.setForeground(Color.BLACK);

l1.add(l3);

l4=new JLabel ("UserName");

l4.setBounds(450,150,200,30);
l4.setFont(new Font("Airal",Font.BOLD,20));

l4.setForeground(Color.BLACK);
l1.add(l4);

l5=new JLabel ("Password");

l5.setBounds(50,200,100,30);
l5.setFont(new Font("Airal",Font.BOLD,20));

l5.setForeground(Color.BLACK);
l1.add(l5);

l6=new JLabel ("Email");


l6.setBounds(450,200,200,30);
l6.setFont(new Font("Airal",Font.BOLD,20));

l6.setForeground(Color.BLACK);
l1.add(l6);

l7=new JLabel ("Father name");

l7.setBounds(50,250,100,30);
l7.setFont(new Font("Airal",Font.BOLD,20));

l7.setForeground(Color.BLACK);
l1.add(l7);

l8=new JLabel ("Phone");


l8.setBounds(450,250,100,30);
l8.setFont(new Font("Airal",Font.BOLD,20));

l8.setForeground(Color.BLACK);
l1.add(l8);

l9=new JLabel ("Material status");

l9.setBounds(50,300,100,30);
l9.setFont(new Font("Airal",Font.BOLD,20));

l9.setForeground(Color.BLACK);
l1.add(l9);

l10=new JLabel ("City");


l10.setBounds(450,300,100,30);
l10.setFont(new Font("Airal",Font.BOLD,20));

l10.setForeground(Color.BLACK);
l1.add(l10);

l11=new JLabel ("Gender");


l11.setBounds(50,350,100,30);
l11.setFont(new Font("Airal",Font.BOLD,20));

l11.setForeground(Color.BLACK);
l1.add(l11);

l12=new JLabel ("Blood Group");

l12.setBounds(450,350,140,30);
l12.setFont(new Font("Airal",Font.BOLD,20));

l12.setForeground(Color.BLACK);
l1.add(l12);
l13=new JLabel ("Age");
l13.setBounds(450,400,100,30);
l13.setFont(new Font("Airal",Font.BOLD,20));

l13.setForeground(Color.BLACK);
l1.add(l13);

l14=new JLabel ("Deceased");

l14.setBounds(450,450,150,30);
l14.setFont(new Font("Airal",Font.BOLD,20));

l14.setForeground(Color.BLACK);
l1.add(l14);

l15=new JLabel ("Address");

l15.setBounds(50,400,120,30);
l15.setFont(new Font("Airal",Font.BOLD,20));

l15.setForeground(Color.BLACK);
l1.add(l15);

l16=new JLabel ("Date ofBirth");

l16.setBounds(50,450,140,30);
l16.setFont(new Font("Airal",Font.BOLD,20));

l16.setForeground(Color.BLACK);
l1.add(l16);

try

{
connectionclass obj1= new connectionclass();
String q1="select * from patient where username='"+username+"'";

ResultSet rest=obj1.stm.executeQuery(q1);
while(rest.next())

{
t1=new JTextField();
t1.setBounds(200,150,150,30);
t1.setText(rest.getString("name"));

l1.add(t1);

t2=new JTextField();
t2.setBounds(600,150,150,30);
t2.setText(rest.getString("username"));

t2.setEditable(false);
l1.add(t2);

t3=new JPasswordField();
t3.setBounds(200,200,150,30);
t3.setText(rest.getString("password"));

t3.setEditable(false);
l1.add(t3);

t4=new JTextField();
t4.setBounds(600,200,150,30);
t4.setText(rest.getString("email"));

l1.add(t4);

t5=new JTextField();
t5.setBounds(200,250,150,30);
t5.setText(rest.getString("fname"));
l1.add(t5);

t6=new JTextField();
t6.setBounds(600,250,150,30);
t6.setText(rest.getString("phone"));

l1.add(t6);

t7=new JTextField();
t7.setBounds(200,300,150,30);
t7.setText(rest.getString("material_status"));

l1.add(t7);

t8=new JTextField();
t8.setBounds(600,300,150,30);
t8.setText(rest.getString("city"));

l1.add(t8);

t9=new JTextField();
t9.setBounds(200,350,150,30);
t9.setText(rest.getString("gender"));

l1.add(t9);

t10=new JTextField();
t10.setBounds(600,350,150,30);
t10.setText(rest.getString("blood"));

l1.add(t10);

t11=new JTextField();
t11.setBounds(600,400,150,30);

t11.setText(rest.getString("age"));
l1.add(t11);

t12=new JTextField();
t12.setBounds(600,450,120,30);
t12.setText(rest.getString("deceased"));

l1.add(t12);

t13=new JTextField();
t13.setBounds(200,400,150,30);
t13.setText(rest.getString("address"));

l1.add(t13);

t14=new JTextField();
t14.setBounds(200,450,150,30);
t14.setText(rest.getString("dob"));

l1.add(t14);

}
catch(Exception ee)

{
ee.printStackTrace();

}
bt1=new JButton("Update");
bt1.setBackground(Color.BLACK);

bt1.setForeground(Color.white);
bt1.setBounds(250,500,150,40);

l1.add(bt1);
bt2=new JButton("Cancel");
bt2.setBackground(Color.BLACK);
bt2.setForeground(Color.WHITE);

bt2.setBounds(450,500,150,40);
l1.add(bt2);

bt1.addActionListener(this);

bt2.addActionListener(this);
f.setVisible(true);

f.setSize(900,600);
f.setLocation(300, 100);

}
else
{

JOptionPane.showMessageDialog(null,"record not found,please fill the right


patient username!");
this.setVisible(false);

}
}
catch(Exception exx)

{
exx.printStackTrace();
}

}
public void actionPerformed (ActionEvent e)

{
if(e.getSource()==bt1)

{
String name=t1.getText();
String username=t2.getText();

String email=t4.getText();
String fname=t5.getText();
String phone=t6.getText();
String material_status=t7.getText();

String city=t8.getText();
String gender=t9.getText();
String blood=t10.getText();
String age=t11.getText();
String deceased=t12.getText();

String address=t13.getText();
String dob=t14.getText()
try

{
connectionclass obj = new connectionclass();
String q2="update patient set
name='"+name+"',email='"+email+"',father_name='"+fname+"',phone='"+phone+"',material
status='"+material_status+"',city='"+city+"',gender='"+gender+"',blood
group='"+blood+"',age='"+age+"',deceased='"+deceased+"',address='"+address+"',date of
birth='"+dob+"' where username='"+username+"'";
obj.stm.executeUpdate(q2);
JOptionPane . showMessageDialog(null,"Details Successfully Updated");

f.setVisible(false);
}
catch(Exception ex)

{
ex.printStackTrace();

}
}
if(e.getSource()==bt2)

{
f.setVisible(false);

}
}

}
addreceptionist.java
package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

import java.sql.*;
import java.util.Random;

public class addreceptionist extends JFrame implements ActionListener

{
JFrame f;
JLabell1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16;

JTextField t1,t2,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
JPasswordField t3;
JButton bt1,bt2;

addreceptionist()
{
f = new JFrame("Add Receptionist");

f.setBackground(Color.WHITE);
f.setLayout(null);

l1=new JLabel();
l1.setBounds(0, 0, 900, 600);

l1.setLayout(null);

ImageIcon img = new


ImageIcon(ClassLoader.getSystemResource("hospital/hms/addres2.jpg"));
Image i1 = img.getImage().getScaledInstance(900, 600, Image.SCALE_SMOOTH);

ImageIcon img1 = new ImageIcon(i1);


l1.setIcon(img1);
l2=new JLabel("Add Receptionist Details");

l2.setBounds(280,30,500,50);
l2.setFont(new Font("Airal",Font.BOLD,30));

l2.setForeground(Color.BLACK);
l1.add(l2);

f.add(l1);

l3=new JLabel ("Name");


l3.setBounds(50,150,150,30);
l3.setFont(new Font("Airal",Font.BOLD,20));

l3.setForeground(Color.BLACK);
l1.add(l3);

t1=new JTextField();
t1.setBounds(200,150,150,30);

l1.add(t1);

l4=new JLabel ("UserName");

l4.setBounds(450,150,200,30);
l4.setFont(new Font("Airal",Font.BOLD,20));
l4.setForeground(Color.BLACK);

l1.add(l4);

t2=new JTextField();
t2.setBounds(600,150,150,30);

l1.add(t2);

l5=new JLabel ("Password");

l5.setBounds(50,200,100,30);
l5.setFont(new Font("Airal",Font.BOLD,20));
l5.setForeground(Color.BLACK);

l1.add(l5);

t3=new JPasswordField();
t3.setBounds(200,200,150,30);

l1.add(t3);

l6=new JLabel ("Email");


l6.setBounds(450,200,200,30);
l6.setFont(new Font("Airal",Font.BOLD,20));
l6.setForeground(Color.BLACK);

l1.add(l6);

t4=new JTextField();
t4.setBounds(600,200,150,30);

l1.add(t4);

l7=new JLabel ("Father Name");

l7.setBounds(50,250,150,30);
l7.setFont(new Font("Airal",Font.BOLD,20));

l7.setForeground(Color.BLACK);
l1.add(l7);

t5=new JTextField();
t5.setBounds(200,250,150,30);

l1.add(t5);

l8=new JLabel ("Phone");


l8.setBounds(450,250,100,30);
l8.setFont(new Font("Airal",Font.BOLD,20));
l8.setForeground(Color.BLACK);

l1.add(l8);

t6=new JTextField();
t6.setBounds(600,250,150,30);

l1.add(t6);

l9=new JLabel ("Qualification");

l9.setBounds(50,300,150,30);
l9.setFont(new Font("Airal",Font.BOLD,20));

l9.setForeground(Color.BLACK);
l1.add(l9);

t7=new JTextField();
t7.setBounds(200,300,150,30);

l1.add(t7);

l10=new JLabel ("City");


l10.setBounds(450,300,100,30);
l10.setFont(new Font("Airal",Font.BOLD,20));

l10.setForeground(Color.BLACK);
l1.add(l10);

t8=new JTextField();
t8.setBounds(600,300,150,30);

l1.add(t8);

l11=new JLabel ("Gender");


l11.setBounds(50,350,100,30);
l11.setFont(new Font("Airal",Font.BOLD,20));
l11.setForeground(Color.BLACK);

l1.add(l11);

t9=new JTextField();
t9.setBounds(200,350,150,30);

l1.add(t9);

l12=new JLabel ("Blood Group");

l12.setBounds(450,350,140,30);
l12.setFont(new Font("Airal",Font.BOLD,20));

l12.setForeground(Color.BLACK);
l1.add(l12);

t10=new JTextField();
t10.setBounds(600,350,150,30);

l1.add(t10);

l13=new JLabel ("Age");


l13.setBounds(450,400,100,30);
l13.setFont(new Font("Airal",Font.BOLD,20));

l13.setForeground(Color.BLACK);
l1.add(l13);

t11=new JTextField();
t11.setBounds(600,400,150,30);

l1.add(t11);

l14=new JLabel ("Joining Date");

l14.setBounds(450,450,150,30);
l14.setFont(new Font("Airal",Font.BOLD,20));
l14.setForeground(Color.BLACK);

l1.add(l14);

t12=new JTextField();
t12.setBounds(600,450,150,30);

l1.add(t12);

l15=new JLabel ("Address");

l15.setBounds(50,400,120,30);
l15.setFont(new Font("Airal",Font.BOLD,20));

l15.setForeground(Color.BLACK);
l1.add(l15);

t13=new JTextField();
t13.setBounds(200,400,150,30);

l1.add(t13);

l16=new JLabel ("Date ofbirth");

l16.setBounds(50,450,140,30);
l16.setFont(new Font("Airal",Font.BOLD,20));

l16.setForeground(Color.BLACK);
l1.add(l16);

t14=new JTextField();
t14.setBounds(200,450,150,30);

l1.add(t14);

bt1=new JButton("Submit");
bt1.setBackground(Color.BLACK);

bt1.setForeground(Color.white);
bt1.setBounds(250,500,150,40);

l1.add(bt1);

bt2=new JButton("Cancel");
bt2.setBackground(Color.BLACK);

bt2.setForeground(Color.WHITE);
bt2.setBounds(450,500,150,40);
l1.add(bt2);

bt1.addActionListener(this);

bt2.addActionListener(this);
f.setVisible(true);

f.setSize(900,600);
f.setLocation(300, 100);

}
public void actionPerformed (ActionEvent e)

{
if(e.getSource()==bt1)

{
String name=t1.getText();
String username=t2.getText();

String password=t3.getText();
String email=t4.getText();
String fname=t5.getText();
String phone=t6.getText();
String qualification=t7.getText();
String city=t8.getText();
String gender=t9.getText();

String blood=t10.getText();
String age=t11.getText();
String jod=t12.getText();
String address=t13.getText();

String dob=t14.getText();
Random r= new Random();
String res_id=""+Math.abs(r.nextInt() % 10000;

try
{
connectionclass obj = new connectionclass();
String q = "insert into receptionist
values('"+res_id+"','"+name+"','"+username+"','"+password+"','"+email+"','"+fname+"','"+ph
one+"','"+qualification+"','"+city+"','"+gender+"','"+blood+"','"+age+"','"+jod+"','"+address+"
','"+dob+"')";
obj.stm.executeUpdate(q);

JOptionPane . showMessageDialog(null,"Receptionist Details


Successfully Inserted");
f.setVisible(false);

}
catch(Exception ex)

{
ex.printStackTrace();

}
}
if(e.getSource()==bt2)

{
f.setVisible(false);
}

}
public static void main(String[] args)
{
new addreceptionist();
}

}
viewreceptionist.java

package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

import java.sql.*;

public class viewreceptionist extends JFrame implements ActionListener

String x[]={"Name" ,"Username","Email","Father


Name","Phone","Qualification", "City","Gender","Blood group","Age","Joining
Date",
"Address","DOB"};

JButton bt,bt1;
Stringy[][]=new String[20][13];

inti=0,j=0;
JTablet;
JLabel l1,l2;
JTextField tf1;
JPanel p1,p2,p3;

Font f,f1;

viewreceptionist()

{
super("Receptionist Information");

setSize(1500,400);
setLocation(1,1);

f=new Font("MS UI Gothic",Font.BOLD,15);

try

{
connectionclass obj=new connectionclass();

String q="Select * from Receptionist";


ResultSet rest=obj.stm.executeQuery(q);

while(rest.next())
{
y[i][j++]=rest.getString("name");
y[i][j++]=rest.getString("username");

y[i][j++]=rest.getString("email");
y[i][j++]=rest.getString("father_name");

y[i][j++]=rest.getString("phone");
y[i][j++]=rest.getString("qualification");
y[i][j++]=rest.getString("city");
y[i][j++]=rest.getString("gender");

y[i][j++]=rest.getString("blood");
y[i][j++]=rest.getString("age");
y[i][j++]=rest.getString("joining_date");

y[i][j++]=rest.getString("address");
y[i][j++]=rest.getString("dob");
i++;

j=0;
}
t=new JTable(y,x);

t.setFont(f);
t.setBackground(Color.BLACK);
t.setForeground(Color.WHITE);

}
catch(Exception ex)

{
ex.printStackTrace();

}
JScrollPane sp=new JScrollPane(t);
f1=new Font("Lucida Fax",Font.BOLD,25);

l1=new JLabel ("Receptionist Username");


l2=new JLabel ("Delete or Edit any Receptionist?");

l2.setHorizontalAlignment(JLabel.CENTER);

l1.setForeground(Color.GRAY);
l2.setForeground(Color.YELLOW);
l1.setFont(f);

l2.setFont(f1);

bt=new JButton("Delete Receptionist");


bt1=new JButton("Edit Receptionist Record");

bt.addActionListener(this);
bt1.addActionListener(this);

bt.setBackground(Color.BLACK);

bt1.setBackground(Color.BLACK);

bt.setForeground(Color.WHITE);

bt1.setForeground(Color.WHITE);

tf1=new JTextField();

tf1.setFont(f);
p1=new JPanel();
p1.setLayout(new GridLayout(1,1,10,10));

p1.add(l2);

p2=new JPanel();
p2.setLayout(new GridLayout(1,4,10,10));

p2.add(l1);
p2.add(tf1);

p2.add(bt);
p2.add(bt1);

p3=new JPanel();
p3.setLayout(new GridLayout(2,1,10,10));

p3.add(p1);
p3.add(p2);

p1.setBackground(Color.BLACK);

p2.setBackground(Color.BLACK);
p3.setBackground(Color.BLACK);
add(p3,"South");
add(sp);

}
public void actionPerformed(ActionEvent ae)

{
String username=tf1.getText();

if(ae.getSource()==bt)
{
try

{
connectionclass obj1=new connectionclass();
String q="delete from receptionist where username='"+username+"'";
obj1.stm.executeUpdate(q);

setVisible(false);
}
catch(Exception e)

{
e.printStackTrace();
}

}
if(ae.getSource()==bt1)

{
if(username.isEmpty())

{
JOptionPane.showMessageDialog(null, "Please fill the receptionist username !");

else
{
setVisible(false);
new Editreceptionist(username).setVisible(true);

}
}

}
public static void main(String[] args)

{
new viewreceptionist().setVisible(true);
}

}
Editreceptionist.java
package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

import java.sql.*;

public class Editreceptionist extends JFrame implements ActionListener

{
JFrame f;
JLabell1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16;

JTextField t1,t2,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
JPasswordField t3;

JButton bt1,bt2;

Editreceptionist(String username)

{
try

{
connectionclass obj= new connectionclass();
String q="select * from receptionist where username='"+username+"'";

ResultSet rest0=obj.stm.executeQuery(q);

if(rest0.next())

{
f = new JFrame("Edit Receptionist");

f.setBackground(Color.WHITE);
f.setLayout(null);
l1=new JLabel();
l1.setBounds(0, 0, 900, 600);

l1.setLayout(null);

ImageIcon img = new


ImageIcon(ClassLoader.getSystemResource("hospital/hms/adddres2.jpg"));
Image i1 = img.getImage().getScaledInstance(900, 600, Image.SCALE_SMOOTH);

ImageIcon img1 = new ImageIcon(i1);


l1.setIcon(img1);

l2=new JLabel("Edit Receptionist Details");

l2.setBounds(280,30,500,50);
l2.setFont(new Font("Airal",Font.BOLD,30));

l2.setForeground(Color.BLACK);
l1.add(l2);

f.add(l1);

l3=new JLabel ("Name");


l3.setBounds(50,150,150,30);
l3.setFont(new Font("Airal",Font.BOLD,20));
l3.setForeground(Color.BLACK);

l1.add(l3);

l4=new JLabel ("UserName");

l4.setBounds(450,150,200,30);
l4.setFont(new Font("Airal",Font.BOLD,20));

l4.setForeground(Color.BLACK);
l1.add(l4);

l5=new JLabel ("Password");

l5.setBounds(50,200,100,30);
l5.setFont(new Font("Airal",Font.BOLD,20));

l5.setForeground(Color.BLACK);
l1.add(l5);

l6=new JLabel ("Email");


l6.setBounds(450,200,200,30);
l6.setFont(new Font("Airal",Font.BOLD,20));

l6.setForeground(Color.BLACK);
l1.add(l6);

l7=new JLabel ("Father name");

l7.setBounds(50,250,100,30);
l7.setFont(new Font("Airal",Font.BOLD,20));

l7.setForeground(Color.BLACK);
l1.add(l7);

l8=new JLabel ("Phone");


l8.setBounds(450,250,100,30);
l8.setFont(new Font("Airal",Font.BOLD,20));

l8.setForeground(Color.BLACK);
l1.add(l8);

l9=new JLabel ("Qualification");

l9.setBounds(50,300,100,30);
l9.setFont(new Font("Airal",Font.BOLD,20));

l9.setForeground(Color.BLACK);
l1.add(l9);

l10=new JLabel ("City");


l10.setBounds(450,300,100,30);
l10.setFont(new Font("Airal",Font.BOLD,20));

l10.setForeground(Color.BLACK);
l1.add(l10);

l11=new JLabel ("Gender");


l11.setBounds(50,350,100,30);
l11.setFont(new Font("Airal",Font.BOLD,20));

l11.setForeground(Color.BLACK);
l1.add(l11);

l12=new JLabel ("Blood Group");

l12.setBounds(450,350,140,30);
l12.setFont(new Font("Airal",Font.BOLD,20));

l12.setForeground(Color.BLACK);
l1.add(l12);
l13=new JLabel ("Age");
l13.setBounds(450,400,100,30);
l13.setFont(new Font("Airal",Font.BOLD,20));

l13.setForeground(Color.BLACK);
l1.add(l13);

l14=new JLabel ("Joining Date");

l14.setBounds(450,450,150,30);
l14.setFont(new Font("Airal",Font.BOLD,20));

l14.setForeground(Color.BLACK);
l1.add(l14);

l15=new JLabel ("Address");

l15.setBounds(50,400,120,30);
l15.setFont(new Font("Airal",Font.BOLD,20));

l15.setForeground(Color.BLACK);
l1.add(l15);

l16=new JLabel ("Date ofBirth");

l16.setBounds(50,450,140,30);
l16.setFont(new Font("Airal",Font.BOLD,20));

l16.setForeground(Color.BLACK);
l1.add(l16);

try

{
connectionclass obj1= new connectionclass();
String q1="select * from patient where username='"+username+"'";

ResultSet rest=obj1.stm.executeQuery(q1);
while(rest.next())

{
t1=new JTextField();
t1.setBounds(200,150,150,30);
t1.setText(rest.getString("name"));

l1.add(t1);

t2=new JTextField();
t2.setBounds(600,150,150,30);
t2.setText(rest.getString("username"));

t2.setEditable(false);
l1.add(t2);

t3=new JPasswordField();
t3.setBounds(200,200,150,30);
t3.setText(rest.getString("password"));

t3.setEditable(false);
l1.add(t3);

t4=new JTextField();
t4.setBounds(600,200,150,30);
t4.setText(rest.getString("email"));

l1.add(t4);

t5=new JTextField();
t5.setBounds(200,250,150,30);
t5.setText(rest.getString("father_name"));
l1.add(t5);

t6=new JTextField();
t6.setBounds(600,250,150,30);
t6.setText(rest.getString("phone"));

l1.add(t6);

t7=new JTextField();
t7.setBounds(200,300,150,30);
t7.setText(rest.getString("qualification"));

l1.add(t7);

t8=new JTextField();
t8.setBounds(600,300,150,30);
t8.setText(rest.getString("city"));

l1.add(t8);

t9=new JTextField();
t9.setBounds(200,350,150,30);
t9.setText(rest.getString("gender"));

l1.add(t9);

t10=new JTextField();
t10.setBounds(600,350,150,30);
t10.setText(rest.getString("blood"));

l1.add(t10);

t11=new JTextField();
t11.setBounds(600,400,150,30);

t11.setText(rest.getString("age"));
l1.add(t11);

t12=new JTextField();
t12.setBounds(600,450,120,30);
t12.setText(rest.getString("joining_date"));

l1.add(t12);

t13=new JTextField();
t13.setBounds(200,400,150,30);
t13.setText(rest.getString("address"));

l1.add(t13);

t14=new JTextField();
t14.setBounds(200,450,150,30);
t14.setText(rest.getString("dob"));

l1.add(t14);

}
catch(Exception ee)

{
ee.printStackTrace();

}
bt1=new JButton("Update");
bt1.setBackground(Color.BLACK);

bt1.setForeground(Color.white);
bt1.setBounds(250,500,150,40);

l1.add(bt1);

bt2=new JButton("Cancel");
bt2.setBackground(Color.BLACK);

bt2.setForeground(Color.WHITE);
bt2.setBounds(450,500,150,40);
l1.add(bt2);
bt1.addActionListener(this);

bt2.addActionListener(this);
f.setVisible(true);

f.setSize(900,600);
f.setLocation(300, 100);

}
else
{

JOptionPane.showMessageDialog(null,"record not found,please fill the


right receptionist username!");
this.setVisible(false);

}
}
catch(Exception exx)

{
exx.printStackTrace();

}
}
public void actionPerformed (ActionEvent e)

{
if(e.getSource()==bt1)

{
String name=t1.getText();
String username=t2.getText();

String email=t4.getText();
String fname=t5.getText();
String phone=t6.getText();
String qualification=t7.getText();

String city=t8.getText();
String gender=t9.getText();

String blood=t10.getText();
String age=t11.getText();
String joining_date=t12.getText();

String address=t13.getText();
String dob=t14.getText();
try

{
connectionclass obj = new connectionclass();
String q2="update Receptionist set
name='"+name+"',email='"+email+"',father_name='"+fname+"',phone='"+phone+"',qalificati
on='"+qualification+"',city='"+city+"',gender='"+gender+"',blood
group='"+blood+"',age='"+age+"',joining_date='"+joining_date+"',address='"+address+"',date
of birth='"+dob+"' where username='"+username+"'";
obj.stm.executeUpdate(q2);
JOptionPane . showMessageDialog(null,"Details Successfully updated");

f.setVisible(false);
}
catch(Exception ex)

{
ex.printStackTrace();

}
}
if(e.getSource()==bt2)

{
f.setVisible(false);

}
}

}
addappointment.java
package hospital;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

import java.sql.*;
import java.util.Random;

public class addappointment extends JFrame implements ActionListener

{
Font f,f1;
JLabell1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17,l18;

JTextField t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12;
JPanel p1,p2,p3;
JButton bt1,bt2,bt3;

Choice ch,ch1,ch2;
String q;

addappointment()

{
super("Add Appointment");

setLocation(450,10);
setSize(740,730);

f=new Font("Airal",Font.BOLD,25);

f1=new Font("Airal",Font.BOLD,18);

ch=new Choice();

ch1=new Choice();
ch2=new Choice();

ch2.add("10AM");

ch2.add("11AM");
ch2.add("12AM");
ch2.add("2PM");
ch2.add("3PM");
ch2.add("4PM");
ch2.add("5PM");

try

{
connectionclass obj=new connectionclass();

q="select username from patient";


ResultSet rest=obj.stm.executeQuery(q);

while(rest.next())
{
ch.add(rest.getString("username"));

}
catch(Exception ex)

{
ex.printStackTrace();

l1=new JLabel ("Add Appointment");

l2=new JLabel ("Username");


l3=new JLabel ("Name");

l4=new JLabel ("Email");


l5=new JLabel ("Father name");

l6=new JLabel ("Phone");


l7=new JLabel ("Material Status");

l8=new JLabel ("City");


l9=new JLabel ("Gender");

l10=new JLabel ("Blood");


l11=new JLabel ("Age");
l13=new JLabel ("Date ofbirth");

l14=new JLabel ("Deceased");


l15=new JLabel ("Check Doctor Availability");

l16=new JLabel ("Select Doctor");


l17=new JLabel ("Appointment Date");

l18=new JLabel ("Appointment Time");

t1=new JTextField();

t2=new JTextField();
t3=new JTextField();
t4=new JTextField();
t5=new JTextField();
t6=new JTextField();
t7=new JTextField();
t8=new JTextField();
t9=new JTextField();
t10=new JTextField();
t11=new JTextField();
t12=new JTextField();

t1.setEditable(false);

t2.setEditable(false);
t3.setEditable(false);
t4.setEditable(false);

t5.setEditable(false);
t6.setEditable(false);
t7.setEditable(false);
t8.setEditable(false);
t9.setEditable(false);
t10.setEditable(false);

bt1=new JButton("Book Appointment");

bt2=new JButton("Back");
bt3=new JButton("Check");

bt1.addActionListener(this);

bt2.addActionListener(this);
bt3.addActionListener(this);

bt1.setBackground(Color.BLUE);

bt2.setBackground(Color.RED);
bt3.setBackground(Color.BLACK);

bt1.setForeground(Color.WHITE);

bt2.setForeground(Color.WHITE);
bt3.setForeground(Color.WHITE);

l1.setHorizontalAlignment(JLabel.CENTER);

l1.setFont(f);

l2.setFont(f1);
l3.setFont(f1);
l4.setFont(f1);
l5.setFont(f1);

l6.setFont(f1);
l7.setFont(f1);
l8.setFont(f1);
l9.setFont(f1);
l10.setFont(f1);
l11.setFont(f1);
l13.setFont(f1);
l14.setFont(f1);
l15.setFont(f1);
l16.setFont(f1);
l17.setFont(f1);
l18.setFont(f1);
ch.setFont(f1);
ch1.setFont(f1);
ch2.setFont(f1);

t1.setFont(f1);

t2.setFont(f1);
t3.setFont(f1);
t4.setFont(f1);
t5.setFont(f1);
t6.setFont(f1);
t7.setFont(f1);
t8.setFont(f1);
t9.setFont(f1);
t10.setFont(f1);
t11.setFont(f1);
t12.setFont(f1);
bt1.setFont(f1);

bt2.setFont(f1);
bt3.setFont(f1);

p1=new JPanel();
p1.setLayout(new GridLayout(1,1,10,10));

p1.add(l1);

p2=new JPanel();
p2.setLayout(new GridLayout(17,2,10,10));

p2.add(l2);

p2.add(ch);
p2.add(l3);
p2.add(t1);
p2.add(l4);
p2.add(t2);
p2.add(l5);
p2.add(t3);
p2.add(l6);
p2.add(t4);
p2.add(l7);
p2.add(t5);
p2.add(l8);
p2.add(t6);
p2.add(l9);
p2.add(t7);
p2.add(l10);
p2.add(t8);
p2.add(l11);
p2.add(t9);

p2.add(l13);
p2.add(t10);
p2.add(l14);
p2.add(t11);
p2.add(l15);
p2.add(bt3);
p2.add(l16);
p2.add(ch1);
p2.add(l17);
p2.add(t12);
p2.add(l18);
p2.add(ch2);
p2.add(bt1);
p2.add(bt2);

p3=new JPanel();
p3.setLayout(new GridLayout(1,1,10,10));

ImageIcon img = new


ImageIcon(ClassLoader.getSystemResource("hospital/icon/addapp1.jpg"));
Image img1 = img.getImage().getScaledInstance(300, 500, Image.SCALE_SMOOTH);

ImageIcon ic1 = new ImageIcon(img1);


l12=new JLabel(ic1);

p3.add(l12);

setLayout(new BorderLayout(10,10));

add(p1,"North");
add(p2,"Center");

add(p3,"West");
ch.addMouseListener(new MouseAdapter()

{
@Override
public void mouseClicked(MouseEvent arg0)
{
try

{
connectionclass obj2=new connectionclass();

String username=ch.getSelectedItem();
String q1="select * from patient where username='"+username+"'";

ResultSet rest1=obj2.stm.executeQuery(q1);
while(rest1.next())

t1.setText(rest1.getString("name"));

t2.setText(rest1.getString("email"));
t3.setText(rest1.getString("father_name"));

t4.setText(rest1.getString("phone"));
t5.setText(rest1.getString("material_status"));

t6.setText(rest1.getString("city"));
t7.setText(rest1.getString("gender"));

t8.setText(rest1.getString("blood"));
t9.setText(rest1.getString("age"));
t10.setText(rest1.getString("dob"));
t11.setText(rest1.getString("deceased"));
}

}
catch(Exception exx)

{
exx.printStackTrace();

}
}

});
}

public void actionPerformed(ActionEvent e)

{
if(e.getSource()==bt3)

{
ch1.removeAll();

try
{
connectionclass obj3=new connectionclass();

String q1="select * from doctor where specialization='"+t11.getText()+"'


and availablity='yes'";
ResultSet rest4=obj3.stm.executeQuery(q1);

while(rest4.next())
{
ch1.add(rest4.getString("username"));

}
}
catch(Exception ee)

{
ee.printStackTrace();

}
}
if(e.getSource()==bt1)

{
String username=ch.getSelectedItem();

String name=t1.getText();
String email=t2.getText();
String fname=t3.getText();
String phone=t4.getText();
String mstatus=t5.getText();
String city=t6.getText();
String gender=t7.getText();
String blood=t8.getText();
String age=t9.getText();
String deceased=t10.getText();

String dob=t11.getText();
String doctor=ch1.getSelectedItem();

String app_date=t12.getText();
String app_time=ch2.getSelectedItem();

String app_status="Open";
Random r=new Random();
String app_id=""+Math.abs(r.nextInt() % 100000);

try

{
connectionclass obj3=new connectionclass();

String q1="insert into


appointment(app_id,p_username,name,email,fname,phone,material_status,city,gender,blood,
age,deceased,doctor_username,appointment_date,appointment_time,appointment_status)valu
es('"+app_id+"','"+username+"','"+name+"','"+email+"','"+fname+"','"+phone+"','"+mstatus+"
','"+city+"','"+gender+"','"+blood+"','"+age+"','"+dob+"','"+deceased+"','"+doctor+"','"+app_d
ate+"','"+app_time+"','"+app_status+"')";
int aa=obj3.stm.executeUpdate(q1);

if(aa==1)
{
JOptionPane.showMessageDialog(null, "your appointment successfully
booked");
this.setVisible(false);

}
else
{
JOptionPane.showMessageDialog(null,"please!,fill all details carefully");

}
}
catch(Exception ee)

{
ee.printStackTrace();

}
}
if(e.getSource()==bt2);

{
this.setVisible(false);
}

}
public static void main(String[] args)

{
new addappointment().setVisible(true);

}
}
Data Dictionary

1. Select * from admin

2. Select * from doctor

3. select * from patient

4. select * from receptionist


Inputs

Indexpage

Login page

Adminhomepage
Adddoctor

Viewdoctor

Addpatient
Viewpatient

Addreceptionist

Viewreceptionist
Addappointment

You might also like