Skip to content

Commit 07c2887

Browse files
committed
Filter vaccination tallies to show only today's records
Ensures vaccinators only see tallies for vaccination records they created today, excluding records from previous days of the same session. This provides accurate daily progress tracking during multi-day vaccination sessions.
1 parent 2b9ae88 commit 07c2887

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

app/components/app_vaccinations_summary_table_component.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def tally_results
1616
.includes(:vaccine)
1717
.administered
1818
.where(performed_by_user: current_user)
19+
.where(created_at: Date.current.all_day)
1920

2021
results = initialize_results_hash
2122
populate_results(results, administered) if administered.any?

spec/features/tallying_spec.rb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@
22

33
describe "Tallying" do
44
scenario "vaccinator can see how many they have administered during a session" do
5-
given_a_session_exists_for_hpv_and_flu
5+
given_a_session_for_hpv_and_flu_is_running_today
66
and_i_have_administered_two_cervarix_vaccines_for_hpv_programme
77
and_administered_one_gardasil_vaccine_for_hpv_programme
88
and_administered_one_fluenz_vaccine_for_flu_programme
9+
and_i_created_vaccination_records_yesterday
910
and_vaccinations_are_recorded_by_other_team_members
1011
and_the_default_vaccine_batches_have_been_set_for_flu_and_hpv
1112

1213
when_i_visit_the_session_record_tab
1314
and_i_click_on_the_expander_your_vaccinations_today
14-
then_i_see_my_vaccinations_in_summary_with_default_batches
15+
then_i_see_my_vaccination_tallies_for_today_with_default_batches
1516
end
1617

1718
scenario "no vaccinations have been administered yet" do
18-
given_a_session_exists_for_hpv_and_flu
19+
given_a_session_for_hpv_and_flu_is_running_today
1920
and_the_default_vaccine_batches_have_been_set_for_flu_and_hpv
2021

2122
when_i_visit_the_session_record_tab
2223
and_i_click_on_the_expander_your_vaccinations_today
23-
then_i_see_my_vaccinations_in_summary_with_all_zero_values_with_default_batches
24+
then_i_see_my_vaccination_tallies_with_all_zero_values_with_default_batches
2425
end
2526

26-
def given_a_session_exists_for_hpv_and_flu
27+
def given_a_session_for_hpv_and_flu_is_running_today
2728
@flu_programme = create(:programme, :flu, vaccines: [])
2829
@hpv_programme = create(:programme, :hpv, vaccines: [])
2930

@@ -124,6 +125,18 @@ def and_administered_one_fluenz_vaccine_for_flu_programme
124125
)
125126
end
126127

128+
def and_i_created_vaccination_records_yesterday
129+
create(
130+
:vaccination_record,
131+
batch: @cervarix_batch,
132+
vaccine: @cervarix_vaccine,
133+
session: @session,
134+
programme: @hpv_programme,
135+
performed_by: @user,
136+
created_at: Time.zone.yesterday
137+
)
138+
end
139+
127140
def and_vaccinations_are_recorded_by_other_team_members
128141
create(
129142
:vaccination_record,
@@ -134,14 +147,14 @@ def and_vaccinations_are_recorded_by_other_team_members
134147
)
135148
end
136149

137-
def then_i_see_my_vaccinations_in_summary_with_default_batches
150+
def then_i_see_my_vaccination_tallies_for_today_with_default_batches
138151
rows = page.all(".nhsuk-table__row")
139152
expect(rows[1]).to have_content("Cervarix 1 #{@cervarix_batch.name} Change")
140153
expect(rows[2]).to have_content("Gardasil 2 Not set")
141154
expect(rows[3]).to have_content("Fluenz 1 #{@fluenz_batch.name} Change")
142155
end
143156

144-
def then_i_see_my_vaccinations_in_summary_with_all_zero_values_with_default_batches
157+
def then_i_see_my_vaccination_tallies_with_all_zero_values_with_default_batches
145158
rows = page.all(".nhsuk-table__row")
146159
expect(rows[1]).to have_content("Cervarix 0 #{@cervarix_batch.name} Change")
147160
expect(rows[2]).to have_content("Gardasil 0 Not set")

0 commit comments

Comments
 (0)