Skip to content

Commit 38103fc

Browse files
committed
Allow HCAs to administer nasal flu using PSD
This adds support for healthcare assistants to administer the nasal flu vaccine under PSD, requiring the session to have the PSD enabled. Note: when PSD is enabled, the HCA is not required to provide the supplier of the vaccine for nasal flu.
1 parent f7068d2 commit 38103fc

File tree

4 files changed

+129
-11
lines changed

4 files changed

+129
-11
lines changed

app/forms/vaccinate_form.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,15 @@ def delivery_site
7474
end
7575

7676
def protocol
77-
if current_user.is_nurse? || vaccine_method == "nasal"
77+
if current_user.is_nurse? && !session.national_protocol_enabled? &&
78+
!session.psd_enabled?
7879
"pgd"
80+
elsif current_user.is_healthcare_assistant? && !session.psd_enabled? &&
81+
vaccine_method == "nasal"
82+
"pgd"
83+
elsif current_user.is_healthcare_assistant? && session.psd_enabled? &&
84+
vaccine_method == "nasal"
85+
"psd"
7986
else
8087
"national"
8188
end
@@ -85,7 +92,21 @@ def supplied_by_users
8592
current_user.selected_team.users.show_in_suppliers
8693
end
8794

88-
def requires_supplied_by_user_id? = !current_user.show_in_suppliers
95+
def requires_supplied_by_user_id?
96+
if session.psd_enabled? && current_user.is_healthcare_assistant?
97+
return false
98+
end
99+
100+
user_not_designated_as_supplier?
101+
end
102+
103+
def operating_under_national_protocol?
104+
session.national_protocol_enabled? && !session.psd_enabled?
105+
end
106+
107+
def user_not_designated_as_supplier?
108+
!current_user.show_in_suppliers
109+
end
89110

90111
def save(draft_vaccination_record:)
91112
return nil if invalid?

app/models/draft_vaccination_record.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class DraftVaccinationRecord
2828
attribute :protocol, :string
2929
attribute :performed_ods_code, :string
3030
attribute :programme_id, :integer
31-
attribute :protocol, :string
3231
attribute :session_id, :integer
3332
attribute :supplied_by_user_id, :integer
3433

spec/features/flu_vaccination_hca_psd_spec.rb

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

3-
describe "Patient Specific Directions" do
3+
describe "Flu vaccination" do
44
before { given_delegation_feature_flag_is_enabled }
55

6-
scenario "Prescriber can bulk add PSDs to patients that don't require triage" do
6+
scenario "Prescriber bulk add PSDs to patients that don't require triage" do
77
given_a_flu_session_exists(user_type: :with_one_nurse)
88
and_patients_exist
99
and_i_am_signed_in(role: :prescriber)
@@ -58,6 +58,17 @@
5858
then_i_should_not_see_the_record_vaccination_section
5959
end
6060

61+
scenario "Nasal flu administered by HCA under PSD" do
62+
given_a_flu_session_exists(user_type: :with_one_healthcare_assistant)
63+
and_patients_exist
64+
and_the_nasal_only_patient_has_a_psd
65+
and_i_am_signed_in(role: :healthcare_assistant)
66+
67+
when_i_visit_the_session_patient_programme_page
68+
and_i_record_that_the_patient_has_been_vaccinated_with_nasal_spray
69+
and_the_vaccination_record_has_psd_as_the_protocol
70+
end
71+
6172
def given_delegation_feature_flag_is_enabled
6273
Flipper.enable(:delegation)
6374
end
@@ -68,9 +79,22 @@ def given_a_flu_session_exists(user_type:)
6879
@team = create(:team, user_type, programmes: @programmes)
6980

7081
@batch =
71-
create(:batch, team: @team, vaccine: @programmes.first.vaccines.first)
82+
create(
83+
:batch,
84+
:not_expired,
85+
team: @team,
86+
vaccine: @programme.vaccines.nasal.first
87+
)
7288

