Sie sind auf Seite 1von 64

HOSPITAL MANAGEMENT SYSTEM

A PROJECT REPORT

Submitted by

Arbind

IN

Information Technology

SCHOOL OF ENGINEERING AND TECHNOLOGY

JAIPUR NATIONAL UNIVERSITY

ACKNOWLEDGEMENT
The satisfaction that accompanies the successful completion of any task would be
incomplete without the mention of people whose ceaseless cooperation made it
possible, whose constant guidance and encouragement crowned all efforts with
success.

I am grateful to our project guides Mr. Manish Suroliya and Mr. R.C. Poonia for
the guidance, inspiration and constructive suggestions that helped me in the
preparation of this project. I would also like to thank all faculty members who
extended their kind support during the accomplishment of the project.
Finally, I express my sincere thanks to all those who helped me directly &
indirectly in many ways in completion of this project.

ABSTRACT

The Software is for the automation of Hospital Management.

It maintains two levels of users:-


Administrator Level For doctors
User Level For reception purposes

The Software includes:-


Maintaining Patient details.
Providing Prescription and Precautions.
Providing and maintaining all kinds of tests for a patient.
Billing and Report generation.

CONTENTS
1. List of tables
2. List of figures
3. Scope of Project
3.1 Features
3.2 Goals of Proposed System
3.3 Technologies used
3.4 Background
4. Feasibility Study
4.1 Technical Feasibility
4.2 Economical Feasibility
4.3 Operational Feasibility
5. Project Scheduling
6. Data Flow Diagrams
7. Entity Relationship Diagram
8. Test Case Analysis
9. Future work
10. Coding

Start
Main
Billing
DoctorInfomodify
DoctorInfoView
DoctorTableFromDatabase
PatientInfo
PatientInfoView
PatientTableFromDatabase
Report
TableFromDatabase

11. Conclusion
12. References

LIST OF TABLES

1. Doctor Table:Field Name

Data Type

did

Number

address

Text

contact

Text

specialization

Text

workfrom

Text

workto

Text

2. Patient Table:Field Name

Data Type

patientno

Number

name

Text

address

Text

contact

Text

bloodgroup

Text

history

Text

dob

Text

current

Text

roomno

Text

dateadd

Text

rtype

Text

gender

Text

docname

Text

LIST OF FIGURES
1. Data Flow Diagram
DFD Level 0
DFD Level 1
DFD Level 2
2. Entity Relationship Diagram(ER Diagram)

SCOPE OF PROJECT
It can be used in any Hospital, Clinic, Dispensary or Pathology labs for maintaining
patient details and their test results.

(a)Features
Project is related to Hospital Management System.
The project maintains two levels of users: Administrator Level-Doctor
User Level-Data Entry Operator
Main facilities available in this project are: Maintaining records of indoor/outdoor patients.
Maintaining patients diagnosis details, advised tests to be done.
Providing different test facilities to a doctor for diagnosis of patients.
X-Ray
Urine Test
Stool Test
Sonography Test
Gastroscopy Test

Colonoscopy Test
Blood Test
Biochemistry Test
Maintaining patients injection entry records.
Maintaining patients history, prescription, medicine, and advice
details.
Providing billing details for indoor/outdoor patients.
Maintaining backup of data as per user requirements (between
mentioned dates).
In this project collection of data is from different pathology labs.
Results of tests, prescription, precautions and diet advice will be automatically
updated in the database.
Related test reports, patient details report, prescription and billing reports can
be generated as per user requirements.
User or Administrator can search a patients record by his/her name or
their registration date.

(b) Goals of proposed system


1. Planned approach towards working: The working in the organization
will be well planned and organized. The data will be stored properly in data
stores, which will help in retrieval of information as well as its storage.
2. Accuracy: The level of accuracy in the proposed system will be higher.
All operation would be done correctly and it ensures that whatever
information is coming from the center is accurate.
3. Reliability: The reliability of the proposed system will be high due to the
above stated reasons. The reason for the increased reliability of the system is
that now there would be proper storage of information.
4. No Redundancy: In the proposed system utmost care would be that
no information is repeated anywhere, in storage or otherwise. This would
assure economic use of storage space and consistency in the data stored.
5. Immediate retrieval of information: The main objective of proposed
system is to provide for a quick and efficient retrieval of information. Any
type of information would be available whenever the user requires.
6. Immediate storage of information: In manual system there are many
problems to store the largest amount of information.
7. Easy to Operate: The system should be easy to operate and should be
such that it can be developed within a short period of time and fit in the limited
budget of the user.

(c) Technologies Used


This project will be a desktop application to be developed in JAVA having
Ms Access as backend.
Database Design (MS Access)
Form Design (JAVA)
Coding editor (Notepad)
Testing (JAVA)

(d) Background
A Hospital is a place where Patients come up for general diseases.
Hospitals provide facilities like:

Consultation by Doctors on Diseases.

Diagnosis for diseases.

Providing treatment facility.

Facility for admitting Patients (providing beds, nursing, medicines


etc.)

Immunization for Patients/Children.

Various operational works that are done in a Hospital are:-

Recording information about the Patients that come.

Generating bills.

Recording information related to diagnosis given to Patients.

Keeping record of the Immunization provided to children/patients.

Keeping information about various diseases and medicines


available to cure them.

These are the various jobs that need to be done in a Hospital by the
operational staff and Doctors. All these works are done on papers. The

work is done as follows:-

Information about Patients is done by just writing the Patients


name, age and gender. Whenever the Patient comes up his

information is stored freshly.

Bills are generated by recording price for each facility provided to


Patient on a separate sheet and at last they all are summed up.

Diagnosis information to patients is generally recorded on the


document, which contains Patient information. It is destroyed

after some time period to decrease the paper load in the office.

Immunization records of children are maintained in preformatted sheets, which are kept in a file.

Information about various diseases is not kept as any document.


Doctors themselves do this job by remembering various medicines.

Feasibility Study
Depending on the results of the initial investigation the survey is now expanded to a
more detailed feasibility study. FEASIBILITY STUDY is a test of system proposal
according to its workability, impact of the organization, ability to meet needs and
effective use of the resources.
During feasibility analysis for this project, following primary areas of interest are to
be considered. Investigation and generating ideas about a new system does this.
Steps in feasibility analysis
Eight steps involved in the feasibility analysis are:

Form a project team and appoint a project leader.

Prepare system flowcharts.

Enumerate potential proposed system.

Define and identify characteristics of proposed system.

Determine and evaluate performance and cost effective of each proposed


system.

Weight system performance and cost data.

Select the best-proposed system.

Prepare and report final project directive to management.

