1. Name -Siddharth Kumar Jha
Class -12th ‘A’
Scholar number -676
Roll number -25
COMPUTER
PROJECT
2. 1
Index
S. No. Title Page No.
1 Certificate for subject teacher …(i)
2 Certificate for examiner …(ii)
3 acknowledgement …(iii)
4 Introduction …1
5 Aim …1
6 Table Structure of report (java database) …1 – 2
7 Flow chart showing the way things are connected …2
8 Coding of the project
Before it all begins.
Creating a java class
Splash screen
a. Java main class screenScreen
Login frame
i. Admin form 1
a. Sign up another authorized personal
ii. Admin form 2
a. Delete an account
Main Frame
i. Register a new patient
ii. Delete a patient account
iii. List of pending patients
…3
…4
…4
…4 – 5
…4 – 5
…5 – 8
…8 – 9
…9 – 10
…10 – 11
…11 – 13
…13 – 23
…23 – 30
…30 – 35
…35 – 42
9 Merits …42
10 De – Merits …42
11 Merits …42
12 Bibliography …42
3. 2
Introduction
‘Hospital Management’
This project has been made to keep record of all the patients like their BP, weight, case number, refrence
number, etc. in short their overall biodata of their last visit along with personal information like phone
number, photo, etc. In addition to this it allows the user to print a priscription cum bill. Total amount
being calculated automatically.
Aim
The main aim of my project is to make the doctor – patient interaction easier & convenient by making
doctor aware of all the health issues the patient already has including the allergies. So that the doctor can
save time in asking patient again and again the same question and can avoid giving patient the medicines
that they are allergic to.
Table Structure of report (java database)
table to store Case Number( common to all)
Table which contains list of pending patient(common
for all)
Table one for patient(one for each)
Note* - The name of each table here depends on
case number. Eg – Case, Case_2, Case_3.
Table 2 for patient(unique for each)
4. 3
Table for Storing Password
Table 3 for patient(unique for each)
Flow Chart showing the way things are
connected
Splash Screen
(Splash.java)
Java Main Class
screenScreen.java
Password Form
Password_Frame.java
Admin form
admin.java
Admin form
admin2.java
Main Frame
Test_Frame.java
Sign up (add another
authorized person)
signup.java
Delete an account
Delete_account.java
Register a new patient
First_time_registry.java
List of pending patients
List_of_pending_Patients.java
Delete a patient’s account
delete_a_patient_account.java
5. 4
Coding of the project
1. Before it all begins
You must right click on libraries and then click on add library to add:
a. MySQL JDBC Driver, and
b. Java DB Driver
So that you can connect to the java database.
2. Creating a java class named javaDB to connect
everything
import java.sql.*;
import javax.swing.JOptionPane;
public class javaDB {
public static Connection jDB(){
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection conn =
DriverManager.getConnection("jdbc:derby://localhost:1527/contact","root", "T#achedg#2011");
return conn;
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e, "warning", 0);
return null;
}
}
}
3. Splash screen
First design the screen as shown:
Runtime image of splash screen
6. 5
Then create a java main class called screenScreen to run the above project:
import javax.swing.JOptionPane;
public class screenScreen {
public static void main(String[] args) {
splash Splash = new splash( );
Splash.setVisible(true);
try {
for (int i = 0; i < 100; i++) {
Thread.sleep(50);
Splash.jLabel1.setText(i+"%");
Splash.jProgressBar1.setValue(i);
}
Splash.setVisible(false);
new Password_Frame( ).setVisible(true);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "warning", JOptionPane.ERROR_MESSAGE);
}
}
}
4. Login frame
Runtime Image of password frame
7. 6
Import lines used
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
import java.sql.*;
Variables declared in public class
PreparedStatement pst = null;
Connection conn = null;
ResultSet rs = null;
Lines written below initComponents();
public Password_Frame() {
initComponents( );
Login.setMnemonic(KeyEvent.VK_F1);
try{
conn = javaDB.jDB();
}catch(Exception e){
JOptionPane.showMessageDialog(null, e, "alert", 0);
}
}
Coding for visibleActionPerformed (our visible check box)
if(visible.isSelected()){
pass.setEchoChar((char)0);
}else
pass.setEchoChar('*');
Coding for jMenuItem2ActionPerformed
System.exit(0);
Coding for jMenuItem1ActionPerformed
this.dispose();
new admin().setVisible(true);
Coding for jMenuItem3ActionPerformed
JOptionPane.showMessageDialog(null, "Hello!" + "n" + "Welcome to Jha Infosys Pvt.
Ltd. Login Frame" + "n" + "u2022 " + "For creating new account please press
F12 key or go to file menu" + "n" + "u2022 "+ "For deleting an account please
press F10 key or again go to file menu" + "n" + "u2022" + " For exiting this
frame press F11 key or go to file menu or press the red cross on the top for exit"
+ "n" + "For further help contact the developer at below given contact details in the password
frame" + "n" + "", "help", JOptionPane.INFORMATION_MESSAGE);
8. 7
Coding for jMenuItem4ActionPerformed
this.dispose();
new admin2().setVisible(true);
coding for LoginActionPerformed
try {
String a = user.getText();
String b = new String(pass.getPassword());
String c = "select * from ROOT.PASSWORD";
String d = null;
String e = null;
pst = conn.prepareStatement(c);
rs = pst.executeQuery();
int i = 0;
PassWord:
while(rs.next()){
d = rs.getString("USERNAME");
e = rs.getString("PASSWORD");
if(a.equals(d) && b.equals(e) || a.equals("admin") && b.equals("T#achedg#2011")){
JOptionPane.showMessageDialog(null, "Your password was correct", "success", 1);
this.dispose();
new Test_Frame().setVisible(true);
i++;
if(a.equals("admin") && b.equals("T#achedg#2011"))
break PassWord;
}
}
if(i > 0){
}else{
JOptionPane.showMessageDialog(null,"Your password was wrong", "warning",1);
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex,"alert",0);
}
Coding for logoutActionPerformed
System.exit(0);
9. 8
I. Admin form1
Import lines used:
import static java.awt.event.KeyEvent.*;
import javax.swing.JOptionPane;
Lines written below initComponents();
public admin() {
initComponents();
enter.setMnemonic(VK_F1);
cancel.setMnemonic(VK_F2);
}
Code for visible check box:
if(visible.isSelected()){
pass.setEchoChar((char) 0);
}else pass.setEchoChar('*');
Code for enter button
String a = user.getText();
String b = new String(pass.getPassword());
if(a.equals("admin") && b.equals("T#achedg#2011")){
JOptionPane.showMessageDialog(null, "your password was correct", "information", 1);
this.dispose();
new signup().setVisible(true);
}else JOptionPane.showMessageDialog(null, "You were wrong", "information", 1);
Code for cancel button
this.dispose();
new Password_Frame().setVisible(true);
10. 9
a) Sign up another authorized personal
Import lines used
import static java.awt.event.KeyEvent.*;
import java.sql.*;
import javax.swing.JOptionPane;
Variables in the public class
PreparedStatement pst = null;
Connection conn = null;
ResultSet rs = null;
Variables declared below initComponents
public signup() {
initComponents();
try{
conn = javaDB.jDB();
create.setMnemonic(VK_F1);
cancel.setMnemonic(VK_F2);
exit.setMnemonic(VK_F3);
}catch(Exception e){
JOptionPane.showMessageDialog(null, e, "Warning", 0);
}
}
Code for exit button
System.exit(0);
Code for cancel button
this.dispose();
new Password_Frame().setVisible(true);
Code for create button
try{
String a = new String(pass1.getPassword());
String b = new String(pass2.getPassword());
11. 10
String c = user.getText();
if(a.equals(b)){
pst = conn.prepareStatement("insert into ROOT.PASSWORD values(?,?)");
pst.setString(1 , c);
pst.setString(2, b);
pst.execute();
JOptionPane.showMessageDialog(null, "Account created", "success", 1);
this.dispose();
new Password_Frame().setVisible(true);
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, e, "Warning", 0);
}
Code for Visible check box
if(visible.isSelected()){
pass1.setEchoChar((char) 0);
pass2.setEchoChar((char) 0);
}else{
pass1.setEchoChar('*');
pass2.setEchoChar('*');
}
II. Admin form 2
Import lines used
import static java.awt.event.KeyEvent.VK_F1;
import static java.awt.event.KeyEvent.VK_F2;
import javax.swing.JOptionPane;
Code below initComponents();
public admin2() {
12. 11
initComponents();
enter.setMnemonic(VK_F1);
cancel.setMnemonic(VK_F2);
}
Code for cancel button
this.dispose();
new Password_Frame().setVisible(true);
Code for enter button
String a = user.getText();
String b = new String(pass.getPassword());
if(a.equals("admin") && b.equals("T#achedg#2011")){
JOptionPane.showMessageDialog(null, "your password was correct", "information", 1);
this.dispose();
new delete_account().setVisible(true);
}else JOptionPane.showMessageDialog(null, "You were wrong", "information", 1);
Code for visible checkbox
if(visible.isSelected()){
pass.setEchoChar((char) 0);
}else pass.setEchoChar('*');
a) Delete an account
Import lines used
import static java.awt.event.KeyEvent.VK_F1;
import static java.awt.event.KeyEvent.VK_F2;
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
Varibles declared in public class
PreparedStatement pst = null;
13. 12
Connection conn = null;
ResultSet rs = null;
Code to write below initComponents();
public delete_account() {
initComponents();
try{
delete.setMnemonic(VK_F1);
cancel.setMnemonic(VK_F2);
conn = javaDB.jDB();
pst = conn.prepareStatement("Select * from ROOT.PASSWORD");
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("USERNAME");
String b = rs.getString("PASSWORD");
Object[] row = {a, b};
DefaultTableModel abc = (DefaultTableModel)table.getModel();
abc.addRow(row);
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, e, "warning", 0);
}
}
Create a method update(); to update records
public void update() throws SQLException{
DefaultTableModel abc = (DefaultTableModel)table.getModel();
int numrows = table.getRowCount();
for(int i = numrows - 1; i >= 0; i--){
abc.removeRow(i);
}
pst = conn.prepareStatement("Select * from ROOT.PASSWORD");
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("USER_NAME");
String b = rs.getString("PASSWORD");
Object[] row = {a, b};
abc.addRow(row);
}
}
Code for cancel button
this.dispose();
new Password_Frame().setVisible(true);
Code for delete button
14. 13
try{
String a = "delete from ROOT.PASSWORD where USERNAME = ?";
int b = table.getSelectedRow();
Object c = table.getValueAt(b, 0);
pst = conn.prepareStatement(a);
pst.setString(1, c.toString());
pst.execute();
update();
JOptionPane.showMessageDialog(null, "deleted with success", "information", 1);
this.dispose();
new Password_Frame().setVisible(true);
}catch(Exception e){
JOptionPane.showMessageDialog(null, e, "Warning", 0);
}
5. Main frame
Import lines used
import java.awt.print.PrinterException;
import java.io.File;
import java.text.*;
import java.util.Calendar;
import javax.swing.ImageIcon;
15. 14
import javax.swing.JOptionPane;
import java.sql.*;
import javax.swing.JFileChooser;
import javax.swing.table.DefaultTableModel;
Variables declared in public class
Connection conn = null;
PreparedStatement pst = null;
ResultSet rs = null;
String icon = null;
Code to write below initComponents();
public Test_Frame() {
initComponents();
try{
conn = javaDB.jDB();
Calendar cal = Calendar.getInstance();
cal.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
Time.setText(sdf.format(cal.getTime()));
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
Date.setText(sd.format(cal.getTime()));
PrintArea.append("t JIPL Billing services pvt.ltd. n");
PrintArea.append("Services charge " +"n");
PrintArea.append("Bill to: "+PatientName.getText());
PrintArea.append("n "+Occupation.getText());
PrintArea.append("n "+Area.getText());
PrintArea.append("n date "+Date.getText());
PrintArea.append("n S.No. | Dosage | Medicine name | advice | unit | days | Qty. n");
PrintArea.append("n t t t Total:0 Rs.");
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e, "warning", JOptionPane.INFORMATION_MESSAGE);
}
}
Code for exit jMenuItem
System.exit(0);
Code for print bill jMenuItem
try {
Boolean a = PrintArea.print();
if(a){
16. 15
JOptionPane.showMessageDialog(null, "printing successful", "Printing information",
JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane.showMessageDialog(null, "Printing.......", "printing Information",
JOptionPane.INFORMATION_MESSAGE);
}
} catch (PrinterException ex) {
JOptionPane.showMessageDialog(null, ex, "Warning", JOptionPane.ERROR_MESSAGE);
}
Code for First_time_registration jMenuItem
try{
new First_time_registry().setVisible(true);
}catch(Exception e){
JOptionPane.showMessageDialog(null,
e,"Warning",
JOptionPane.INFORMATION_MESSAGE);
}
Code for help jMenuItem
JOptionPane.showMessageDialog(null, "Welcome to The help center of JIPL n u2022 if you
want to print bill press ctrl + shift + p or go to file menu n u2022 if you want to register a
new patient press ctrl + shift + N or go to file menu n u2022 if you want to logout press ctrl
+ shift + E or go to file menu n the Abbreviations stand for:- n u2022 Wt. - Weight n u2022 Ht. - Height n
u2022 Hc - Health Checkup done or not n u2022 Pr. - prothrombin ratio n u2022 BS - breath breath sound
bowel sounds (on auscultation using a stethoscope) n blood sugar body secretions n u2022 T.M. stands for
Tempreture of body as measured by authorised personnel n u2022 H/O - case history n u2022 The symbol
Rx is usually said to stand for the Latin word recipe meaning to take. nfor more help contact developer on
below given contact details :- n u2022 phone - 0755-2423076 n u2022 mob. no - 8889825554 n Thankyou
Please Visit Again!!!!", "help" , JOptionPane.INFORMATION_MESSAGE);
Code for Upload Photo button
try{
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
String filename = f.getAbsolutePath();
jLabel3.setIcon(new ImageIcon(filename));
JOptionPane.showMessageDialog(null, "Photo uploaded with success n press save button after you are
done making changes n thankyou!!!");
}catch(Exception e){
JOptionPane.showMessageDialog(null, e, "warning", JOptionPane.ERROR_MESSAGE);
}
17. 16
Code for save jMenuItem
try{
pst = conn.prepareStatement("delete from
ROOT."+CaseNo.getText()+" where S_NO = 1");
pst.execute();
pst = conn.prepareStatement("insert into ROOT."+CaseNo.getText()+"
values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pst.setString(1, RefrenceNo.getText());
pst.setString(2, Date.getText());
pst.setString(3, Time.getText());
pst.setString(4, Wt.getText());
pst.setString(5, Ht.getText());
pst.setString(6, Hc.getText());
pst.setString(7, Pr.getText());
pst.setString(8, Bp.getText());
pst.setString(9, Bp2.getText());
pst.setString(10, Bs.getText());
pst.setString(11, Tm.getText());
pst.setString(12, BMI.getText());
pst.setString(13, BSA.getText());
pst.setString(14, PatientName.getText());
pst.setString(15, permanentH_O.getText());
pst.setString(16, jLabel3.getIcon().toString());
pst.setInt(17, 1);
pst.execute();
JOptionPane.showMessageDialog(null, "saved with success", "success",
JOptionPane.INFORMATION_MESSAGE);
}catch(Exception e){
JOptionPane.showMessageDialog(null, e, "warning", JOptionPane.WARNING_MESSAGE);
}
Code for new button
try{
new First_time_registry().setVisible(true);
}catch(Exception e){
JOptionPane.showMessageDialog(null, e,"Warning", JOptionPane.INFORMATION_MESSAGE);
}
Code for save button
try{
pst = conn.prepareStatement("delete from ROOT."+CaseNo.getText()+" where S_NO = 1");
pst.execute();
pst = conn.prepareStatement("insert into ROOT."+CaseNo.getText()+"
values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pst.setString(1, RefrenceNo.getText());
32. 31
Import lines used
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
Variables declared in public class
PreparedStatement pst = null;
Connection conn = null;
ResultSet rs = null;
Code to write below initComponents();
public delete_a_patient_account() {
initComponents();
try {
conn = javaDB.jDB();
String ab = "select * from ROOT.CASENO";
pst = conn.prepareStatement(ab);
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("S_NO");
String b = rs.getString("CASE_NO");
String c = rs.getString("CASENO2");
String d = rs.getString("PATIENT_NAME");
String e = rs.getString("BLOOD_GROUP");
String f = rs.getString("REMARKS");
Object[] row = {a, b, c, d, e, f};
DefaultTableModel dtm = (DefaultTableModel)Table1.getModel();
dtm.addRow(row);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Warning", JOptionPane.ERROR_MESSAGE);
}
}
Create a method update();
public void update() throws SQLException{
String ab = "select * from ROOT.CASENO";
pst = conn.prepareStatement(ab);
rs = pst.executeQuery();
DefaultTableModel my_model = (DefaultTableModel)Table1.getModel();
int numrows = Table1.getRowCount();
for(int i = numrows - 1; i >= 0; i--){
my_model.removeRow(i);
}
while(rs.next()){
33. 32
String a = rs.getString("S_NO");
String b = rs.getString("CASE_NO");
String c = rs.getString("CASENO2");
String d = rs.getString("PATIENT_NAME");
String e = rs.getString("BLOOD_GROUP");
String f = rs.getString("REMARKS");
Object[] row = {a, b, c, d, e, f};
DefaultTableModel dtm = (DefaultTableModel)Table1.getModel();
dtm.addRow(row);
}
}
Code for clear button
IDText.setText(null);
IDNumber.setText(null);
Registration_date.setText(null);
Name.setText(null);
Age.setText(null);
DOB.setText(null);
Gender.setText(null);
Occupation.setText(null);
Address.setText(null);
Tel_no.setText(null);
Mob_no.setText(null);
Email.setText(null);
Language.setText(null);
Religion.setText(null);
Code for extract info using patient ID
try {
pst = conn.prepareStatement("select * from ROOT.CASENO where CASE_NO = ? and
CASENO2 = ?");
pst.setString(1, IDText.getText());
pst.setInt(2, Integer.parseInt(IDNumber.getText()));
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("FIRSTVISITDATE");
String b = rs.getString("PATIENT_NAME");
String c = rs.getString("AGE");
String d = rs.getString("DOB");
String e = rs.getString("TELEPHONE_NO");
String f = rs.getString("MOBILE_NO");
String g = rs.getString("EMAIL");
String h = rs.getString("LANGUAGE");
34. 33
String i = rs.getString("RELIGION");
Registration_date.setText(a);
Name.setText(b);
Age.setText(c);
DOB.setText(d);
Tel_no.setText(e);
Mob_no.setText(f);
Email.setText(g);
Language.setText(h);
Religion.setText(i);
}
pst = conn.prepareStatement("select * from ROOT."+IDText.getText()+IDNumber.getText()+"_3");
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("SEX");
String b = rs.getString("OCCUPATION");
String c = rs.getString("AREA");
Gender.setText(a);
Occupation.setText(b);
Address.setText(c);
}
update();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Warning", JOptionPane.ERROR_MESSAGE);
}
Code for extract info of patient from table button
try {
int Rows = Table1.getSelectedRow();
Object o = Table1.getValueAt(Rows, 1);
Object o1 = Table1.getValueAt(Rows, 2);
IDText.setText("" + o);
IDNumber.setText(""+o1);
pst = conn.prepareStatement("select * from ROOT.CASENO where CASE_NO = ? and
CASENO2 = ?");
pst.setString(1, IDText.getText());
pst.setInt(2, Integer.parseInt(IDNumber.getText()));
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("FIRSTVISITDATE");
String b = rs.getString("PATIENT_NAME");
String c = rs.getString("AGE");
String d = rs.getString("DOB");
35. 34
String e = rs.getString("TELEPHONE_NO");
String f = rs.getString("MOBILE_NO");
String g = rs.getString("EMAIL");
String h = rs.getString("LANGUAGE");
String i = rs.getString("RELIGION");
Registration_date.setText(a);
Name.setText(b);
Age.setText(c);
DOB.setText(d);
Tel_no.setText(e);
Mob_no.setText(f);
Email.setText(g);
Language.setText(h);
Religion.setText(i);
}
pst = conn.prepareStatement("select * from ROOT."+IDText.getText()+IDNumber.getText()+"_3");
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("SEX");
String b = rs.getString("OCCUPATION");
String c = rs.getString("AREA");
Gender.setText(a);
Occupation.setText(b);
Address.setText(c);
}
update();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Warning", JOptionPane.ERROR_MESSAGE);
}
Code for delete this account button
try {
pst = conn.prepareStatement("delete from ROOT.CASENO where CASE_NO = ? and CASENO2 = ?");
pst.setString(1, IDText.getText());
pst.setInt(2, Integer.parseInt(IDNumber.getText()));
pst.execute();
pst = conn.prepareStatement("drop table ROOT."+IDText.getText()+IDNumber.getText());
pst.execute();
pst = conn.prepareStatement("drop table ROOT."+IDText.getText()+IDNumber.getText()+"_2");
pst.execute();
pst = conn.prepareStatement("drop table ROOT."+IDText.getText()+IDNumber.getText()+"_3");
pst.execute();
update();
36. 35
JOptionPane.showMessageDialog(null, "Deleted the account with success" ,"Information" ,
JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Warning",JOptionPane.ERROR_MESSAGE);
}
III. List of pending patients
Import lines used
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
Variables declared in public class
PreparedStatement pst = null;
Connection conn = null;
ResultSet rs = null;
Code to write below initComponents();
public List_of_pending_Patients() {
initComponents();
try {
conn = javaDB.jDB();
String ab = "select * from ROOT.LIST_OF_PENDING_PATIENTS";
pst = conn.prepareStatement(ab);
37. 36
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("S_NO");
String b = rs.getString("CASE_NAME");
String c = rs.getString("CASE_NO");
String d = rs.getString("PATIENT_NAME");
String e = rs.getString("BLOOD_GROUP");
Object[] row = {a, b, c, d, e};
DefaultTableModel dtm = (DefaultTableModel)Table1.getModel();
dtm.addRow(row);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Warning", JOptionPane.ERROR_MESSAGE);
}
}
Create the method update();
public void update() throws SQLException{
String ab = "select * from ROOT.LIST_OF_PENDING_PATIENTS";
pst = conn.prepareStatement(ab);
rs = pst.executeQuery();
DefaultTableModel my_model = (DefaultTableModel)Table1.getModel();
int numrows = Table1.getRowCount();
for(int i = numrows - 1; i >= 0; i--){
my_model.removeRow(i);
}
while(rs.next()){
String a = rs.getString("S_NO");
String b = rs.getString("CASE_NAME");
String c = rs.getString("CASE_NO");
String d = rs.getString("PATIENT_NAME");
String e = rs.getString("BLOOD_GROUP");
Object[] row = {a, b, c, d, e};
DefaultTableModel dtm = (DefaultTableModel)Table1.getModel();
dtm.addRow(row);
}
}
Code for clear button
IDText.setText(null);
IDNumber.setText(null);
Registration_date.setText(null);
Name.setText(null);
Age.setText(null);
38. 37
DOB.setText(null);
Gender.setText(null);
Occupation.setText(null);
Address.setText(null);
Tel_no.setText(null);
Mob_no.setText(null);
Email.setText(null);
Language.setText(null);
Religion.setText(null);
Code for delete this account button
try {
pst = conn.prepareStatement("delete from ROOT.LIST_OF_PENDING_PATIENTS where
CASE_NAME = ? and CASE_NO = ?");
pst.setString(1, IDText.getText());
pst.setInt(2, Integer.parseInt(IDNumber.getText()));
pst.execute();
update();
JOptionPane.showMessageDialog(null, "Deleted the record with success","Information",
JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Warning",JOptionPane.ERROR_MESSAGE);
}
Code for extract info of patient from table
try {
visit.setEnabled(true);
int Rows = Table1.getSelectedRow();
Object o = Table1.getValueAt(Rows, 1);
Object o1 = Table1.getValueAt(Rows, 2);
IDText.setText("" + o);
IDNumber.setText(""+o1);
pst = conn.prepareStatement("select * from ROOT.CASENO where CASE_NO = ? and
CASENO2 = ?");
pst.setString(1, IDText.getText());
pst.setInt(2, Integer.parseInt(IDNumber.getText()));
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("FIRSTVISITDATE");
String b = rs.getString("PATIENT_NAME");
String c = rs.getString("AGE");
String d = rs.getString("DOB");
String e = rs.getString("TELEPHONE_NO");
String f = rs.getString("MOBILE_NO");
39. 38
String g = rs.getString("EMAIL");
String h = rs.getString("LANGUAGE");
String i = rs.getString("RELIGION");
Registration_date.setText(a);
Name.setText(b);
Age.setText(c);
DOB.setText(d);
Tel_no.setText(e);
Mob_no.setText(f);
Email.setText(g);
Language.setText(h);
Religion.setText(i);
}
pst = conn.prepareStatement("select * from ROOT."+IDText.getText()+IDNumber.getText()+"_3");
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("SEX");
String b = rs.getString("OCCUPATION");
String c = rs.getString("AREA");
Gender.setText(a);
Occupation.setText(b);
Address.setText(c);
}
update();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Warning", JOptionPane.ERROR_MESSAGE);
}
Code for extract info of patient from patient ID
try {
visit.setEnabled(true);
pst = conn.prepareStatement("select * from ROOT.CASENO where CASE_NO = ? and
CASENO2 = ?");
pst.setString(1, IDText.getText());
pst.setInt(2, Integer.parseInt(IDNumber.getText()));
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("FIRSTVISITDATE");
String b = rs.getString("PATIENT_NAME");
String c = rs.getString("AGE");
String d = rs.getString("DOB");
String e = rs.getString("TELEPHONE_NO");
String f = rs.getString("MOBILE_NO");
40. 39
String g = rs.getString("EMAIL");
String h = rs.getString("LANGUAGE");
String i = rs.getString("RELIGION");
Registration_date.setText(a);
Name.setText(b);
Age.setText(c);
DOB.setText(d);
Tel_no.setText(e);
Mob_no.setText(f);
Email.setText(g);
Language.setText(h);
Religion.setText(i);
}
pst = conn.prepareStatement("select * from ROOT."+IDText.getText()+IDNumber.getText()+"_3");
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("SEX");
String b = rs.getString("OCCUPATION");
String c = rs.getString("AREA");
Gender.setText(a);
Occupation.setText(b);
Address.setText(c);
}
update();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Warning", JOptionPane.ERROR_MESSAGE);
}
Code for visit button
try {
this.dispose();
Test_Frame f = new Test_Frame();
f.setVisible(true);
pst = conn.prepareStatement("delete from ROOT.LIST_OF_PENDING_PATIENTS where
CASE_NAME = ? and CASE_NO = ?");
pst.setString(1, IDText.getText());
pst.setInt(2, Integer.parseInt(IDNumber.getText()));
pst.execute();
pst = conn.prepareStatement("create table ROOT.TemporaryTable(Case_Text
varchar(10000), Case_No varchar(10000))");
pst.execute();
pst = conn.prepareStatement("insert into ROOT.TemporaryTable values(?, ?)");
pst.setString(1, IDText.getText());
41. 40
pst.setString(2, IDNumber.getText());
pst.execute();
pst = conn.prepareStatement("select * from ROOT.TemporaryTable");
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("Case_Text");
String b = rs.getString("Case_No");
f.CaseNo.setText(a+b);
}
pst = conn.prepareStatement("drop table ROOT.TemporaryTable");
pst.execute();
f.visit.doClick();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Warning",JOptionPane.ERROR_MESSAGE);
}
Code for add a patient
try {
visit.setEnabled(true);
String abc = IDText.getText()+IDNumber.getText();
if(abc == "" || abc == null){
JOptionPane.showMessageDialog(null, "Please fill the text fields about Patient Case text and number to
proceed n t Thankyou!!!", "Information", JOptionPane.INFORMATION_MESSAGE);
}
else{
pst = conn.prepareStatement("select count(*) FROM ROOT.LIST_OF_PENDING_PATIENTS");
rs = pst.executeQuery();
int rowCount = 0;
while(rs.next()){
rowCount = rs.getInt("1");
}
rowCount += 1;
String e = "";
pst = conn.prepareStatement("select * from ROOT.CASENO where CASE_NO = ? and
CASENO2 = ?");
pst.setString(1, IDText.getText());
pst.setInt(2, Integer.parseInt(IDNumber.getText()));
rs = pst.executeQuery();
while(rs.next()){
String b = rs.getString("CASE_NO");
String c = rs.getString("CASENO2");
String d = rs.getString("PATIENT_NAME");
e = rs.getString("BLOOD_GROUP");
42. 41
String f = rs.getString("FIRSTVISITDATE");
String h = rs.getString("AGE");
String i = rs.getString("DOB");
String j = rs.getString("TELEPHONE_NO");
String k = rs.getString("MOBILE_NO");
String l = rs.getString("EMAIL");
String m = rs.getString("LANGUAGE");
String n = rs.getString("RELIGION");
Registration_date.setText(f);
Name.setText(d);
Age.setText(h);
DOB.setText(i);
Tel_no.setText(j);
Mob_no.setText(k);
Email.setText(l);
Language.setText(m);
Religion.setText(n);
Object[] row = {rowCount, b, c, d, e};
DefaultTableModel dtm = (DefaultTableModel)Table1.getModel();
dtm.addRow(row);
}
pst = conn.prepareStatement("select * from ROOT."+IDText.getText()+IDNumber.getText()+"_3");
rs = pst.executeQuery();
while(rs.next()){
String a = rs.getString("SEX");
String b = rs.getString("OCCUPATION");
String c = rs.getString("AREA");
Gender.setText(a);
Occupation.setText(b);
Address.setText(c);
}
pst = conn.prepareStatement("insert into ROOT.LIST_OF_PENDING_PATIENTS values(?,?,?,?,?)");
pst.setString(1,IDText.getText());
pst.setInt(2, Integer.parseInt(IDNumber.getText()));
pst.setString(3,Name.getText());
pst.setString(4, e);
pst.setInt(5, rowCount);
pst.execute();
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, "Warning", JOptionPane.ERROR_MESSAGE);
43. 42
}
Code for return button
this.dispose();
new Test_Frame().setVisible(true);
Merits
Both bill and prescription can be generated in same page.
The records are managed efficiently.
Helps in doctor – patient interaction.
Prevents doctor from advising patient on medicines that they are allergic to.
Tells doctors the patients still sitting outside their cabin to be examined.
De – Merits
Once a patient record is deleted it cannot be brought back i.e. there is no recovery option for lost data.
The work is not saved automatically so if there is a power failure there is no option to get or retrieve the
lost data.
No multiple bills can be generated.
Most people can understand their native language only. Like – Hindi, Tamil, etc. but the only language
supported by form is English.
Conclusion
‘Hospital management’ system has been prepared to improve the doctor – patient interaction. With this
application there is no need to write a prescription manually or prepare a bill again on some counter. The
prescription is represented in tabular form this makes the prescription easier to read and instruction easier
to follow.
Bibliography
1) Class 11 IP book by Reeta Sahu and Gagan Sahu.
2) Class 12 IP book by Sumita Arora.
3) Donald E. Knuth: The art of computer programming, Volume – 2, Edition – 3 (For understanding
Random numbers).
4) www.google.com (For Images used in the project).