Skip to content

Commit f712e71

Browse files
authored
Ensure "Other" delivery site can be chosen (#3492)
This fixes a regression that was added in 2073e01 where the "Other" delivery site no longer works as it requires the vaccine to be present, but we don't have a vaccine at that point. Instead we can allow the user to select a delivery site across all the vaccines. I suspect this will need to be revisited for Flu where we have nasal spray and injection vaccines and the vaccine that the nurse selects needs to match the approriate delivery site.
2 parents 6e55e35 + 409d7cf commit f712e71

File tree

4 files changed

+39
-14
lines changed

4 files changed

+39
-14
lines changed

app/helpers/vaccinations_helper.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# frozen_string_literal: true
22

33
module VaccinationsHelper
4-
def vaccination_delivery_methods_for(vaccine)
5-
vaccine.available_delivery_methods.map do |m|
6-
[m, VaccinationRecord.human_enum_name("delivery_methods", m)]
4+
def available_delivery_methods_for(object)
5+
object.available_delivery_methods.map do
6+
[it, VaccinationRecord.human_enum_name("delivery_methods", it)]
77
end
88
end
99

10-
def vaccination_delivery_sites_for(vaccine)
11-
vaccine.available_delivery_sites.map do |s|
12-
[s, VaccinationRecord.human_enum_name("delivery_sites", s)]
10+
def available_delivery_sites_for(object)
11+
object.available_delivery_sites.map do
12+
[it, VaccinationRecord.human_enum_name("delivery_sites", it)]
1313
end
1414
end
1515
end

app/models/programme.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ def birth_academic_years
7171
year_groups.map(&:to_birth_academic_year)
7272
end
7373

74+
def available_delivery_methods
75+
vaccines.flat_map(&:available_delivery_methods).uniq
76+
end
77+
78+
def available_delivery_sites
79+
vaccines.flat_map(&:available_delivery_sites).uniq
80+
end
81+
7482
def common_delivery_sites
7583
if hpv? || menacwy? || td_ipv?
7684
%w[left_arm_upper_position right_arm_upper_position]

app/views/draft_vaccination_records/delivery.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
<% content_for(:before_content) { f.govuk_error_summary } %>
1616

1717
<%= f.govuk_collection_radio_buttons :delivery_method,
18-
vaccination_delivery_methods_for(@draft_vaccination_record.vaccine),
18+
available_delivery_methods_for(@draft_vaccination_record.programme),
1919
:first,
2020
:second,
2121
legend: { text: "Method" } %>
2222

2323
<%= f.govuk_collection_radio_buttons :delivery_site,
24-
vaccination_delivery_sites_for(@draft_vaccination_record.vaccine),
24+
available_delivery_sites_for(@draft_vaccination_record.programme),
2525
:first,
2626
:second,
2727
legend: { text: "Site" } %>

spec/features/hpv_vaccination_administered_spec.rb

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
describe "HPV vaccination" do
44
around { |example| travel_to(Time.zone.local(2024, 2, 1)) { example.run } }
55

6-
scenario "Administered" do
6+
scenario "Administered with common delivery site" do
77
given_i_am_signed_in
88

99
when_i_go_to_a_patient_that_is_ready_to_vaccinate
10-
and_i_record_that_the_patient_has_been_vaccinated
10+
and_i_fill_in_pre_screening_questions
11+
and_i_record_that_the_patient_has_been_vaccinated(
12+
"Left arm (upper position)"
13+
)
1114
and_i_see_only_not_expired_batches
1215
and_i_select_the_batch
1316
then_i_see_the_confirmation_page
@@ -53,6 +56,20 @@
5356
and_a_text_is_sent_to_the_parent_confirming_the_vaccination
5457
end
5558

59+
scenario "Administered with other delivery site" do
60+
given_i_am_signed_in
61+
62+
when_i_go_to_a_patient_that_is_ready_to_vaccinate
63+
and_i_fill_in_pre_screening_questions
64+
and_i_record_that_the_patient_has_been_vaccinated("Other")
65+
and_i_select_the_delivery
66+
and_i_select_the_batch
67+
then_i_see_the_confirmation_page
68+
69+
when_i_confirm_the_details
70+
then_i_see_a_success_message
71+
end
72+
5673
def given_i_am_signed_in
5774
programme = create(:programme, :hpv_all_vaccines)
5875
organisation =
@@ -92,16 +109,16 @@ def when_i_go_to_a_patient_that_is_ready_to_vaccinate
92109
click_link @patient.full_name
93110
end
94111

95-
def and_i_record_that_the_patient_has_been_vaccinated
96-
# pre-screening
112+
def and_i_fill_in_pre_screening_questions
97113
check "know what the vaccination is for, and are happy to have it"
98114
check "have not already had the vaccination"
99115
check "are feeling well"
100116
check "have no allergies which would prevent vaccination"
117+
end
101118

102-
# vaccination
119+
def and_i_record_that_the_patient_has_been_vaccinated(where)
103120
choose "Yes"
104-
choose "Left arm (upper position)"
121+
choose where
105122
click_button "Continue"
106123
end
107124

0 commit comments

Comments
 (0)