1. RAJOKARI INSTITUTE OF
TECHNOLGY,
RAJOKARI, NEW DELHI-110038
Board of Technical Education
(Govt. of NCT of Delhi)
MAJOR PROJECT REPORT
ON
HOSPITAL MANAGEMENT SYSTEM
Using Java Programming and Database
2019
SUBMITTED IN PARTIAL FULFILLMENT
FOR AWARD OF DIPLOMA IN
COMPUTER ENGINEERING
(Batch 2016-2019)
SUBMITTED BY
Ranjit Singh (1613051041)
UNDER GUIDANCE OF
Mrs. Antima Jain
2. CERTIFICATE
This is to certify that Hospital Management System embodies
the original work done by Ranjit Singh during this project
submission as a partial fulfillment of the requirement for the
Hospital Management System, of Rajokari Institute of
Technology.
Umesh Chand
Principal
(Rajokari Institute of Technology)
Mrs. Antima Jain
Assistant Professor
3. ACKNOWLEDGEMENT
My unreserved gratitude goes to God, who gave me the
opportunity to complete this journey. To my family, I say
thank you for your support. To all my friends I say am
grateful that you all came my way.
Special thanks to my supervisor, Mrs. Antima Jain for her
support and patience throughout this thesis project.
Thanks to Mr. for the knowledge I gained from him and for
pushing me to the extreme during his programming classes. I
actually learnt a lot from him.
Ranjit Singh
4. CONTENTS
1. Introduction
1.1 Purpose
1.2 Scope
1.3 Relevant Tools and Technologies
1.3.1 Java Programming Language
1.3.2 JDK and JRE
1.3.3 MySQL
1.3.4 Netbeans IDE
1.4 Overview
2. OverallDescription
2.1 Goals of Proposed System
2.2 Background
2.3 Current Management System
2.4 ProjectRequirements
2.5 User Characteristics
2.6 Constraints
2.7 Definition of Problems
2.8 Alternative Solutions
3. Feasibility Study
3.1 Technical Feasibility
3.2 EconomicalFeasibility
3.3 Operational Feasibility
3.4 Schedule Feasibility
4. Entity Relationship Diagram
5. Database and GUI Design
5.1 Database Design
5.2 GUI Design
5.2.1 LoginForm
5. 5.2.2 Home Screen
5.2.2.1 Users Menu
a) New User
b) Change Password
c) Login Details
5.2.2.2 Patients Menu
a) Registration
b) Services
5.2.2.3 Doctors Menu
a) Entry
5.2.2.4 Rooms Menu
a) Add Rooms
b) Admit
c) Discharge
d) Billing
5.2.2.5 Help
a) About
b) Logout
6. Implementation
6.1 Login Form
6.2 Home Page
6.3 New User
6.4 Update User
6.5 Delete Patient Record
6.6 Services
6.7 Patient Registration
6.8 Admit Patient
6.9 Discharge Patient
6.10 Rooms
6.11 Generating Bill
7. Testing
8. Conclusion
9. Bibliography
6. LIST OF FIGURES AND TABLES
Figure 1. Entity Relationship Diagram
Figure 2. Login Form
Figure 3. Home Screen
Figure 4. Users Menu
Figure 5. New User Form
Figure 6. Change Password Form
Figure 7. Login Details Form
Figure 8. Patients Menu
Figure 9. Registration Form
Figure 10. Services Form
Figure 11. Doctors Menu
Figure 12. Entry Form
Figure 13. Rooms Menu
Figure 14. Add Rooms Form
Figure 15. Admit Form
Figure 16. Discharge Form
Figure 17. Bill Form
Figure 18. Help Menu
Figure 19. About Form
Table 1. Project Requirements
Table 2. User Table
Table 3. Registration Table
Table 4. Patient Registration Table
Table 5. Admit Patient Table
Table 6. Discharge Patient RoomTable
Table 7. RoomTable
Table 8. Services Table
Table 9. Bill RoomTable
Table 10. Software testing template and results
7. 1. Introduction
1.1) Purpose
The Software is for the automation of Hospital Management.
It maintains one levels of user:-
Administrator Level
The Software includes:-
Maintaining Patient ‘s details.
Maintaining Doctor’s details.
Maintaining Room records.
Bill generation.
1.2) Scope
It can be used in any Hospital, Clinic and Dispensaryfor maintaining
patient details.
1.3) Relevant Tools and Technologies
This chapter presents some discussions about the relevant tools and technologies
used to develop the e-commerce web application. Some of the tools and
technologies are Java programming language, JDK and JRE, MySQL and
Netbeans IDE.
1.3.1 Java Programming Language
This is the main programming language used to develop the application. The Java
Programming Language was formerly developed by Sun Microsystems as
proposedbyJames Gosling. It was first released in 1995. It runs on Mac OS,
Windows, the different versions of UNIX, and other platforms. Java is considered
to be secure and robust. Also, it is multithreading and platform independent (unlike
C and C++)
1.3.2 JDK and JRE
The Java Development Kit (JDK) is a software development environment for
developing applets and applications written in Java. It consists of an interpreter, a
Java compiler, a documentation generator (JavaDoc) and several other tools for
building Java applications. The Java Runtime Environment is a component of JDK,
and it consists of the Java Virtual Machine (JVM), libraries, files and other
8. components for running applications written in Java. JVM is an implementation of
JRE for running Java bytecode.
1.3.3 MySQL
MySQL is a free, open source relational database management system (RDBMS)
that supports Structured QueryLanguage(SQL).An RDBMS is a system used to
manage databases, and it is made up of tables containing columns and rows, where
the tables are related by keys. MySQL DBMS is the world’s most popular open
sourcedatabase system and one of the most commonly used database systems for
Java web applications. It is one of the fastest RDBMS and it is easy to use. Also, it
runs on almost all platforms, such as Windows, Linux and OS X.
1.3.4 Netbeans IDE
Netbeans is an integrated development environment (IDE) for Java Netbeans
allows applications to be developed from a set of modular software components
called modules. Netbeans runs on Windows, macOS, Linux and Solaris. In
addition to Java development, it has extensions for other languages like PHP, C,
C++ and JavaScript. Applications based on Netbeans, including the Netbeans IDE,
can be extended by third party developers. The latest release of Netbeans is
Netbeans IDE 10.0, which was released in December 2018.
1.4) Overview
Projectis related to Hospital Management System.
The projectmaintains one level of users:-
Administrator Level-Doctor
Main facilities available in this projectare:-
Maintaining records of indoor/outdoorpatients.
Maintaining records of services provided to the patient.
Maintaining records of doctors registered with the hospital/clinic.
Providing billing details for indoor/outdoorpatients.
Maintaining details of users logging in.
. Administrator can search a patient’s record.
9. 2. Overall Description
2.1) 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 properstorage of information.
4. No Redundancy: - In the proposedsystem utmost care would be that
no information is repeated anywhere, in storage or otherwise. This would
assure economic use of storage space and consistencyin the data stored.
5. Immediate retrieval of information: - The main objective of
proposed system is to provide for a quick and efficientretrieval 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 developedwithin a short period of time and fit in the
limited budget of the user.
10. 2.2) 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 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. Wheneverthe 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 onthe 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 pre-formatted sheets,
which are kept in a file.
Information about various diseases is not kept as any document. Doctor
themselves do this job by remembering various medicines.
All this work is done manually by the receptionistand other operational staff
and lot of papers are needed to be handled and taken care of. Doctors
have to remembervarious medicines available for diagnosis and
sometimesmiss better alternatives as they can’t rememberthem at that
time.
11. 2.3) Current Management System
Most hospitals face several challenges with Hospital Management
System because some of them are still using manual processes, while the
ones that use the computerized method are also faced with the challenge
of adjusting to it. Such problems include:
High cost of software development, deployment and improvement.
Difficulty in migrating from manual processes, because both staff and
patients are used to the manual processes and so are unable to speedily
cope with the new system.
Lack of IT friendly medical personnel is also presenting several
challenges.
Huge influx of patients visiting government hospitals makes the
process of migrating to automated processes highly difficult. They do
not have the patience to wait for registration and data entry and often fail
to understand the functioning of automated processes.
Considering the above, there is need for the improvement of
computerized hospital management system to such hospitals as it would
help provide and customize clinical data, enable faster diagnosis with
ready-made templates, allow doctors to follow advanced medical
prescription patterns, and so on.
12. 2.4) Project Requirements
Hardware Requirements
Processor RAM Disk Space
Pentium IV or
higher
64 MB or higher 150 MB
Software Requirements
Operating System Database
Win- 07 , Win -10 or any other
higher version
MySQL 5.1 or higher
Table 1: Project Requirements
2.5) User Characteristics
Every user should be:
Comfortable to work on computer.
He must have knowledge in medical field.
He must also have basic knowledge of English too.
2.6) Constraints
GUI is only in English.
Login and password is used for identification of user and there is no
facility for guest.
13. 2.7) Definitions of problems
Problems with conventional system
1. Lack of immediate retrievals: -The information is very difficult to
retrieve and to find particular information like- E.g. - To find out about the
patient’s history, the user has to go through various registers.This results
in inconvenience and wastage of time.
2. Lack of immediate information storage: - The information
generated by various transactions takes time and efforts to be stored at
right place.
3. Lack of prompt updating: - Various changes to information like
patient details or immunization details of child are difficultto make as paper
work is involved.
4. Error prone manual calculation: - Manual calculations are error
prone and take a lot of time this may result in incorrect information. For
example calculation of patient’s bill based on various treatments.
5. Preparation of accurate and prompt reports: - This becomesa
difficult task as information is difficultto collectfrom various registers.
2.8) Alternative Solutions
1. Improved ManualSystem:-
One of the alternative solutions is the improvement of the manual system.
Anything, which can be done by using automated methods,can be done
manually. But the question arises how to perform thing manually in a sound
manner. Following are some suggestions,which can be useful in the
manual system.
A more sophisticate register maintenance for various Patient Information,
Doctordiary, Immunization Details and a good system for writing bill
14. amount employees and stock availed for the customers can be maintained
at central place.
Adequate staff may be maintained so that updates are made at the very
moment at the same time. Properperson for properwork should be made
responsible so that a betterefficiencycould be achieved. This needs a lot
of work force.
2. Batch System:-
Another alternative solution can be used of computerbased batch system
for maintaining the information regarding purchase details, customers and
employees.A batch system refers to a system in which data is processed
in a periodicalbasis.
The batch system is able to achieve most of the goals and sub goals. But a
batch system data is processed in sequential basis. Therefore batch
system is not suggested.
3. Online System:-
This system (HMS) provides online storage/updates and retrieval facility.
This system promises very less or no paper work and also provides help to
Doctorand operational staff.
In this system everything is stored electronically so very less amount of
paperwork is required and information can be retrieved very easily without
searching here and there into registers.This system is beendiscussed
here.
3. 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 proposalaccording to its workability, impact of the
organization, ability to meet needs and effective use of the resources.It
focuses onthese major questions:
1. What are the user’s demonstrable needs and how does a candidate
system meet them?
2. What resources are available for given candidate system?
3. What are the likely impacts of the candidate system on the organization?
4. Whether it is worth to solve the problem?
15. 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 projectleader.
Prepare system flowcharts.
Enumerate potential proposedsystem.
Define and identify characteristics of proposedsystem.
Determine and evaluate performance and costeffective of each
proposed system.
Weightsystem performance and costdata.
Selectthe best-proposed system.
Prepare and report final project directive to management.
3.1) Technical feasibility
A study of availability of resources that may affectthe ability to achieve an
acceptable system.This evaluation determines whether the technology
needed forthe proposed system is available or not.
Can the work for the projectbe done with current equipmentexisting
software technology& available personal?
Can the system be upgraded if developed?
If new technologyis needed then what can be developed?
This is concerned with specifying equipmentand software that will
successfullysatisfy the user requirement. The technical needs of the
system may include:
Front-endand back-end selection
An important issue for the developmentof a project is the selectionof
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
developmentof the project.
The aspects of our study included the following factors.
16. Front-endselection:
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 supportsome popular back end like MySQL.
According to the above stated features we selected Netbeans IDE 6.5.1 as
the front-end for developing our project.
Back-endSelection:
1. Multiple user support.
2. Efficientdata handling.
3. Provide inherent features for security.
4. Efficientdata retrieval and maintenance.
5. Stored procedures.
6. Popularity.
17. 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 MySQL as the backend.
The technical feasibility is frequently the most difficultarea encountered at
this stage. It is essentialthat the process ofanalysis and definition be
conducted in parallel with an assessmentto technical feasibility. It centers
on the existing computersystem (hardware, software etc.) and to what
extent it can supportthe proposed system.
3.2) Economical feasibility
Economic justification is generally the “Bottom Line” considerationfor most
systems.
Economic justification includes a broad range of concerns that includes
costbenefit analysis. In this we weight the costand 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
designphase.
The financial and the economic questions during the preliminary
investigation are verified to estimate the following:
The costto conducta full system investigation.
The cost of hardware and software for the class of application being
considered.
The benefits in the form of reduced cost.
The proposedsystem will give the minute information, as a result the
performance is improved which in turn may be expected to provide
increased profits.
18. This feasibility checks whether the system can be developedwith the
available funds. The Hospital ManagementSystem does not
require enormous amount of money to be developed.This can be
done economicallyif planned judicially, so it is economicallyfeasible.
The cost of projectdepends uponthe number of man-hours required.
3.3) Operational Feasibility
It is mainly related to human organizations and political aspects.The points
to be consideredare:
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.
3.4) Schedule feasibility
Time evaluation is the most important considerationin the developmentof
project.The time schedule required for the developedof this project is very
important since more developmenttime effectmachine time, cost and
cause delay in the developmentof other systems.
A reliable Hospital ManagementSystem can be developed inthe
considerable amount of time.
19. 4. Entity Relationship Diagram
Figure 1: Entity Relationship Diagram
Hospital Management
System
have
Admin
PasswordLogin
Id
do
Login
do
Patient
Registration
do
Doctor
Registration
do
Generate
Bills
create
ee
New Users
do
Admit
Patients
do
Discharge
Patients
20. 5. Database and GUI Design
Every Java application needs to have an operational database to store its
generated data. More so, a simple and interactive Graphical User
Interface (GUI) is one of the success indicators of any application
project. This chapter presents the database and GUI design for this
Hospital Management application.
5.1 Database Design
MySQL database management system is the most popular database
system for Java applications because of its speed, reliability, and
flexibility. All the data generated by this application are managed on
MySQL database system. The following numbered list gives a brief
explanation of these tables.
5.1.1. Data Tables
1. Users Table
Field Name Datatype Size Description
User_name Text 20 Primary Key
Password Text 20
Table 1: Users Table
2. Registration Table
Field Name Datatype Size Description
Name Text 20
User_Name Text 20 Primary Key
Password Text 20
21. Email_id Text 30
Contact_No Number 10
Table 2: Registration Table
3. Doctor Table
Field Name Datatype Size Description
Doctor ID Number 10 Primary Key
Doctor Name Text 20
Father Name Text 20
Email Text 50
Contact No. Text 11
Qualifications Text 50
Gender Text 01
Blood Group Text 05
Date of
Joining
Date
Address Text 100
Table 3: Doctor Table
4. Patient Registration Table
Field Name Datatype Size Description
Patient ID Number 10 Primary Key
Patient Name Text 20
Father Name Text 20
Email Text 30
Contact No. Number 11
Age Number 02
Remarks Text 100
22. Gender Text 01
Blood Group Text 03
Address Text 100
Table 4: Patient Registration Table
5. Admit Patient Room Table
Field Name Datatype Size Description
Patient ID Number 10 Primary Key
Disease Text 50
Admit Date Date
Room No. Number 05 References
from ‘Room’
Table
Doctor ID Number 10 References
from ’Doctor’
Table
AP_Remarks Text 50
Table 5: Admit Patient Room Table
6. Discharge Patient Room Table
Field Name Datatype Size Description
Admit ID Number 20
Discharge
Date
Date
DP_Remarks Text 50
Table 6: Discharge Patient Room Table
23. 7. Room Table
Field Name Datatype Size Description
Room No. Number 05 Primary Key
Room Type Text 10
Room Charges Number 10
Room Status Text 10
Table 7: Room Table
8. Services Table
Field Name Datatype Size Description
Service Name Text 20
Service Date Date
Patient ID Number 10 References
from ‘Patient
Registration’
Table
Service
Charges
Number 10
Service ID Number 10 Primary Key
Auto-
increment
Table 8: Services Table
9. Bill Room Table
Field Name Datatype Size Description
Discharge ID Number 05
Billing Date Date
No. of Days Number 05
Service
Charges
Number 10
24. Payment
Mode
Text 20
Payment
Mode Details
Text 100
Room Charges Number 10
Total Room
Charges
Number 10
Total Charges Number 10
Bill No. Text 15 Primary Key
Table 9: Bill Room Table
5.2 GUI Design
The user interfaces for this application were designed using Netbeans
IDE. The following subsections present the descriptions of these
interfaces.
5.2.1 Login Form
The login form of the application is shown in Figure 2.It is the first form
of the application where the user is prompted to enter the username and
the password.
25. Figure 2: Login Form
5.2.2 Home Screen
The home screen of the application is as shown in the Figure 3. It
contains a menu bar with different menus viz. Users, Patients, Doctors,
Rooms and Help. This form allows the user to navigate through these
menus and do the relevant task.
Figure 3: Home Screen
26. The various options available under these menus are as follows:
5.2.2.1 Users Menu
Figure 4: Users Menu
a) New User
This option allows the user to register another user using his/her
username. The shortcut key to select this option is Ctrl+N.
Figure 5 shows the form which is to be filled to register as user.
27. Figure 5: New User Form
b) Change Password
This option lets the user to change his/her login password. User
can also change his/her password by using the shortcut key Ctrl+C.
The Change Password form is as shown in the Figure 6.
Figure 6: Change Password Form
28. c) Login Details
This option lets the administrator see the details of other users. The
details can also be seen pressing Ctrl+D.
Figure 7 shows the form containing login details.
Figure 7: Login Details
5.2.2.2 Patients Menu
Figure 8: Patients Menu
29. a) Registration
The registration form is as shown in the Figure 9. This form is
accessed when the user clicks the registration option or presses the
key Ctrl+R. On this form, patient is registered by filling the form.
It allows selecting a doctor from a list of available doctors by
clicking on the doctor’s name. It also shows the list of registered
patients.
Figure 9: Registration Form
b) Services
30. The services form is as shown in the Figure 10. It allows selecting
the name of the patient receiving services from a table containing
the name of registered patients.
The shortcut key Ctrl+S can also be used to open this form.
Figure 10: Services Form
5.2.2.3 Doctors Menu
31. Figure 11: Services Menu
a) Entry
Figure 12 shows the Doctor’s Registration form which can be
accessed by selecting Entry option from Doctors Menu or by
pressing Ctrl+E.
This form registers the doctor with the hospital/clinic and marks
him/her as available to treat the patients.
32. Figure 12: Doctor’s Registration Form
5.2.2.4 Rooms Menu
Figure 13: Rooms Menu
a) Add Rooms
Figure 14 shows the Add Room form. This option adds a
room in the hospital and is marked as vacant by default. The
room type can either be General or Deluxe. The form also
shows a list of rooms along with their type, charges and
status.
33. Figure 14: Add Rooms Form
b) Admit
The Patient Admit form is as shown in Figure 15. The form
shows two tables from which the patient to be admitted and
the doctor attending the patient can be choosen.
Figure 15: Patient Admit Form
34. c) Discharge
Figure 16 shows the discharge form. By clicking the”>” button
(placed alongside the Patient ID text field) , all the entry gets
filled . Only “Discharge Date” and “Remarks “need to be filled
to discharge the patient.
Figure 16: Discharge Form
d) Billing
The successfully discharged patient has to pay the bill for the
treatment and services received by him at the hospital. The
Billing form is as shown in Figure 17.
35. The button”>” (placed alongside the Patient ID textfield)
displays the list of patients who have been discharged. The
Admin selects the name for whom he wants to generate bill.
The patient info gets filled when Admin selects the name. The
“Payment Details” are filled by the admin and a “Bill No.” is
generated.
Figure 17: Billing Form
5.2.2.4 Help Menu
36. Figure 18: Help Menu
a) About
Figure 19 shows the About Menu which recites the facility
provided by this Hospital Management System and also
briefs about the developer of this application.
Ctrl+I can also be used to jump to this option.
37. Figure 19: About
b) Logout
By clicking on the Logout menu or by pressing the key
Ctrl+L user logs out from the application.
6. Implementation
Implementation in software development is the process of realizing an
application’s requirements and design. It mainly involves mapping the
design into coding in order to achieve the specifications stated for the
application. This section will describe the key implementation processes
and some code snippets of this desktop application.
38. 6.1 Login Page
Code Snippet 1 shows the process for logging on the application.
The username and password entered in the form are matched with the
user details stored in the database. If the details entered are identical
with the stored information then the permission is granted otherwise a
message is displayed as “Login Failed!!”
The username ”Ranjit” and password “hr36” can be used to login for the
first time.
import javax.swing.JOptionPane;
import java.sql.*;
public class login extends javax.swing.JFrame {
public login() {
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
if (txtUsername.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter user name");
return;
}
if (jPassword.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter password");
return;
}
con=Connect.ConnectDB();
String sq1= "select * from users where user_name= '" + txtUsername.getText() +
"' and password ='" + jPassword.getText() + "'";
try{
pst=con.prepareStatement(sq1);
rs= pst.executeQuery();
if (rs.next()){
this.hide();
Main frm=new Main();
41. obj1.setVisible(true);
}
private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent
evt) {
login obj1= new login();
obj1.setVisible(true);
}
6.3 New User
The implementation of registering new user is given below.
Connect.DB() method is used to connect the application with database.
The “fieldname.equals()”(the field name may vary) method makes sure
that none of the entry is left blank. The string “sql2” is used to check
that already existed username in the database is not entered while
registering as a new user. If any text field is left blank then a
corresponding message is shown in dialog box with the help of
JOPtionPane.showMessageDialog() method. If the username entered is
not as same as one in the database then string “sql2” is used to enter the
details entered in the registration form to be stored in the database.
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
public class NewUser extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
public NewUser() {
initComponents();
45. Connect.DB() method is used to connect the application with database.
The string “sql2” is responsible for updating the users detail stored in the
database.
try{
con=Connect.ConnectDB();
Statement stmt1= con.createStatement();
String s= cmbRoomNo.getSelectedItem().toString();
String t= cmbRoomNo1.getSelectedItem().toString();
if (!t.equals(s)){
String sql2="Select RoomNo from Room where RoomNo= '" +
cmbRoomNo.getSelectedItem()+ "' and RoomStatus='Booked'";
rs=stmt1.executeQuery(sql2);
if(rs.next()){
JOptionPane.showMessageDialog( this, "Room is already booked","Error",
JOptionPane.ERROR_MESSAGE);
cmbRoomNo.setSelectedItem("");
cmbRoomNo.requestDefaultFocus();
return;
}
}
Code Snippet 3: Updating user details
6.5 Delete Patient Record
Code Snippet 4 shows the implementation of registering patient.
Connect.DB() method is used to connect the application with database.
The string “sql” is responsible for deleting the users detail stored from
the database.
private void DeleteActionPerformed(java.awt.event.ActionEvent evt) {
try
{
int P = JOptionPane.showConfirmDialog(null," Are you sure want to
delete ?","Confirmation",JOptionPane.YES_NO_OPTION);
if (P==0)
46. {
con=Connect.ConnectDB();
String sql= "delete from registration where user_name = '" +
txtUsername.getText() + "'";
pst=con.prepareStatement(sql);
pst.execute();
String sql1= "delete from Users where user_name = '" +
txtUsername.getText() + "'";
pst=con.prepareStatement(sql1);
pst.execute();
JOptionPane.showMessageDialog(this,"Successfully deleted");
reset();
}
}catch(SQLException ex){
JOptionPane.showMessageDialog(this,ex);
}
}
Code Snippet 4: Deleting patient details
6.6 Services
The implementation of providing services to the patient is shown below.
Connect.DB() method is used to connect the application with database.
Get_Data1() method is used to retrieve patient details from database
using string “sql”.
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
47. public class Services extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
public Services() {
initComponents();
setLocationRelativeTo(null);
txtServiceID.setVisible(false);
Get_Data1();
}
private void Get_Data1(){
try{
con=Connect.ConnectDB();
String sql="select PatientID as 'Patient ID', PatientName as 'Patient
Name' from Patientregistration order by PatientName";
pst=con.prepareStatement(sql);
rs= pst.executeQuery();
tblPatient.setModel(DbUtils.resultSetToTableModel(rs));
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
private void Reset()
{
txtPatientID.setText("");
txtServiceCharges.setText("");
txtPatientName.setText("");
txtServiceDate.setText("");
txtServiceName.setText("");
txtSave.setEnabled(true);
txtUpdate.setEnabled(false);
txtDelete.setEnabled(false);
}
48. private void txtNewActionPerformed(java.awt.event.ActionEvent
evt) {
Reset();
}
private void txtSaveActionPerformed(java.awt.event.ActionEvent evt) {
try{
con=Connect.ConnectDB();
if (txtServiceName.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter service name");
return;
}
if (txtServiceDate.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter service date");
return;
}
if (txtPatientID.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please retrieve patient id");
return;
}
if (txtServiceCharges.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter service charges");
return;
}
String sql= "insert into
Services(ServiceName,ServiceDate,PatientID,ServiceCharges)values('
"+ txtServiceName.getText() + "','"+ txtServiceDate.getText() + "','" +
txtPatientID.getText() + "'," + txtServiceCharges.getText() + ")";
pst=con.prepareStatement(sql);
pst.execute();
JOptionPane.showMessageDialog(this,"Successfully
saved","Record",JOptionPane.INFORMATION_MESSAGE);
txtSave.setEnabled(false);
}catch( SQLException ex){
49. JOptionPane.showMessageDialog(this,ex);
}
}
private void txtDeleteActionPerformed(java.awt.event.ActionEvent
evt) {
try{
int P = JOptionPane.showConfirmDialog(null," Are you sure want to
delete ?","Confirmation",JOptionPane.YES_NO_OPTION);
if (P==0)
{
con=Connect.ConnectDB();
String sql= "delete from Services where ServiceID = " +
txtServiceID.getText() + "";
pst=con.prepareStatement(sql);
pst.execute();
JOptionPane.showMessageDialog(this,"Successfully deleted");
Reset();
}
}catch(SQLException ex){
JOptionPane.showMessageDialog(this,ex);
}
}
private void txtUpdateActionPerformed(java.awt.event.ActionEvent
evt) {
try{
con=Connect.ConnectDB();
String sql= "update Services set ServiceName='" +
txtServiceName.getText() +"',ServiceDate='" +
txtServiceDate.getText()+ "',PatientID='" + txtPatientID.getText() +
"',ServiceCharges='" + txtServiceCharges.getText() + "' where
ServiceID='" + txtServiceID.getText() + "'";
pst=con.prepareStatement(sql);
pst.execute();
51. 6.7Patient Registration
The implementation of registering patient is shown in the code.
Connect.DB() method is used to connect the application with database.
The “fieldname.equals()”( the field names may vary) method makes sure
that none of the entry is left blank. If any text field is left blank then a
corresponding message is shown in dialog box with the help of
JOPtionPane.showMessageDialog() method. The string “sql2” is used to
check that already existed username in the database is not entered while
registering as a new user. If the username entered is not as same as one
in the database then string “sql” is used to enter the details entered in the
registration form to be stored in the database.
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
public class Registration extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
public Registration() {
initComponents();
}
try{
con=Connect.ConnectDB();
if (txtId.getText().equals("")) {
OptionPane.showMessageDialog( this, "Please enter patient id","Error",
JOptionPane.ERROR_MESSAGE);
return;
52. }
if (txtName.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter patient
name","Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (txtFname.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter Father's
name","Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (txtAdd.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter address","Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if (txtContact.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter contact
no.","Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (txtAge.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter age","Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if (cmbGender.getSelectedItem().equals("")) {
JOptionPane.showMessageDialog( this, "Please select gender","Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if (cmbBG.getSelectedItem().equals("")) {
54. private void btnGetDataActionPerformed(java.awt.event.ActionEvent
evt) {
this.hide();
PatientRec frm=new PatientRec();
frm.setVisible(true);
Code Snippet 6: Registering patient
6.8 Admit Patient
The implementation of admitting patient is given in the code below.
Connect.DB() method is used to connect the application with database.
Get_Data1() method is used to retrieve patient details from database
using string “sql”.
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
public class Patient_Admit_Room extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
public Patient_Admit_Room() {
initComponents();
setLocationRelativeTo(null);
fillcombo();
cmbRoomNo.setSelectedIndex(-1);
cmbRoomNo1.setVisible(false);
Get_Data1();
56. JOptionPane.showMessageDialog( this, "Please enter admit
date","Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (cmbRoomNo.getSelectedItem().equals("")) {
JOptionPane.showMessageDialog( this, "Please select room no.","Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if (txtDoctorID.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please retrieve doctor
id","Error", JOptionPane.ERROR_MESSAGE);
return;
}
if (txtDoctorName.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter retrieve doctor
name","Error", JOptionPane.ERROR_MESSAGE);
return;
}
Statement stmt1= con.createStatement();
String sql2="Select RoomNo from Room where RoomNo= '" +
cmbRoomNo.getSelectedItem()+ "' and RoomStatus='Booked'";
rs=stmt1.executeQuery(sql2);
if(rs.next()){
JOptionPane.showMessageDialog( this, "Room is already
booked","Error", JOptionPane.ERROR_MESSAGE);
cmbRoomNo.setSelectedItem("");
cmbRoomNo.requestDefaultFocus();
return;
}
Statement stmt= con.createStatement();
57. String sql1="Select PatientID,AdmitDate from AdmitPatient_Room
where PatientID= '" + PatientID.getText() + "' and AdmitDate='" +
txtAdmitDate + "'";
rs=stmt.executeQuery(sql1);
if(rs.next()){
JOptionPane.showMessageDialog( this, "Record already exists","Error",
JOptionPane.ERROR_MESSAGE);
return;
}
String sql= "insert into
admitpatient_room(PatientID,Disease,AdmitDate,RoomNo,DoctorID,A
P_Remarks)values('"+ PatientID.getText() + "','"+ txtDisease.getText()
+ "','"+ txtAdmitDate.getText() + "','"+
cmbRoomNo.getSelectedItem()+ "','" + txtDoctorID.getText() + "','"+
txtRemarks.getText() + "')";
Pst =con.prepareStatement(sql);
pst.execute();
String sql3= "update room set RoomStatus='Booked' where RoomNo='"
+ cmbRoomNo.getSelectedItem() + "'";
pst=con.prepareStatement(sql3);
pst.execute();
JOptionPane.showMessageDialog(this,"Successfully
admitted","Patient",JOptionPane.INFORMATION_MESSAGE);
btnSave.setEnabled(false);
}catch( SQLException ex){
JOptionPane.showMessageDialog(this,ex);
}
}
Code Snippet 7: Admitting Patient
6.9 Discharge Patient
The implementation of discharging patient is given in the code.
58. Connect.DB() method is used to connect the application with database.
The string “sql” is responsible for inserting the discharge details of the
patient in the table “Discharge Patient Room”. The string “sql3” updates
the table” Room” and marks the status of room as vacant.
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
public class Patient_Discharge_room extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
public Patient_Discharge_room() {
initComponents();
setLocationRelativeTo(null);
}
private void btnSaveActionPerformed(java.awt.event.ActionEvent evt)
{
try{
con=Connect.ConnectDB();
if (PatientID.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please retrieve Patient ID");
return;
}
if (txtPatientName.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please retrieve patient
Name");
return;
59. }
if (txtGender.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please retrieve Gender");
return;
}
if (txtBloodGroup.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please retrieve blood group");
return;
}
if (txtDisease.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please retrieve disease");
return;
}
if (txtAdmitDate.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please retrieve admit date");
return;
}
if (txtDoctorID.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please retrieve doctor id");
return;
}
if (txtDoctorName.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter retrieve doctor
name");
return;
}
if (txtDischargeDate.getText().equals("")) {
JOptionPane.showMessageDialog( this, "Please enter discharge date");
return;
}
Statement stmt;
stmt= con.createStatement();
String sql1="Select AdmitID from DischargePatient_Room
60. where AdmitID= " + PatientID.getText() + "";
rs=stmt.executeQuery(sql1);
if(rs.next()){
JOptionPane.showMessageDialog( this, "Record already exists");
return;
}
String sql= "insert into
DischargePatient_Room(AdmitID,DischargeDate,DP_Remarks)values("+
PatientID.getText() + ",'"+ txtDischargeDate.getText() + "','"+
txtRemarks.getText() + "')";
pst=con.prepareStatement(sql);
pst.execute();
String sql3= "update room set RoomStatus='Vacant' where RoomNo='"
+ txtRoomNo.getText() + "'";
pst=con.prepareStatement(sql3);
pst.execute();
JOptionPane.showMessageDialog(this,"Successfully
discharged","Patient",JOptionPane.INFORMATION_MESSAGE);
btnSave.setEnabled(false);
}catch( SQLException ex){
JOptionPane.showMessageDialog(this,ex);
}
}
private void btnDeleteActionPerformed(java.awt.event.ActionEvent
evt) {
try{
int P = JOptionPane.showConfirmDialog(null," Are you sure want to
delete ?","Confirmation",JOptionPane.YES_NO_OPTION);
if (P==0)
{
con=Connect.ConnectDB();
67. 6.11 Generating Bill
The method for generating bill after discharging the patient is shown
below. Connect.DB() method is used to connect the application with
database. The string “sql1” is responsible for verifying patient’s detail
stored in the database is not same. Further, the string, “sql” is
responsible for inserting details of the form “Bill” in the table
Bill_Room.
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.lang.String;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
public class Bill_Room extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
public Bill_Room() {
initComponents();
setLocationRelativeTo(null);
Get_Data1();
}
private void Get_Data1(){
try{
con=Connect.ConnectDB();
String sql="select PatientRegistration.PatientID as 'Patient ID', PatientName as
'Patient Name',sum(serviceCharges) as 'Service Charges' from
Services,PatientRegistration where
Services.PatientID=PatientRegistration.PatientID group by
72. Bill_RoomRec frm= new Bill_RoomRec();
frm.setVisible(true);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
this.hide();
Patient_Discharge_roomRec2 frm = new Patient_Discharge_roomRec2();
frm.setVisible(true);
}
Code Snippet 9: Generating Bill
7. TESTING
Software testing is carried out on a software application mainly to detect
software bugs or missing requirements of the application. It involves the
process of investigating and evaluating a software product or application
in order to make sure that its business and technical requirements are
fulfilled. For the purpose of testing, this application was deployed and
run on Netbeans IDE 6.5.1. For simplicity, the testing template in
Table 10 was used for the testing.
Table 10. Software testing template and results.
S.No. Test
Description
Steps Expected
System
Response
Status
(Pass/Fail)
1. Access the login
form of the
application to
view home
screen.
Enter the
username and
password in the
login form.
The home
screen of the
application is
displayed.
Pass
73. 2. Registering New
User
Go to User
menu. Select
New User
option. Fill the
form and click
on Save button.
A message
”Successfully
Registered” is
displayed in a
dialog box.
Pass
3. Updating User
Details
Click “Get
Data” button.
Select the user
whose details
need to be
updated and
click on Save
button.
A message
”Successfully
Updated” is
displayed in a
dialog box.
Pass
4. Viewing Login
Details
Go to Users tab
and select
Login Details.
A form
containing
username and
password is
displayed.
Pass
5. Registering New
Patient
Go to Patient
menu. Select
Registration
option. Fill the
form and click
on Save button.
A message
”Successfully
Registered” is
displayed in a
dialog box.
Pass
6. Services Go to Patient
menu. Select
Services
option. Fill the
form and click
on Save button.
A message
”Successfully
Registered” is
displayed in a
dialog box.
Pass
7. Doctor
Registration
Go to Doctors
menu. Select
Entry option.
Fill the form
A message
”Successfully
Registered” is
displayed in a
Pass
74. and click on
Save button.
dialog box.
8. Adding Rooms Go to Rooms
menu. Select
Add Rooms
option. Fill the
form and click
on Save button.
A message
”Room Added”
is displayed in a
dialog box.
Pass
9. Admitting
Patient
Go to Rooms
Menu. Select
Admit option.
Fill the form
and click on
Save button.
A message
”Successfully
admitted” is
displayed in a
dialog box.
Pass
10. Discharging
Patient
Go to Rooms
Menu. Select
Discharge
option. Fill the
form and click
on Save button.
A message
”Successfully
discharged” is
displayed in a
dialog box.
Pass
11. Generating Bill Go to Rooms
Menu. Select
Discharge
option. Fill the
form and click
on Save button.
A bill no. is
generated by
concatenating
patient ID and
Date of
discharge.
Pass
12. Help Go to About
Menu. Select
Help option.
A form
containing
description of
the application
is displayed
Pass
75. 8. CONCLUSION
The project Hospital ManagementSystem (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, diet
advice, and medicines prescribed to patient and doctor. It also provides injection
details and billing facility on the basis of patient’s status whether it is an indoor or
outdoorpatient. The system also provides the facility of backup as per the
requirement.
Future Enhancements
The proposed system is Hospital Management System. We can enhance
this system by including more facilities like pharmacy system for the
stock details of medicines in the pharmacy. Providing such features
enable the users to include more comments in the system.
76. 9. BIBLIOGRAPHY
1. Informatics Practices –XI by Sumita Arora
2. Informatics Practices –XII by Sumita Arora
Web References:
1. www.istockphotos.com
2. www.google.com
3. www.geeksforgeeks.com