Skip to content

Commit 09441c8

Browse files
committed
Update vaccine method filter to search on primary method
This updates the "Vaccine method" filter which users can use to look for patients that have consented to a particular vaccine method, to filter only on the "primary" method (which will be the first one in the array) as this is the method that will be used in the UI and it's otherwise confusing to see patients for the secondary methods where the content on the page is based around the primary method. In practice, this is only really relevant for nasal and injection where a patient is primarily nasal and can optionally be injection. Jira-Issue: MAV-1468
1 parent e4a6cbf commit 09441c8

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

app/models/patient/consent_status.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ class Patient::ConsentStatus < ApplicationRecord
3232

3333
scope :has_vaccine_method,
3434
->(vaccine_method) do
35-
where(
36-
"vaccine_methods @> ARRAY[?]::integer[]",
37-
vaccine_methods.fetch(vaccine_method)
38-
)
35+
where("vaccine_methods[1] = ?", vaccine_methods.fetch(vaccine_method))
3936
end
4037

4138
enum :status,

spec/forms/search_form_spec.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,22 @@
390390
vaccine_methods: %w[nasal injection]
391391
)
392392

393-
create(
394-
:patient_session,
395-
:consent_given_triage_not_needed,
396-
programmes: [programme]
393+
_injection_only_patient =
394+
create(
395+
:patient_session,
396+
:consent_given_triage_not_needed,
397+
programmes: [programme]
398+
)
399+
400+
injection_primary_patient =
401+
create(
402+
:patient_session,
403+
:consent_given_triage_not_needed,
404+
programmes: [programme]
405+
)
406+
407+
injection_primary_patient.patient.consent_statuses.first.update!(
408+
vaccine_methods: %w[injection nasal]
397409
)
398410

399411
expect(form.apply(scope)).to contain_exactly(nasal_patient_session)

0 commit comments

Comments
 (0)