2. Technical feasibility
It is a study of resource availability that may affect the ability to achieve an
acceptable system. This evaluation determines whether the technology
needed for the proposed system is available or not.
Can the work for the project be done with current equipment existing
software technology & available personal?
Can the system be upgraded if developed?
If new technology is needed then what can be developed?
This is concerned with specifying equipment and software that will
successfully satisfy the user requirement. The technical needs of the system
may include:

Front-end and back-end selection An important issue for the development of a


project is the selection of suitable front-end and back-end. When we decided to
develop the project we went through an extensive study to determine the most
suitable platform that suits the needs of the organization as well as helps in
development of the project.
The aspects of our study included the following factors.
Front-end selection:
1. It must have a graphical user interface that assists employees that are not from
IT background.
2. Scalability and extensibility.
3. Flexibility.
4. Robustness.
5. According to the organization requirement and the culture.
6. Must provide excellent reporting features with good printing support.
7. Platform independent.
8. Easy to debug and maintain.
9. Event driven programming facility.
10. Front end must support some popular back end like Ms Access.
According to the above stated features we selected JAVA as the front-end
for developing our project.
Back-end Selection:
1. Multiple user support.
2. Efficient data handling.
3. Provide inherent features for security.
4. Efficient data retrieval and maintenance.
5. Stored procedures.
6. Popularity.
7. Operating System compatible.
8. Easy to install.
9. Various drivers must be available.
10. Easy to implant with the Front-end.
According to above stated features we selected Ms-Access as the backend.

The technical feasibility is frequently the most difficult area encountered at this stage.
It is essential that the process of analysis and definition be conducted in parallel with
an assessment to technical feasibility. It centers on the existing computer system
(hardware, software etc.) and to what extent it can support the proposed system.
2. Economical feasibility
Economic justification is generally the Bottom Line consideration for most
systems. Economic justification includes a broad range of concerns that includes
cost benefit analysis. In this we weight the cost and the benefits associated with the
candidate system and if it suits the basic purpose of the organization i.e. profit
making, the project is making to the analysis and design phase.

The financial and the economic questions during the preliminary investigation
are verified to estimate the following:
The cost to conduct a full system investigation. The cost of hardware and software
for the class of application are considered.
The benefits in the form of reduced cost.
The proposed system will give the minute information, as a result the performance
is improved which in turn may be expected to provide increased profits.
This feasibility checks whether the system can be developed with the available
funds.
The Hospital Management System does not require enormous amount of money
to be developed. This can be done economically if planned judicially, so it is
economically feasible. The cost of project depends upon the number of man- hours
required.
3. Operational Feasibility
It is mainly related to human organizations and political aspects. The points to be
considered are:
What changes will be brought with the system?
What organization structures are disturbed?
What new skills will be required? Do the existing staff members have these skills?
If not, can they be trained in due course of time?

The system is operationally feasible as it very easy for the End users to operate it. It
only needs basic information about Windows platform.

Project Scheduling
Time evaluation is the most important consideration in the development of project.
The time schedule required for the developed of this project is very important since
more development time effect machine time, cost and cause delay in the
development of other systems.
A reliable Hospital Management System can be developed in the considerable
amount of time.

Project Requirements
Hardware Requirements
Processor

RAM

Pentium II, Pentium III, 512Mb or Higher


Pentium IV or higher

Software Requirements
Operating System

Database

Win-98,Win-XP, Linux or

Ms Access

any other higher version.

DISK SPACE
1 GB or more

Application Design

Data Flow Diagram

DATABASE DESIGN
Entity Relationship Diagram-

TEST CASE ANALYSIS

CODING
START
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
class start extends JFrame implements ActionListener
{
JButton bpat,bdoc,bbill,breport,bback,bexit;
JLabel linfo,linfo1,linfo2,linfo3,linfo4;
start()
{
super("Hospital Management System");
setSize(1024,768);
setVisible(true);
setLayout(null);
linfo=new JLabel("SELECT THE APPROPRIATE OPTION");
linfo.setBounds(30,137,210,20);
add(linfo);
linfo1=new JLabel("1. For Inserting, Modifying, Retrieving Patients related Data");
linfo1.setBounds(50,205,335,20);
add(linfo1);
linfo2=new JLabel("2. For Inserting, Modifying, Retrieving Doctors related Data");
linfo2.setBounds(50,275,335,20);
add(linfo2);
linfo3=new JLabel("3. Billing Details");
linfo3.setBounds(50,345,150,20);
add(linfo3);
linfo4=new JLabel("4. Patient and Doctor related Data");
linfo4.setBounds(50,413,250,20);
add(linfo4);
bpat=new JButton("Patient", new ImageIcon("images/Advances.png"));
bpat.setBounds(430,200,180,30);
add(bpat);
bdoc=new JButton("Doctor",new ImageIcon("images/Advances.png"));
bdoc.setBounds(430,270,180,30);
add(bdoc);
bbill=new JButton("Billing",new ImageIcon("images/Attendance.png"));
bbill.setBounds(430,340,180,30);
add(bbill);

breport=new JButton("Reports",new ImageIcon("images/edit.png"));


breport.setBounds(430,408,180,30);
add(breport);
bback=new JButton("BACK" ,new ImageIcon("images/preview_Hover.png"));
bback.setBounds(230,515,100,30);
add(bback);
bexit=new JButton("EXIT" ,new ImageIcon("images/exits.png"));
bexit.setBounds(730,515,100,30);
add(bexit);
bpat.addActionListener(new patient());
bdoc.addActionListener(new doctor());
bbill.addActionListener(new billing());
bexit.addActionListener(new exit());
bback.addActionListener(new back());
breport.addActionListener(new report());
}
public void actionPerformed(ActionEvent ae)
{}
class report implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new Report();
setVisible(false);
}
};
class back implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new main();
setVisible(false);
}
}
class patient implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new patStart();
setVisible(false);
}
}
class doctor implements ActionListener
{

public void actionPerformed(ActionEvent ae)


{
new docStart();
setVisible(false);
}
}
class billing implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new Billing();
setVisible(false);
}
}
class exit implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
System.exit(0);
}
}
}

