Akshay, Himanshu

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

1

A
Project Report
on
(HOSPITAL MANAGEMENT SYSTEM)

Submitted in Partial Fulfillment of the Requirements


For the award of the degree of
BACHELOR OF COMPUTER APPLICATIONS

SUBMITTED BY: SUBMITTED TO:


AKSHAY KUMAR (190855106025) Dr. PARMOD SHARMA

HIMANSHU (190855106077) (Asst. Prof.)


2

ACKNOWLEDGEMENT

This research project report on “Hospital management system” is the result of idea and
suggestions to me by Dr.PARMODKUMARwe have received unfailing encouragement and
inspiration of Dr. PARMOD KUMAR whose exceptional knowledge and unparalleled
behavior is full of ardent inspiration in it. However, we can never adequate thank all those
who have their assistance, guidance, cooperation criticism contributed to the improvement of
this report. We are ebullient in expressing my intense in debtless heartiest gratitude to all of
them.

Since performance feedback is essential for effective communication,


mistakes and creative feedback of the report may be unhesitatingly
communicated to me, which will be as far as possible duly acknowledged
and most welcome. In this report, whatever is beneficial comes from
almighty, and whatever is faulty is mine.

AKSHAY KUMAR (190855106025)


HIMANSHU (190855106077)
3

DECLARATION
We ( AKSHAY KUMAR and HIMANSHU ) hereby declare that the project
report title“HOSPITAL
MANAGEMENT SYSTEM”is an original work carried out by us under the
supervision of Dr.PARMOD SHARMA.I further declare that this workhas not
been submitted to any other Institute/University for the award of thedegree of
Master of Computer Applications.

AKSHAY KUMAR (190855106025)


HIMANSHU (190855106077)
4

CONTENTS

INTRODUCTION 06
OBJECTIVES OF THE PROJECT 07
HARFDWARE AND SOFTWARE REQUIREMENT 08
BACK-END FRONT-END 09
MODULES AND DETAILS 11
SRS 12
DATAFLOW DIAGRAM 17
ER DIAGRAM 20-21
DATABASE 23
CODING 35-72
CONCLUSION 73
FUTURE SCOPE 75
BIBLIOGRAPHY 76
5

1.INTRODUCTION:

Human body is a very complex and sophisticated structure and comprises of millions of
functions. All these complicated functions have been understoodbyman him, part-by-part
their research and experiments. As science andtechnology progressed, medicine became an
integral part of the research. Gradually, medical science became an entirely new branch of
science. As of today, the health Sector comprises ofinstitutions i.e. Hospitals, etc. research
and development institutions and medical college, Thusthe Health sector aims at providing
the best medical facilities to the common man.

The project Hospital Management system includes registration of patients, storing their
details into the system, and also computerized billing in the pharmacy, and labs. The
Software has the facility to give a unique id for every patient and stores the details of every
patient and the staff automatically. It includes a search facility to know the current status of
each rows.User can search availability of a doctor and the details of a patient using the id.
6

1.1 SCOPE OF THE SYSTEM:


The proposed software product is the Hospital Management System(HMS).The system
will be used in any Hospital, Clinic, Dispensary or Pathology labsin any Hospital, Clinic,
Dispensary or Pathology labs.The current system in use is a paper–based system. It is too
slow and cannot provide update
lists of patients within a reasonable timeframe. The intentions of the systems are to reduce
over-time pay and increase the number of patients that can be treated accurately.
Requirements
statements in this document are both functional and non-functional.

Hospitals and healthcare centers have undergone a charge for its betterment. The
administrations of healthcaresector are opting IT solutions for the better management and
patient care in their hospital campus. Have a look at some salient features of hospital
management software.

1.2 PROJECT DESCRIPTION:

Hospital are the essential part of our lives, providing best medical facilitiesto people
suffering from various ailments, which may be due to change in climateconditions, increased
work-load, emotional trauma stress etc. It is necessary forthe hospitals to keep track of its
day-to-day activities & record of its patients,doctors, nurse, ward boys and other staff
personals that keep the hospital running smoothly & successfully.
But keeping track of all the activities and their record on paper is very cumbersome and
error proved. It also is very inefficient and a time -consumingprocess observing the
continuous
increase in population and number of peoplevisiting the hospital, Recording and maintaining
all these records are highlyunreliable inefficient and error-prove. It is also not economically
technically feasible to maintain these records on paper.
7

