-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHospitalUser.java
More file actions
277 lines (236 loc) · 12 KB
/
HospitalUser.java
File metadata and controls
277 lines (236 loc) · 12 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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package teamprojectsavecare;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import javax.swing.JOptionPane;
/**
*
* @author seanr
*/
public class HospitalUser extends User {
protected String hospitalID;
protected String surgeryID;
public HospitalUser() {
}
public HospitalUser(String hospitalID, String surgeryID, String UserId, String userFirstName, String userLastName, String userPPSNumber, String userEmail, String userPassword, String userType) {
super(UserId, userFirstName, userLastName, userPPSNumber, userEmail, userPassword, userType);
this.hospitalID = hospitalID;
this.surgeryID = surgeryID;
}
public String getHospitalID() {
return hospitalID;
}
public void setHospitalID(String hospitalID) {
this.hospitalID = hospitalID;
}
public String getSurgeryID() {
return surgeryID;
}
public void setSurgeryID(String surgeryID) {
this.surgeryID = surgeryID;
}
@Override
public String toString() {
return super.toString() + "HospitalUser{" + "hospitalID=" + hospitalID + ", surgeryID=" + surgeryID + '}';
}
//This method update fields of the user table.
//If the patient changes fields in the patient table it may need to be updated in the user table also.
//if so then this method is called where needed.
public void changeDataUsersTable(String updateContent, String updateField) {
try {
Statement statement = myConn.createStatement();
statement.execute("Update Users"
+ " SET User" + updateField + "='" + updateContent + "'"
+ " WHERE " + "UserEmail" + "='" + userEmail + "';");
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, e); //error from try
}//end try catch
}
public void setDoctorsFields(String email) {
}
//This method stores all the signed in patients medications prescribed stored in the database
//Procedures completed are added into the passed in medications prescribed arraylist
public void storeMedications(Patient patient, ArrayList<MedicationPrescribed> meds) {
try {
Statement stmt = myConn.createStatement();
ResultSet rs = stmt.executeQuery(
"select MedicationDatePrescribed,"
+ "MedicationDateEnd, "
+ "Medication.MedicationName,"
+ "Medication.MedicationBrand, "
+ "Medication.MedicationSideEffects, "
+ "Medication.MedicationDose,"
+ "Doctor.DoctorFirstName,"
+ "Doctor.DoctorLastName, "
+ "Medication.MedicationRecommendation, "
+ " PrescriptionId "
+ "from MedicationPrescribed "
+ "INNER JOIN Doctor ON MedicationPrescribed.DoctorId = Doctor.DoctorId "
+ "INNER JOIN Medication ON MedicationPrescribed.MedicationId = Medication.MedicationId "
+ "WHERE PatientId ='" + patient.getPatientID() + "';");
// while loop to iterate through all records of customer table and display them
// in the text field
meds.clear();
while (rs.next()) {
MedicationPrescribed med = new MedicationPrescribed();
med.setMedicationDatePrescribed(rs.getString(1));
med.setMedicationDateEnded(rs.getString(2));
med.setMedicationName(rs.getString(3));
med.setMedicationBrand(rs.getString(4));
med.setMedicationSideEffects(rs.getString(5));
med.setMedicationDose(rs.getString(6));
med.setDoctorFirstName(rs.getString(7));
med.setDoctorLastName(rs.getString(8));
med.setMedicationRecommendation(rs.getString(9));
med.setPrescriptionId(rs.getString(10));
meds.add(med);
}
} catch (SQLException ex) {
System.out.println(ex);
} catch (Exception ex) {
System.out.println(ex);
}
}
//This method stores all the signed in patients procedures completed stored in the database
//Procedures completed are added into the passed in proecedures compleded arraylist
public void storeProcedures(Patient patient, ArrayList<ProceduresCompleted> procedures) {
try {
Statement stmt = myConn.createStatement();
ResultSet rs = stmt.executeQuery(
"select Procedures.ProcedureName,"
+ "Procedures.ProcedureDescription, "
+ "Hospital.HospitalName,"
+ "Doctor.DoctorFirstName,"
+ "Doctor.DoctorLastName, "
+ "ProcedureCompletedDate, "
+ "ProcedureCompletedSummary, "
+ "Procedures.ProcedureRiskLevel, "
+ "Procedures.ProcedureId, "
+ "ProcedureCompletedId "
+ "from ProceduresCompleted "
+ "INNER JOIN Doctor ON ProceduresCompleted.DoctorId = Doctor.DoctorId "
+ "INNER JOIN Procedures ON ProceduresCompleted.ProcedureId = Procedures.ProcedureId "
+ "INNER JOIN Hospital ON ProceduresCompleted.HospitalId = Hospital.HospitalId "
+ "WHERE PatientId ='" + patient.getPatientID() + "';");
// while loop to iterate through all records of customer table and display them
// in the text field
procedures.clear();
while (rs.next()) {
ProceduresCompleted procedureObject = new ProceduresCompleted();
procedureObject.setProcedureName(rs.getString(1));
procedureObject.setProcedureDescription(rs.getString(2));
procedureObject.setHopspitalName(rs.getString(3));
procedureObject.setDoctorFirstName(rs.getString(4));
procedureObject.setDoctorLastName(rs.getString(5));
procedureObject.setProcedureCompletedDate(rs.getString(6));
procedureObject.setProcedureCompletedSummary(rs.getString(7));
procedureObject.setProcedureRiskLevel(rs.getString(8));
procedureObject.setProcedureId(rs.getString(9));
procedureObject.setProcedureCompletedId(rs.getString(10));
procedures.add(procedureObject);
}
} catch (SQLException ex) {
System.out.println(ex);
} catch (Exception ex) {
System.out.println(ex);
}
}
//This method stores all the signed in patients hospital appointments.
//Query completed referencing the patient id signed in.
//All appoinments of the signed in patient are loaded into an arraylist.
public void storeAppointmets(Patient patient, ArrayList<Appointment> appointments) {
try {
Statement stmt = myConn.createStatement();
ResultSet rs = stmt.executeQuery(
"select Hospital.HospitalName, "
+ "Hospital.HospitalPhoneNumber, "
+ "Doctor.DoctorFirstName,"
+ "Doctor.DoctorLastName, "
+ "AppointmentDate, "
+ "AppointmentTime, "
+ "AppointmentSummary, "
+ "Department.DepartmentId, "
+ "Clinics.ClinicId, "
+ "Clinics.ClinicName, "
+ "AppointmentId "
+ "from Appointment "
+ "INNER JOIN Doctor ON Appointment.DoctorId = Doctor.DoctorId "
+ "INNER JOIN Patient ON Appointment.PatientId = Patient.PatientId "
+ "INNER JOIN Hospital ON Appointment.HospitalId = Hospital.HospitalId "
+ "INNER JOIN Department ON Appointment.DepartmentId = Department.DepartmentId "
+ "INNER JOIN Clinics ON Appointment.ClinicId = Clinics.ClinicId "
+ "WHERE Patient.PatientId ='" + patient.getPatientID()
+ "';");
// while loop to iterate through all records of customer table and display them
// in the text field
appointments.clear();
while (rs.next()) {
Appointment appointment = new Appointment();
appointment.setHospitalName(rs.getString(1));
appointment.setHospitalPhoneNumber(rs.getString(2));
appointment.setDoctorFirstName(rs.getString(3));
appointment.setDoctorLastName(rs.getString(4));
appointment.setAppointmentDate(rs.getString(5));
appointment.setAppointmentTime(rs.getString(6));
appointment.setAppointmentSummary(rs.getString(7));
appointment.setDepartmentId(rs.getString(8));
appointment.setClinicId(rs.getString(9));
appointment.setAppointmentId(rs.getString(11));
appointment.setClinicName(rs.getString(10));
appointments.add(appointment);
}
} catch (SQLException ex) {
System.out.println(ex);
} catch (Exception ex) {
System.out.println(ex);
}
}
//This method stores all the signed in patients surgery appointments.
//Query completed referencing the patient id signed in.
//All appoinments of the signed in patient are loaded into an arraylist.
public void storeSurgeryAppointmets(Patient patient, ArrayList<Appointment> hospitalAppointments) {
try {
Statement stmt = myConn.createStatement();
ResultSet rs = stmt.executeQuery(
"select Surgery.SurgeryName, "
+ "Surgery.SurgeryPhoneNumber, "
+ "Doctor.DoctorFirstName,"
+ "Doctor.DoctorLastName, "
+ "AppointmentDate, "
+ "AppointmentTime, "
+ "AppointmentSummary, "
+ "AppointmentId "
+ "from Appointment "
+ "INNER JOIN Doctor ON Appointment.DoctorId = Doctor.DoctorId "
+ "INNER JOIN Patient ON Appointment.PatientId = Patient.PatientId "
+ "INNER JOIN Surgery ON Appointment.SurgeryId = Surgery.SurgeryId "
+ "WHERE Patient.PatientId ='" + patient.getPatientID()
+ "';");
// while loop to iterate through all records of customer table and display them
// in the text field
hospitalAppointments.clear();
while (rs.next()) {
Appointment appointment = new Appointment();
appointment.setSurgeryName(rs.getString(1));
appointment.setSurgeryPhoneNumber(rs.getString(2));
appointment.setDoctorFirstName(rs.getString(3));
appointment.setDoctorLastName(rs.getString(4));
appointment.setAppointmentDate(rs.getString(5));
appointment.setAppointmentTime(rs.getString(6));
appointment.setAppointmentSummary(rs.getString(7));
appointment.setAppointmentId(rs.getString(8));
hospitalAppointments.add(appointment);
}
} catch (SQLException ex) {
System.out.println(ex);
} catch (Exception ex) {
System.out.println(ex);
}
}
}