MAIN
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class main extends JFrame implements ActionListener
{
static JFrame frame;
private String username;
private String password;
private static JFrame loginFrame;
private static JPanel panel1;
private static JPanel panel2;
private static JPanel panel3;
private JButton loginBtn;
private JButton exitBtn;
int dialogtype = JOptionPane.PLAIN_MESSAGE;
String dialogmessage;
String dialogs;
private JLabel nameLbl;
private JLabel userLbl;
private JLabel passwordLbl;
private static JTextField userTxt;
private static JPasswordField passwordTxt;
public String loginname;
public String loginpass;

Dimension screen

Toolkit.getDefaultToolkit().getScreenSize();

main()
{
panel1 = new JPanel();
panel1.setLayout(new FlowLayout());
nameLbl = new JLabel("Hospital Managment ");
panel2 = new JPanel();
panel2.setLayout(new GridLayout(2,2));
userLbl = new JLabel("Username :");
userTxt = new JTextField(20);
passwordLbl = new JLabel("Password :");
passwordTxt = new JPasswordField(20);
panel3 = new JPanel();
panel3.setLayout(new FlowLayout());

loginBtn = new JButton("Login", new ImageIcon("images/key.gif"));


loginBtn.addActionListener(this);
exitBtn = new JButton("Exit", new ImageIcon("images/Keys.gif"));
exitBtn.addActionListener(this);
panel1.add(nameLbl);
panel1.setOpaque(true);
panel2.add(userLbl);
panel2.add(userTxt);
panel2.add(passwordLbl);
panel2.add(passwordTxt);
panel2.setOpaque(true);
panel3.add(loginBtn);
panel3.add(exitBtn);
panel3.setOpaque(true);
frame = new JFrame("Hospital Managment");
frame.setSize(300,200);
Container pane = frame.getContentPane();
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
pane.add(panel1);
pane.add(panel2);
pane.add(panel3);
frame.setLocation((screen.width - 500)/2,((screen.height-350)/2));
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);

}
});
}
public void actionPerformed(ActionEvent event)
{
Object source = event.getSource();
if(source.equals(loginBtn))
{
String loginname,loginpass;
loginname = userTxt.getText().trim();
loginpass = passwordTxt.getText().trim();
if(loginname.equals("s") && loginpass.equals("s"))
{
dialogmessage = "Welcome - " +loginname;
dialogtype = JOptionPane.INFORMATION_MESSAGE;
JOptionPane.showMessageDialog((Component)null, dialogmessage, dialogs, dialogtype);
userTxt.setText("");
new start();
setVisible(false);
frame.dispose();
}
else{
JOptionPane.showMessageDialog(null,"Invaild User name and password" ,
"WARNING!!!",JOptionPane.INFORMATION_MESSAGE);
userTxt.setText("");
passwordTxt.setText("");
}
}
else if(source.equals(exitBtn))
{
System.exit(0);
}
}
public static void main(String[] args)
{
new main();
}
}

BILLING
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import java.text.*;

class Billing extends JFrame implements ActionListener


{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;
JLabel lmain,lpname,lpno,ldad,lddis,lrt,ltamt,temp;
JTextField tfname,tfno,tfdateadd,tfrtype,tftamt;
JButton bsub,bclr,bback;
Billing()
{
super("Billing Information");
setSize(1024,768);
setVisible(true);
setLayout(null);
lmain=new JLabel("Billing Information");
lmain.setBounds(440,35,107,15);
add(lmain);
lpname=new JLabel("Patient Name :");
lpname.setBounds(104,97,85,25);
add(lpname);
tfname=new JTextField(30);
tfname.setBounds(230,100,225,20);
add(tfname);
lpno=new JLabel("Patient No. :");
lpno.setBounds(570,97,70,25);
add(lpno);
tfno=new JTextField(30);
tfno.setBounds(694,100,70,20);
add(tfno);
ldad=new JLabel("Date of Admission :");
ldad.setBounds(104,175,120,25);
add(ldad);
tfdateadd=new JTextField(20);
tfdateadd.setBounds(230,178,80,20);
add(tfdateadd);
lddis=new JLabel("Date of Discharge :");
lddis.setBounds(570,175,120,25);
add(lddis);

lrt=new JLabel("Room Type :");


lrt.setBounds(104,242,70,25);
add(lrt);
tfrtype=new JTextField(20);
tfrtype.setBounds(230,242,80,20);
add(tfrtype);
ltamt=new JLabel("Total Amount :");
ltamt.setBounds(104,380,85,25);
add(ltamt);
tftamt=new JTextField(20);
tftamt.setBounds(230,380,120,20);
add(tftamt);
bsub=new JButton("SEARCH" ,new ImageIcon("images/setting.png"));
bsub.setBounds(300,643,110,30);
add(bsub);
bclr=new JButton("CLEAR",new ImageIcon("images/LOGGOFF.PNG"));
bclr.setBounds(470,643,100,30);
add(bclr);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(580,643,100,30);
add(bback);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:pat");
}
catch(Exception e)
{
System.out.println(e);
}
bclr.addActionListener(new clear());
bsub.addActionListener(new submit());
bback.addActionListener(new back());
try
{
Calendar cal=Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
df.setLenient(false);
System.out.println(df.format(cal.getTime()));
String dd1=df.format(cal.getTime());

temp=new JLabel(dd1);
temp.setBounds(694,178,80,20);
add(temp);
}
catch (Exception e)
{
new ErrorDialog2();
}
}
public void actionPerformed(ActionEvent ae)
{}
class clear implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
tfname.setText("");
tfno.setText("");
tfdateadd.setText("");
tfrtype.setText("");
tftamt.setText("");
}
}
class back implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new start();
setVisible(false);
}
}
class submit extends Frame implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
try
{
Integer no,num=Integer.parseInt(tfno.getText());
String name,room,dateadd,rtype;
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM PAT WHERE
patientno="+num);
if(rs.next())
{
no=rs.getInt("patientno");
name=rs.getString("name");

dateadd=rs.getString("dateadd");
System.out.println(dateadd);
rtype=rs.getString("rtype");
tfname.setText(name);
tfdateadd.setText(dateadd);
tfrtype.setText(rtype);
}
try
{
Calendar cal=Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
df.setLenient(false);
int dnow=cal.get(Calendar.DAY_OF_MONTH);
int mnow=cal.get(Calendar.MONTH);
int ynow=cal.get(Calendar.YEAR);
int
mnowF=mnow+1;
Calendar cal1=Calendar.getInstance();
cal1.setTime(df.parse(tfdateadd.getText()));
SimpleDateFormat sf2=new SimpleDateFormat("yyyy,MM,dd");
sf2.setLenient(false);

int daddd=cal1.get(Calendar.DAY_OF_MONTH);
int daddMM=cal1.get(Calendar.MONTH);
int daddYY=cal1.get(Calendar.YEAR);
int daddMMF=daddMM+1;
long from = new
java.util.GregorianCalendar(ynow,mnowF,dnow).getTime().getTime();
long to = new
java.util.GregorianCalendar(daddYY,daddMMF,daddd).getTime().getTime();
double difference = from-to;
long days = Math.round((difference/(1000*60*60*24)));
long bill=0;
String rt=tfrtype.getText();
if(rt.equals("Deluxe"))
{
System.out.println(tfrtype.getText());
int m=2000;

System.out.println(m);
bill=days*m;
System.out.println("total bill = "+bill);
}
if(rt.equals("Private"))
{
int m=800;
System.out.println(m);
bill=days*m;
System.out.println("total bill = "+bill);
}
if(rt.equals("Semi-Private"))
{
int m=600;
System.out.println(m);
bill=days*m;
System.out.println("total bill = "+bill);
}
if(rt.equals("General"))
{
int m=400;
System.out.println(m);
bill=days*m;
System.out.println("total bill = "+bill);
}
String FinalBill=(new Long(bill)).toString();
tftamt.setText(FinalBill);
}
catch (Exception e)
{
System.out.println(e);
}
}
catch (SQLException sq)
{
System.out.println(sq);
}
}
}
public static void main(String[] args)
{
new Billing();
}
}