1.2.2 IMPLEMENTATION OF PROPOSED SYSTEM:

It involves careful planning, investigation of the current system and itsconstraints on


implementation, design of methods to achieve the change Over and an evaluation of change
over methods a part form planning. Two major takes of programming the implementation is
education and training of the users and testing of the system.The more complex the system
being implementation, the more involved willbe the system analysis and design effort
required
just for implementation.
8

1.3 ADVANTANGES OF PROJECT:

 Patient identification number (PIN)-unique identity

 On next visit, need not weight in long queue for registering again

 Prescription & lab reports printouts are given to the patient.

2.2 FRONT END COVRAGE:


• Java Netbeans IDE.

2.3 BACK END COVRAGE:

 MYSQL

2.4 SOFTWARE AND HARDWRAE REQUIREMENTS:

HARDWARE REQUIREMENTS:
 PROCESSOR p3 & Above
 RAM 1GB
 HARDDISK 512GB
 MONITOR
 KEYBOARD
 MOUSE
9

SOFTWARE REQUIREMENTS
• Jdk1.7
• MYSQL

3.2 Feasibility study:

 From a project team and appoint a project leader.


 Prepare system flowcharts.
 Enumerate potential proposed system.
 Define and identity characteristics of proposed system.
 Determine and evaluate performance and cost effective of each proposed
system.

3.3 System Analysis:

Level 0 DFD –

A Data Flow Diagram (DFD) is a graphical tool used to describe and analyze the
movement of data through a system - manual or automated including the processes, stores of
data and delays in the system. They are central tools and the basis from which other
components
are developed. It depicts the transformation of data, independent of the physical components,
from input to output through logical processes and the interaction between process.
In a DFD there are four components:
Sources or Destinations of data such as human, entities that interact with system, outside the
system boundary, who form the source and the recipient of information are depicted in the
form
of a closed rectangle.

Personal details IPD&OPD

Admin Level-0
Patient
Hospital
Patient
10

Bill report details bills generate

Level DFD

patient Room
11

not foundAccessing pat. Infoavailable room

Searching
Process

Display

process

E-R DAIGRAM:

H Add

P Name P id H id H name

Patient Hospital
Addmitted in

H city
Paddress
P m no.

Doctor
12

3.4 DATABASE TABLE:

LOGIN TABLE

Field Name Type Size Constraints


13

User Name Varchar 40 Primary key


Password Varchar 40 Not null
Type Varchar 40 Not null

PATIENT TABLE

Field Name Type Size Constraints


Patient_ id Varchar 20 Primary key
Patient name Varchar 40 Not_ null
Age Varchar 10 Not_ null
Gender Varchar 10 Not_ null
Date of Checkup Varchar 20 Not_ null
Address Varchar 20 Not_ null
Contact_ no. Varchar 30 Not _null
Admit Varchar 20 Not _null

DOCTOR TABLE:

Field name Type Size Constraints


Doctor_ id Varchar 10 Primary key

Doctor_ Name Varchar 10 Not_ null


Gender Varchar 10 Not _null
E_ mail Varchar 15 Not _null
Address Varchar 10 Not _null
14

Contact_ no. Varchar 15 Not _null


Specialization Varchar 10 Not _null
Experience Varchar 10 Not _null
Date_ of_ Admit Varchar 10 Not _null

DISCHARGE:

Field_name Type Size Constraints

Id_ no. Varchar 20 Primary key

Patient _Name Varchar 40 Not _null


Date _of _Admit Varchar 20 Not _null
Date_ of_ Discharge Varchar 20 Not null
15

No._ of_ days Varchar 20 Not_ null


Room _no. Varchar 20 Not null
Room _Charges Varchar 20 Not _null
Medicine_ Charges Varchar 30 Not _null
Other _Charges Varchar 40 Not null
Total_ Charges Varchar 20 Not _null

3.6 Testing, Implement:

The testing phase is an important part of software development. It is computerized system


Will help in automatic process of finding errors and missing operations and also a complete
Verification to determine whether the objectives are met and the requirements are satisfied.