73-
@session = create(:session, team: @team, programmes: @programmes)
89+
@session =
90+
create(
91+
:session,
92+
:today,
93+
:requires_no_registration,
94+
:psd_enabled,
95+
team: @team,
96+
programmes: @programmes
97+
)
7498
end
7599

76100
def and_patients_exist
@@ -88,6 +112,14 @@ def and_patients_exist
88112
)
89113
end
90114

115+
def and_the_nasal_only_patient_has_a_psd
116+
create(
117+
:patient_specific_direction,
118+
patient: @patient_nasal_only,
119+
programme: @programme
120+
)
121+
end
122+
91123
def and_i_am_signed_in(role:)
92124
sign_in @team.users.first, role:
93125
end
@@ -164,4 +196,25 @@ def then_i_should_not_see_the_patient
164196
def then_i_should_not_see_the_record_vaccination_section
165197
expect(page).not_to have_text("Record flu vaccination with injection")
166198
end
199+
200+
def and_i_record_that_the_patient_has_been_vaccinated_with_nasal_spray
201+
within all("section")[0] do
202+
check "I have checked that the above statements are true"
203+
end
204+
205+
within all("section")[1] do
206+
choose "Yes"
207+
click_button "Continue"
208+
end
209+
210+
choose @batch.name
211+
click_button "Continue"
212+
click_on "Confirm"
213+
214+
expect(page).to have_text("Vaccination outcome recorded for flu")
215+
end
216+
217+
def and_the_vaccination_record_has_psd_as_the_protocol
218+
expect(@patient_nasal_only.vaccination_records.first.protocol).to eq("psd")
219+
end
167220
end

spec/forms/vaccinate_form_spec.rb

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
# frozen_string_literal: true
22

33
describe VaccinateForm do
4-
subject(:form) { described_class.new(programme:, current_user:) }
4+
subject(:form) do
5+
described_class.new(programme:, current_user:, session_date:)
6+
end
7+
8+
let(:programme) { build(:programme) }
9+
let(:current_user) do
10+
build(:user, show_in_suppliers: user_designated_as_supplier)
11+
end
12+
let(:session) { build(:session, psd_enabled:, national_protocol_enabled:) }
13+
let(:session_date) { session.session_dates.first }
514

6-
let(:programme) { create(:programme) }
7-
let(:current_user) { create(:user) }
15+
let(:psd_enabled) { false }
16+
let(:national_protocol_enabled) { false }
17+
let(:user_designated_as_supplier) { true }
818

919
describe "validations" do
1020
it do
@@ -30,7 +40,8 @@
3040
described_class.new(
3141
identity_check_confirmed_by_patient: false,
3242
programme:,
33-
current_user:
43+
current_user:,
44+
session_date:
3445
)
3546
end
3647

@@ -49,4 +60,38 @@
4960

5061
it { should validate_length_of(:pre_screening_notes).is_at_most(1000) }
5162
end
63+
64+
describe "#requires_supplied_by_user_id?" do
65+
subject(:requires_supplied_by_user_id?) do
66+
form.requires_supplied_by_user_id?
67+
end
68+
69+
context "when operating under national protocol" do
70+
let(:psd_enabled) { false }
71+
let(:national_protocol_enabled) { true }
72+
let(:user_designated_as_supplier) { false }
73+
74+
it "requires supplier ID" do
75+
expect(requires_supplied_by_user_id?).to be(true)
76+
end
77+
end
78+
79+
context "when user is designated as a supplier" do
80+
let(:psd_enabled) { false }
81+
let(:user_designated_as_supplier) { true }
82+
83+
it "does not require supplier ID" do
84+
expect(requires_supplied_by_user_id?).to be(false)
85+
end
86+
end
87+
88+
context "when PSD is enabled and user is designated as a supplier" do
89+
let(:psd_enabled) { true }
90+
let(:user_designated_as_supplier) { true }
91+
92+
it "does not require supplier ID" do
93+
expect(requires_supplied_by_user_id?).to be(false)
94+
end
95+
end
96+
end
5297
end

0 commit comments

Comments
 (0)