Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions spec/factories/patients.rb
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,82 @@
end
end

trait :consent_given_nasal_triage_safe_to_vaccinate_nasal do
consents do
programmes.map do |programme|
association(
:consent,
:given_nasal,
:from_mum,
:health_question_notes,
patient: instance,
team:,
programme:
)
end
end

consent_statuses do
programmes.map do |programme|
association(
:patient_consent_status,
:given_nasal_only,
patient: instance,
programme:
)
end
end

triage_statuses do
programmes.map do |programme|
association(
:patient_triage_status,
:safe_to_vaccinate_nasal,
patient: instance,
programme:
)
end
end
end

trait :consent_given_injection_and_nasal_triage_safe_to_vaccinate_injection do
consents do
programmes.map do |programme|
association(
:consent,
:given_nasal,
:from_mum,
:health_question_notes,
patient: instance,
team:,
programme:
)
end
end

consent_statuses do
programmes.map do |programme|
association(
:patient_consent_status,
:given_nasal_or_injection,
patient: instance,
programme:
)
end
end

triage_statuses do
programmes.map do |programme|
association(
:patient_triage_status,
:safe_to_vaccinate,
patient: instance,
programme:
)
end
end
end

trait :consent_refused do
triage_not_required

Expand Down
29 changes: 27 additions & 2 deletions spec/features/flu_vaccination_hca_national_protocol_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@
then_i_am_able_to_vaccinate_them_using_injection_instead_of_nasal
end

def given_a_session_exists(psd_enabled: false)
scenario "HCA viewing record tab where national protocol is turned off and patient triaged for injection" do
given_a_session_exists(national_protocol_enabled: false)
and_a_nasal_and_injection_patient_exists_triaged_as_safe_vaccinate_with_injection

when_i_visit_the_session_record_tab
then_i_should_not_see_the_patient
end

def given_a_session_exists(
psd_enabled: false,
national_protocol_enabled: true
)
@programme = create(:programme, :flu)
programmes = [@programme]

Expand Down Expand Up @@ -65,7 +76,8 @@ def given_a_session_exists(psd_enabled: false)
:national_protocol_enabled,
team: @team,
programmes:,
psd_enabled:
psd_enabled:,
national_protocol_enabled:
)
end

Expand All @@ -90,6 +102,15 @@ def and_patients_exist
)
end

def and_a_nasal_and_injection_patient_exists_triaged_as_safe_vaccinate_with_injection
@patient_nasal_and_injection =
create(
:patient,
:consent_given_injection_and_nasal_triage_safe_to_vaccinate_injection,
session: @session
)
end

def and_the_nasal_and_injection_patient_has_a_psd
create(
:patient_specific_direction,
Expand All @@ -116,6 +137,10 @@ def then_i_see_only_the_injection_patients
expect(page).to have_content(@patient_injection_only.full_name)
end

def then_i_should_not_see_the_patient
expect(page).not_to have_content(@patient_nasal_and_injection.full_name)
end

def when_i_click_on_the_nasal_only_patient
click_on @patient_nasal_only.full_name
end
Expand Down
20 changes: 20 additions & 0 deletions spec/features/flu_vaccination_hca_pgd_supply_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
then_i_am_not_able_to_vaccinate_them
end

scenario "Patient consents nasal, has health issues, and is triaged as safe to vaccinate" do
given_a_session_exists
and_a_nasal_patient_exists_with_health_issues_marked_safe_vaccinate_with_nasal

when_i_visit_the_session_record_tab
and_i_click_on_the_nasal_only_patient
then_i_am_able_to_vaccinate_them_nasal_only
end

def given_a_session_exists
@programme = create(:programme, :flu)
programmes = [@programme]
Expand Down Expand Up @@ -68,6 +77,15 @@ def and_patients_exist
)
end

def and_a_nasal_patient_exists_with_health_issues_marked_safe_vaccinate_with_nasal
@patient_nasal_only =
create(
:patient,
:consent_given_nasal_triage_safe_to_vaccinate_nasal,
session: @session
)
end

def when_i_visit_the_session_record_tab
sign_in @user, role: :healthcare_assistant
visit session_record_path(@session)
Expand All @@ -82,6 +100,8 @@ def then_i_only_see_nasal_spray_patients
def when_i_click_on_the_nasal_only_patient
click_on @patient_nasal_only.full_name
end
alias_method :and_i_click_on_the_nasal_only_patient,
:when_i_click_on_the_nasal_only_patient

def when_i_click_on_the_nasal_and_injection_patient
click_on @patient_nasal_and_injection.full_name
Expand Down