|
21 | 21 | let(:programme) { Programme.sample } |
22 | 22 | let(:session) { create(:session, programmes: [programme]) } |
23 | 23 | let(:patient) { create(:patient, session:) } |
| 24 | + let(:location) { create(:school) } |
24 | 25 |
|
25 | 26 | context "when already vaccinated" do |
26 | 27 | let(:programme) { Programme.hpv } |
27 | 28 |
|
28 | 29 | let!(:vaccination_record) do |
29 | | - create(:vaccination_record, :already_had, patient:, programme:) |
| 30 | + create(:vaccination_record, :already_had, patient:, programme:, location:) |
30 | 31 | end |
31 | 32 |
|
32 | | - its(:status) { should be(:vaccinated_already) } |
33 | 33 | its(:date) { should eq(vaccination_record.performed_at.to_date) } |
34 | 34 | its(:disease_types) { should eq(%w[human_papillomavirus]) } |
35 | 35 | its(:dose_sequence) { should be_nil } |
| 36 | + its(:location_id) { should eq(location.id) } |
| 37 | + its(:status) { should be(:vaccinated_already) } |
36 | 38 | its(:vaccine_methods) { should be_empty } |
37 | 39 | its(:without_gelatine) { should be_nil } |
38 | 40 | end |
|
41 | 43 | let(:programme) { Programme.hpv } |
42 | 44 |
|
43 | 45 | let!(:vaccination_record) do |
44 | | - create(:vaccination_record, patient:, programme:) |
| 46 | + create(:vaccination_record, patient:, programme:, location:) |
45 | 47 | end |
46 | 48 |
|
47 | | - its(:status) { should be(:vaccinated_fully) } |
48 | 49 | its(:date) { should eq(vaccination_record.performed_at.to_date) } |
49 | 50 | its(:disease_types) { should eq(%w[human_papillomavirus]) } |
50 | 51 | its(:dose_sequence) { should be_nil } |
| 52 | + its(:location_id) { should eq(location.id) } |
| 53 | + its(:status) { should be(:vaccinated_fully) } |
51 | 54 | its(:vaccine_methods) { should be_empty } |
52 | 55 | its(:without_gelatine) { should be_nil } |
53 | 56 | end |
|
56 | 59 | let(:programme) { Programme.mmr } |
57 | 60 |
|
58 | 61 | let!(:vaccination_record) do |
59 | | - create(:vaccination_record, patient:, programme:) |
| 62 | + create(:vaccination_record, patient:, programme:, location:) |
60 | 63 | end |
61 | 64 |
|
62 | | - its(:status) { should be(:needs_consent_no_response) } |
63 | 65 | its(:date) { should eq(vaccination_record.performed_at.to_date) } |
64 | 66 | its(:disease_types) { should be_nil } |
65 | 67 | its(:dose_sequence) { should be_nil } |
| 68 | + its(:location_id) { should be_nil } |
| 69 | + its(:status) { should be(:needs_consent_no_response) } |
66 | 70 | its(:vaccine_methods) { should be_nil } |
67 | 71 | its(:without_gelatine) { should be_nil } |
68 | 72 |
|
|
81 | 85 | before { create(:consent, :given, patient:, programme:) } |
82 | 86 |
|
83 | 87 | let!(:vaccination_record) do |
84 | | - create(:vaccination_record, :unwell, patient:, programme:) |
| 88 | + create(:vaccination_record, :unwell, patient:, programme:, location:) |
85 | 89 | end |
86 | 90 |
|
87 | | - its(:status) { should be(:cannot_vaccinate_unwell) } |
88 | 91 | its(:date) { should eq(vaccination_record.performed_at.to_date) } |
89 | 92 | its(:disease_types) { should eq(programme.disease_types) } |
| 93 | + its(:location_id) { should be_nil } |
| 94 | + its(:status) { should be(:cannot_vaccinate_unwell) } |
90 | 95 | its(:vaccine_methods) { should contain_exactly("injection") } |
91 | 96 | its(:without_gelatine) { should be(false) } |
92 | 97 |
|
93 | 98 | context "on a different day" do |
94 | 99 | let!(:vaccination_record) do |
95 | | - create(:vaccination_record, :unwell, :yesterday, patient:, programme:) |
| 100 | + create( |
| 101 | + :vaccination_record, |
| 102 | + :unwell, |
| 103 | + :yesterday, |
| 104 | + patient:, |
| 105 | + programme:, |
| 106 | + location: |
| 107 | + ) |
96 | 108 | end |
97 | 109 |
|
98 | | - its(:status) { should be(:due) } |
99 | 110 | its(:date) { should eq(vaccination_record.performed_at.to_date) } |
| 111 | + its(:location_id) { should be_nil } |
| 112 | + its(:status) { should be(:due) } |
100 | 113 | end |
101 | 114 | end |
102 | 115 |
|
103 | 116 | context "when the child refused" do |
104 | 117 | before { create(:consent, :given, patient:, programme:) } |
105 | 118 |
|
106 | 119 | let!(:vaccination_record) do |
107 | | - create(:vaccination_record, :refused, patient:, programme:) |
| 120 | + create(:vaccination_record, :refused, patient:, programme:, location:) |
108 | 121 | end |
109 | 122 |
|
110 | | - its(:status) { should be(:cannot_vaccinate_refused) } |
111 | 123 | its(:date) { should eq(vaccination_record.performed_at.to_date) } |
112 | 124 | its(:disease_types) { should eq(programme.disease_types) } |
| 125 | + its(:location_id) { should be_nil } |
| 126 | + its(:status) { should be(:cannot_vaccinate_refused) } |
113 | 127 | its(:vaccine_methods) { should contain_exactly("injection") } |
114 | 128 | its(:without_gelatine) { should be(false) } |
115 | 129 |
|
|
118 | 132 | create(:vaccination_record, :unwell, :yesterday, patient:, programme:) |
119 | 133 | end |
120 | 134 |
|
121 | | - its(:status) { should be(:due) } |
122 | 135 | its(:date) { should eq(vaccination_record.performed_at.to_date) } |
| 136 | + its(:location_id) { should be_nil } |
| 137 | + its(:status) { should be(:due) } |
123 | 138 | end |
124 | 139 | end |
125 | 140 |
|
126 | 141 | context "when contraindicated" do |
127 | 142 | before { create(:consent, :given, patient:, programme:) } |
128 | 143 |
|
129 | 144 | let!(:vaccination_record) do |
130 | | - create(:vaccination_record, :contraindicated, patient:, programme:) |
| 145 | + create( |
| 146 | + :vaccination_record, |
| 147 | + :contraindicated, |
| 148 | + patient:, |
| 149 | + programme:, |
| 150 | + location: |
| 151 | + ) |
131 | 152 | end |
132 | 153 |
|
133 | | - its(:status) { should be(:cannot_vaccinate_contraindicated) } |
134 | 154 | its(:date) { should eq(vaccination_record.performed_at.to_date) } |
135 | 155 | its(:disease_types) { should eq(programme.disease_types) } |
| 156 | + its(:location_id) { should be_nil } |
| 157 | + its(:status) { should be(:cannot_vaccinate_contraindicated) } |
136 | 158 | its(:vaccine_methods) { should contain_exactly("injection") } |
137 | 159 | its(:without_gelatine) { should be(false) } |
138 | 160 |
|
|
141 | 163 | create(:vaccination_record, :unwell, :yesterday, patient:, programme:) |
142 | 164 | end |
143 | 165 |
|
144 | | - its(:status) { should be(:due) } |
145 | 166 | its(:date) { should eq(vaccination_record.performed_at.to_date) } |
| 167 | + its(:location_id) { should be_nil } |
| 168 | + its(:status) { should be(:due) } |
146 | 169 | end |
147 | 170 | end |
148 | 171 |
|
|
153 | 176 | create(:attendance_record, :absent, patient:, session:) |
154 | 177 | end |
155 | 178 |
|
156 | | - its(:status) { should be(:cannot_vaccinate_absent) } |
157 | 179 | its(:date) { should eq(attendance_record.date) } |
158 | 180 | its(:disease_types) { should eq(programme.disease_types) } |
| 181 | + its(:location_id) { should be_nil } |
| 182 | + its(:status) { should be(:cannot_vaccinate_absent) } |
159 | 183 | its(:vaccine_methods) { should contain_exactly("injection") } |
160 | 184 | its(:without_gelatine) { should be(false) } |
161 | 185 |
|
|
181 | 205 | ) |
182 | 206 | end |
183 | 207 |
|
184 | | - its(:status) { should be(:cannot_vaccinate_delay_vaccination) } |
185 | 208 | its(:date) { should eq(Date.tomorrow) } |
186 | 209 | its(:disease_types) { should eq(programme.disease_types) } |
187 | 210 | its(:dose_sequence) { should be_nil } |
| 211 | + its(:location_id) { should be_nil } |
| 212 | + its(:status) { should be(:cannot_vaccinate_delay_vaccination) } |
188 | 213 | its(:vaccine_methods) { should contain_exactly("injection") } |
189 | 214 | its(:without_gelatine) { should be(false) } |
190 | 215 | end |
|
195 | 220 | create(:triage, :invite_to_clinic, patient:, programme:) |
196 | 221 | end |
197 | 222 |
|
198 | | - its(:status) { should be(:needs_triage) } |
199 | 223 | its(:date) { should be_nil } |
200 | 224 | its(:disease_types) { should eq(programme.disease_types) } |
201 | 225 | its(:dose_sequence) { should be_nil } |
| 226 | + its(:location_id) { should be_nil } |
| 227 | + its(:status) { should be(:needs_triage) } |
202 | 228 | its(:vaccine_methods) { should be_nil } |
203 | 229 | its(:without_gelatine) { should be_nil } |
204 | 230 | end |
|
209 | 235 | create(:triage, :do_not_vaccinate, patient:, programme:) |
210 | 236 | end |
211 | 237 |
|
212 | | - its(:status) { should be(:cannot_vaccinate_do_not_vaccinate) } |
213 | 238 | its(:date) { should be_nil } |
214 | 239 | its(:disease_types) { should eq(programme.disease_types) } |
215 | 240 | its(:dose_sequence) { should be_nil } |
| 241 | + its(:location_id) { should be_nil } |
| 242 | + its(:status) { should be(:cannot_vaccinate_do_not_vaccinate) } |
216 | 243 | its(:vaccine_methods) { should be_nil } |
217 | 244 | its(:without_gelatine) { should be_nil } |
218 | 245 | end |
219 | 246 |
|
220 | 247 | context "when needs triage" do |
221 | 248 | before { create(:consent, :given, :needing_triage, patient:, programme:) } |
222 | 249 |
|
223 | | - its(:status) { should be(:needs_triage) } |
224 | 250 | its(:date) { should be_nil } |
225 | 251 | its(:disease_types) { should eq(programme.disease_types) } |
226 | 252 | its(:dose_sequence) { should be_nil } |
| 253 | + its(:location_id) { should be_nil } |
| 254 | + its(:status) { should be(:needs_triage) } |
227 | 255 | its(:vaccine_methods) { should be_nil } |
228 | 256 | its(:without_gelatine) { should be_nil } |
229 | 257 | end |
230 | 258 |
|
231 | 259 | context "when consent is refused" do |
232 | 260 | before { create(:consent, :refused, patient:, programme:) } |
233 | 261 |
|
234 | | - its(:status) { should be(:has_refusal_consent_refused) } |
235 | 262 | its(:date) { should be_nil } |
236 | 263 | its(:disease_types) { should be_empty } |
237 | 264 | its(:dose_sequence) { should be_nil } |
| 265 | + its(:location_id) { should be_nil } |
| 266 | + its(:status) { should be(:has_refusal_consent_refused) } |
238 | 267 | its(:vaccine_methods) { should be_nil } |
239 | 268 | its(:without_gelatine) { should be_nil } |
240 | 269 | end |
|
245 | 274 | create(:consent, :given, patient:, programme:, parent: create(:parent)) |
246 | 275 | end |
247 | 276 |
|
248 | | - its(:status) { should be(:has_refusal_consent_conflicts) } |
249 | 277 | its(:date) { should be_nil } |
250 | 278 | its(:disease_types) { should be_empty } |
251 | 279 | its(:dose_sequence) { should be_nil } |
| 280 | + its(:location_id) { should be_nil } |
| 281 | + its(:status) { should be(:has_refusal_consent_conflicts) } |
252 | 282 | its(:vaccine_methods) { should be_nil } |
253 | 283 | its(:without_gelatine) { should be_nil } |
254 | 284 | end |
255 | 285 |
|
256 | 286 | context "when consent is needed" do |
257 | | - its(:status) { should be(:needs_consent_no_response) } |
258 | 287 | its(:date) { should be_nil } |
259 | 288 | its(:disease_types) { should be_nil } |
260 | 289 | its(:dose_sequence) { should be_nil } |
| 290 | + its(:location_id) { should be_nil } |
| 291 | + its(:status) { should be(:needs_consent_no_response) } |
261 | 292 | its(:vaccine_methods) { should be_nil } |
262 | 293 | its(:without_gelatine) { should be_nil } |
263 | 294 | end |
264 | 295 |
|
265 | 296 | context "when not eligible" do |
266 | 297 | let(:patient) { create(:patient, year_group: 20) } |
267 | 298 |
|
268 | | - its(:status) { should be(:not_eligible) } |
269 | 299 | its(:date) { should be_nil } |
270 | 300 | its(:disease_types) { should be_nil } |
271 | 301 | its(:dose_sequence) { should be_nil } |
| 302 | + its(:location_id) { should be_nil } |
| 303 | + its(:status) { should be(:not_eligible) } |
272 | 304 | its(:vaccine_methods) { should be_nil } |
273 | 305 | its(:without_gelatine) { should be_nil } |
274 | 306 | end |
|
0 commit comments