Software testing is carried out in three steps:

1. The first includes unit testing, where in each module is tested to provide its
correctness
validity and also determine any missing operations and to verify whether the
objectives
have been met. Errors are noted down and corrected immediately.

2. The second step includes integration testing. It need not be the case, the software
16

whose modules when run individually and showing perfect results, will also show
perfect
results when run as a whole

5. CONCLUSION:

 The project Hospital Management System (HMS) is for computerized the


working

in a hospital.

 It generates test report; provide prescription details including various tests, check-

up and medicines prescription to patient and doctor. It also provides injection

details and billing facility.

Login form
17

HOSPITAL MANAGEMENT SYSTEM


Patient form

Doctor form
18

Discharge Form
19

Login form coding


importjavax.swing.*;

importjava.awt.*;

importjava.awt.event.*;

importjava.sql.*;

import Package.Welcome;

class Login{

JLabel l3;

String userName = "root";

String password = "neha";

String url = "jdbc:mysql://localhost:3306/Hos";

//JTextField t;

//JTextField p;

public Login(){

JFrame f=new JFrame("Login");

JLabel l1=new JLabel("User Name");

JLabel l2=new JLabel("Password");

l1.setFont(new Font("Monaco",Font.BOLD,15));

l2.setFont(new Font("Monaco",Font.BOLD,15));

JPasswordField p=new JPasswordField();

JTextField t=new JTextField();

t.setFont(new Font("Monaco",Font.BOLD,15));

JButton b1=new JButton("Login");

JButton b2=new JButton("Reset");

JButton b3=new JButton("Exit");

l3=new JLabel();

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

l1.setBounds(20,50,150,20);

l2.setBounds(20,90,150,20);

t.setBounds(110,50,120,20);

p.setBounds(110,90,120,20);

b2.setBounds(80,120,70,20);

b1.setBounds(160,120,70,20);

b3.setBounds(245,120,70,20);
20

f.setSize(600,600);

b2.addActionListener(new ActionListener(){

public void actionPerformed(ActionEventae){

t.getText();

p.getText();

t.setText("");

l3.getText();

l3.setText("");

p.setText("");

});

b3.addActionListener(new ActionListener(){

public void actionPerformed(ActionEventae){

f.dispose();

});

b1.addActionListener(new ActionListener(){

public void actionPerformed(ActionEventae){

try{

Connection con=DriverManager.getConnection(url,userName,password);

Statement st=con.createStatement();

ResultSetrs=st.executeQuery("select *from Admins");

String un=t.getText();

String pw=p.getText();

rs.next();

if(un.equals(rs.getString(1)) &&pw.equals(rs.getString(2))){

f.dispose();

new Welcome();

else

JOptionPane.showMessageDialog(null,"Unsuccessfull");

con.close();
21

catch(Exception e){

System.out.println("error"+e);

});

f.add(l1);

f.add(t);

f.add(l2);

f.add(p);

f.add(b2);

f.add(b1);

f.add(b3);

f.add(l3);

f.setLayout(null);

f.setResizable(false);

f.setLocationRelativeTo(null);

f.setVisible(true);

public static void main(String arg[]){

new Login();

Welcome form coding

package Package;
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
import Package.HospitalManagementSystem;
22

public class Welcome


{
JFrame f1;
JLabel lbltitle1,lbltitle2,lbltitle3,lbldev,lbln1,lbln2,lblwar;
JButtonbtncon;
ImageIconimg;
JLabeljlpic;
Font ft1,ft2,ft3;
public Welcome()
{
f1=new JFrame("Welcome");
f1.setSize(700,600);
//f1.getContentPane().setBackground(Color.CYAN);
f1.setLayout(null);
f1.setVisible(true);
//f1.setResizable(false);
f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

img=new ImageIcon("main.jpg");
jlpic=new JLabel(img);
jlpic.setBounds(2,40,400,400);
f1.add(jlpic);
lbltitle1=new JLabel("Hospital Management System");
ft1=new Font("monotype corsiva",Font.BOLD+Font.ITALIC,30);
lbltitle1.setFont(ft1);
lbltitle1.setBounds(10,10,690,40);
f1.add(lbltitle1);
lbltitle2=new JLabel(":-Developed By");
ft1=new Font("monotype corsiva",Font.BOLD+Font.ITALIC,30);
lbltitle2.setFont(ft1);
lbltitle2.setBounds(430,80,200,50);
lbltitle3=new JLabel("1.Neha Pundir");
ft1=new Font("monotype corsiva",Font.BOLD+Font.ITALIC,30);
lbltitle3.setFont(ft1);
lbltitle3.setBounds(430,150,200,50);
23

lbldev=new JLabel("2.Payal Mainval");


ft1=new Font("monotype corsiva",Font.BOLD+Font.ITALIC,30);
lbldev.setFont(ft1);
lbldev.setBounds(430,220,220,50);
lbln1=new JLabel(":-Submitted To");
ft1=new Font("monotype corsiva",Font.BOLD+Font.ITALIC,30);
lbln1.setFont(ft1);
lbln1.setBounds(430,300,220,50);
lbln2=new JLabel(": Mr. sanjay Kant");
ft1=new Font("monotype corsiva",Font.BOLD+Font.ITALIC,30);
lbln2.setFont(ft1);
lbln2.setBounds(430,340,250,100);
lblwar=new JLabel("Warning :SRC");
ft1=new Font("monotype corsiva",Font.BOLD+Font.ITALIC,30);
lblwar.setFont(ft1);
lblwar.setBounds(10,420,680,100);
btncon=new JButton("continue");
ft1=new Font("monotype corsiva",Font.BOLD+Font.ITALIC,30);
btncon.setFont(ft1);
btncon.setBounds(200,520,200,50);
f1.setVisible(true);
btncon.addActionListener(new ActionListener(){
public void actionPerformed(ActionEventae){
f1.dispose();
newHospitalManagementSystem();
}
});
f1.add(lbltitle2);
f1.add(lbltitle3);
f1.add(lbldev);
f1.add(lbln1);
f1.add(lbln2);
f1.add(lblwar);
f1.add(btncon);
}
24

Hospital form Coding


package Package;
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.*;
import Package.Doctor;
//import Package.Patient;
import Package.Discharge;
class HospitalManagementSystem
{
JFrame f1;
JButtonbtnPatientInfo,btnDoctorInfo,btnDischarge,btnExit;
HospitalManagementSystem()
{
f1=new JFrame("Hospital Management System");
btnPatientInfo=new JButton("PATIENT Info");
btnDoctorInfo=new JButton("DOCTOR Info");
btnDischarge=new JButton("DISCHARGE");
btnExit=new JButton("EXIT");
f1.setSize(600,500);
f1.setLayout(null);
f1.setVisible(true);
btnPatientInfo.setBounds(50,80,250,50);
btnDoctorInfo.setBounds(50,150,250,50);
btnDischarge.setBounds(50,220,250,50);
btnExit.setBounds(120,380,100,30);
f1.add(btnPatientInfo);
f1.add(btnDoctorInfo);
f1.add(btnDischarge);
f1.add(btnExit);
btnExit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEventae){
25

f1.dispose();
}
});
btnPatientInfo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEventae){
f1.dispose();
new Patient();
}
});
btnDischarge.addActionListener(new ActionListener(){
public void actionPerformed(ActionEventae){
f1.dispose();
new Discharge();
}
});
btnDoctorInfo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEventae){
f1.dispose();
new Doctor();
}
});;
//btnDischarge.addActionListener(this);
//btnExit.addActionListener(this);
}
/*public void actionPerformed(ActionEventae)
{
if(ae.getSource()==btnPatientInfo)
{
new Patient();
}
if(ae.getSource()==btnExit)
{
System.exit(0);
}
if(ae.getSource()==btnDoctorInfo)
26

{
new Doctor();
}
}*/
/*public static void main(String arg[])
{
HospitalManagementSystem HMS1=new HospitalManagementSystem();
}*/
}

Patient Form coding


package Package;
importjava.awt.*;
importjavax.swing.*;
importjava.awt.event.*;
27

importjava.sql.*;
public class Patient extends JFrame implements ActionListener
{
JLabel l1,l2,l3,l4,l5,l6,l7;
JTextField tf1,tf2,tf3,tf4,tf5,tf6,tf7;
JButton b1,b2,b3,b4,b5;
ResultSetrs;
Connection con;
Statement st;
//JLabellpic;
//ImageIconimg;
public Patient()
{
setSize(1400,1400);
setLayout(null);
setVisible(true);
setTitle("Patient");
//img=new ImageIcon("E:/ggg.jpg");
//lpic=new JLabel(img);
//lpic.setBounds(0,0,500,500);

init();
components();
refresh();
}
public void init()
{
l1=new JLabel("ID");
l1.setBounds(40,60,130,30);
l2=new JLabel("Name");
l2.setBounds(40,110,130,30);
l3=new JLabel("Father Name");
l3.setBounds(40,160,130,30);
l4=new JLabel("Address");
l4.setBounds(40,210,130,30);
28

l5=new JLabel("Age");
l5.setBounds(40,260,130,30);
l6=new JLabel("Disease");
l6.setBounds(40,310,130,30);
l7=new JLabel("Gender");
l7.setBounds(40,360,130,30);
//l8=new JLabel("Date");
//l8.setBounds(40,410,130,30);
b1=new JButton("Save");
b1.setBounds(40,480,100,30);
b2=new JButton("Back");
b2.setBounds(150,480,100,30);
b3=new JButton("Update");
b3.setBounds(300,480,100,30);
b4=new JButton("Delete");
b4.setBounds(430,480,100,30);
b5=new JButton("New");
b5.setBounds(570,480,100,30);
tf1=new JTextField();
tf1.setBounds(180,60,150,30);
tf2=new JTextField();
tf2.setBounds(180,110,150,30);
tf3=new JTextField();
tf3.setBounds(180,160,150,30);
tf4=new JTextField();
tf4.setBounds(180,210,150,30);
tf5=new JTextField();
tf5.setBounds(180,260,150,30);
tf6=new JTextField();
tf6.setBounds(180,310,150,30);
tf7=new JTextField();
tf7.setBounds(180,360,150,30);

}
public void components()
29

{
add(l1);
add(l2);
add(l3);
add(l4);
add(l5);
add(l6);
add(l7);
//add(l8);
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(tf1);
add(tf2);
add(tf3);
add(tf4);
add(tf5);
add(tf6);
add(tf7);
//add(tf8);
//add(lpic);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
refresh();
}
});
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
30

