-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdatePatientFrame.java
335 lines (305 loc) · 15.7 KB
/
UpdatePatientFrame.java
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package hospitalmanagementsystem;
import java.util.ArrayList;
import javax.swing.JOptionPane;
/**
*
* @author Fame
*/
public class UpdatePatientFrame extends javax.swing.JFrame {
FileHandlerPatient f=new FileHandlerPatient();
ArrayList<Patients> s=new ArrayList<Patients>();
/**
* Creates new form UpdatePatientFrame
*/
public UpdatePatientFrame() {
super("****UPDATE PATIENT DETAILS****");
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
patientIdJLabel = new javax.swing.JLabel();
patientIdJField = new javax.swing.JTextField();
okJB = new javax.swing.JToggleButton();
nameJLabel = new javax.swing.JLabel();
idJLabel = new javax.swing.JLabel();
genderJLabel = new javax.swing.JLabel();
diseaseJLabel = new javax.swing.JLabel();
admitDateJLabel = new javax.swing.JLabel();
ageJLabel = new javax.swing.JLabel();
nameJF = new javax.swing.JTextField();
idJF = new javax.swing.JTextField();
diseaseJField = new javax.swing.JTextField();
admitDateJField = new javax.swing.JTextField();
ageJF = new javax.swing.JTextField();
updateJB = new javax.swing.JToggleButton();
backJB = new javax.swing.JToggleButton();
maleJRB = new javax.swing.JRadioButton();
femaleJRB = new javax.swing.JRadioButton();
otherJRB = new javax.swing.JRadioButton();
updateJLabel = new javax.swing.JLabel();
pictureJLabel = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
patientIdJLabel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
patientIdJLabel.setForeground(new java.awt.Color(255, 0, 0));
patientIdJLabel.setText("ID:");
getContentPane().add(patientIdJLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(45, 84, 50, 25));
patientIdJField.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
patientIdJFieldMouseClicked(evt);
}
});
getContentPane().add(patientIdJField, new org.netbeans.lib.awtextra.AbsoluteConstraints(205, 82, 250, 32));
okJB.setBackground(new java.awt.Color(204, 51, 255));
okJB.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
okJB.setIcon(new javax.swing.ImageIcon("C:\\Users\\Fame\\Documents\\NetBeansProjects\\HospitalManagementSystem\\src\\hospitalmanagementsystem\\Images\\Done-icon.png")); // NOI18N
okJB.setText("OK");
okJB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okJBActionPerformed(evt);
}
});
getContentPane().add(okJB, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 120, 100, 30));
nameJLabel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
nameJLabel.setForeground(new java.awt.Color(255, 0, 0));
nameJLabel.setText("NAME:");
getContentPane().add(nameJLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(45, 171, -1, -1));
idJLabel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
idJLabel.setForeground(new java.awt.Color(255, 0, 0));
idJLabel.setText("ID:");
getContentPane().add(idJLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(45, 223, 47, -1));
genderJLabel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
genderJLabel.setForeground(new java.awt.Color(255, 0, 0));
genderJLabel.setText("GENDER:");
getContentPane().add(genderJLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(45, 293, -1, -1));
diseaseJLabel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
diseaseJLabel.setForeground(new java.awt.Color(255, 0, 0));
diseaseJLabel.setText("DISEASE:");
getContentPane().add(diseaseJLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(45, 369, -1, -1));
admitDateJLabel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
admitDateJLabel.setForeground(new java.awt.Color(255, 0, 0));
admitDateJLabel.setText("ADMIT DATE:");
getContentPane().add(admitDateJLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(45, 414, -1, -1));
ageJLabel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
ageJLabel.setForeground(new java.awt.Color(255, 0, 0));
ageJLabel.setText("AGE:");
getContentPane().add(ageJLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(45, 327, -1, -1));
getContentPane().add(nameJF, new org.netbeans.lib.awtextra.AbsoluteConstraints(205, 161, 250, 27));
getContentPane().add(idJF, new org.netbeans.lib.awtextra.AbsoluteConstraints(205, 220, 250, 27));
getContentPane().add(diseaseJField, new org.netbeans.lib.awtextra.AbsoluteConstraints(205, 365, 250, 28));
getContentPane().add(admitDateJField, new org.netbeans.lib.awtextra.AbsoluteConstraints(205, 411, 250, 27));
getContentPane().add(ageJF, new org.netbeans.lib.awtextra.AbsoluteConstraints(205, 328, 250, 26));
updateJB.setBackground(new java.awt.Color(255, 0, 255));
updateJB.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
updateJB.setIcon(new javax.swing.ImageIcon("C:\\Users\\Fame\\Documents\\NetBeansProjects\\HospitalManagementSystem\\src\\hospitalmanagementsystem\\Images\\update.png")); // NOI18N
updateJB.setText("UPDATE");
updateJB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
updateJBActionPerformed(evt);
}
});
getContentPane().add(updateJB, new org.netbeans.lib.awtextra.AbsoluteConstraints(459, 450, 130, 31));
backJB.setBackground(new java.awt.Color(0, 255, 0));
backJB.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
backJB.setIcon(new javax.swing.ImageIcon("C:\\Users\\Fame\\Documents\\NetBeansProjects\\HospitalManagementSystem\\src\\hospitalmanagementsystem\\Images\\back-icon.png")); // NOI18N
backJB.setText("BACK");
backJB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backJBActionPerformed(evt);
}
});
getContentPane().add(backJB, new org.netbeans.lib.awtextra.AbsoluteConstraints(45, 459, 110, 31));
buttonGroup1.add(maleJRB);
maleJRB.setText("MALE");
getContentPane().add(maleJRB, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 287, 60, 30));
buttonGroup1.add(femaleJRB);
femaleJRB.setText("FEMALE");
getContentPane().add(femaleJRB, new org.netbeans.lib.awtextra.AbsoluteConstraints(259, 287, 70, 30));
buttonGroup1.add(otherJRB);
otherJRB.setText("OTHER");
getContentPane().add(otherJRB, new org.netbeans.lib.awtextra.AbsoluteConstraints(349, 287, 70, 30));
updateJLabel.setFont(new java.awt.Font("Stencil", 1, 24)); // NOI18N
updateJLabel.setForeground(new java.awt.Color(255, 51, 51));
updateJLabel.setText("UPDATE PATIENT DETAILS");
getContentPane().add(updateJLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(137, 11, -1, -1));
pictureJLabel.setIcon(new javax.swing.ImageIcon("C:\\Users\\Fame\\Documents\\NetBeansProjects\\HospitalManagementSystem\\src\\hospitalmanagementsystem\\Images\\clean-medical-background.jpg")); // NOI18N
getContentPane().add(pictureJLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 750, 500));
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void okJBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okJBActionPerformed
// TODO add your handling code here:
boolean check=false;
idJF.setEditable(false);
try{
String id=patientIdJField.getText();
if(id.equals("")){
throw new NullPointerException();
}
else{
try{
int idd=Integer.parseInt(id);
s=f.getArray();
for(int i=0;i<s.size();i++){
Patients p=s.get(i);
if(p.getId()==(idd)){
check=true;
nameJF.setText(p.getName());
admitDateJField.setText(p.getAdmitDate());
diseaseJField.setText(p.getDisease());
idJF.setText(p.getId()+"");
ageJF.setText(p.getAge()+"");
String gender=p.getGender();
if(gender.equalsIgnoreCase("MALE")){
maleJRB.setSelected(true);
}
else if(gender.equalsIgnoreCase("FEMALE")){
femaleJRB.setSelected(true);
}
else if(gender.equalsIgnoreCase("OTHER")){
otherJRB.setSelected(true);
}
}
}
if(check==true){
JOptionPane.showMessageDialog(this, "****RECORD IS FOUND SUCCESSFULLY****","***CONFIRMATION***",JOptionPane.INFORMATION_MESSAGE);
}
else if(check==false){
JOptionPane.showMessageDialog(this, "****RECORD IS NOT FOUND!!!!","***INVALID***",JOptionPane.ERROR_MESSAGE);
}
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "NUMBER FORMAT EXCEPTION OCCURED ENTER INTEGER IN FIELD ID","***INVALID***",JOptionPane.ERROR_MESSAGE);
}
}
}
catch(NullPointerException e){
JOptionPane.showMessageDialog(this, "NULL POINTER EXCEPTION OCCURED,PATIENT ID FIELD IS EMPTY, ENTER ID IN FIELD ID","***INVALID***",JOptionPane.ERROR_MESSAGE);
}
}//GEN-LAST:event_okJBActionPerformed
private void backJBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backJBActionPerformed
// TODO add your handling code here:
new PatientModuleFrame().setVisible(true);
this.dispose();
}//GEN-LAST:event_backJBActionPerformed
private void updateJBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateJBActionPerformed
// TODO add your handling code here:
try{
String name=nameJF.getText();
String admitDate=admitDateJField.getText();
String disease=diseaseJField.getText();
String age=ageJF.getText();
String id=idJF.getText();
String gender=null;
if(maleJRB.isSelected()){
gender="male";
}
else if(femaleJRB.isSelected()){
gender="female";
}
if(otherJRB.isSelected()){
gender="other";
}
if(name.equals("")||admitDate.equals("")||disease.equals("")||age.equals("")||id.equals("")||gender.equals("")){
throw new NullPointerException();
}
else{
try{
int a=Integer.parseInt(age);
int i=Integer.parseInt(id);
Patients p=new Patients(name,gender,disease,admitDate,i,a);
f.update(p);
JOptionPane.showMessageDialog(this, "UPDATED SUCCESSFULLY","***CONFIRMATION***",JOptionPane.INFORMATION_MESSAGE);
nameJF.setText("");
admitDateJField.setText("");
diseaseJField.setText("");
ageJF.setText("");
idJF.setText("");
maleJRB.setSelected(false);
femaleJRB.setSelected(false);
otherJRB.setSelected(false);
patientIdJField.setText("");
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(this, "****NUMBER FORMAT EXCEPTION, ****ENTER ANY INTEGER IN FIELD AGE****","**INVALID**",JOptionPane.ERROR_MESSAGE);
}
}
}
catch(NullPointerException e){
JOptionPane.showMessageDialog(this, "****NULL POINTER EXCEPTION,FILL DOCTOR ID FIELD****","**INVALID**",JOptionPane.ERROR_MESSAGE);
}
}//GEN-LAST:event_updateJBActionPerformed
private void patientIdJFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_patientIdJFieldMouseClicked
// TODO add your handling code here:
patientIdJField.setText("");
}//GEN-LAST:event_patientIdJFieldMouseClicked
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(UpdatePatientFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(UpdatePatientFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(UpdatePatientFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(UpdatePatientFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new UpdatePatientFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField admitDateJField;
private javax.swing.JLabel admitDateJLabel;
private javax.swing.JTextField ageJF;
private javax.swing.JLabel ageJLabel;
private javax.swing.JToggleButton backJB;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JTextField diseaseJField;
private javax.swing.JLabel diseaseJLabel;
private javax.swing.JRadioButton femaleJRB;
private javax.swing.JLabel genderJLabel;
private javax.swing.JTextField idJF;
private javax.swing.JLabel idJLabel;
private javax.swing.JRadioButton maleJRB;
private javax.swing.JTextField nameJF;
private javax.swing.JLabel nameJLabel;
private javax.swing.JToggleButton okJB;
private javax.swing.JRadioButton otherJRB;
private javax.swing.JTextField patientIdJField;
private javax.swing.JLabel patientIdJLabel;
private javax.swing.JLabel pictureJLabel;
private javax.swing.JToggleButton updateJB;
private javax.swing.JLabel updateJLabel;
// End of variables declaration//GEN-END:variables
}