5
5
6
6
scenario "prescriber can bulk add PSDs to patients that don't require triage" do
7
7
given_a_flu_programme_with_a_running_session ( user_type : :with_one_nurse )
8
- and_a_patient_who_doesnt_need_triage_exists
8
+ and_a_patient_with_consent_given_nasal_only_triage_not_needed
9
+ and_a_patient_with_consent_given_injection_only_triage_not_needed
9
10
and_i_am_signed_in
10
11
11
12
when_i_go_to_the_session_psds_tab
12
- then_the_patient_should_have_psd_status_not_added
13
+ then_the_patients_should_have_psd_status_not_added
14
+ and_i_should_only_see_one_child_eligible_for_bulk_adding_psd
13
15
and_i_should_see_one_child_eligible_for_psd
14
16
15
17
when_i_click_add_new_psds
16
18
and_should_see_again_one_child_eligible_for_psd
17
19
18
20
when_i_click_on_button_to_bulk_add_psds
19
- then_the_patient_should_have_psd_status_added
21
+ then_the_nasal_patient_should_have_psd_status_added
22
+ and_the_injection_patient_should_have_psd_status_not_added
20
23
and_zero_children_should_be_eligible_for_psd
21
24
end
22
25
23
26
scenario "admin cannot bulk add PSDs to patients" do
24
27
given_a_flu_programme_with_a_running_session ( user_type : :with_one_admin )
25
- and_a_patient_who_doesnt_need_triage_exists
28
+ and_a_patient_with_consent_given_nasal_only_triage_not_needed
26
29
and_i_am_signed_in ( role : :admin )
27
30
28
31
when_i_go_to_the_session_psds_tab
33
36
given_a_flu_programme_with_a_running_session (
34
37
user_type : :with_one_healthcare_assistant
35
38
)
36
- and_a_patient_who_doesnt_need_triage_exists
39
+ and_a_patient_with_consent_given_nasal_only_triage_not_needed
37
40
and_i_am_signed_in ( role : :healthcare_assistant )
38
41
39
42
when_i_go_to_the_session_psds_tab
@@ -45,22 +48,33 @@ def given_delegation_feature_flag_is_enabled
45
48
end
46
49
47
50
def given_a_flu_programme_with_a_running_session ( user_type :)
48
- programmes = [ create ( :programme , :flu ) ]
49
- @team = create ( :team , user_type , programmes :)
51
+ @ programmes = [ create ( :programme , :flu ) ]
52
+ @team = create ( :team , user_type , programmes : @programmes )
50
53
51
54
@batch =
52
- create ( :batch , team : @team , vaccine : programmes . first . vaccines . first )
55
+ create ( :batch , team : @team , vaccine : @ programmes. first . vaccines . first )
53
56
54
- @session = create ( :session , team : @team , programmes :)
57
+ @session = create ( :session , team : @team , programmes : @programmes )
55
58
end
56
59
57
- def and_a_patient_who_doesnt_need_triage_exists
58
- @patient_triage_not_needed =
60
+ def and_a_patient_with_consent_given_nasal_only_triage_not_needed
61
+ @nasal_patient =
59
62
create (
60
- :patient_session ,
61
- :consent_given_triage_not_needed ,
63
+ :patient ,
64
+ :consent_given_nasal_only_triage_not_needed ,
65
+ programmes : @programmes ,
62
66
session : @session
63
- ) . patient
67
+ )
68
+ end
69
+
70
+ def and_a_patient_with_consent_given_injection_only_triage_not_needed
71
+ @injection_patient =
72
+ create (
73
+ :patient ,
74
+ :consent_given_injection_only_triage_not_needed ,
75
+ programmes : @programmes ,
76
+ session : @session
77
+ )
64
78
end
65
79
66
80
def and_i_am_signed_in ( role : :nurse )
@@ -72,12 +86,16 @@ def when_i_go_to_the_session_psds_tab
72
86
visit session_patient_specific_directions_path ( @session )
73
87
end
74
88
75
- def then_the_patient_should_have_psd_status_not_added
89
+ def then_the_patients_should_have_psd_status_not_added
76
90
expect ( page ) . to have_text ( "PSD not added" )
77
91
end
78
92
79
- def then_the_patient_should_have_psd_status_added
80
- expect ( page ) . to have_text ( "PSD added" )
93
+ def then_the_nasal_patient_should_have_psd_status_added
94
+ expect_patient_to_have_psd_status ( @nasal_patient , "PSD added" )
95
+ end
96
+
97
+ def and_the_injection_patient_should_have_psd_status_not_added
98
+ expect_patient_to_have_psd_status ( @injection_patient , "PSD not added" )
81
99
end
82
100
83
101
def and_i_should_see_one_child_eligible_for_psd
@@ -103,4 +121,17 @@ def when_i_click_on_button_to_bulk_add_psds
103
121
def then_i_should_not_see_link_to_bulk_add_psds
104
122
expect ( page ) . not_to have_text ( "Add new PSDs" )
105
123
end
124
+
125
+ def and_i_should_only_see_one_child_eligible_for_bulk_adding_psd
126
+ expect ( page ) . to have_text (
127
+ "There are 1 children with consent for the nasal flu vaccine"
128
+ )
129
+ end
130
+
131
+ def expect_patient_to_have_psd_status ( patient , status )
132
+ full_name = "#{ patient . family_name . upcase } , #{ patient . given_name } "
133
+ patient_link = page . find ( "a" , text : full_name )
134
+ patient_card = patient_link . ancestor ( ".nhsuk-card" )
135
+ expect ( patient_card ) . to have_css ( ".nhsuk-tag" , text : status )
136
+ end
106
137
end
0 commit comments