Вы находитесь на странице: 1из 88

HOSPITAL MANAGEMENT SYSTEM

PROBLEM STATEMENT
Aim:
To write a problem statement for Hospital Management System application.
Problem Statement:
This project is aimed to automate the hospital management system. The
purpose of the project entitled as HOSPITAL MANAGEMENT SYSTEM is to
computerize the Front Office Management of Hospital to develop software which is user
friendly, simple, fast, and cost effective. It deals with the collection of patients
information, diagnosis details, etc. Traditionally, it was done manually. The main
function of the system is to register and store patient details and doctor details and
retrieve these details as and when required, and also to manipulate these details
meaningfully. This function of Hospital Management Information System deals with
registering the new Patient by giving unique Identification Number to the Patient. This
number is unique throughout the System for identifying the patient. Simultaneous update
and changes are made to the databases. Identification number is also provided to doctor
to retrieve and to change doctor details. The software is used by administrator or
receptionist in the hospital. The software is secured by username and password, accessed
by administrator or receptionist of the hospital.

1. Login:
This module is used to login to the Hospital Management System.

2. Patient:
This module is for adding, querying, editing and deleting patient details in the
database.

3. Doctor:
This module is used to retrieve doctor details from the database and also for
adding new doctor details in the database.

4. Billing Details:
This module is to add billing details such as consultation fee, pharmacy bill, other
expense, ward rent and medical test.

5. Username and Password Change:


This module is to change desired username and password by the administrator.

Result:
Thus the problem statement for Career Guidance has been successfully defined.

SOFTWARE REQUIREMENT SPECIFICATION


Aim:
To prepare the SRS documentation for the Hospital Management System.
1. Introduction:
This documentation aims at defining the overall software requirements for
Hospital Management System.
1.1 Purpose:

The software is for maintaining records for Hospital Management.


It is used by either administrator or receptionist.
The software includes: Maintaining patient details.
Maintaining doctor details.
Bill generation.

1.2 Scope:
It can be used in any hospital or clinic for maintaining patient records and their
bill generation.
1.3 Definitions and Abbreviations:
Not applicable.
1.4 References:
Not applicable.
1.5 Overview:
The rest of the document describes the various system requirements, interfaces,
features and functionalities in detail.
2. Overall Description:
This section gives an overall description of the system under development,
including general factors that affect the product and its requirements.

2.1 Product Perspective


The application will be platform independent with java as front end and oracle as
back end.

Front-end client
application.

Back end
database.

2.1.1 User Interfaces


The application will have a user-friendly and button navigation to forms.
Following screens will be provided.
(i)
(ii)
(iii)
(iv)
(v)
(vi)

A login screen for entering username and password will be provided.


A Home screen with buttons is provided for navigating to other four forms
such as patient, doctor, billing and changing username password.
In patient screen, two panes are provided. One for adding patient details
and other one for retrieval, update and deletion of patient details.
In doctor screen, similar to patient screen, two separate panes are there for
adding and updating doctor details along with deletion.
In billing screen, bill details are updated based on unique id provided for
each patient.
Username and password of the software can be changed by entering the
old username and password and then by providing new username and
password in the username password changing screen.

2.1.2 Hardware Interfaces


Screen resolution of at least 800*600-required for proper and complete viewing
screens. Higher resolution would not be a problem.
2.1.3 Software Interfaces
(i)
(ii)
(iii)
(iv)

Since the application is java based, it is platform independent.


Oracle10g as the DBMS-for database. It serves as the back end for
application. It should be installed in the system.
JDK version 1.7 or higher should be installed for supporting java.
NetBeans7.0- for coding and developing the software.

Software mentioned in pt. (iv) above, will be required only for developing the
application. The final application will be packaged as an independent setup program,
which will be delivered to the department.
2.1.4 Memory Constraints
At least 1GB ram and 2.5GB space on hard disk will be required for running the
application.
2.2 Operations
This product release will not cover any automated housekeeping aspects of the
database. The DBA at the client side will be responsible for manually deleting old/nonrequired data. Database backup and recovery will also have to be handled by the DBA.
2.3 Site Adaptation Requirements
The terminals at client site will have to support the hardware and software interfaces
specified in the above sections.
2.4 Product Functions
A summary of the major functions that the software will perform:
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)
(viii)

(ix)

A login system for enabling only authorised access to the administrator or


receptionist.
Administrator will be able to add/delete information about patients such as
patients name, age, gender, address, problem and ward number.
Administrator will be able to modify/update the patient details such as age,
address, problem and ward number.
Administrator will be able to add/delete information about doctors such as
doctors name, age, gender, address and specialist.
Administrator will be able to modify/update the doctor details such as age,
address and specialist.
Unique ID is auto-generated for both patients and doctors. It cannot be
changed by the administrator.
Information is retrieved by submitting Unique ID in the query box.
Administrator will be able to add/modify/delete the billing details of
patients. Billing details include doctor consultation fee, pharmacy bill,
medical test, ward rent and other expenses. Total bill is saved to patients
database.
Username and password can be changed by the administrator. Initially
default username and password is given to the client.

2.5 User Characteristics

Education level: At least graduates should be comfortable with English


language.
Experience: Should be experienced with the aspects of a hospital
management.
Technical expertise: Should be comfortable using general purpose
applications on a computer.

2.6 Constraints
(i)

(ii)
(iii)
(iv)

Since Oracle10g is used as a backend for maintaining database, it


requires a major portion of resources to be allocated in the memory
hence by slowing the computation and increasing computational
complexity.
Administrator is responsible for the safeguard of the username and
password.
The ID once assigned even though deleted is no longer available in
future.
Password recovery option is not provided.

2.7 Assumptions And Dependencies


Unique ID is assigned to the patients and doctors do not change.
3. Specific Requirements
This section contains the software requirements to a level of detail sufficient to
enable designers to design the system and testers to test that system.
3.1 External Interface Requirements
This section provides the user interface requirements.
3.1.1 Login Screen
This will be the first screen that will be displayed in the software. It will allow the
administrator to login in to the software. Various fields available on the screen will be
(i)
(ii)

Username: Alphanumeric of length up to 20 characters.


Password: Alphanumeric of length up to 20 characters.

3.1.2 Home Screen

This screen is the home screen of the software, which contains buttons to navigate
to other screens. It is accessible only by the administrator.

3.1.3 Patient Screen


This screen contains two panels. They are new patients and patient details. Both
panels are provided with a home button to switch over to home screen. New patient panel
will allow the administrator to add new patient records in the database. Various fields
available on the screen will be
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)

ID : Numbers of length up to 3 characters. It is auto-generated


irrespective of the use of administrators.
Name: Alphabetic letters of length up to 30 characters.
Age: Numbers of length up to 3 characters.
Sex: Alphabetic letters of length up to 6 characters.
Problem: Alphabetic letters of length up to 30 characters.
Ward: Numbers of length up to 4 characters.
Address: Alphanumeric of length up to 100 characters.

Patient details panel will allow the administrator to retrieve the details of patient
from the database by submitting the patient id in the query box. It also allows the
administrator to edit the details of patients and to delete the records of patients. Various
fields available on the screen will be
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)

ID: Takes the input of patient id.


