-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppointment.java
More file actions
163 lines (121 loc) · 3.64 KB
/
Copy pathAppointment.java
File metadata and controls
163 lines (121 loc) · 3.64 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
import java.util.ArrayList;
public class Appointment{
public String patientID;
public String doctorID;
public String appointmentID;
public String date;
public String time;
public String status;
public Appointment(String appointmentID,String patientID,String doctorID,String date,String time,String status) {
this.patientID = patientID;
this.doctorID = doctorID;
this.appointmentID = appointmentID;
this.date = date;
this.time = time;
this.status = status;
if(date == null || date.isEmpty()){
System.out.println("Date cannot be empty.");
this.date = "Not Set";
}
else{
this.date = date;
}
// Validation for empty time
if(time == null || time.isEmpty()){
System.out.println("Time cannot be empty.");
this.time = "Not Set";
}
else{
this.time = time;
}
this.status = status;
}
public Appointment(){
}
public Appointment(Doctor d,Patient p) {
this.doctorID=d.getID();
this.patientID=p.getID();
}
public void setPatientID(String patientID) {
this.patientID = patientID;
}
public void setDoctorID(String doctorID) {
this.doctorID = doctorID;
}
public void setAppointmentID(String appointmentID) {
this.appointmentID = appointmentID;
}
public void setDate(String date) {
if(date == null || date.isEmpty()){
System.out.println("Date cannot be empty.");
}
else{
this.date = date;
}
}
public void setTime(String time) {
if(time == null || time.isEmpty()){
System.out.println("Time cannot be empty.");
}
else{
this.time = time;
}
}
public void setStatus(String status) {
if(this.status != null &&
this.status.equalsIgnoreCase("Cancelled")
&& status.equalsIgnoreCase("Completed")) {
System.out.println("Cancelled appointment cannot be completed.");
}
else {
this.status = status;
}
}
public String getPatientID() {
return patientID;
}
public String getDoctorID() {
return doctorID;
}
public String getAppointmentID() {
return appointmentID;
}
public String getDate() {
return date;
}
public String getTime() {
return time;
}
public String getStatus() {
return status;
}
@Override
public String toString() {
return appointmentID + "," +
patientID + "," +
doctorID + "," +
date + "," +
time + "," +
status;
}
public static boolean isDoctorAvailable(ArrayList<Appointment> appointments,
String doctorID,
String date,
String time) {
for(Appointment a : appointments) {
if(a.getDoctorID().equals(doctorID)
&& a.getDate().equals(date)
&& a.getTime().equals(time)
&& !a.getStatus().equalsIgnoreCase("Cancelled")) {
return false;
}
}
return true;
}
public static boolean patientHasDoctor(Patient p) {
if(p.getAssigned_doctor() == null) {
return false;
}
return true;
}
}