Skip to content

Commit 5f85c9e

Browse files
committed
Allow HCA's to use PGD supply with PSD and national protocols enabled
If the PSD and national protocol are enabled, but the patient only has consent for the nasal spray, in which case we would need to ensure that this box further up on the page shows.
1 parent b5c6d57 commit 5f85c9e

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

app/forms/vaccinate_form.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ def delivery_site
7474
end
7575

7676
def protocol
77-
if nurse_using_pgd? || healthcare_assistant_using_pgd?
77+
if nurse_using_pgd? || healthcare_assistant_using_pgd? ||
78+
healthcare_assistant_psd_and_national_nasal_only_without_psd?
7879
"pgd"
7980
elsif healthcare_assistant_using_psd?
8081
"psd"
@@ -99,17 +100,30 @@ def healthcare_assistant_using_psd?
99100

100101
def requires_supplied_by_user_id?
101102
return false if healthcare_assistant_using_psd?
103+
return true if healthcare_assistant_psd_and_national_nasal_only_without_psd?
102104

103105
user_not_designated_as_supplier?
104106
end
105107

108+
def healthcare_assistant_psd_and_national_nasal_only_without_psd?
109+
healthcare_assistant_using_psd_and_national_protocol? && !psd_exists? &&
110+
consented_for_nasal_only?
111+
end
112+
106113
def psd_exists?
107114
patient.patient_specific_directions.any? do
108115
it.programme_id == programme.id &&
109116
it.academic_year == session.academic_year
110117
end
111118
end
112119

120+
def consented_for_nasal_only?
121+
patient.consent_status(
122+
programme:,
123+
academic_year: session.academic_year
124+
).vaccine_methods == ["nasal"]
125+
end
126+
113127
def healthcare_assistant_using_psd_and_national_protocol?
114128
current_user.is_healthcare_assistant? && session.psd_enabled? &&
115129
session.national_protocol_enabled?

spec/features/flu_vaccination_hca_psd_spec.rb

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,32 @@
6565
and_i_am_signed_in(role: :healthcare_assistant)
6666

6767
when_i_visit_the_session_patient_programme_page
68-
and_i_record_that_the_patient_has_been_vaccinated_with_nasal_spray
68+
then_i_am_able_to_vaccinate_them_with_nasal_via_psd
6969
and_the_vaccination_record_has_psd_as_the_protocol
7070
end
7171

72+
scenario "PSD and national protocol enabled, no PSD, but patient consented nasal spray" do
73+
given_a_flu_session_exists(
74+
user_type: :with_one_healthcare_assistant,
75+
national_protocol_enabled: true
76+
)
77+
and_patients_exist
78+
and_i_am_signed_in(role: :healthcare_assistant)
79+
80+
when_i_visit_the_session_patient_programme_page
81+
then_i_am_able_to_vaccinate_them_via_pgd
82+
and_the_vaccination_record_has_pdg_as_the_protocol
83+
end
84+
7285
def given_delegation_feature_flag_is_enabled
7386
Flipper.enable(:delegation)
7487
end
7588

76-
def given_a_flu_session_exists(user_type:)
89+
def given_a_flu_session_exists(user_type:, national_protocol_enabled: false)
7790
@programme = create(:programme, :flu)
7891
@programmes = [@programme]
7992
@team = create(:team, user_type, programmes: @programmes)
93+
@nurse = create(:nurse, team: @team)
8094

8195
@batch =
8296
create(
@@ -93,7 +107,8 @@ def given_a_flu_session_exists(user_type:)
93107
:requires_no_registration,
94108
:psd_enabled,
95109
team: @team,
96-
programmes: @programmes
110+
programmes: @programmes,
111+
national_protocol_enabled:
97112
)
98113
end
99114

@@ -197,7 +212,7 @@ def then_i_should_not_see_the_record_vaccination_section
197212
expect(page).not_to have_text("Record flu vaccination with injection")
198213
end
199214

200-
def and_i_record_that_the_patient_has_been_vaccinated_with_nasal_spray
215+
def then_i_am_able_to_vaccinate_them_with_nasal_via_psd
201216
within all("section")[0] do
202217
check "I have checked that the above statements are true"
203218
end
@@ -214,7 +229,27 @@ def and_i_record_that_the_patient_has_been_vaccinated_with_nasal_spray
214229
expect(page).to have_text("Vaccination outcome recorded for flu")
215230
end
216231

232+
def then_i_am_able_to_vaccinate_them_via_pgd
233+
check "I have checked that the above statements are true"
234+
235+
select @nurse.full_name
236+
within all("section")[1] do
237+
choose "Yes"
238+
end
239+
click_on "Continue"
240+
241+
choose @batch.name
242+
click_on "Continue"
243+
244+
click_on "Confirm"
245+
click_on "Record vaccinations"
246+
end
247+
217248
def and_the_vaccination_record_has_psd_as_the_protocol
218249
expect(@patient_nasal_only.vaccination_records.first.protocol).to eq("psd")
219250
end
251+
252+
def and_the_vaccination_record_has_pdg_as_the_protocol
253+
expect(@patient_nasal_only.vaccination_records.first.protocol).to eq("pgd")
254+
end
220255
end

0 commit comments

Comments
 (0)