DoctorInfomodify
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class DoctorInfomodify extends JFrame implements ActionListener
{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;
JLabel lmain,ldi,lname,ladd,ltel,lspecial,ldid,ldspec,lwork,lworkfrom,lworkto;
JTextField tfname,tftel,tfdid,tfworkf,tfworkt;
TextArea taadd,taspecial;
JButton bsub,bclr,bmod,bback;
int x,y;
String str;
clsSettings settings = new clsSettings();
DoctorInfomodify()
{
super("Doctor Information");
setSize(1024,768);
setVisible(true);
setLayout(null);
lmain=new JLabel("Doctor Information");
lmain.setBounds(440,35,107,15);
add(lmain);
ldi=new JLabel("Doctor Information");
ldi.setBounds(40,70,120,15);
add(ldi);
lname=new JLabel("Name :");
lname.setBounds(104,97,70,25);
add(lname);
tfname=new JTextField(30);
tfname.setBounds(270,97,250,20);
add(tfname);
ladd=new JLabel("Address :");
ladd.setBounds(104,138,70,15);
add(ladd);
taadd=new TextArea();

taadd.setBounds(270,138,250,100);
add(taadd);
ltel=new JLabel("Contact :");
ltel.setBounds(575,138,50,25);
add(ltel);
ldid=new JLabel("Doctor ID:");
ldid.setBounds(570,97,70,25);
add(ldid);
tfdid=new JTextField(30);
tfdid.setBounds(643,97,50,20);
add(tfdid);
tftel=new JTextField(30);
tftel.setBounds(640,138,200,20);
add(tftel);
settings.Numvalidator(tftel);
ldspec=new JLabel("Specialization :");
ldspec.setBounds(104,310,100,25);
add(ldspec);
taspecial=new TextArea();
taspecial.setBounds(270,310,250,100);
add(taspecial);
lwork=new JLabel("Working hours :");
lwork.setBounds(570,310,100,15);
add(lwork);
lworkfrom=new JLabel("From :");
lworkfrom.setBounds(670,305,37,25);
add(lworkfrom);
tfworkf=new JTextField(30);
tfworkf.setBounds(710,310,30,20);
add(tfworkf);
settings.Numvalidator(tfworkf);
lworkto=new JLabel("to :");
lworkto.setBounds(747,305,20,25);
add(lworkto);
tfworkt=new JTextField(30);
tfworkt.setBounds(775,310,30,20);
add(tfworkt);
settings.Numvalidator(tfworkt);

bsub=new JButton("SEARCH",new ImageIcon("images/search.png"));


bsub.setBounds(250,643,110,30);
add(bsub);
bclr=new JButton("CLEAR",new ImageIcon("images/LOGGOFF.PNG"));
bclr.setBounds(390,643,100,30);
add(bclr);
bmod=new JButton("MODIFY",new ImageIcon("images/modify.png"));
bmod.setBounds(530,643,100,30);
add(bmod);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(700,643,100,30);
add(bback);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:doc");
}
catch(Exception e)
{
System.out.println(e);
}
bclr.addActionListener(new clear());
bsub.addActionListener(new submit());
bmod.addActionListener(new modify());
bback.addActionListener(new back());
}
public void actionPerformed(ActionEvent ae)
{}

class clear implements ActionListener


{
public void actionPerformed(ActionEvent ae)
{
tfname.setText("");
tftel.setText("");
tfdid.setText("");
tfworkf.setText("");
tfworkt.setText("");
taadd.setText("");

taspecial.setText("");
}
}
public static void main(String[] args)
{
new DoctorInfomodify();
System.out.println("Doctors Info Mod");
}
class back implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new docStart();
setVisible(false);
}
}
class submit implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
try{
Integer num=Integer.parseInt(tfdid.getText());
String name;
String addr;
String contact;
String spec;
String workf;
String workt;
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM DOC WHERE did="+num);
if(rs.next())
{
num=rs.getInt("did");
name=rs.getString("name");
addr=rs.getString("address");
contact=rs.getString("contact");
spec=rs.getString("specialization");
workf=rs.getString("workfrom");
workt=rs.getString("workto");
tfname.setText(name);
taadd.setText(addr);
tftel.setText(contact);
taspecial.setText(spec);
tfworkf.setText(workf);
tfworkt.setText(workt);
}
}
catch(SQLException sq)

{
System.out.println(sq);
}
}
}
class modify implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
try{
Integer num1=Integer.parseInt(tfdid.getText());
if(num1.equals(null))
{
System.out.println("num");
throw new BlankException();
}
String name1=tfname.getText();
int a;
a=name1.charAt(0);
if(name1.equals("") || a==32)
{
throw new BlankException();
}
else
{
for(int i=0; i<name1.length(); i++)
{
boolean check = Character.isLetter(name1.charAt(i));
a=name1.charAt(i);
System.out.print(" "+a);
if(!((a>=65 && a<=90) || (a>=97 && a<=122) || (a==32)
||(a==46)))
{
throw new NameEx();
}
}
}
String addr1=taadd.getText();
if(addr1.equals(null))
{
System.out.println("addr");
throw new BlankException();
}
String contact1=tftel.getText();
String spec1=taspecial.getText();
String workf1=tfworkf.getText();
String workt1=tfworkt.getText();
String str="UPDATE DOC SET
name=?,address=?,contact=?,specialization=?,workfrom=?,workto=? WHERE did=?";

Statement st1= cn.createStatement();


PreparedStatement psmt=cn.prepareStatement(str);
psmt.setString(1,name1);
psmt.setString(2,addr1);
psmt.setString(3,contact1);
psmt.setString(4,spec1);
psmt.setString(5,workf1);
psmt.setString(6,workt1);
psmt.setInt(7,num1);
psmt.executeUpdate();
new SuccessDialog2();
}
catch(SQLException sq)
{
String message = "Enter Valid Doctor ID and Contact.";
JOptionPane.showMessageDialog(new JFrame(), message, "ERROR!",
JOptionPane.ERROR_MESSAGE);
System.out.println(sq);
}
catch(BlankException be)
{
new ErrorDialog2();
}
catch(NumberFormatException nfe)
{
new ErrorDialog();
}
catch(NameEx ne)
{
new ErrorDialog1();
}
catch(Exception e)
{
System.out.println(e);
new EDt();
}
}
}

