-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDoctorTest.java
158 lines (152 loc) · 6.36 KB
/
DoctorTest.java
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
package bbtrial.nl.logicgate.ace;
import java.util.HashMap;
import junit.framework.TestCase;
public class DoctorTest extends TestCase {
public void testPatientLetterDueDate(){
Doctor doctor = new Doctor("strangelove");
PatientCategoryPreference pcp1 = new PatientCategoryPreference("T1");
pcp1.setDueBase("lastLetter");
pcp1.setDueUnit("y");
pcp1.setDueOffset(1);
pcp1.setDue2Base("visitDate");
pcp1.setDue2Unit("d");
pcp1.setDue2Offset(0);
PatientCategoryPreference pcp2 = new PatientCategoryPreference("T2");
pcp2.setDueBase("visitDate");
pcp2.setDueUnit("w");
pcp2.setDueOffset(4);
pcp2.setDue2Base("lastLetter");
pcp2.setDue2Unit("w");
pcp2.setDue2Offset(6);
PatientCategoryPreference pcp3 = new PatientCategoryPreference("T3");
pcp3.setDueBase("visitDate");
pcp3.setDueUnit("w");
pcp3.setDueOffset(-4);
HashMap<String, PatientCategoryPreference> pcpMap = new HashMap<String, PatientCategoryPreference>();
pcpMap.put("T1", pcp1);
pcpMap.put("T2", pcp2);
pcpMap.put("T3", pcp3);
doctor.setPatientCategoryPreferences(pcpMap);
Patient liz = new Patient("liz");
liz.setCategory("T1");
Letter lizl = new Letter();
lizl.setFinishDate(new RCalendar("2011-3-21"));
liz.setLastLetter(lizl);
doctor.patientLetterDueDate(liz);
assertTrue(new RCalendar("2012-3-21").equals(liz.getLetterDueDate()));
//liz should be 1 year after the finish date of the letter
Patient jo = new Patient("jo");
jo.setCategory("T1");
jo.setVisitDate(new RCalendar("2011-6-1"));
doctor.patientLetterDueDate(jo);
assertTrue(new RCalendar("2011-6-1").equals(jo.getLetterDueDate()));
//jo should be = visit date
Patient sarahjane = new Patient("sarahjane");
sarahjane.setCategory("T2");
sarahjane.setVisitDate(new RCalendar("2011-1-1"));
Letter l2 = new Letter();
l2.setFinishDate(new RCalendar("2011-2-2"));
sarahjane.setLastLetter(l2);
doctor.patientLetterDueDate(sarahjane);
assertTrue(new RCalendar("2011-1-29").equals(sarahjane.getLetterDueDate()));
//sarahjane should be 4 weeks after visit date
Patient harry = new Patient("harry");
harry.setCategory("T2");
harry.setLastLetter(l2);
doctor.patientLetterDueDate(harry);
assertTrue(new RCalendar("2011-3-16").equals(harry.getLetterDueDate()));
//harry should be 6 weeks after finish date
Patient leela = new Patient("leela");
leela.setCategory("T3");
leela.setVisitDate(new RCalendar("2011-3-3"));
doctor.patientLetterDueDate(leela);
assertTrue(new RCalendar("2011-2-3").equals(leela.getLetterDueDate()));
//leela should be 4 weeks before the visit date
Patient k9 = new Patient("k9");
k9.setCategory("T3");
doctor.patientLetterDueDate(k9);
assertTrue(new RCalendar().equals(k9.getLetterDueDate()));
}
public void testFirstPossibleReminderDate(){
Doctor doctor = new Doctor("strangelove");
PatientCategoryPreference pcp1 = new PatientCategoryPreference("T1");
PatientCategoryPreference pcp2 = new PatientCategoryPreference("T2");
PatientCategoryPreference pcp3 = new PatientCategoryPreference("T3");
PatientCategoryPreference pcp4 = new PatientCategoryPreference("T4");
pcp1.setRemindBase("lastLetter");
pcp1.setRemindUnit("d");
pcp1.setRemindOffset(6);
//6 days after the last letter
pcp2.setRemindBase("visitDate");
pcp2.setRemindUnit("w");
pcp2.setRemindOffset(6);
//6 weeks after the visitDate
pcp3.setRemindBase("letterDueDate");
pcp3.setRemindUnit("d");
pcp3.setRemindOffset(30);
//30 days after the letterDueDate
pcp4.setRemindBase("letterDueDate");
pcp4.setRemindUnit("w");
pcp4.setRemindOffset(-2);
//2 weeks before letter due date
HashMap<String, PatientCategoryPreference> pcpMap = new HashMap<String, PatientCategoryPreference>();
pcpMap.put("T1", pcp1);
pcpMap.put("T2", pcp2);
pcpMap.put("T3", pcp3);
pcpMap.put("T4", pcp4);
doctor.setPatientCategoryPreferences(pcpMap);
Patient liz = new Patient("liz");
liz.setCategory("T1");
Letter lizl = new Letter();
lizl.setFinishDate(new RCalendar("2011-3-21"));
liz.setLastLetter(lizl);
liz.setVisitDate(new RCalendar("2011-2-2"));
liz.setLetterDueDate(new RCalendar("2011-9-21"));
doctor.firstPossibleReminderDate(liz);
assertTrue(new RCalendar("2011-3-27").equals(liz.getFirstPossibleReminderDate()));
//change liz's category
liz.setCategory("T2");
doctor.firstPossibleReminderDate(liz);
assertTrue(new RCalendar("2011-3-16").equals(liz.getFirstPossibleReminderDate()));
liz.setCategory("T3");
doctor.firstPossibleReminderDate(liz);
assertTrue(new RCalendar("2011-10-21").equals(liz.getFirstPossibleReminderDate()));
liz.setCategory("T4");
doctor.firstPossibleReminderDate(liz);
assertTrue(new RCalendar("2011-9-7").equals(liz.getFirstPossibleReminderDate()));
Patient katarina = new Patient("katarina");
katarina.setCategory("T1");
doctor.firstPossibleReminderDate(katarina);
assertTrue(new RCalendar().equals(katarina.getFirstPossibleReminderDate()));
//katarina has no info to use
liz.setFirstPossibleReminderDate(null);
liz.setCategory("NA");
doctor.firstPossibleReminderDate(liz);
assertNull(liz.getFirstPossibleReminderDate());
//set liz's category to something that doesn't exist
}
public void testFirstPossibleReminderDateLocal(){
Doctor who = new Doctor("who");
PatientCategoryPreference pcp = new PatientCategoryPreference("cp");
HashMap<String, PatientCategoryPreference> pcpMap = new HashMap<String, PatientCategoryPreference>();
pcp.setRemindBase("local");
pcp.setRemindUnit("w");
pcp.setRemindOffset(-1);
pcpMap.put("cp", pcp);
who.setPatientCategoryPreferences(pcpMap);
//alice has a letter for this visit, expect null
Patient alice = new Patient("alice");
alice.setCategory("cp");
alice.setVisitDate(new RCalendar("2011-7-7"));
alice.setLetterDueDate(new RCalendar("2011-8-8"));
//the caterpillar is just due for a letter. Expect 2011-6-30
Patient caterpillar = new Patient("caterpillar");
caterpillar.setCategory("cp");
caterpillar.setVisitDate(new RCalendar("2011-7-7"));
caterpillar.setLetterDueDate(new RCalendar("2011-7-10"));
who.firstPossibleReminderDate(alice);
who.firstPossibleReminderDate(caterpillar);
assertNull(alice.getFirstPossibleReminderDate());
assertTrue(caterpillar.getFirstPossibleReminderDate().equals(new RCalendar("2011-6-30")));
}
}