|
286 | 286 | "consent_conflicts" => 0 |
287 | 287 | ) |
288 | 288 | end |
| 289 | + |
| 290 | + it "counts all no response consent statuses consistently in aggregate totals" do |
| 291 | + team = Team.last |
| 292 | + programme = Programme.hpv |
| 293 | + team.programmes << programme |
| 294 | + |
| 295 | + session = create(:session, team:, programmes: [programme]) |
| 296 | + |
| 297 | + no_response_patient = |
| 298 | + create(:patient, session:, parents: [create(:parent)]) |
| 299 | + create( |
| 300 | + :consent_notification, |
| 301 | + :request, |
| 302 | + patient: no_response_patient, |
| 303 | + session:, |
| 304 | + programmes: [programme] |
| 305 | + ) |
| 306 | + |
| 307 | + create(:patient, session:, parents: [create(:parent, :non_contactable)]) |
| 308 | + |
| 309 | + request_scheduled_session = |
| 310 | + create( |
| 311 | + :session, |
| 312 | + team:, |
| 313 | + programmes: [programme], |
| 314 | + send_consent_requests_at: Date.tomorrow |
| 315 | + ) |
| 316 | + create( |
| 317 | + :patient, |
| 318 | + session: request_scheduled_session, |
| 319 | + parents: [create(:parent)] |
| 320 | + ) |
| 321 | + |
| 322 | + create(:patient, session:, parents: [create(:parent)]) |
| 323 | + |
| 324 | + refused_patient = create(:patient, session:, parents: [create(:parent)]) |
| 325 | + create(:consent, :refused, patient: refused_patient, programme:, team:) |
| 326 | + |
| 327 | + conflict_patient = create(:patient, session:) |
| 328 | + parent1 = create(:parent) |
| 329 | + parent2 = create(:parent) |
| 330 | + create(:parent_relationship, patient: conflict_patient, parent: parent1) |
| 331 | + create(:parent_relationship, patient: conflict_patient, parent: parent2) |
| 332 | + create( |
| 333 | + :consent, |
| 334 | + :given, |
| 335 | + patient: conflict_patient, |
| 336 | + programme:, |
| 337 | + team:, |
| 338 | + parent: parent1 |
| 339 | + ) |
| 340 | + create( |
| 341 | + :consent, |
| 342 | + :refused, |
| 343 | + patient: conflict_patient, |
| 344 | + programme:, |
| 345 | + team:, |
| 346 | + parent: parent2 |
| 347 | + ) |
| 348 | + |
| 349 | + PatientStatusUpdater.call |
| 350 | + |
| 351 | + refresh_reporting_views! |
| 352 | + |
| 353 | + get :index, params: { programme: "hpv" } |
| 354 | + |
| 355 | + expect(parsed_response["no_consent"]).to eq(6) |
| 356 | + expect(parsed_response["consent_refused"]).to eq(1) |
| 357 | + expect(parsed_response["consent_conflicts"]).to eq(1) |
| 358 | + expect(parsed_response["consent_no_response"]).to eq(4) |
| 359 | + end |
289 | 360 | end |
290 | 361 |
|
291 | 362 | describe "#index.csv" do |
|
0 commit comments