Name: Display the name of patients name.
Age: Shows patients age.
Sex: Shows the patients gender.
Problem: Patients problem will be displayed in this field.
Ward: Assigned ward number is shown in this field.
Address: Address of patient is displayed in this field.

3.1.4 Doctor Screen


This screen contains two panels. They are new doctors and doctor details. Both
panels are provided with a home button to switch over to home screen. New doctor panel
will allow the administrator to add new doctor records in the database. Various fields
available on the screen will be

(i)

ID : Numeric of length up to 3 characters. It is auto-generated


irrespective of the use of administrators.
Name: Alphabetic letters of length up to 30 characters.
Age: Numeric of length up to 3 characters.
Sex: Alphabetic letters of length up to 6 characters.
Specialist: Alphanumeric of length up to 30 characters.
Address: Alphanumeric of length up to 100 characters.

(ii)
(iii)
(iv)
(v)
(vi)

Doctor details panel will allow the administrator to retrieve the details of doctor
from the database by submitting the doctor id in the query box. It also allows the
administrator to edit the details of doctors and to delete the records of doctors. Various
fields available on the screen will be
(i)
(ii)
(iii)
(iv)
(v)
(vi)

ID: Takes the doctor id as query.


Name: Doctors name will be displayed.
Age: Age of doctor is shown.
Sex: Doctors gender is showed here.
Specialist: Displays the specialisation of Doctor.
Address: Address of doctor is displayed in this field.

3.1.5 Billing Screen


Billing details are added to the patients record in this screen. It is achieved by
submitting patient id in the query and then added/edited the billing information. It also
provides to delete bill records of patient from database. Various fields available on the
screen will be
(i)
(ii)
(iii)
(iv)
(v)
(vi)
(vii)

(viii)

ID: The patient is given as query in the id field.


Patient name: Displays the patients name here.
Consultation fee: Numbers of length up to 3 characters. Doctor
consultation fee is added/edited in the field.
Pharmacy: Numbers of length up to 5 characters. Pharmacy bill is
add /edited here.
Medical test: Numbers of length up to 5 characters. Total expense
of medical tests conducted on patient is add/edited here.
Other expense: Numeric of length up to 5 characters. It includes
other expense of patient.
Ward rent: Numeric of length up to 5 characters. Total ward rent is
add/edited in this field.
Total bill: Numeric of length up to 7 characters. Total bill
calculated is displayed in this field.

3.1.6 Username and Password Changing Screen


Initially default username and password is provided to the administrator. The
desired username and password can be changed in this screen. New username and
password replaces the old username and password in the database. Various fields
available on the screen will be
(i)
(ii)
(iii)
(iv)

Old username: It verifies the old username.


Old password: It verifies the old password.
New username: The desired username by the administrator is
provided here.
New password: The new password is changed in this field. Both
username and password alphanumeric character length is 20
characters.

3.2 System Features


3.2.1 Patient Information Maintenance
Description
The system will maintain records about patients getting admitted in hospital. Id,
Name, age, gender, address, problem, ward number along with their billing details are
added in patient record. Patient id is auto-generated and a unique id is assigned to each
patient. The system will allow creation/modification/deletion of new/existing records of
patients.
Validity checks:
(i)
(ii)
(iii)
(iv)
(v)

Only administrator will be authorised to access the patient


information.
Unique id is auto-generated, so it is assigned automatically
whenever adding new patients.
After deletion of records, id also deleted along with records. The id
cannot be claimed in future.
All the fields regarding patient information such as Name, age,
gender, address, problem, ward number cannot be left blank.
Patients billing information such as doctor consultation fee and
pharmacy bill cannot be left blank.

Error handling/response to abnormal situations:


If any of above validation does not hold true, appropriate error messages will be
prompted to the user for doing the needful.

3.2.2 Doctor Information Maintenance


Description:
The system will maintain records about doctors working in hospital. Id, Name,
age, gender, address along with their specialist details are added in doctors record. Doctor
id is auto-generated and a unique id is assigned to each patient. The system will allow
creation/modification/deletion of new/existing records of doctors.
Validity Checks:
(i)
(ii)
(iii)
(iv)

Only administrator will be authorised to access the doctor


information.
Unique id is auto-generated, so it is assigned automatically
whenever adding new doctors.
After deletion of records, id also deleted along with records. The id
cannot be claimed in future.
All the fields regarding doctor information such as Name, age,
gender, address, problem, specialist cannot be left blank.

Error handling/response to abnormal situations:


If any of above validation does not hold true, appropriate error messages will be
prompted to the user for doing the needful.
3.2.3 User Account Information Maintenance
Description:
The system will maintain record of username and password of the administrator.
The new username and password replaces the old username and password of the
administrator.
Validity checks:
(i)
(ii)
(iii)

Username cannot be blank.


Password cannot be blank.
When a new username and password is created, old username and
password is deleted from the record.

Error handling/response to abnormal situations:


If any of above validation does not hold true, appropriate error messages will be
prompted to the user for doing the needful
3.3 Software System Attributes

3.3.1 Security
The application will be password protected. Users will have to enter correct
username, password and role in order to access the application.
3.3.2 Maintainability
The application will be designed in a maintainable manner.
3.3.3 Portability
Application will work in any OS platform since it is java based. But oracle10g has
to be installed previously in the system.

3.4 Logical Database Requirements:


The following information will be placed in a database:
(i)
(ii)
(iii)
(iv)

Patient info: Name, id, age, gender, problem, address, ward


number.
Doctor info: Name, id, age, gender, specialist, address.
Bill info: Patient name, id, consultation fee, pharmacy, medical
test, ward rent and total bill.
Logging info: Username and password

Patient info:
Id

Name

Age

Gender

Problem

100

Ram

24

Male

Fever

Address
88,

Ward
6

mandaiyur,
Trichy.
101

kumar

45

Male

Dengue

32,
Airport,
Trichy.

Doctor info:
Id

Name

Age

Gender

Specialization

100

Raja

34

Male

general

Address
43,
mandaiyur,
Trichy.

101

Sekar

51

Male

Eye

23,
Mathur,
Trichy.

Bill info:
Id

Name

Fee

Pharma

Test

Other

Rent

total

100

Ram

150

190

100

20

1000

1460

101

kumar

220

1000

200

100

1000

2520

Logging info:
Username

Password

Admin

admin

Result:
Thus the SRS documentation for the Hospital Management System has been
analyzed and prepared.

USE CASE DIAGRAM


Aim:
The aim is to design a use case diagram for Hospital Management System.
Purpose:
Use case diagram shows the design features. Moreover, the use case diagram is
the first point when designing new system by using UML and when explaining the
requirement forthe system in analysis, implementation and documentations stage.
Furthermore, the use casediagram used to understand the system and what system is. The
use case diagram has four components:
1.

Actor: A role played by a person, other system external system

2.

Use cases: A start-to-finish feature of the system

3.

System boundary: System boundary boxes is separate between the actors


and the use cases and it represent by rectangle around the use cases of the
system

4.

Relationship: The relationship is the association between the actors as well


as it illustrate the actors that are participating in a use case.

Actor:
Administrator:
Admin adds and updates the details of doctors, patients and patients bill records
in the database.
Database:
All the details of patients, doctors and logging are accessed by admin in the
database.

Result:
Thus the use case diagram for Hospital Management System has been designed.

