-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewPatient.java
More file actions
210 lines (156 loc) · 4.61 KB
/
ViewPatient.java
File metadata and controls
210 lines (156 loc) · 4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
package bootathonfinal;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
class ViewPatient
{
JFrame f;
static JTextField jt;
static int Checkup;
public ViewPatient() {
// TODO Auto-generated constructor stub
f=ObjectFile.getFrame("Patient records");
jt=new JTextField();
JLabel jl=new JLabel("Patients_id");
jl.setFont(new Font("Times New Roman", Font.BOLD,24));
jl.setBounds(400,200, 200, 30);
jt.setBounds(530, 200, 250, 40);
JButton jb2=ObjectFile.getButton("View");
JButton jb=ObjectFile.getButton("Update Patients info");
jb.setBounds(580,260 , 300, 40);
jb2.setBounds(460,260, 100, 40);
JButton ViewPatient=ObjectFile.getButton("View Patient");
JButton ViewallPatient=ObjectFile.getButton("View all Patient");
JButton chart1 = ObjectFile.getButton("Diseases Analysis");
ViewPatient.setBounds(60, 160, 270, 40);
chart1.setBounds(60, 280, 270, 40);
ViewallPatient.setBounds(60, 220, 270, 40);
ViewallPatient.setForeground(Color.gray);
chart1.setForeground(Color.gray);
jb.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(!jt.getText().isEmpty() && jt.getText().length()==4)
{
Connection con=ObjectFile.getjdbc();
String s="";
try {
Statement st =con.createStatement();
String Query="Select Patient_id from Patients where Patient_id='"+jt.getText()+"'";
ResultSet rs=st.executeQuery(Query);
while(rs.next())
{
s=rs.getString("Patient_id");
System.out.println(s);
}
if(s.equals(jt.getText()))
{
System.out.println("Success");
try {
Statement st1 =con.createStatement();
String Query1="insert into Checkup(Hospital_id,Patient_id) values('"+FirstPage.hid+"','"+jt.getText()+"')";
System.out.println(Query1);
int d=st1.executeUpdate(Query1);
if(d==1)
con.close();
desc();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
else
{
JOptionPane.showMessageDialog(f,"Enter the Valid Patient_id");
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
else
{
JOptionPane.showMessageDialog(f, "Enter valid Patient id");
}
}
});
jb2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub\
Connection con=ObjectFile.getjdbc();
String s="";
try {
Statement st =con.createStatement();
String Query="Select Patient_id from Patients where Patient_id='"+jt.getText()+"'";
ResultSet rs=st.executeQuery(Query);
while(rs.next())
{
s=rs.getString("Patient_id");
System.out.println(s);
}
if(s.equals(jt.getText()))
{
System.out.println("Success");
new SinglePatientRecords(s);
}
else
{
JOptionPane.showMessageDialog(f,"Enter the Valid Patient_id");
}
con.close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
f.add(ViewallPatient);
f.add(chart1);
f.add(ViewPatient);
f.add(jb);
f.add(jb2);
f.add(jl);
f.add(jt);
JPanel panel = ObjectFile.getpanel();
f.add(panel);
}
public static void desc()
{
Connection con=ObjectFile.getjdbc();
try {
Statement st =con.createStatement();
String Query="select Checkup_id from Checkup where Patient_id='"+jt.getText()+"' and Hospital_id='"+FirstPage.hid+"' ORDER BY Checkup_id DESC";
System.out.println(Query);
ResultSet rs=st.executeQuery(Query);
while(rs.next())
{
int d=rs.getInt("Checkup_id");
new UpdatePatientInfo(d);
break;
}
con.close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
public static void main(String []args)
{
new ViewPatient();
}
}