-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEHR.java
More file actions
72 lines (60 loc) · 2.53 KB
/
Copy pathEHR.java
File metadata and controls
72 lines (60 loc) · 2.53 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
// EHR.java (Electronic Health Record)
package vhs;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class EHR implements Serializable {
private String recordId;
private Patient patient;
private List<MedicalRecord> medicalRecords;
private List<Prescription> prescriptions;
private Date creationDate;
private Date lastUpdated;
public EHR(Patient patient) {
this.patient = patient;
this.recordId = "EHR" + patient.getId();
this.medicalRecords = new ArrayList<>();
this.prescriptions = new ArrayList<>();
this.creationDate = new Date();
this.lastUpdated = new Date();
}
// Getters and Setters
public String getRecordId() { return recordId; }
public Patient getPatient() { return patient; }
public void setPatient(Patient patient) { this.patient = patient; }
public List<MedicalRecord> getMedicalRecords() { return medicalRecords; }
public void setMedicalRecords(List<MedicalRecord> medicalRecords) { this.medicalRecords = medicalRecords; }
public List<Prescription> getPrescriptions() { return prescriptions; }
public void setPrescriptions(List<Prescription> prescriptions) { this.prescriptions = prescriptions; }
public Date getCreationDate() { return creationDate; }
public Date getLastUpdated() { return lastUpdated; }
public void setLastUpdated(Date lastUpdated) { this.lastUpdated = lastUpdated; }
// Methods
public void addMedicalRecord(String diagnosis, String treatment, String notes, Provider provider) {
MedicalRecord record = new MedicalRecord(diagnosis, treatment, notes, provider, new Date());
medicalRecords.add(record);
lastUpdated = new Date();
}
public void addPrescription(Prescription prescription) {
prescriptions.add(prescription);
lastUpdated = new Date();
}
public List<Prescription> getActivePrescriptions() {
List<Prescription> active = new ArrayList<>();
for (Prescription p : prescriptions) {
if (p.isActive()) {
active.add(p);
}
}
return active;
}
// Updated: Adding new feature commits!
@Override
public String toString() {
return "EHR ID: " + recordId +
", Patient: " + patient.getName() +
", Records: " + medicalRecords.size() +
", Prescriptions: " + prescriptions.size();
}
}