CLASS DIAGRAM
Aim:
To design the class diagram for Hospital Management System.
Purpose:
Class diagrams are arguably the most used UML diagram type. It is the main
building block of any object oriented solution. It shows the classes in a system, attributes
and operations of each class and the relationship between each class. In most modelling
tools a class has three parts, name at the top, attributes in the middle and operations or
methods at the bottom. In large systems with many classes related classes are grouped
together to create class diagrams. Different relationships between diagrams are show by
different types of Arrows. Below is a image of a class diagram. It includes Attributes and
Operation.
Attributes:
Any class cannot make it process without addressing the states and behavior of
that object. It should have the attributes middle section of object (or class) box with lower
case letter for each name.
Operations:
Operations are located in third (bottom) class section. They must define in each
class box, because the object (class) did not know what should do and which other class
should interact. The operation tells object what is the message passed to the receiver
object, and the last one invoked that message to perform operation. .
Login: This class consists of username and password of admin as attributes and signin as
operation.
Main form: This class consists of options to switch over to other class and this is the
main class.

Doctor: This class consists of doctor details such as name, id, age, gender and
specialization along with add, edit, and delete operations.
Patient: This class contains add, edit, and delete operations along with attributes such as
name, id, age, gender, problem and ward no.
Billing details: This includes the consultation fee, ward rent and pharmacy bill. Bill
details are displayed along with patient records.
Query: This class is for querying doctor and patient details.

Result:
Thus the class diagram for Hospital Management System has been designed.

SEQUENCE DIAGRAM
Aim:
To develop a Sequence diagram for Hospital Management System
Purpose:
Sequence diagrams in UML shows how object interact with each other and the
order those interactions occur. Its important to note that they show the interactions for a
particular scenario. The processes are represented vertically and interactions are show as
arrows.
Sequence diagrams are an easy and intuitive way of describing the behaviour of
the system by viewing the interaction between the system and its environment. A
sequence diagram shows an interaction arranged in a time sequence.
It shows the objects participating in the interaction by their lifelines and the
messages they exchange, arranged in a time sequence. A sequence diagram has two
dimensions: the vertical dimension represents time, the horizontal dimension represents
different objects. The vertical line is called the objects lifeline. The lifeline represents
the objects existence during the interaction.

Result:
Thus the class diagram for Hospital Management System has been designed.

COLLABORATION DIAGRAM

Aim:
To design a collaboration diagram for Hospital Management System.

Purpose:
Collaboration diagram and sequence diagrams are alternate representations of an
interaction. A collaboration diagram is an interaction diagram that shows the order of
messages that implement an operation or a transaction. Collaboration diagram is an
interaction diagram that shows the order of messages that implement an operation or a
transaction. Collaboration diagram shows object s, their links and their messages. They
can also contain simple class instances and class utility instances. During, analysis
indicates the semantics of the primary and secondary interactions. Design, shows the
semantics of mechanisms in the logical design of system. Toggling between the sequence
and collaboration diagrams when we work in either a sequence or collaboration diagram,
it is possible to view the corresponding diagram by pressing F5 key

Result:
Thus the collaboration diagram for Hospital Management System has been
designed.

ACTIVITY DIAGRAM
Aim:
To design an activity diagram for Hospital Management System.
Purpose:
It shows organization and their dependence among the set of components. These
diagrams are particularly useful in connection with workflow and in describing
behaviours that has a lot of parallel processing. An activity is a state of doing something:
either a real-world process, or the execution of a software routine.
Activity:
An activity represents the performance of a task on duty. It may also represent the
execution of a statement in a procedure.
Decision:
A decision represents a condition on situation during the life of an object, which it
satisfies some condition or waits for an event.
Start state:
It represents the condition explicitly the beginning of a workflow on an activity.
Object flow:
An object on an activity diagram represents the relationship between activity and
object that creates or uses it.
Synchronization:
It enables us to see a simultaneous workflow in an activity.
End state:
An end state represents a final or terminal state on an activity diagram or state
chart diagram.

Result:
Thus the activity diagram for Hospital Management System has been designed.

STATE CHART DIAGRAM


Aim
To design a State Chart diagram for Hospital Management System
Description:
The state chart diagram made the dynamic behaviour of individual classes. State
chart shows the sequences of states that an object goes through events and state
transitions. A state chart contains one state start and multiple end states.
Decision:
It represents a specific location state chart diagram where the work flow may
branch based upon guard conditions.
Synchronization:
It gives a simultaneous workflow in a state chart diagram. They visually define
forks and joints representing parallel workflow.
Forks and joins:
A fork construct is used to model a single flow of control. Every work must be
followed by a corresponding join. Joints have two or more flow that unit into a single
flow.
State:
A state is a condition or situation during a life of an object in which it satisfies
condition or waits for some events.
Transition:
It is a relationship between two activities and between states and activities.
Start state:
A start state shows the beginning of a workflow or beginning of a state machine
on a state chart diagram.
End state:
It is a final or terminal state.

Result:
Thus the state chart diagram for Hospital Management System has been designed.

IMPLEMENTATION DIAGRAMS
Aim:
To design the implementation diagrams for Hospital Management System

Purpose:
Implementation diagrams show the implementation phase of system development,
such as the source code structure and the run-time implementation structure. There are
two types of implementation diagrams:
1. Component Diagram
2. Deployment Diagram

Component Diagram:
Component diagrams model the physical components such as source code,
executable program, user interface in a design. A component diagram is a graph of the
designs components connected by dependency relationships.

Deployment Diagram:
Deployment diagrams show the configuration of run-time processing elements
and the software components, processes, and objects that live in them. It is a graph of
nodes, connected by communication association.

Component Diagram:

Deployment Diagram:

Result:
Thus implementation diagrams have been designed for Hospital Management
System.

FORWARD ENGINEERING

Aim:
To implement forward engineering for Hospital Management System using the
tools available in Star UML.

Forward Engineering:
The java classes can be generated by the engineering aspects like automatic code
conversion method of the StarUML. The class diagram developed in the software design
phase contains all the relevant classes and it defines the relationships between classes.
This class diagram is used to generate the code template for the system
To generate the Java stub code using StarUML:

Go to Tools on the main menu, expand Java, and select Generate Code.

From this dialog box, select the model, probably named Model1 and press
Next

Choose Select All to generate stub code for all the classes in the model/diagram
and then press Next

Select a valid output directory and select Next

In the Options Setup be sure to check bothGenerate the Documentation by


JavaDoc. All other checkboxes should be unchecked. Then press Next.

StarUML will now generate the codes stubs froms the diagram. Click Finish to
exit the dialog.

Then generate stub code to add functionality to the application.

Input:

Output:
Login.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Log In.java
// @ Date : 17-10-2012

// @ Author :
//
//
public class Log In extends Main Form, Main Form {
public Object username;
public Object password;
public void Signin() {

}
}
Mainform.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Main Form.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Main Form extends Doctor, Patient {
public Object Menu Button;
public void Choose() {
}
}
Doctor.java:
//
//
// Generated by StarUML(tm) Java Add-In
//

