Skip to content

Commit b955001

Browse files
committed
Allow recording injection for nasal patients
This adds the ability for nurses to record an injection for a patient if they've got consent for both the nasal spray and the injection. Jira-Issue: MAV-1338
1 parent 870197e commit b955001

3 files changed

Lines changed: 106 additions & 39 deletions

File tree

app/components/app_vaccinate_form_component.html.erb

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,40 @@
6666
<% hint = "Pre-screening checks must be completed for vaccination to go ahead" %>
6767

6868
<%= f.govuk_radio_buttons_fieldset :vaccine_method, legend: nil do %>
69-
<% if common_delivery_sites_options.length > 1 %>
70-
<%= f.govuk_radio_button :vaccine_method, vaccine_method, label: { text: "Yes" }, hint: { text: hint }, link_errors: true do %>
71-
<%= f.govuk_collection_radio_buttons :delivery_site,
72-
common_delivery_sites_options,
73-
:value,
74-
:label,
75-
legend: {
76-
text: "Where will the injection be given?",
77-
size: "s",
78-
} %>
69+
<% vaccine_methods.each_with_index do |vaccine_method, index| %>
70+
<% if index == 1 %>
71+
<%= f.govuk_radio_divider %>
72+
<% end %>
73+
74+
<% label = if index.zero?
75+
"Yes"
76+
else
77+
"No — but they can have the #{Vaccine.human_enum_name(:method_prefix, vaccine_method)} #{programme.name_in_sentence} instead"
78+
end %>
79+
80+
<% options = common_delivery_site_options(vaccine_method) %>
81+
82+
<% if options.length > 1 %>
83+
<%= f.govuk_radio_button :vaccine_method, vaccine_method, label: { text: label }, hint: { text: hint }, link_errors: index.zero? do %>
84+
<%= f.govuk_collection_radio_buttons :delivery_site,
85+
options,
86+
:value,
87+
:label,
88+
legend: {
89+
text: "Where will the #{Vaccine.human_enum_name(:method, vaccine_method).downcase} be given?",
90+
size: "s",
91+
} %>
92+
<% end %>
93+
<% else %>
94+
<%= f.govuk_radio_button :vaccine_method, vaccine_method, label: { text: label }, hint: { text: hint }, link_errors: index.zero? do %>
95+
<%= f.hidden_field :delivery_site, value: options.first.value %>
96+
<% end %>
97+
<% end %>
98+
99+
<% if index.zero? %>
100+
<%= f.govuk_radio_button :vaccine_method, "none", label: { text: "No" } %>
79101
<% end %>
80-
<% else %>
81-
<%= f.govuk_radio_button :vaccine_method, vaccine_method, label: { text: "Yes" }, hint: { text: hint }, link_errors: true %>
82-
<%= f.hidden_field :delivery_site, value: common_delivery_sites_options.first.value %>
83102
<% end %>
84-
<%= f.govuk_radio_button :vaccine_method, "none", label: { text: "No" } %>
85103
<% end %>
86104

87105
<%= f.hidden_field :dose_sequence, value: dose_sequence %>

app/components/app_vaccinate_form_component.rb

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def url
1818
session_patient_programme_vaccinations_path(session, patient, programme)
1919
end
2020

21-
def vaccine_method
22-
patient.approved_vaccine_methods(programme:).first
21+
def vaccine_methods
22+
patient.approved_vaccine_methods(programme:)
2323
end
2424

2525
def dose_sequence
@@ -33,29 +33,26 @@ def dose_sequence
3333

3434
CommonDeliverySite = Struct.new(:value, :label)
3535

36-
def common_delivery_sites_options
37-
@common_delivery_sites_options ||=
38-
begin
39-
options =
40-
COMMON_DELIVERY_SITES
41-
.fetch(vaccine_method)
42-
.map do |value|
43-
label = VaccinationRecord.human_enum_name(:delivery_site, value)
44-
CommonDeliverySite.new(value:, label:)
45-
end
46-
47-
if vaccine_method == "injection"
48-
options << CommonDeliverySite.new(value: "other", label: "Other")
36+
def common_delivery_site_options(vaccine_method)
37+
options =
38+
COMMON_DELIVERY_SITES
39+
.fetch(vaccine_method)
40+
.map do |value|
41+
label = VaccinationRecord.human_enum_name(:delivery_site, value)
42+
CommonDeliverySite.new(value:, label:)
4943
end
5044

51-
options
52-
end
45+
if vaccine_method == "injection"
46+
options << CommonDeliverySite.new(value: "other", label: "Other")
47+
end
48+
49+
options
5350
end
5451

5552
def vaccination_name
5653
vaccination =
5754
if programme.has_multiple_vaccine_methods?
58-
Vaccine.human_enum_name(:method, vaccine_method).downcase
55+
Vaccine.human_enum_name(:method, vaccine_methods.first).downcase
5956
else
6057
"vaccination"
6158
end
@@ -67,5 +64,5 @@ def ask_not_taking_medication? = programme.doubles? || programme.flu?
6764

6865
def ask_not_pregnant? = programme.td_ipv?
6966

