-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDoctor.java
More file actions
111 lines (87 loc) · 3.14 KB
/
Doctor.java
File metadata and controls
111 lines (87 loc) · 3.14 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
import java.util.ArrayList;
/**
* Doctor class is responsible for examining Patient objects
*
* @author Randy Pham
*/
public class Doctor extends Account {
// TODO: something something patient list
private MessageHandler messageHandler;
private Patient currentPatient;
private String doctorFirstName;
private int doctorID;
// default constructor
public Doctor() {
super();
messageHandler = new MessageHandler();
doctorID = 0;
doctorFirstName = "John";
currentPatient = null;
}
// overload constructor
public Doctor(String doctorFirstName, int doctorID, String username, String password) {
super(username, password);
messageHandler = new MessageHandler();
this.doctorFirstName = doctorFirstName;
this.doctorID = doctorID;
}
public void examinePatient(String patientSummary, String medication, String date) {
// examines currentPatient here
String visitSummary = date + ": " + patientSummary;
System.out.println(visitSummary);
prescribeMedication(medication);
checkoutPatient(visitSummary);
}
@Override
public void sendMessage(Account recipient, String message) {
// uses messageHandler to message Patient
Patient patient = (Patient) recipient;
String messageToSend = "Doctor " + doctorFirstName + ": " + message;
try {
messageHandler.writeMessage(this, patient, messageToSend);
} catch (Exception e) {
System.out.println("there was a problem creating a message from doctor to current patient");
e.printStackTrace();
}
}
// GETTER METHODS
public Patient getCurrentPatient() {
return this.currentPatient;
}
public String getDoctorFirstName() {
return this.doctorFirstName;
}
public int getDoctorID() {
return this.doctorID;
}
// SETTER METHODS
public void setCurrentPatient(Patient currentPatient) {
this.currentPatient = currentPatient;
}
public void setDoctorFirstName(String doctorFirstName) {
this.doctorFirstName = doctorFirstName;
}
public void setDoctorID(int doctorID) {
this.doctorID = doctorID;
}
// HELPER METHODS
private void checkoutPatient(String summary) {
// updates patient history with any notes
// patient history[] will show the last 10 visits
// add patient summary into queue
currentPatient.patientHistory.add(summary);
// check if queue is over 10
if (currentPatient.patientHistory.size() > 10) {
// if it is over 10, we keep removing elements until the size is 10
while (currentPatient.patientHistory.size() > 10) {
currentPatient.patientHistory.poll();
}
}
// update the patient history array for display purposes
currentPatient.patientHistoryArray = new ArrayList<String>(currentPatient.patientHistory);
}
private void prescribeMedication(String medication) {
// gives medication to patient
currentPatient.assignMedication(medication);
}
}