{
if(e.getSource()==b2)
{
//new WelcomePage();
}

refresh();
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mydsn");
Statement st=con.createStatement();
intt=st.executeUpdate("insertinto tblcustomer VALUES('"+tf1.getText()
+"','"+tf2.getText()+"','"+tf3.getText()+"','"+tf4.getText()
+"','"+tf5.getText()+"','"+tf6.getText()+"','"+tf7.getText()+"')");
if(t>0)
{
JOptionPane.showMessageDialog(null,"Record Saved...");
st.close();
con.close();
refresh()
}
Else
JOptionPane.showMessageDialog(null,"RecordNotSaved...");
//UserBind();
}catch(Exception ex){
System.out.println(ex);
JOptionPane.showMessageDialog(null,ex);
}
}
31

if(e.getSource()==b3)
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connectioncon=DriverManager.getConnection("jdbc:odbc:mydsn");
Statement st=con.createStatement();
Intrs=st.executeUpdate("update tblcustomer set cusname='"+tf2.getText()
+"',cusmedicine='"+tf3.getText()+"',medquantity='"+tf4.getText()
+"',addres='"+tf5.getText()+"',ndate='"+tf6.getText()
+"',price='"+tf7.getText()+"' where cusid='"+tf1.getText()+"'");
if(rs>0)
{
JOptionPane.showMessageDialog(null,"Record Updated...");
st.close();
con.close();
refresh()
}
Else
JOptionPane.showMessageDialog(null,"Record Not updated...");
//UserBind();
}catch(Exception ex){
System.out.println(ex);
JOptionPane.showMessageDialog(null,ex);
}
}
if(e.getSource()==b4)
{
try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mydsn");
Statement st=con.createStatement();
intrs=st.executeUpdate("delete from tblcustomer where
cusid='"+tf1.getText()+"'");
if(rs>0)
{
JOptionPane.showMessageDialog(null,"Record Delete...");
32

st.close();
con.close();
refresh();
}
else
JOptionPane.showMessageDialog(null,"Record Not Delete...");
//UserBind();
}catch(Exception ex){
System.out.println(ex);
JOptionPane.showMessageDialog(null,ex);
}
}
}
public void refresh(){
tf1.setText(" ");
tf2.setText(" ");
tf3.setText(" ");
tf4.setText(" ");
tf5.setText(" ");
tf6.setText(" ");
tf7.setText(" ");
}
/*public static void main(String[]ar)
{
new Patient();
}*/
}
33