// @ Project : Untitled
// @ File Name : Doctor.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Doctor {
public Object Name;
public Object Id;
public Object Age;
public Object Specialisation;
public void Add() {
}
public void Edit() {
}
public void Delete() {
}
}
Patient.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Patient.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Patient extends Billing Details {
public Object Name;

public Object Id;


public Object Age;
public Object Problem;
public void Add() {
}
public void Edit() {
}
public void Delete() {
}
}
Query.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Query,.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Query, {
public Object Id;
public void DisplayDoctor() {
}
public void DisplayPatient() {
}
}
Billingdetails.java:
//
//

// Generated by StarUML(tm) Java Add-In


//
// @ Project : Untitled
// @ File Name : Billing Details.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Billing Details {
public Object Consultation Fee;
public Object Ward Rent;
public Object Pharmacy;
public void Display() {
}
}

Result:
Thus the forward engineering was done successfully for the Hospital Management
System.

REVERSE ENGINEERING
Aim:
To create the reverse engineering for Hospital Management System using the
tools available in Star UML.
Reverse Engineering:
The star UML tool can be used to generate by reverse engineering .The class
diagram developed in the software design phase contains all the relevant classes and it
defines the relationships between classes. This class diagram is used to generate the code
template for the system.
To perform reverse engineering using StarUML:

Go to Tools on the main menu, expand Java, and select Reverse


Engineering.

From this dialog box, select the source code for reverse engineering.

Choose Add All to generate diagrams for all the template classes in the
model/diagram and then press Next

Select a valid output directory or select the package to contain the result of
reverse engineering.

Choose appropriate model and select Next

In the Options Setup, Give the name of the diagram. Then press
(Run)R

StarUML will now generate class diagram from the code template.

Click Finish to exit the dialog.

Input:
Login.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Log In.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Log In extends Main Form, Main Form {
public Object username;
public Object password;
public void Signin() {

}
}
Mainform.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Main Form.java
// @ Date : 17-10-2012
// @ Author :
//

//
public class Main Form extends Doctor, Patient {
public Object Menu Button;
public void Choose() {
}
}
Doctor.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Doctor.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Doctor {
public Object Name;
public Object Id;
public Object Age;
public Object Specialisation;
public void Add() {
}
public void Edit() {
}
public void Delete() {
}
}

Patient.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Patient.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Patient extends Billing Details {
public Object Name;
public Object Id;
public Object Age;
public Object Problem;
public void Add() {
}
public void Edit() {
}
public void Delete() {
}
}
Query.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Query,.java
// @ Date : 17-10-2012

// @ Author :
//
//
public class Query, {
public Object Id;
public void DisplayDoctor() {
}
public void DisplayPatient() {
}
}
Billingdetails.java:
//
//
// Generated by StarUML(tm) Java Add-In
//
// @ Project : Untitled
// @ File Name : Billing Details.java
// @ Date : 17-10-2012
// @ Author :
//
//
public class Billing Details {
public Object Consultation Fee;
public Object Ward Rent;
public Object Pharmacy;
public void Display() {
}
}

Output:

Result:
Thus the reverse engineering was done successfully for the Hospital Management
System.

DATA FLOW DIAGRAM


Aim:
To draw data flow diagram for Hospital Management System.

Data Flow Diagram:

Level 0:

Level 1:

Level 2:

Result:
Thus the data flow diagram has been designed for Hospital Management System.

SOFTWARE TESTING
Aim:
To study various test approaches for testing a software.
What is testing?
Testing is the process of evaluating a system or its component(s) with the intent to
find that whether it satisfies the specified requirements or not. This activity results in the
actual, expected and difference between their results. In simple words testing is executing
a system in order to identify any gaps, errors or missing requirements in contrary to the
actual desire or requirements.
According to ANSI/IEEE 1059 standard, Testing can be defined as A process of
analyzing a software item to detect the differences between existing and required
conditions (that is defects/errors/bugs) and to evaluate the features of the software item.
Who does testing?
It depends on the process and the associated stakeholders of the project(s). In the
IT industry, large companies have a team with responsibilities to evaluate the developed
software in the context of the given requirements. Moreover, developers also conduct
testing which is called Unit Testing. In most cases, following professionals are involved
in testing of a system within their respective capacities:

Software Tester

Software Developer

Project Lead/Manager

End User

Different companies have difference designations for people who test the software on
the basis of their experience and knowledge such as Software Tester, Software Quality
Assurance Engineer, and QA Analyst etc. It is not possible to test the software at any
time during its cycle. The next two sections state when testing should be started and when
to end it during the SDLC.

Manual testing
This type includes the testing of the Software manually i.e. without using any
automated tool or any script. In this type the tester takes over the role of an end user and
test the Software to identify any un-expected behavior or bug. There are different stages
for manual testing like unit testing, Integration testing, System testing and User
Acceptance testing.
Testers use test plan, test cases or test scenarios to test the Software to ensure the
completeness of testing. Manual testing also includes exploratory testing as testers
explore the software to identify errors in it.
Automation testing
Automation testing which is also known as Test Automation is when the tester
writes scripts and uses another software to test the software. This process involves
automation of a manual process. Automation Testing is used to re-run the test scenarios
that were performed manually, quickly and repeatedly.

Apart from regression testing, Automation testing is also used to test the
application from load, performance and stress point of view. It increases the test
coverage; improve accuracy, saves time and money in comparison to manual testing.

Testing Methods
Black Box Testing
The technique of testing without having any knowledge of the interior workings
of the application is Black Box testing. The tester is oblivious to the system architecture
and does not have access to the source code. Typically, when performing a black box test,
a tester will interact with the system's user interface by providing inputs and examining
outputs without knowing how and where the inputs are worked upon.
White Box Testing
White box testing is the detailed investigation of internal logic and structure of the
code. White box testing is also called glass testing or open box testing. In order to
perform white box testing on an application, the tester needs to possess knowledge of the
internal working of the code. The tester needs to have a look inside the source code and
find out which unit/chunk of the code is behaving inappropriately.
Grey Box Testing
Grey Box testing is a technique to test the application with limited knowledge of
the internal workings of an application. In software testing, the term the more you know
the better carries a lot of weight when testing an application.
Mastering the domain of a system always gives the tester an edge over someone
with limited domain knowledge. Unlike black box testing, where the tester only tests the
application's user interface, in grey box testing, the tester has access to design documents
and the database. Having this knowledge, the tester is able to better prepare test data and
test scenarios when making the test plan.
Unit Testing
This type of testing is performed by the developers before the setup is handed
over to the testing team to formally execute the test cases. Unit testing is performed by

the respective developers on the individual units of source code assigned areas. The
developers use test data that is separate from the test data of the quality assurance team.
The goal of unit testing is to isolate each part of the program and show that individual
parts are correct in terms of requirements and functionality.
Integration Testing
The testing of combined parts of an application to determine if they function
correctly together is Integration testing. There are two methods of doing Integration
Testing Bottom-up Integration testing and Top down Integration testing.
S.N. Integration Testing Method
Bottom-up integration
1

This testing begins with unit testing, followed by tests of progressively higherlevel combinations of units called modules or builds.
Top-Down integration

This testing, the highest-level modules are tested first and progressively lowerlevel modules are tested after that.
In a comprehensive software development environment, bottom-up testing is

usually done first, followed by top-down testing. The process concludes with multiple
tests of the complete application, preferably in scenarios designed to mimic those it will
encounter in customers' computers, systems and network.

Test Results:

Result:
Thus various approaches on software testing has been studied.

