-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProcedure_Menu_Panel.java
More file actions
executable file
·370 lines (252 loc) · 10.7 KB
/
Procedure_Menu_Panel.java
File metadata and controls
executable file
·370 lines (252 loc) · 10.7 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
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/*****************************************************************************************************
* A Procedure menu to display to the user all the options for interacting with the Procedure
* database relation.
*****************************************************************************************************/
public class Procedure_Menu_Panel extends JPanel
{
/* Main panel displayed to the user */
private JPanel current_panel;
/* Pointer to the main java window for passing to new instances of a main menu button panel */
protected Hospital_Frame hospital_frame;
/* Pointer to menu button panel so it can be removed when necessary */
private JPanel main_menu_button;
/* String to get input data from fields */
private String input;
/*********************************************************************************
* Main constructor used for setting up the Procedure_Menu_Panel.
*********************************************************************************/
public Procedure_Menu_Panel ( Hospital_Frame frame )
{
this.hospital_frame = frame;
setLayout(new GridLayout(2,1));
add(current_panel = new Procedure_Button_Options());
add(main_menu_button = new Main_Menu_Button(hospital_frame));
}
/*********************************************************************************
* Switches the current main panel to the passed in one
*********************************************************************************/
protected void changeCurrentPanel(JPanel panel)
{
remove(current_panel);
// need to remove and re-add so the button stays on the bottom
remove(main_menu_button);
add(current_panel = panel);
add(main_menu_button = new Main_Menu_Button(hospital_frame));
revalidate();
repaint();
} // end changeCurrentPanel()
/*********************************************************************************
* Panel for displaying options for interacting with database.
*********************************************************************************/
private class Procedure_Button_Options extends JPanel
{
/* Buttons to take user to a panel for interacting with the Procedure relation */
private JButton insert_procedure_button, delete_procedure_button;
/*********************************************************************************
* Main constructor used for setting up the Procedure_Menu_Panel.
*********************************************************************************/
public Procedure_Button_Options ()
{
setLayout(new GridBagLayout());
initializeButtons();
addActionListeners();
add(insert_procedure_button);
add(delete_procedure_button);
}
/*********************************************************************************
* Initializes the buttons for Procedure_Menu_Panel.
*********************************************************************************/
private void initializeButtons()
{
insert_procedure_button = new JButton("Add New Procedure");
delete_procedure_button = new JButton("Delete Existing Procedure");
}
/*********************************************************************************
* Adds the action listeners for Procedure_Button_Options.
*********************************************************************************/
private void addActionListeners()
{
/* Add functionality - Display panel for inserting a new Procedure */
insert_procedure_button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
changeCurrentPanel(new Insert_Procedure_Menu_Panel());
}
});
/* Add functionality - Display panel for deleting an existing Procedure */
delete_procedure_button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
changeCurrentPanel(new Delete_Procedure_Menu_Panel());
}
});
} // end addActionListeners()
} // end Procedure Button Options Class
/*****************************************************************************************************
* A menu displayed to the user to insert a new Procedure into the database.
*****************************************************************************************************/
private class Insert_Procedure_Menu_Panel extends JPanel
{
/* Text fields for the user to enter intput data */
private JTextField procedure_description_field, patient_ssn_field, doctor_ssn_field,
nurse_ssn_field, scheduled_time_field, scheduled_date_field;
/*********************************************************************************
* Main constructor used for setting up the Insert_Procedure_Menu_Panel.
*********************************************************************************/
public Insert_Procedure_Menu_Panel()
{
setLayout(new GridLayout(8, 2));
initializeTextFields();
add(new JLabel("Enter information of Procedure to be added: "));
add(new JLabel(""));
add(new JLabel(" Procedure Description:"));
add(procedure_description_field);
add(new JLabel(" Patient SSN:"));
add(patient_ssn_field);
add(new JLabel(" Doctor SSN:"));
add(doctor_ssn_field);
add(new JLabel(" Nurse SSN:"));
add(nurse_ssn_field);
add(new JLabel(" Scheduled Date:"));
add(scheduled_date_field);
add(new JLabel(" Scheduled Time:"));
add(scheduled_time_field);
add(new Back_Button());
add(new Submit_Button());
}
/*********************************************************************************
* Initializes the text fields for Insert_Procedure_Menu_Panel.
*********************************************************************************/
private void initializeTextFields()
{
procedure_description_field = new JTextField(25);
patient_ssn_field = new JTextField(6);
doctor_ssn_field = new JTextField(6);
nurse_ssn_field = new JTextField(6);
scheduled_date_field = new JTextField(6);
scheduled_time_field = new JTextField(6);
}
/******************************************************************************
* Submit button for Insert_Procedure_Menu_Panel class.
******************************************************************************/
private class Submit_Button extends JButton
{
/******************************************************************
* Main constructor for Submit_Button
******************************************************************/
public Submit_Button()
{
super("Submit");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
// get input from ssn field into ssn string variable
loadInput();
// insert the procedure into the database
Doctor.insertPPT("PROCEDURE", input);
JOptionPane.showMessageDialog(null,"Submitted");
}
});
}
/******************************************************************
* Load input from ssn field into corresponding string variable and
* return that string.
******************************************************************/
private String loadInput()
{
// get input from textfields and load them into a single string
input = procedure_description_field.getText() + "\t" + scheduled_time_field.getText() + "\t"
+ scheduled_date_field.getText() + "\t" + patient_ssn_field.getText() + "\t" + doctor_ssn_field.getText() + "\t" +
nurse_ssn_field.getText();
// if this point is reached age and ssn were successfully retrieved
return input;
}
} // end Submit_Button class
} // end Insert Procedure menu class
/*****************************************************************************************************
* A menu displayed to the user to delete an existing Procedure from the database.
*****************************************************************************************************/
private class Delete_Procedure_Menu_Panel extends JPanel
{
/* Text fields for the user to enter intput data */
private JTextField procedure_id_field;
/*********************************************************************************
* Main constructor used for setting up the Delete_Procedure_Menu_Panel.
*********************************************************************************/
public Delete_Procedure_Menu_Panel()
{
setLayout(new GridLayout(4, 2));
initializeTextFields();
add(new Centered_Text_Panel("Enter ID of Procedure to be deleted:"));
add(procedure_id_field);
add(new JLabel(""));
add(new JLabel(""));
add(new Back_Button());
add(new Submit_Button());
}
/*********************************************************************************
* Initializes the text fields for Delete_Procedure_Menu_Panel.
*********************************************************************************/
private void initializeTextFields()
{
procedure_id_field = new JTextField(6);
}
/******************************************************************************
* Submit button for Delete_Procedure_Menu_Panel class.
******************************************************************************/
private class Submit_Button extends JButton
{
/******************************************************************
* Main constructor for Submit_Button
******************************************************************/
public Submit_Button()
{
super("Submit");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
// get input from ssn field into ssn string variable
loadInput();
// delete the procedure into the database
Patient.delete(input, "PROCEDURE");
}
});
}
/******************************************************************
* Load input from ssn field into corresponding string variable and
* return that string.
******************************************************************/
private String loadInput()
{
// get input from textfields and load them into a single string
input = procedure_id_field.getText();
// if this point is reached age and ssn were successfully retrieved
return input;
}
} // end Submit_Button class
} // end Delete_Procedure_Menu_Panel class
/*********************************************************************************
* Returns the user to the main Procedure menu
*********************************************************************************/
private class Back_Button extends JButton
{
public Back_Button()
{
super("<- Back");
addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
changeCurrentPanel(new Procedure_Button_Options());
}
});
}
}
} // end Procedure menu class