Doctor Form coding


package Package;
importjava.awt.*;
importjavax.swing.*;
importjava.awt.event.*;
importjava.sql.*;
public class Doctor extends JFrame implements ActionListener
{
JLabel l1,l2,l3,l4,l5,l6,l7;
JTextField tf1,tf2,tf3,tf4,tf5,tf6,tf7;
JButton b1,b2,b3,b4,b5;
ResultSetrs;
Connection con;
Statement st;
//JLabellpic;
//ImageIconimg;
public Doctor()
{
setSize(1400,1400);
34

setLayout(null);
setVisible(true);
setTitle("Doctor");
//img=new ImageIcon("E:/ggg.jpg");
//lpic=new JLabel(img);
//lpic.setBounds(0,0,500,500);
init();
components();
refresh();
}
public void init()
{
l1=new JLabel("Doctor ID");
l1.setBounds(40,60,130,30);
l2=new JLabel("Doctor Name");
l2.setBounds(40,110,130,30);
l3=new JLabel("Email:");
l3.setBounds(40,160,130,30);
l4=new JLabel("Address");
l4.setBounds(40,210,130,30);
l5=new JLabel("mobile no:");
l5.setBounds(40,260,130,30);
l6=new JLabel("Age");
l6.setBounds(40,310,130,30);
l7=new JLabel("Gender");
l7.setBounds(40,360,130,30);
b1=new JButton("Save");
b1.setBounds(40,480,100,30);
b2=new JButton("Back");
b2.setBounds(170,480,100,30);
b3=new JButton("Update");
b3.setBounds(300,480,100,30);
b4=new JButton("Delete");
b4.setBounds(430,480,100,30);
b5=new JButton("New");
35

b5.setBounds(570,480,100,30);
tf1=new JTextField();
tf1.setBounds(180,60,150,30);
tf2=new JTextField();
tf2.setBounds(180,110,150,30);
tf3=new JTextField();
tf3.setBounds(180,160,150,30);
tf4=new JTextField();
tf4.setBounds(180,210,150,30);
tf5=new JTextField();
tf5.setBounds(180,260,150,30);
tf6=new JTextField();
tf6.setBounds(180,310,150,30);
tf7=new JTextField();
tf7.setBounds(180,360,150,30);
}
public void components()
{
add(l1);
add(l2);
add(l3);
add(l4);
add(l5);
add(l6);
add(l7);
//add(l8);
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(tf1);
add(tf2);
add(tf3);
add(tf4);
36

add(tf5);
add(tf6);
add(tf7);
//add(tf8);
//add(lpic);
b1.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
refresh();
}
});
b2.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b2)
{
//new WelcomePage();
}
refresh();
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mydsn");
Statement st=con.createStatement();
int t=st.executeUpdate("insert into tblcustomer VALUES('"+tf1.getText()
+"','"+tf2.getText()+"','"+tf3.getText()+"','"+tf4.getText()
+"','"+tf5.getText()+"','"+tf6.getText()+"','"+tf7.getText()+"')");
37