DoctorInfoView
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class DoctorInfoView extends JFrame implements ActionListener
{
static Connection cn=null;
static Connection cn2=null;
Statement st=null;
Statement st2=null;
ResultSet rs=null;
ResultSet rs2=null;
JLabel lmain,ldi,lname,ladd,ltel,lspecial,ldid,ldspec,lwork,lworkfrom,lworkto,lpatlist;
JTextField tfname,tftel,tfdid,tfworkf,tfworkt;
TextArea taadd,taspecial,tapatlist;
JButton bsub,bclr,bback;
DoctorInfoView()
{
super("Doctor Information");
setSize(1024,768);
setVisible(true);
setLayout(null);
lmain=new JLabel("Doctor Information");
lmain.setBounds(440,35,107,15);
add(lmain);
ldi=new JLabel("Doctor Information");
ldi.setBounds(40,70,120,15);
add(ldi);
lname=new JLabel("Name :");
lname.setBounds(104,97,70,25);
add(lname);
tfname=new JTextField(30);
tfname.setBounds(270,97,250,20);
add(tfname);
ladd=new JLabel("Address :");
ladd.setBounds(104,138,70,15);
add(ladd);
taadd=new TextArea();
taadd.setBounds(270,138,250,100);

add(taadd);
ltel=new JLabel("Contact :");
ltel.setBounds(575,138,50,25);
add(ltel);
ldid=new JLabel("Doctor ID:");
ldid.setBounds(570,97,70,25);
add(ldid);
tfdid=new JTextField(30);
tfdid.setBounds(643,97,50,20);
add(tfdid);
tftel=new JTextField(30);
tftel.setBounds(640,138,200,20);
add(tftel);
ldspec=new JLabel("Specialization :");
ldspec.setBounds(104,310,100,25);
add(ldspec);
taspecial=new TextArea();
taspecial.setBounds(270,310,250,100);
add(taspecial);
lwork=new JLabel("Working hours :");
lwork.setBounds(570,200,100,15);
add(lwork);
lworkfrom=new JLabel("From :");
lworkfrom.setBounds(670,200,37,25);
add(lworkfrom);
tfworkf=new JTextField(30);
tfworkf.setBounds(710,200,30,20);
add(tfworkf);
lworkto=new JLabel("to :");
lworkto.setBounds(747,200,20,25);
add(lworkto);
tfworkt=new JTextField(30);
tfworkt.setBounds(775,200,30,20);
add(tfworkt);
lpatlist=new JLabel("Patient List");
lpatlist.setBounds(570,290,80,25);
add(lpatlist);

tapatlist=new TextArea();
tapatlist.setBounds(570,310,250,100);
add(tapatlist);
bsub=new JButton("SEARCH",new ImageIcon("images/search.png"));
bsub.setBounds(300,643,110,30);
add(bsub);
bclr=new JButton("CLEAR",new ImageIcon("images/LOGGOFF.PNG"));
bclr.setBounds(470,643,100,30);
add(bclr);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(580,643,100,30);
add(bback);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:doc");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn2=DriverManager.getConnection("Jdbc:Odbc:pat");
}
catch(Exception e)
{
System.out.println(e);
}
bclr.addActionListener(new clear());
bsub.addActionListener(new submit());
bback.addActionListener(new back());
}
class clear implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
tfname.setText("");
tftel.setText("");
tfdid.setText("");
tfworkf.setText("");
tfworkt.setText("");
taadd.setText("");
taspecial.setText("");
tapatlist.setText("");
}
}
class back implements ActionListener
{

public void actionPerformed(ActionEvent ae)


{
new docStart();
setVisible(false);
}
}
public void actionPerformed(ActionEvent ae)
{}
class patinfo implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
}
};
class submit implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
try{
tapatlist.setText("");
Integer num=Integer.parseInt(tfdid.getText());
String name;
String addr;
String contact;
String spec;
String workf;
String workt;
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM DOC WHERE did="+num);
if(rs.next())
{
num=rs.getInt("did");
name=rs.getString("name");
addr=rs.getString("address");
contact=rs.getString("contact");
spec=rs.getString("specialization");
workf=rs.getString("workfrom");
workt=rs.getString("workto");
tfname.setText(name);
taadd.setText(addr);
tftel.setText(contact);
taspecial.setText(spec);
tfworkf.setText(workf);
tfworkt.setText(workt);
}
}

catch(SQLException sq)
{
System.out.println(sq);
}
try{
String docname=tfname.getText();
System.out.println(docname);
Statement st2=cn2.createStatement();
ResultSet rs2=st2.executeQuery("SELECT patientno,name FROM PAT WHERE
docname='"+docname+"'");
ResultSetMetaData rsmt=rs2.getMetaData();
int ctr=rsmt.getColumnCount();
while(rs2.next())
{
for(int i=1;i<=ctr;i++)
{
tapatlist.append(rs2.getString(i)+" ");
}
tapatlist.append("\n");
}
}
catch(SQLException sq)
{
System.out.println(sq);
}
}
}
public static void main(String[] args)
{
new DoctorInfoView();
System.out.println("Doctors Info Add");
}
}

DoctorTableFromDatabase
import java.awt.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
class DoctorTableFromDatabase extends JFrame
{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;
DoctorTableFromDatabase()
{

Vector columnNames = new Vector();


Vector data = new Vector();
try
{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:doc");
}
catch(Exception e)
{
System.out.println(e);
}
// Read data from a table
String sql = "Select * from DOC";
Statement stmt = cn.createStatement();
ResultSet rs = stmt.executeQuery( sql );
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
// Get column names
for (int i = 1; i <= columns; i++)
{
columnNames.addElement(md.getColumnName(i));
}
// Get row data
while (rs.next())
{
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++)
{
row.addElement(rs.getObject(i));
}
data.addElement( row );
}
}
catch(Exception e)
{
System.out.println( e );
}
// Create table with database data
JTable table = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(table);

getContentPane().add( scrollPane );
JPanel buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
}
public static void main(String[] args)
{
DoctorTableFromDatabase frame = new DoctorTableFromDatabase();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}