70-
def ask_asthma_flare_up? = vaccine_method == "nasal"
67+
def ask_asthma_flare_up? = vaccine_methods.include?("nasal")
7168
end

spec/features/flu_vaccination_administered_spec.rb

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
scenario "Administered with nasal spray" do
77
given_i_am_signed_in_with_flu_programme
8-
and_there_is_a_flu_session_today_with_two_patients_ready_to_vaccinate
8+
and_there_is_a_flu_session_today_with_patients_ready_to_vaccinate
99
and_there_are_nasal_and_injection_batches
1010
and_sync_vaccination_records_to_nhs_on_create_feature_is_enabled
1111

@@ -24,7 +24,7 @@
2424

2525
scenario "Administered with injection" do
2626
given_i_am_signed_in_with_flu_programme
27-
and_there_is_a_flu_session_today_with_two_patients_ready_to_vaccinate
27+
and_there_is_a_flu_session_today_with_patients_ready_to_vaccinate
2828
and_there_are_nasal_and_injection_batches
2929

3030
when_i_go_to_the_injection_only_patient
@@ -39,9 +39,27 @@
3939
and_a_text_is_sent_to_the_parent_confirming_the_vaccination
4040
end
4141

42+
scenario "Administered with injection instead of nasal" do
43+
given_i_am_signed_in_with_flu_programme
44+
and_there_is_a_flu_session_today_with_patients_ready_to_vaccinate
45+
and_there_are_nasal_and_injection_batches
46+
47+
when_i_go_to_the_nasal_or_injection_patient
48+
then_i_see_the_vaccination_form_for_nasal_spray
49+
and_i_see_the_option_to_administer_injection
50+
51+
when_i_record_that_the_patient_has_been_vaccinated_with_injection_instead
52+
then_i_see_the_check_and_confirm_page_for_injection
53+
and_i_get_confirmation_after_recording
54+
55+
when_vaccination_confirmations_are_sent
56+
then_an_email_is_sent_to_the_parent_confirming_the_vaccination
57+
and_a_text_is_sent_to_the_parent_confirming_the_vaccination
58+
end
59+
4260
scenario "Switching between nasal and injection" do
4361
given_i_am_signed_in_with_flu_programme
44-
and_there_is_a_flu_session_today_with_two_patients_ready_to_vaccinate
62+
and_there_is_a_flu_session_today_with_patients_ready_to_vaccinate
4563
and_there_are_nasal_and_injection_batches
4664

4765
when_i_go_to_the_nasal_only_patient
@@ -71,14 +89,21 @@ def given_i_am_signed_in_with_flu_programme
7189
sign_in @organisation.users.first
7290
end
7391

74-
def and_there_is_a_flu_session_today_with_two_patients_ready_to_vaccinate
75-
@nasal_patient =
92+
def and_there_is_a_flu_session_today_with_patients_ready_to_vaccinate
93+
@nasal_only_patient =
7694
create(
7795
:patient,
7896
:consent_given_nasal_only_triage_not_needed,
7997
:in_attendance,
8098
session: @session
8199
)
100+
@nasal_or_injection_patient =
101+
create(
102+
:patient,
103+
:consent_given_nasal_or_injection_triage_not_needed,
104+
:in_attendance,
105+
session: @session
106+
)
82107
@injection_patient =
83108
create(
84109
:patient,
@@ -120,7 +145,13 @@ def and_sync_vaccination_records_to_nhs_on_create_feature_is_enabled
120145

121146
def when_i_go_to_the_nasal_only_patient
122147
visit session_record_path(@session)
123-
@patient = @nasal_patient
148+
@patient = @nasal_only_patient
149+
click_link @patient.full_name
150+
end
151+
152+
def when_i_go_to_the_nasal_or_injection_patient
153+
visit session_record_path(@session)
154+
@patient = @nasal_or_injection_patient
124155
click_link @patient.full_name
125156
end
126157

@@ -144,6 +175,12 @@ def then_i_see_the_vaccination_form_for_injection
144175
)
145176
end
146177

178+
def and_i_see_the_option_to_administer_injection
179+
expect(page).to have_content(
180+
"No — but they can have the injected flu instead"
181+
)
182+
end
183+
147184
def when_i_record_that_the_patient_has_been_vaccinated_with_nasal_spray
148185
within all("section")[0] do
149186
check "I have checked that the above statements are true"
@@ -175,6 +212,21 @@ def when_i_record_that_the_patient_has_been_vaccinated_with_injection
175212
click_button "Continue"
176213
end
177214

215+
def when_i_record_that_the_patient_has_been_vaccinated_with_injection_instead
216+
within all("section")[0] do
217+
check "I have checked that the above statements are true"
218+
end
219+
220+
within all("section")[1] do
221+
choose "No — but they can have the injected flu instead"
222+
choose "Left arm (upper position)"
223+
click_button "Continue"
224+
end
225+
226+
choose @injection_batch.name
227+
click_button "Continue"
228+
end
229+
178230
def then_i_see_the_check_and_confirm_page_for_nasal_spray
179231
expect(page).to have_content("Check and confirm")
180232
expect(page).to have_content(@patient.full_name)

0 commit comments

Comments
 (0)