if(t>0)
{
JOptionPane.showMessageDialog(null,"Record Saved...");
st.close();
con.close();
refresh();
}
else
JOptionPane.showMessageDialog(null,"Record Not Saved...")
//UserBind();
}catch(Exception ex){
System.out.println(ex);
JOptionPane.showMessageDialog(null,ex);
}
}
if(e.getSource()==b3)
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mydsn");
Statement st=con.createStatement();
intrs=st.executeUpdate("update tblcustomer set cusname='"+tf2.getText()
+"',cusmedicine='"+tf3.getText()+"',medquantity='"+tf4.getText()
+"',addres='"+tf5.getText()+"',ndate='"+tf6.getText()
+"',price='"+tf7.getText()+"' where cusid='"+tf1.getText()+"'");
if(rs>0)
{
JOptionPane.showMessageDialog(null,"Record Updated...");
st.close();
con.close();
refresh();
}
Else
JOptionPane.showMessageDialog(null,"Record Not updated...");
//UserBind();
}catch(Exception ex){
38

System.out.println(ex);
JOptionPane.showMessageDialog(null,ex);
}
}
if(e.getSource()==b4)
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mydsn");
Statement st=con.createStatement();
intrs=st.executeUpdate("delete from tblcustomer where
cusid='"+tf1.getText()+"'");
if(rs>0)
{
JOptionPane.showMessageDialog(null,"Record Delete...");
st.close();
con.close();
refresh();
}
else
JOptionPane.showMessageDialog(null,"Record Not Delete...");
//UserBind();
}catch(Exception ex){
System.out.println(ex);
JOptionPane.showMessageDialog(null,ex);
}
}
}
public void refresh(){
tf1.setText(" ");
tf2.setText(" ");
tf3.setText(" ");
tf4.setText(" ");
tf5.setText(" ");
tf6.setText(" ");
39

tf7.setText(" ");
}
/*public static void main(String[]ar)
{
new Doctor();
}*/
}