PatientInfo
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.text.*;
class NameEx extends Exception{}
class BlankException extends Exception{}
class PatientInfo extends JFrame implements ActionListener
{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;
JLabel
lmain,lpi,lname,ladd,ltel,lmi,lbg,ldob,lhis,lcur,lpno,lroom,ldateadd,lgender,lrtype,ldtip,ldtip2,ldocname
;
JTextField tfname,tftel,tfdob,tfpno,tfroom,tfdateadd,tfdocname;
TextArea taadd,tahis,tacur;
Choice chbg,chrt;
CheckboxGroup cbmf;
Checkbox cbm,cbf;
JButton bsub,bclr,bback;
String dialogmessage;
String dialogs;
int dialogtype = JOptionPane.PLAIN_MESSAGE;
clsSettings settings = new clsSettings();
PatientInfo()
{
super("Add Patient Information");
setSize(1024,768);
setVisible(true);
setLayout(null);

// PERSONAL INFORMATION
lmain=new JLabel("Add Patient Information");
lmain.setBounds(440,35,160,15);
add(lmain);
lpi=new JLabel("Add Personal Information");
lpi.setBounds(40,70,150,15);
add(lpi);
lname=new JLabel("Name :");
lname.setBounds(104,97,70,25);
add(lname);
tfname=new JTextField(30);
tfname.setBounds(270,97,250,20);
add(tfname);
ladd=new JLabel("Address :");
ladd.setBounds(104,138,70,15);
add(ladd);
taadd=new TextArea();
taadd.setBounds(270,138,250,100);
add(taadd);
ltel=new JLabel("Contact :");
ltel.setBounds(575,138,50,25);
add(ltel);
lpno=new JLabel("Patient No.:");
lpno.setBounds(570,97,70,25);
add(lpno);
tftel=new JTextField(30);
tftel.setBounds(640,138,250,20);
add(tftel);
settings.Numvalidator(tftel);
tfpno=new JTextField(30);
tfpno.setBounds(643,97,50,20);
add(tfpno);
// END
lroom=new JLabel("Room No.:");
lroom.setBounds(720,97,60,20);
add(lroom);

tfroom=new JTextField(30);
tfroom.setBounds(788,97,60,20);
add(tfroom);

lmi=new JLabel("Medical Information");


lmi.setBounds(40,268,120,15);
add(lmi);
lbg=new JLabel("Blood Group :");
lbg.setBounds(104,306,79,15);
add(lbg);
chbg=new Choice();
chbg.setBounds(270,306,53,15);
chbg.addItem("A -ve");
chbg.addItem("A +ve");
chbg.addItem("B -ve");
chbg.addItem("B +ve");
chbg.addItem("AB -ve");
chbg.addItem("AB +ve");
chbg.addItem("O +ve");
chbg.addItem("O -ve");
add(chbg);
ldob=new JLabel("Date of Birth :");
ldob.setBounds(575,306,120,15);
add(ldob);
tfdob=new JTextField(15);
tfdob.setBounds(696,305,80,20);
add(tfdob);
ldtip=new JLabel("(dd-mm-yyyy)");
ldtip.setBounds(782,305,100,20);
add(ldtip);
lhis=new JLabel("History :");
lhis.setBounds(104,365,50,15);
add(lhis);
tahis=new TextArea();
tahis.setBounds(270,365,250,100);
add(tahis);
lcur=new JLabel("Current Problem :");
lcur.setBounds(575,365,100,15);
add(lcur);

ldocname=new JLabel("Attending Doctor :");


ldocname.setBounds(575,510,130,15);
add(ldocname);
tacur=new TextArea();
tacur.setBounds(720,365,250,100);
add(tacur);
ldateadd=new JLabel("Date Of Admission :");
ldateadd.setBounds(575,180,120,25);
add(ldateadd);
tfdateadd=new JTextField(40);
tfdateadd.setBounds(696,180,80,20);
add(tfdateadd);
tfdocname=new JTextField(100);
tfdocname.setBounds(720,510,250,20);
add(tfdocname);
ldtip2=new JLabel("(dd-mm-yyyy)");
ldtip2.setBounds(782,180,100,20);
add(ldtip2);
bsub=new JButton("ADD",new ImageIcon("images/add.gif"));
bsub.setBounds(362,643,100,30);
add(bsub);
bclr=new JButton("CLEAR",new ImageIcon("images/LOGGOFF.PNG"));
bclr.setBounds(470,643,100,30);
add(bclr);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(580,643,100,30);
add(bback);
lgender=new JLabel("Gender :");
lgender.setBounds(596,223,50,15);
add(lgender);
cbmf=new CheckboxGroup();
cbm=new Checkbox("Male",cbmf,true);
cbf=new Checkbox("Female",cbmf,false);
cbm.setBounds(698,223,50,15);
add(cbm);
cbf.setBounds(760,223,60,15);
add(cbf);

lrtype=new JLabel("Type Of Room : ");


lrtype.setBounds(104,510,120,25);
add(lrtype);
chrt=new Choice();
chrt.setBounds(270,510,80,15);
chrt.addItem("Deluxe");
chrt.addItem("Private");
chrt.addItem("Semi-Private");
chrt.addItem("General");
add(chrt);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:pat");
}
catch(Exception e)
{
System.out.println(e);
}
bclr.addActionListener(new clear());
bsub.addActionListener(new submit());
bback.addActionListener(new back());
Calendar cal=Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
System.out.println(df.format(cal.getTime()));
}
//End of constructor
public void actionPerformed(ActionEvent ae)
{}
public static void main(String[] args)
{
new PatientInfo();
}
class clear implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
tfname.setText("");
tftel.setText("");
tfdob.setText("");
taadd.setText("");
tahis.setText("");
tacur.setText("");
tfpno.setText("");
tfroom.setText("");