DESIGN PROCESS
Aim:
To implement application using JDK as front end and Oracle as back end.
Login form:

Main form:

Patient form:

Doctor form:

Billing details:

Username and password changing form:

CODINGS
Login form:
This form allows the administrator to entering into the application by providing
username and password. Default username and password is given to admin, later both can
be changed by the administrator. If a wrong entry has made, a message box will be
prompted to the user.
package hospital;
import java.awt.event.KeyEvent;
import java.sql.*;
public class Login extends javax.swing.JFrame {
Connection c;
Statement s;
ResultSet r;
public Login() {
try {
Driver
d
=
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

(Driver)

c=
DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl",
"scott", "tiger");
}catch(ClassNotFoundException | InstantiationException | IllegalAccessException |
SQLException e) {
System.out.println("Driver " + e.getMessage());
}
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try{

s=c.createStatement();

r=s.executeQuery("select * from log ");

if(r.next()){
if(User.getText().equals(r.getString(1))&&Password.getText().equals(r.getString(
2)))
{

Hos_main h=new Hos_main();


h.show();
this.hide();
}
else
{
javax.swing.JOptionPane.showMessageDialog(null,"Wrong
password");
User.setText("");
Password.setText("");
}
}

}catch (Exception e){


System.out.println(e.getMessage());
}
}

private void PasswordKeyPressed(java.awt.event.KeyEvent evt) {


if(evt.getKeyCode()==KeyEvent.VK_ENTER)
try{

s=c.createStatement();

r=s.executeQuery("select * from log ");

Username

or

if(r.next()){
if(User.getText().equals(r.getString(1))&&Password.getText().equals(r.getString(
2)))
{
Hos_main h=new Hos_main();
h.show();
this.hide();
}
else
{
javax.swing.JOptionPane.showMessageDialog(null,"Wrong
password");
User.setText("");
Password.setText("");
}
}

}catch (Exception e){


System.out.println(e.getMessage());
}}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Login().setVisible(true);
}
});
}
// Variables declaration - do not modify

Username

or

private javax.swing.JPasswordField Password;


private javax.swing.JTextField User;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
// End of variables declaration
}

Main Form:
In this form, the admin can switch over to other forms such as patient, doctor,
billing details and username & password changing forms. This form act as home screen
for the application
package hospital;
public class Hos_main extends javax.swing.JFrame {
public Hos_main() {
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
patient k=new patient();
k.show();
this.hide();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Doctor i=new Doctor();
i.show();
this.hide();

}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
createuser u=new createuser();
u.show();
this.hide();// TODO add your handling code here:
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
Billing b= new Billing();
b.show();
this.hide();
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
Login g=new Login();
g.show();
this.hide();// TODO add your handling code here:
}
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Hos_main().setVisible(true);
}
});
}
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;