Patient Admit coding

importjava.awt.*;

importjava.awt.event.*;

importjavax.swing.*;

importjava.sql.*;
40

class PatientAdmitDetails implements ActionListener, ItemListener

JFrame f1;

JLabel lb1,lb2,lb3,lb4,lb5,lb6,lb7,lb8,lb9,lb10,lb11;

JTextField txt1,txt2,txt3,txt4,txt5,txt6, txt7,txtadd;

JButtonbtnadd,btnsave,btnback;

ImageIconimg;

JLabeljlpic;

Choice ch;

Choice ch1,chbrn;

Connection con;

String s1,s2;

Statement st;

ResultSetrs;

PatientAdmitDetails()

f1=new JFrame("Patient Admit Details");

f1.setSize(800,700);

f1.setLayout(null);

f1.setVisible(true);

//f1.setResizable(false);

img=new ImageIcon("rahul1.jpg");
41

jlpic=new JLabel(img);

jlpic.setBounds(400,8,300,400);

f1.add(jlpic);

lb1=new JLabel("I.P.D No");

lb1.setBounds(40,40,60,40);

f1.add(lb1);

txt1=new JTextField();

txt1.setBounds(140,40,100,40);

f1.add(txt1);

lb2=new JLabel("Patient Name");

lb2.setBounds(40,90,80,40);

f1.add(lb2);

txt2=new JTextField();

txt2.setBounds(140,90,100,40);

f1.add(txt2);

lb3=new JLabel("Father's/Husband's name");

lb3.setBounds(40,140,100,40);
42

f1.add(lb3);

txt3=new JTextField();

txt3.setBounds(140,140,100,40);

f1.add(txt3);

lb4=new JLabel("Age");

lb4.setBounds(40,190,100,40);

f1.add(lb4);

txt4=new JTextField();

txt4.setBounds(140,190,100,40);

f1.add(txt4);

lb5=new JLabel("Gender");

lb5.setBounds(40,240,100,40);

f1.add(lb5);

ch=new Choice();

ch.add("Male");

ch.add("Female");

ch.setBounds(140,240,100,40);
43

f1.add(ch);

lb6=new JLabel("Time");

lb6.setBounds(40,290,80,40);

f1.add(lb6);

txt5=new JTextField();

txt5.setBounds(140,290,100,40);

f1.add(txt5);

lb7=new JLabel("Address");

lb7.setBounds(40,340,80,40);

f1.add(lb7);

txtadd=new JTextField();

txtadd.setBounds(140,340,200,40);

f1.add(txtadd);

lb8=new JLabel("Date of Admit");

lb8.setBounds(40,390,100,40);

f1.add(lb8);
44

txt6=new JTextField();

txt6.setBounds(140,390,100,30);

f1.add(txt6);

ewJLabel("Room");

lb9.setBounds(40,440,120,40);

f1.add(lb9);

ch1=new Choice();

ch1.add("General");

ch1.add("Private");

ch1.setBounds(160,450,100,40);

f1.add(ch1);

lb11=new JLabel("");