tfdateadd.setText("");
}
}
class back implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new patStart();
setVisible(false);
}
}
class submit implements ActionListener, ItemListener
{
public void itemStateChanged(ItemEvent ie)
{
}
public void actionPerformed(ActionEvent ae)
{
try{
Integer count=0;
Integer num=Integer.parseInt(tfpno.getText());
if(num.equals(null))
{
System.out.println("num");
throw new BlankException();
}
String name=tfname.getText();
int a;
a=name.charAt(0);
if(name.equals("") || a==32)
{
System.out.println("name=="+name);
throw new BlankException();
}
else
{
for(int i=0; i<name.length(); i++)
{
boolean check = Character.isLetter(name.charAt(i));
a=name.charAt(i);
System.out.print(" "+a);
if(!((a>=65 && a<=90) || (a>=97 && a<=122) || (a==32)
||(a==46)))
{
throw new NameEx();
}
}
}

String addr=taadd.getText();
if(addr.equals(null))
{
System.out.println("addr");
throw new BlankException();
}
Long contact=Long.parseLong(tftel.getText());
String blgr=chbg.getSelectedItem();
String hist=tahis.getText();
String dob=tfdob.getText();
if(dob.equals(null))
{
System.out.println("dob");
throw new BlankException();
}
String current=tacur.getText();
if(current.equals(null))
{
System.out.println("current");
throw new BlankException();
}
String room=tfroom.getText();
String dateadd=tfdateadd.getText();
if(dateadd.equals(null))
{
System.out.println("dateadd");
throw new BlankException();
}
String docname=tfdocname.getText();
if(docname.equals(null))
{
System.out.println("docname");
throw new BlankException();
}
Calendar cal=Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
df.setLenient(false);
java.util.Date myDate = df.parse(dateadd);
System.out.println(dateadd);
String rtype=chrt.getSelectedItem();
String gender="";
if(cbm.getState()==true)
{
gender="male";
}
if(cbf.getState()==true)
{

gender="female";
}
Statement st=cn.createStatement();
st.executeUpdate("INSERT INTO PAT
VALUES('"+num+"','"+name+"','"+addr+"','"+contact+"','"+blgr+"','"+hist+"','"+dob+"','"+current+"','"+r
oom+"','"+dateadd+"','"+rtype+"','"+gender+"','"+docname+"');");
new SuccessDialog();
}
catch (ParseException e)
{
new EDt();
}
catch(BlankException be)
{
new ErrorDialog2();
}
catch(NumberFormatException nfe)
{
new ErrorDialog();
}
catch(SQLException sq)
{
System.out.println(sq);
}
catch(NameEx ne)
{
new ErrorDialog1();
}
catch(Exception e)
{
System.out.println(e);
new EDt();
}
}
}
}

PatientInfoView
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class PatientInfoView extends JFrame implements ActionListener
{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;

JLabel
lmain,lpi,lname,ladd,ltel,lmi,lbg,ldob,lhis,lcur,lpno,lnote,lroom,ldateadd,lgender,lrtype,ldtip,ldtip2,ldo
cname;
JTextField tfname,tftel,tfpno,tfbg,tfroom,tfdateadd,tfmf,tfrtype,tfdocname,tfdob;
TextArea taadd,tahis,tacur;
JButton bsub,bclr,bback;
PatientInfoView()
{
super("View Patient Information");
setSize(1024,768);
setVisible(true);
setLayout(null);
// PERSONAL INFORMATION
lmain=new JLabel("View Patient Information");
lmain.setBounds(440,35,140,15);
add(lmain);
lnote=new JLabel("Insert Patient Number");
lnote.setBounds(641,75,127,15);
add(lnote);
lpi=new JLabel("Personal Information");
lpi.setBounds(40,70,120,15);
add(lpi);
lname=new JLabel("Name :");
lname.setBounds(104,97,70,25);
add(lname);
tfname=new JTextField(30);
tfname.setBounds(270,97,250,20);
add(tfname);
ladd=new JLabel("Address :");
ladd.setBounds(104,138,70,15);
add(ladd);
taadd=new TextArea();
taadd.setBounds(270,138,250,100);
add(taadd);
ltel=new JLabel("Contact :");
ltel.setBounds(575,138,50,25);
add(ltel);

lpno=new JLabel("Patient No.:");


lpno.setBounds(570,97,70,25);
add(lpno);
tftel=new JTextField(30);
tftel.setBounds(640,138,250,20);
add(tftel);
tfpno=new JTextField(30);
tfpno.setBounds(643,97,50,20);
add(tfpno);
// END
lmi=new JLabel("Medical Information");
lmi.setBounds(40,268,120,15);
add(lmi);
lbg=new JLabel("Blood Group :");
lbg.setBounds(104,306,79,15);
add(lbg);
tfbg=new JTextField(30);
tfbg.setBounds(270,306,53,20);
add(tfbg);
ldob=new JLabel("Date of Birth :");
ldob.setBounds(575,306,135,15);
add(ldob);
lhis=new JLabel("History :");
lhis.setBounds(104,365,50,15);
add(lhis);
tahis=new TextArea();
tahis.setBounds(270,365,250,100);
add(tahis);
lcur=new JLabel("Current Problem :");
lcur.setBounds(575,365,100,15);
add(lcur);
tacur=new TextArea();
tacur.setBounds(720,365,250,100);
add(tacur);
lroom=new JLabel("Room No.:");
lroom.setBounds(720,97,60,20);
add(lroom);

tfroom=new JTextField(30);
tfroom.setBounds(788,97,60,20);
add(tfroom);
ldateadd=new JLabel("Date Of Admission :");
ldateadd.setBounds(575,180,120,25);
add(ldateadd);
tfdateadd=new JTextField(40);
tfdateadd.setBounds(696,180,80,20);
add(tfdateadd);
lgender=new JLabel("Gender :");
lgender.setBounds(575,223,50,15);
add(lgender);
tfmf=new JTextField(50);
tfmf.setBounds(698,223,80,20);
add(tfmf);
lrtype=new JLabel("Type Of Room : ");
lrtype.setBounds(104,510,120,25);
add(lrtype);
tfrtype=new JTextField();
tfrtype.setBounds(270,510,80,20);
add(tfrtype);

bsub=new JButton("SEARCH",new ImageIcon("images/search.png"));


bsub.setBounds(300,643,110,30);
add(bsub);
bclr=new JButton("CLEAR",new ImageIcon("images/LOGGOFF.PNG"));
bclr.setBounds(470,643,100,30);
add(bclr);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(580,643,100,30);
add(bback);
ldtip2=new JLabel("(dd-mm-yyyy)");
ldtip2.setBounds(782,180,100,20);
add(ldtip2);
tfdocname=new JTextField(100);
tfdocname.setBounds(720,510,250,20);
add(tfdocname);

ldocname=new JLabel("Attending Doctor :");


ldocname.setBounds(575,510,130,15);
add(ldocname);
ldtip=new JLabel("(dd-mm-yyyy)");
ldtip.setBounds(782,305,100,20);
add(ldtip);
ldob=new JLabel("Date of Birth :");
ldob.setBounds(575,306,120,15);
add(ldob);
tfdob=new JTextField(15);
tfdob.setBounds(696,305,80,20);
add(tfdob);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:pat");
}
catch(Exception e)
{
System.out.println(e);
}

bclr.addActionListener(new clear());
bsub.addActionListener(new submit());
bback.addActionListener(new back());
}
public void actionPerformed(ActionEvent ae)
{}
public static void main(String[] args)
{
PatientInfoView piv=new PatientInfoView();
}
class clear implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
tfname.setText("");
tftel.setText("");
tfdob.setText("");
taadd.setText("");
tahis.setText("");
tacur.setText("");
tfpno.setText("");
tfroom.setText("");