private javax.swing.JLabel jLabel1;


}
Patient form:
In this form, admin can save patient details such as patients name, age, address,
problem, gender and ward no. This is a tabbed pane form, one form is for adding patient
details and another form for querying, editing and deleting patient details. Patient details
are retrieved by submitting patients unique identification number in the query box. The
id cannot be used in future even though it is deleted from records.
package hospital;
import java.awt.Color;
import java.awt.HeadlessException;
import java.sql.*;
public class patient extends javax.swing.JFrame {
Connection con;
Statement st;
ResultSet rst, rst1,rs;
PreparedStatement pst;
public patient() {
try {
Driver
d
=
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

(Driver)

con = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl",
"scott", "tiger");
pst = con.prepareStatement("insert into pat_det values(?,?,?,?,?,?,?)");
//con.setAutoCommit(true);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| SQLException e) {
System.out.println("Driver " + e.getMessage());

}
initComponents();
NEWQUERY.setVisible(false);
NAME2.disable();
AGE2.disable();
SEX2.disable();
PROBLEM2.disable();
ADDRESS2.disable();
WARD2.disable();
AGE2.setDisabledTextColor(Color.black);
NAME2.setDisabledTextColor(Color.black);
PROBLEM2.setDisabledTextColor(Color.black);
ADDRESS2.setDisabledTextColor(Color.black);
SEX2.setDisabledTextColor(Color.black);
WARD2.setDisabledTextColor(Color.black);
try {
st = con.createStatement();
rst = st.executeQuery("select max(id) from pat_det");
if (rst.next())
{
if(rst.getInt(1)==0)
ID3.setText(100+"");
else
ID3.setText((rst.getInt(1) + 1) + "");
}
else {
ID3.setText(100 + "");

}
} catch (Exception e) {
System.out.println(e.getMessage());
}

private void SAVEActionPerformed(java.awt.event.ActionEvent evt) {


try
{
if(NAME3.getText().isEmpty()||AGE3.getText().isEmpty()||SEX3.getText().isEm
pty()||PROBLEM3.getText().isEmpty()||ADDRESS3.getText().isEmpty()||WARD
3.getText().isEmpty())
{
javax.swing.JOptionPane.showMessageDialog(null, "You have to fill
all the fields");
}
else
{
if(AGE3.getText().length()>3)
javax.swing.JOptionPane.showMessageDialog(null, "Entered Wrong
data in AGE");
else if(WARD3.getText().length()>3)
javax.swing.JOptionPane.showMessageDialog(null,
in WARD NO.");
else
{
pst.setInt(1,Integer.parseInt(ID3.getText()));
pst.setString(2,NAME3.getText());
pst.setInt(3, Integer.parseInt(AGE3.getText()));
pst.setString(4,SEX3.getText());
pst.setString(5,PROBLEM3.getText());

"Entered

Wrong

data

pst.setString(6,ADDRESS3.getText());
pst.setInt(7,Integer.parseInt(WARD3.getText()));
pst.executeUpdate();
javax.swing.JOptionPane.showMessageDialog(null,
sucessfully");

"patient

details

added

Hos_main i=new Hos_main();


i.show();
this.dispose();
}
}
}catch(SQLException | HeadlessException e)
{
System.out.println(e.getMessage());
}
}

private void QUERY1ActionPerformed(java.awt.event.ActionEvent evt) {


try
{
if(QUERY.getText().length()==0)
javax.swing.JOptionPane.showMessageDialog(null, "Enter the valid ID");
else
{
st=con.createStatement();
rst1=st.executeQuery("select
*
id="+Integer.parseInt(QUERY.getText()));
if(rst1.next())
{

from

pat_det

where

String name=rst1.getString("name");
System.out.print(name);
QUERY.disable();
NEWQUERY.setVisible(true);
NAME2.setText(rst1.getString(2));
AGE2.setText(rst1.getInt(3)+"");
SEX2.setText(rst1.getString(4));
PROBLEM2.setText(rst1.getString(5));
ADDRESS2.setText(rst1.getString(6));
WARD2.setText(Integer.parseInt(rst1.getString(7))+"");
}
else
{
javax.swing.JOptionPane.showMessageDialog(null, "Enter the valid ID sir");
QUERY.setText("");
}
}
}catch(SQLException | NumberFormatException e)
{
System.out.println(e.getMessage());
}
}

private void NEWQUERYActionPerformed(java.awt.event.ActionEvent evt) {


QUERY.enable();
QUERY.setText("");
NAME2.setText("");

AGE2.setText("");
SEX2.setText("");
PROBLEM2.setText("");
ADDRESS2.setText("");
WARD2.setText("");
NEWQUERY.setVisible(false);
}
private void EDITActionPerformed(java.awt.event.ActionEvent evt) {
PROBLEM2.enable();
ADDRESS2.enable();
WARD2.enable();
}

private void SAVE1ActionPerformed(java.awt.event.ActionEvent evt) {


try
{
st=con.createStatement();
st.executeUpdate("update
pat_det
set
problem=
'"+PROBLEM2.getText()+"',address='"+ADDRESS2.getText()+"',ward="+Integer.parseI
nt(WARD2.getText())+" where id="+Integer.parseInt(QUERY.getText()));
}catch(SQLException | NumberFormatException e)
{
System.out.println(e.getMessage());
}
}

private void DELETEActionPerformed(java.awt.event.ActionEvent evt) {


try

{
st=con.createStatement();
st.executeUpdate("delete pat_det where id="+Integer.parseInt(QUERY.getText()));
javax.swing.JOptionPane.showMessageDialog(null, "ID deleted");
Hos_main j=new Hos_main();
j.show();
this.hide();
}catch(SQLException | NumberFormatException e)
{
System.out.println(e.getMessage());
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Hos_main j=new Hos_main();
j.show();
this.hide();
}

java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new patient().setVisible(true);
}
});
}

// Variables declaration - do not modify


private javax.swing.JTextArea ADDRESS2;

private javax.swing.JTextArea ADDRESS3;


private javax.swing.JTextField AGE2;
private javax.swing.JTextField AGE3;
private javax.swing.JButton DELETE;
private javax.swing.JPanel DETAILS;
private javax.swing.JButton EDIT;
private javax.swing.JTextField ID3;
private javax.swing.JTextField NAME2;
private javax.swing.JTextField NAME3;
private javax.swing.JPanel NEW;
private javax.swing.JButton NEWQUERY;
private javax.swing.JTextField PROBLEM2;
private javax.swing.JTextField PROBLEM3;
private javax.swing.JTextField QUERY;
private javax.swing.JButton QUERY1;
private javax.swing.JButton SAVE;
private javax.swing.JButton SAVE1;
private javax.swing.JTextField SEX2;
private javax.swing.JTextField SEX3;
private javax.swing.JTextField WARD2;
private javax.swing.JTextField WARD3;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel20;

private javax.swing.JLabel jLabel21;


private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel28;
private javax.swing.JLabel jLabel29;
private javax.swing.JLabel jLabel30;
private javax.swing.JLabel jLabel31;
private javax.swing.JLabel jLabel32;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTabbedPane jTabbedPane1;
// End of variables declaration
}
Doctor form:
This form is for saving doctor details and for querying their details. This is a
tabbed pane containing two forms. One is for adding new doctor details and another one
for querying their details. Doctor details such as doctor name, age, specialization,
address, gender are added in doctor details.
package hospital;
import java.awt.Color;
import java.awt.HeadlessException;
import java.sql.*;

public class Doctor extends javax.swing.JFrame {

Connection con;
Statement st;
ResultSet rst, rst1;
PreparedStatement pst;

public Doctor() {
try {
Driver
d
=
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

(Driver)

con=DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl",
"scott", "tiger");
pst = con.prepareStatement("insert into doc_det values(?,?,?,?,?,?)");
//con.setAutoCommit(true);
}
catch
(ClassNotFoundException
IllegalAccessException | SQLException e) {

System.out.println("Driver " + e.getMessage());


}
initComponents();
NEWQUERY.setVisible(false);
NAME2.disable();
NAME2.setDisabledTextColor(Color.black);
AGE2.disable();
AGE2.setDisabledTextColor(Color.black);
SEX2.disable();
SEX2.setDisabledTextColor(Color.black);

InstantiationException

SPECIAL2.disable();
SPECIAL2.setDisabledTextColor(Color.black);
ADDRESS2.disable();
ADDRESS2.setDisabledTextColor(Color.black);
try {
st = con.createStatement();
rst = st.executeQuery("select max(id) from doc_det");
if (rst.next())
{
System.out.println(rst.getInt(1));
if(rst.getInt(1)==0)
ID3.setText(100+"");
else
ID3.setText((rst.getInt(1) + 1) + "");
}
else {
ID3.setText(100 + "");
}
} catch (Exception e) {
System.out.println(e.getMessage());
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


Hos_main j=new Hos_main();
j.show();
this.hide();
}

private void NEWQUERYActionPerformed(java.awt.event.ActionEvent evt) {


QUERY.enable();
QUERY.setText("");
NAME2.setText("");
AGE2.setText("");
SEX2.setText("");
SPECIAL2.setText("");
ADDRESS2.setText("");
NEWQUERY.setVisible(false);
}

private void EDITActionPerformed(java.awt.event.ActionEvent evt) {


ADDRESS2.enable();
SPECIAL2.enable();
}

private void DELETEActionPerformed(java.awt.event.ActionEvent evt) {


try {
st=con.createStatement();
st.executeUpdate("delete
id="+Integer.parseInt(QUERY.getText()));

doc_det

javax.swing.JOptionPane.showMessageDialog(null, "ID deleted");


Hos_main j=new Hos_main();
j.show();
this.hide();
}catch(SQLException | NumberFormatException e) {
System.out.println(e.getMessage());

where

}
}

private void QUERY1ActionPerformed(java.awt.event.ActionEvent evt) {


try {
if(QUERY.getText().length()==0)
javax.swing.JOptionPane.showMessageDialog(null, "Enter the valid ID");
else {
st=con.createStatement();
rst1=st.executeQuery("select
*
from
id="+Integer.parseInt(QUERY.getText()));

doc_det

where

if(rst1.next()) {
QUERY.disable();
QUERY.setDisabledTextColor(Color.black);
NEWQUERY.setVisible(true);
NAME2.setText(rst1.getString(2));
AGE2.setText(rst1.getInt(3)+"");
SEX2.setText(rst1.getString(4));
SPECIAL2.setText(rst1.getString(5));
ADDRESS2.setText(rst1.getString(6));
if(rst1.getString(2)==null){
javax.swing.JOptionPane.showMessageDialog(null,"Record not found!") ;
}

} else {
javax.swing.JOptionPane.showMessageDialog(null, "Enter the valid ID");
QUERY.setText("");
}

}
}catch(SQLException | NumberFormatException e) {
System.out.println(e.getMessage());
}
}
private void SAVE1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
st=con.createStatement();
st.executeUpdate("update
doc_det
address='"+ADDRESS2.getText()+"',special='"+SPECIAL2.getText()+"'
id="+Integer.parseInt(QUERY.getText()));

set
where

}catch(SQLException | NumberFormatException e) {
System.out.println(e.getMessage());
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Hos_main j=new Hos_main();
j.show();
this.hide();
}

private void SAVEActionPerformed(java.awt.event.ActionEvent evt) {


try {
if(NAME3.getText().isEmpty()||AGE3.getText().isEmpty()||SEX3.getText().isEm
pty()||SPECIAL3.getText().isEmpty()||ADDRESS3.getText().isEmpty()) {

javax.swing.JOptionPane.showMessageDialog(null, "You have to fill


all the fields");

} else {
if(AGE3.getText().length()>3)
javax.swing.JOptionPane.showMessageDialog(null, "Entered Wrong
data in AGE");
else {
pst.setInt(1,Integer.parseInt(ID3.getText()));
pst.setString(2,NAME3.getText());
pst.setInt(3, Integer.parseInt(AGE3.getText()));
pst.setString(4,SEX3.getText());
pst.setString(6,SPECIAL3.getText());
pst.setString(5,ADDRESS3.getText());
pst.executeUpdate();
javax.swing.JOptionPane.showMessageDialog(null,
sucessfully");
Hos_main i=new Hos_main();
i.show();
this.dispose();
}
}
}catch(SQLException | HeadlessException e) {
System.out.println(e.getMessage());
}
}

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {


new Doctor().setVisible(true);

"value

added

}
});
}
// Variables declaration - do not modify
private javax.swing.JTextArea ADDRESS2;
private javax.swing.JTextArea ADDRESS3;
private javax.swing.JTextField AGE2;
private javax.swing.JTextField AGE3;
private javax.swing.JButton DELETE;
private javax.swing.JPanel DETAILS;
private javax.swing.JButton EDIT;
private javax.swing.JTextField ID3;
private javax.swing.JTextField NAME2;
private javax.swing.JTextField NAME3;
private javax.swing.JPanel NEW;
private javax.swing.JButton NEWQUERY;
private javax.swing.JTextField QUERY;
private javax.swing.JButton QUERY1;
private javax.swing.JButton SAVE;
private javax.swing.JButton SAVE1;
private javax.swing.JTextField SEX2;
private javax.swing.JTextField SEX3;
private javax.swing.JTextField SPECIAL2;
private javax.swing.JTextField SPECIAL3;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel17;


private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel28;
private javax.swing.JLabel jLabel29;
private javax.swing.JLabel jLabel30;
private javax.swing.JLabel jLabel32;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTabbedPane jTabbedPane1;
// End of variables declaration
}
Billing details:
In this form, patient billing details are added. Details including consultation fee,
pharmacy bill, ward rent, other expense and medical test are manually added by the
administrator.
package hospital;
import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.HeadlessException;

import java.sql.*;
public class Billing extends javax.swing.JFrame {
Connection con;
Statement st;
ResultSet rst, rst1,rs;
PreparedStatement pst;
/** Creates new form Billing */
public Billing() {
try {
Driver
d
=
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

(Driver)

con = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl",
"scott", "tiger");
pst = con.prepareStatement("insert into bill_det values(?,?,?,?,?,?,?,?)");
//con.setAutoCommit(true);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| SQLException e) {
System.out.println("Driver " + e.getMessage());
}
initComponents();
LFee.setVisible(false);
LName.setVisible(false) ;
LOther.setVisible(false);
LPharma.setVisible(false);
LRent.setVisible(false);
LTest.setVisible(false);
Fee.setVisible(false);
NAME.setVisible(false) ;

Other.setVisible(false);
Pharma.setVisible(false);
Rent.setVisible(false);
Test.setVisible(false);
jButton3.setVisible(false);
total.setVisible(false);
LTotal.setVisible(false);
TotalBill.setVisible(false);
edit.setVisible(false);
delete.setVisible(false);
newq.setVisible(false);
save.setVisible(false);
TotalBill.setDisabledTextColor(Color.black);
Fee.setDisabledTextColor(Color.black);
NAME.setDisabledTextColor(Color.black);
Other.setDisabledTextColor(Color.black);
Pharma.setDisabledTextColor(Color.black);
Rent.setDisabledTextColor(Color.black);
Test.setDisabledTextColor(Color.black);
}

private void EnterActionPerformed(java.awt.event.ActionEvent evt) {


try
{
if(QUERY.getText().length()==0)
javax.swing.JOptionPane.showMessageDialog(null, "Enter the valid ID");
else

{
st=con.createStatement();
rst1=st.executeQuery("select
*
id="+Integer.parseInt(QUERY.getText()));

from

pat_det

where

if(rst1.next())
{
st=con.createStatement();
rs=st.executeQuery("select
*
id="+Integer.parseInt(QUERY.getText()));

from

if(rs.next())
{
QUERY.disable();
NAME.setVisible(true);
LName.setVisible(true);
NAME.setText(rs.getString(2));
LFee.setVisible(true);
LOther.setVisible(true);
LPharma.setVisible(true);
LRent.setVisible(true);
LTest.setVisible(true);
Fee.setVisible(true);
Fee.setText(Integer.parseInt(rs.getString(3))+"");
Other.setVisible(true);
Other.setText(Integer.parseInt(rs.getString(6))+"");
Pharma.setVisible(true);
Pharma.setText(Integer.parseInt(rs.getString(4))+"");
Rent.setVisible(true);

bill_det

where

Rent.setText(Integer.parseInt(rs.getString(7))+"");
Test.setVisible(true);
Test.setText(Integer.parseInt(rs.getString(5))+"");
total.setVisible(true);
LTotal.setVisible(true);
TotalBill.setVisible(true);
TotalBill.setText(Integer.parseInt(rs.getString(8))+"");
edit.setVisible(true);
delete.setVisible(true);
newq.setVisible(true);
save.setVisible(false);
jButton3.setVisible(true);
Fee.disable();
NAME.disable() ;
Other.disable();
Pharma.disable();
Rent.disable();
Test.disable();
TotalBill.disable();
}
else{
QUERY.disable();
NAME.setVisible(true);
LName.setVisible(true);
NAME.setText(rst1.getString(2));
LFee.setVisible(true);
LOther.setVisible(true);

LPharma.setVisible(true);
LRent.setVisible(true);
LTest.setVisible(true);
Fee.setVisible(true);
Other.setVisible(true);
Pharma.setVisible(true);
Rent.setVisible(true);
Test.setVisible(true);
total.setVisible(true);
LTotal.setVisible(true);
TotalBill.setVisible(true);
Fee.setText(0+"");
Pharma.setText(0+"");
Test.setText(0+"");
Other.setText(0+"");
Rent.setText(0+"");
TotalBill.setText(0+"");
TotalBill.disable();
save.setVisible(true);
newq.setVisible(true);
}
}
else
{
javax.swing.JOptionPane.showMessageDialog(null, "Enter the valid ID sir");
QUERY.setText("");
}

}
}catch(SQLException | NumberFormatException e)
{
System.out.println(e.getMessage());
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Hos_main h = new Hos_main();
h.show();
this.hide();// TODO add your handling code here:
}

private void totalActionPerformed(java.awt.event.ActionEvent evt) {


int n=0;
if(Fee.getText().length()>3||Pharma.getText().length()>5||Test.getText().length()>
5||Other.getText().length()>5||Rent.getText().length()>5){
javax.swing.JOptionPane.showMessageDialog(null, "This is called day robbery!!!");
}
else{
n=Integer.parseInt(Fee.getText())+Integer.parseInt(Pharma.getText())+Integer.par
seInt(Test.getText())+Integer.parseInt(Other.getText())+Integer.parseInt(Rent.get
Text());
TotalBill.setText(n+"");
TotalBill.disable();
}

// TODO add your handling code here:

private void saveActionPerformed(java.awt.event.ActionEvent evt) {

try{
if(TotalBill.getText().isEmpty()||TotalBill.getText().length()<2){
javax.swing.JOptionPane.showMessageDialog(null, "Total Bill is not calculated
");
}

else{
pst.setInt(1,Integer.parseInt(QUERY.getText()));
pst.setString(2,NAME.getText());
pst.setInt(3,Integer.parseInt(Fee.getText()));
pst.setInt(4,Integer.parseInt(Pharma.getText()));
pst.setInt(5,Integer.parseInt(Test.getText()));
pst.setInt(6,Integer.parseInt(Other.getText()));
pst.setInt(7,Integer.parseInt(Rent.getText()));
pst.setInt(8,Integer.parseInt(TotalBill.getText()));
pst.executeUpdate();
javax.swing.JOptionPane.showMessageDialog(null, "Bill added sucessfully");
Hos_main i=new Hos_main();
i.show();
this.dispose();
}
}catch(SQLException | HeadlessException e)
{
System.out.println(e.getMessage());
}
}
private void editActionPerformed(java.awt.event.ActionEvent evt) {
Fee.enable();

NAME.enable() ;
Other.enable();
Pharma.enable();
Rent.enable();
Test.enable();
}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {


try
{
st=con.createStatement();
st.executeUpdate("update
bill_det
set
fee=
"+Integer.parseInt(Fee.getText())+",pharma="+Integer.parseInt(Pharma.getText()
)+",test="+Integer.parseInt(Test.getText())+",other="+Integer.parseInt(Other.getT
ext())+",rent="+Integer.parseInt(Rent.getText())+",total="+Integer.parseInt(Total
Bill.getText())+" where id="+Integer.parseInt(QUERY.getText()));
javax.swing.JOptionPane.showMessageDialog(null, "Bill updated");
Hos_main m= new Hos_main();
m.show();
this.hide();
}catch(SQLException | NumberFormatException e)
{
System.out.println(e.getMessage());
}
}

private void deleteActionPerformed(java.awt.event.ActionEvent evt) {


try
{

st=con.createStatement();
st.executeUpdate("delete
id="+Integer.parseInt(QUERY.getText()));

bill_det

javax.swing.JOptionPane.showMessageDialog(null, "ID deleted");


Hos_main j=new Hos_main();
j.show();
this.hide();
}catch(SQLException | NumberFormatException e)
{
System.out.println(e.getMessage());
}
}

private void newqActionPerformed(java.awt.event.ActionEvent evt) {


LFee.setVisible(false);
LName.setVisible(false);
LOther.setVisible(false);
LPharma.setVisible(false);
LRent.setVisible(false);
LTest.setVisible(false);
Fee.setVisible(false);
NAME.setVisible(false) ;
Other.setVisible(false);
Pharma.setVisible(false);
Rent.setVisible(false);
Test.setVisible(false);
jButton3.setVisible(false);
total.setVisible(false);

where

LTotal.setVisible(false);
TotalBill.setVisible(false);
edit.setVisible(false);
delete.setVisible(false);
newq.setVisible(false);
QUERY.enable();
QUERY.setText("");:
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {


new Billing().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton Enter;
private javax.swing.JTextField Fee;
private javax.swing.JLabel LFee;
private javax.swing.JLabel LName;
private javax.swing.JLabel LOther;
private javax.swing.JLabel LPharma;
private javax.swing.JLabel LRent;
private javax.swing.JLabel LTest;
private javax.swing.JLabel LTotal;
private javax.swing.JTextField NAME;

private javax.swing.JTextField Other;


private javax.swing.JTextField Pharma;
private javax.swing.JTextField QUERY;
private javax.swing.JTextField Rent;
private javax.swing.JTextField Test;
private javax.swing.JTextField TotalBill;
private javax.swing.JButton delete;
private javax.swing.JButton edit;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel2;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JButton newq;
private javax.swing.JButton save;
private javax.swing.JButton total;
// End of variables declaration
}
Username and Password changing Form:
In this form, administrator can assign his/her desired username and password.
New username and password replaces the old username and password.
package hospital;
import java.sql.*;

public class createuser extends javax.swing.JFrame {


Connection c;
Statement s;

ResultSet r;
PreparedStatement p;
public createuser() {
try {
Driver
d
=
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

(Driver)

c=
DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl", "scott",
"tiger");
p = c.prepareStatement("insert into log values(?,?)");
//con.setAutoCommit(true);
}
catch
(ClassNotFoundException
IllegalAccessException | SQLException e) {

InstantiationException

System.out.println("Driver " + e.getMessage());


}
initComponents();
newuser.setVisible(false);
newpass.setVisible(false);
nuser.setVisible(false);
npass.setVisible(false);
Create.setVisible(false);
}
private void CreateActionPerformed(java.awt.event.ActionEvent evt) {
try{ s=c.createStatement();
if(newuser.getText().isEmpty()||newpass.getText().isEmpty())
{
javax.swing.JOptionPane.showMessageDialog(null, "username and password not
entered!!");
}

else{
s.executeUpdate("delete from log where name= '"+olduser.getText()+"'");
p.setString(1,newuser.getText());
p.setString(2, newpass.getText());
p.executeUpdate();
javax.swing.JOptionPane.showMessageDialog(null, "username and password
changed");
Login h=new Login();
h.show();
this.hide();
}
}catch(SQLException | NumberFormatException e){
System.out.print(e);
}
}

private void newuserActionPerformed(java.awt.event.ActionEvent evt) {


}

private void verifyActionPerformed(java.awt.event.ActionEvent evt) {


try{
s=c.createStatement();
r=s.executeQuery("select * from log");
if(r.next()){
if(olduser.getText().equals(r.getString(1))&&oldpass.getText().equals(r.getString(2)))
{
newuser.setVisible(true);

newpass.setVisible(true);
nuser.setVisible(true);
npass.setVisible(true);
Create.setVisible(true);

}
else
{
javax.swing.JOptionPane.showMessageDialog(null,"Wrong
password");

Username

olduser.setText("");
oldpass.setText("");
}
}
}catch (Exception e){
System.out.println(e.getMessage());
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Hos_main j=new Hos_main();
j.show();
this.hide();
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {


new createuser().setVisible(true);

or

}
});
}
// Variables declaration - do not modify
private javax.swing.JButton Create;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPasswordField newpass;
private javax.swing.JTextField newuser;
private javax.swing.JLabel npass;
private javax.swing.JLabel nuser;
private javax.swing.JPasswordField oldpass;
private javax.swing.JTextField olduser;
private javax.swing.JButton verify;
// End of variables declaration
}

Tables
The database table pat_det contains the patient details.
Id

Name

Age

Gender

Problem

100

Ram

24

Male

Fever

Address

Ward

88,

mandaiyur,
Trichy.
101

kumar

45

Male

Dengue

32,

Airport,
Trichy.

The database table doc_det contains the doctor details.


Id

Name

Age

Gender

Specialization

100

Raja

34

Male

general

Address
43,
mandaiyur,
Trichy.

101

Sekar

51

Male

Eye

23,
Mathur,
Trichy.

The database table bill_det contains the billing details of patients.


Id

Name

Fee

Pharma

Test

Other

Rent

total

100

Ram

150

190

100

20

1000

1460

101

kumar

220

1000

200

100

1000

2520

The database table log contains the username and password of admin.
Username

Password

Admin

admin

Result:
Thus the design process has been implemented successfully.

Вам также может понравиться