lb11.setBounds(280,450,40,40);

f1.add(lb11);

chbrn=new Choice();

chbrn.setBounds(350,450,100,40);

f1.add(chbrn);
45

lb10=new JLabel("Diagnosis By");

lb10.setBounds(40,490,140,40);

f1.add(lb10);

txt7=new JTextField();

txt7.setBounds(140,490,300,30);

f1.add(txt7);

btnadd=new JButton("Add new Patient");

btnadd.setBounds(150,550,100,60);

f1.add(btnadd);

btnsave=new JButton("save");

btnsave.setBounds(280,550,100,60);

f1.add(btnsave);

s2="Booked";

btnback=new JButton("Back");

btnback.setBounds(420,550,100,60);

f1.add(btnback);

btnsave.setEnabled(false);

txt1.setEnabled(false);
46

txt2.setEnabled(false);

txt3.setEnabled(false);

txt4.setEnabled(false);

txt5.setEnabled(false);

txtadd.setEnabled(false);

txt6.setEnabled(false);

txt7.setEnabled(false);

ch.setEnabled(false);

ch1.setEnabled(false);

btnadd.addActionListener(this);

btnsave.addActionListener(this);

btnback.addActionListener(this);

ch1.addItemListener(this);

//Coding of
connectivity==============================================
====

try

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("jdbc:odbc:hospital");

st=con.createStatement();

rs=st.executeQuery("Insert * from PatientAdmit");


47

if(rs.next())

txt1.setText(String.valueOf(rs.getInt(1)));

catch(Exception e)

System.out.print(e);

//Coding of JButton Handling ===========================

public void actionPerformed(ActionEventae)

int id;

if(ae.getSource()==btnadd)

btnsave.setEnabled(true);

btnadd.setEnabled(false);
48

txt2.setEnabled(true);

txt3.setEnabled(true);

txt4.setEnabled(true);

txt5.setEnabled(true);

txt6.setEnabled(true);

txt7.setEnabled(true);

txtadd.setEnabled(true);

ch.setEnabled(true);

ch1.setEnabled(true);

try

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("jdbc:odbc:hospital");

st=con.createStatement();

rs=st.executeQuery("select max(ipdn) from PatientAdmit");

if(rs.next())

id=rs.getInt(1);

id=id+1;

txt1.setText(String.valueOf(id));

}
49

catch(Exception e)

System.out.print(e);

if(ae.getSource()==btnsave)

try

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("jdbc:odbc:hospital");

st=con.createStatement();

int i=st.executeUpdate("insert into PatientAdmit


values("+Integer.parseInt(txt1.getText())+",'"+txt2.getText()
+"','"+txt3.getText()+"','"+txt4.getText()+"','"+ch.getSelectedItem()
+"','"+txt5.getText()+"','"+txtadd.getText()+"','"+txt6.getText()
+"','"+ch1.getSelectedItem()+"','"+chbrn.getSelectedItem()
+"','"+txt7.getText()+"')");

int j=st.executeUpdate("update Room set status='"+s2+"' where


brno="+Integer.parseInt(chbrn.getSelectedItem())+"");

if(i>0)
50

JOptionPane.showMessageDialog(null, "Record Successfully


Saved......");

btnsave.setEnabled(false);

btnadd.setEnabled(true);

catch(Exception e)

System.out.print(e);

if(ae.getSource()==btnback)

PatientInformationForm pi=new PatientInformationForm();

f1.hide();

public void itemStateChanged(ItemEventie)

{
51

if(ie.getSource()==ch1)

String s1="Free";

chbrn.removeAll();

try

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("jdbc:odbc:hospital");

st=con.createStatement();

rs=st.executeQuery("select * from Room where status='"+s1+"'


and category='"+ch1.getSelectedItem()+"'");

while(rs.next())

chbrn.add(String.valueOf(rs.getInt(3)));

catch(Exception e)

System.out.print(e);

}
52

public static void main(String arg[])

PatientAdmitDetails pa1=new PatientAdmitDetails();

BIBLOGRAPHY

1. JAVA NETBEANS
2. DBMS: Data Base Management System
“Ramez, Elmarsi ,Shamakant , B.Navathe”,Fifth Edition
3. www.google.com

You might also like