tfdateadd.setText("");
tfrtype.setText("");
tfmf.setText("");
tfbg.setText("");
}
}
class back implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new patStart();
setVisible(false);
}
}
class submit extends Frame implements ActionListener
{
Integer num,no=0;
String name,addr,contact,blgr,hist,dob,current,room,dateadd,rtype,mf,docname;
public void actionPerformed(ActionEvent ae)
{
try{
num=Integer.parseInt(tfpno.getText());
Statement st=cn.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM PAT WHERE patientno="+num);
System.out.println(num);
if(rs.next())
{
no=rs.getInt("patientno");
name=rs.getString("name");
addr=rs.getString("address");
contact=rs.getString("contact");
hist=rs.getString("history");
dob=rs.getString("dob");
current=rs.getString("current");
blgr=rs.getString("bloodgroup");
room=rs.getString("roomno");
dateadd=rs.getString("dateadd");
rtype=rs.getString("rtype");
mf=rs.getString("gender");
docname=rs.getString("docname");
tfname.setText(name);
tftel.setText(contact);
tfdob.setText(dob);
taadd.setText(addr);
tahis.setText(hist);
tacur.setText(current);

tfbg.setText(blgr);
tfroom.setText(room);
tfdateadd.setText(dateadd);
tfrtype.setText(rtype);
tfmf.setText(mf);
tfdocname.setText(docname);
}
}
catch(SQLException sq)
{
System.out.println(sq);
}
}
}
}

PatientTableFromDatabase
import java.awt.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
class PatientTableFromDatabase extends JFrame
{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;
PatientTableFromDatabase()
{
Vector columnNames = new Vector();
Vector data = new Vector();
try
{
// Connect to the Database
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:pat");
}
catch(Exception e)
{
System.out.println(e);
}

// Read data from a table


String sql = "Select * from PAT";
Statement stmt = cn.createStatement();
ResultSet rs = stmt.executeQuery( sql );
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();

// Get column names


for (int i = 1; i <= columns; i++)
{
columnNames.addElement(md.getColumnName(i));
}
// Get row data
while (rs.next())
{
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++)
{
row.addElement(rs.getObject(i));
}
data.addElement( row );
}
}
catch(Exception e)
{
System.out.println( e );
}
// Create table with database data
JTable table = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
getContentPane().add( scrollPane );
JPanel buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
}
public static void main(String[] args)
{

PatientTableFromDatabase frame = new PatientTableFromDatabase();


frame.setDefaultCloseOperation( EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}

Report
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
class Report extends JFrame implements ActionListener
{
static Connection cn=null;
static Connection cn2=null;
Statement st=null;
Statement st2=null;
ResultSet rs=null;
ResultSet rs2=null;
JButton bpat,bdoc,bback;
JLabel lpat,ldoc;
Report()
{
super("Reports");
setSize(1024,768);
setVisible(true);
setLayout(null);
lpat=new JLabel("For Patients Reports Click Here :");
lpat.setBounds(100,200,400,30);
add(lpat);
ldoc=new JLabel("For Patients Reports Click Here :");
ldoc.setBounds(100,350,400,30);
add(ldoc);
bpat=new JButton("Display Patient's Report",new ImageIcon("images/emp.png"));
bpat.setBounds(400,200,250,30);
add(bpat);
bdoc=new JButton("Display Doctor's Report",new ImageIcon("images/users.png"));
bdoc.setBounds(400,350,250,30);
add(bdoc);
bback=new JButton("BACK",new ImageIcon("images/restore.png"));
bback.setBounds(480,600,100,30);

add(bback);
bpat.addActionListener(new patreport());
bdoc.addActionListener(new docreport());
bback.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if (ae.getSource()==bback)
{
new start();
setVisible(false);
}
}
class patreport implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
PatientTableFromDatabase frame=new PatientTableFromDatabase();
frame.setDefaultCloseOperation(1);
frame.pack();
frame.setVisible(true);
}
}
class docreport implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
new DoctorTableFromDatabase();
DoctorTableFromDatabase frame=new DoctorTableFromDatabase();
frame.setDefaultCloseOperation(1);
frame.pack();
frame.setVisible(true);
}
}
public static void main(String[] args)
{
new Report();
}
}

TableFromDatabase
import java.awt.*;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;

class PatientTableFromDatabase extends JFrame


{
static Connection cn=null;
Statement st=null;
ResultSet rs=null;
PatientTableFromDatabase()
{
Vector columnNames = new Vector();
Vector data = new Vector();
try
{
// Connect to the Database
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("Jdbc:Odbc:pat");
}
catch(Exception e)
{
System.out.println(e);
}
// Read data from a table
String sql = "Select * from PAT";
Statement stmt = cn.createStatement();
ResultSet rs = stmt.executeQuery( sql );
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();

// Get column names


for (int i = 1; i <= columns; i++)
{
columnNames.addElement(md.getColumnName(i));
}
// Get row data
while (rs.next())
{
Vector row = new Vector(columns);

for (int i = 1; i <= columns; i++)


{
row.addElement(rs.getObject(i));
}
data.addElement( row );
}
}
catch(Exception e)
{
System.out.println( e );
}
// Create table with database data
JTable table = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane(table);
getContentPane().add( scrollPane );
JPanel buttonPanel = new JPanel();
getContentPane().add( buttonPanel, BorderLayout.SOUTH );
}
public static void main(String[] args)
{
PatientTableFromDatabase frame = new PatientTableFromDatabase();
frame.setDefaultCloseOperation( EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}

CONCLUSION
The project Hospital Management System (HMS) is for computerizing the
working in a hospital. The software takes care of all the requirements of an
average hospital and is capable to provide easy and effective storage of
information related to patients that come up to the hospital.
It generates test reports; provide prescription details including various
tests, and medicines prescribed to patient and doctor. It also provides
injection details and billing facility on the basis of patients status whether it
is an indoor or outdoor patient.

REFERENCES
1. The Complete Reference JAVA Seventh Edition: Herbert Schildt
2. Advanced Java Programming: Er. V.K Jain
3. Core and Advanced Java :Cay Horstmann, Gary Cornell
4. Microsoft Office : MS Access
5. Microsoft access 2010 a jargon free guide: Paul Barnett

Das könnte Ihnen auch gefallen