Newer
Older
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
package edu.ncsu.csc.itrust.beans;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* A bean for storing data about a prescription.
*
* A bean's purpose is to store data. Period. Little or no functionality is to be added to a bean
* (with the exception of minor formatting such as concatenating phone numbers together).
* A bean must only have Getters and Setters (Eclipse Hint: Use Source > Generate Getters and Setters.
* to create these easily)
*/
public class PrescriptionBean {
private long id = 0L;
private MedicationBean medication = new MedicationBean();
private long visitID = 0L;
private String startDateStr = new SimpleDateFormat("MM/dd/yyyy").format(new Date());
private String endDateStr = new SimpleDateFormat("MM/dd/yyyy").format(new Date());
private int dosage = 0;
private String instructions = "";
private List<OverrideReasonBean> reasons = null;
private String overrideReasonOther = "";
public PrescriptionBean() {
}
@Override
public boolean equals(Object other) {
return (other != null) && this.getClass().equals(other.getClass())
&& this.equals((PrescriptionBean) other);
}
/**
* @param other
* @return
*/
private boolean equals(PrescriptionBean other) {
return (medication == other.medication || (medication != null && medication.equals(other.medication)))
&& visitID == other.visitID
&& startDateStr.equals(other.startDateStr)
&& endDateStr.equals(other.endDateStr)
&& dosage == other.dosage
&& instructions.equals(other.instructions);
}
@Override
public int hashCode() {
return 42; // any arbitrary constant will do
}
/**
* getters and setters for dosage,
* reason, override reason
*/
public int getDosage() {
return dosage;
}
public void setDosage(int dosage) {
this.dosage = dosage;
}
public List<OverrideReasonBean> getReasons() {
if (reasons==null){
reasons = new ArrayList<OverrideReasonBean>();
}
return reasons;
}
public void setReasons(List<OverrideReasonBean> reasons) {
this.reasons = reasons;
}
public void addReason(OverrideReasonBean reason){
if(reasons == null){
reasons = new ArrayList<OverrideReasonBean>();
}
reasons.add(reason);
}
public Date getEndDate() {
try {
return new SimpleDateFormat("MM/dd/yyyy").parse(endDateStr);
} catch (java.text.ParseException e) {
return null;
}
}
public void setEndDateStr(String endDate) {
this.endDateStr = endDate;
}
public void setEndDate(Date endDate) {
this.endDateStr = new SimpleDateFormat("MM/dd/yyyy").format(endDate);
}
public String getInstructions() {
return instructions;
}
public void setInstructions(String instruction) {
this.instructions = instruction;
}
public MedicationBean getMedication() {
return medication;
}
public void setMedication(MedicationBean medication) {
this.medication = medication;
}
public Date getStartDate() {
try {
return new SimpleDateFormat("MM/dd/yyyy").parse(startDateStr);
} catch (ParseException e) {
return null;
}
}
public String getStartDateStr() {
return startDateStr;
}
public String getEndDateStr() {
return endDateStr;
}
public void setStartDateStr(String startDate) {
this.startDateStr = startDate;
}
public long getVisitID() {
return visitID;
}
public void setVisitID(long visitID) {
this.visitID = visitID;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getOverrideReasonOther() {
return overrideReasonOther;
}
public void setOverrideReasonOther(String overrideReasonOther) {
this.overrideReasonOther = overrideReasonOther;
}
}