-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReport.java
More file actions
150 lines (138 loc) · 4.17 KB
/
Copy pathReport.java
File metadata and controls
150 lines (138 loc) · 4.17 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
import java.util.*;
import java.io.*;
/**
* This is a Report class
* @author Andre Ke
* @author Ryan Su
* @author Wesley Goh
* @author Zilin Weng
* @version Java 17.0.1
*/
class Report implements Serializable, ReadFromFileable{
private static final long serialVersionUID = -9027040502307744183L;
String patientID;
String doctor;
String testsDone;
String patientStatus;
String timeAdmitted;
String medicationPrescribed;
String results;
String height;
String weight;
String bloodtype;
/**
* Explanation - constructs an instance of Report
* @param patientID - a String representing the patient's ID
* @param doctor - a String representing the doctor
* @param timeAdmitted - a String representing the time the patient was admitted
* @param patientStatus - a String representing the patient's status
* @param medicationPrescribed - a String representing the medicine prescribed to patient
* @param testsDone - a String representing the tests done for patient
* @param results - a String representing results of patient
* @param bloodType - a String representing blood type of patient
* @param height - a String representing height of patient
* @param weight - a String representing weight of patient
*/
public Report(String patientID, String doctor, String timeAdmitted, String patientStatus, String medicationPrescribed, String testsDone, String results, String bloodType, String height, String weight){
this.patientID = patientID;
this.doctor = doctor;
this.testsDone = testsDone;
this.patientStatus = patientStatus;
this.timeAdmitted = timeAdmitted;
this.medicationPrescribed = medicationPrescribed;
this.results = results;
this.bloodtype = bloodType;
this.height = height;
this.weight = weight;
}
/**
* Explanation - gets patient ID
* @return a String stored in patientID
*/
public String getPatientID(){
return this.patientID;
}
/**
* Explanation - gets doctor
* @return a String stored in doctor
*/
public String getDoctor(){
return this.doctor;
}
/**
* Explanation gets tests done
* @return a String stored in testsDone
*/
public String getTestsDone() {
return this.testsDone;
}
/**
* Explanation - gets patient status
* @return a String stored in patientStatus
*/
public String getPatientStatus(){
return this.patientStatus;
}
/**
* Explanation - gets medication prescribed
* @return a String stored in medicationPrescribed
*/
public String getMedicationPrescribed(){
return this.medicationPrescribed;
}
/**
* Explanation - gets time admitted
* @return a String stored in timeAdmitted
*/
public String getTimeAdmitted(){
return this.timeAdmitted;
}
/**
* Explanation - gets results
* @return a String stored in results
*/
public String getResults(){
return this.results;
}
/**
* Explanation - prints report
* @return a String that contains report details
*/
@Override
public String toString(){
return "Patient: " + this.patientID
+ "\nDoctor: " + this.doctor
+ "\nTests Done: " + this.testsDone
+ "\nPatient Status: "+ this.patientStatus
+ "\nTime Admitted: " + this.timeAdmitted
+ "\nMedication(s) Prescribed: " + this.medicationPrescribed
+ "\nResults: " + this.results;
}
/**
* Explanation - reads a file and makes an object ArrayList of the file
* @param fileName - a String representing the file name
* @param clazz - a Class of any object
* @return an ArrayList that can hold any object
* @throws IOException if the file name is not found
* @throws ClassNotFoundException if the class being converted to is not found
*/
@Override
public <T> ArrayList<T> readFromFile(String fileName, Class<T> clazz) throws IOException, ClassNotFoundException {
ArrayList<T> objects = new ArrayList<>();
try (FileInputStream fis = new FileInputStream(fileName);
ObjectInputStream ois = new ObjectInputStream(fis)) {
while (true) {
objects.add(clazz.cast(ois.readObject()));
}
}
catch (EOFException e){
return objects;
}
catch (Exception e){
e.printStackTrace();
}
finally{
return objects;
}
}
}