Skip to content

Commit 1dabaf1

Browse files
committed
Ensure PSD supplier is attached to vaccination record
When recording a vaccination record under the PSD protocol, we need to attached the person who supplied the vaccine (i.e. who created the PSD) to the vaccination record. This also ensures that these details are included in any reports.
1 parent a0a52c6 commit 1dabaf1

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

app/forms/vaccinate_form.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ def save(draft_vaccination_record:)
152152
draft_vaccination_record.programme = programme
153153
draft_vaccination_record.protocol = protocol
154154
draft_vaccination_record.session_id = session.id
155-
draft_vaccination_record.supplied_by_user_id = supplied_by_user_id
155+
draft_vaccination_record.supplied_by_user_id =
156+
supplied_by_user_id || psd_created_by_user_id
156157

157158
draft_vaccination_record.save # rubocop:disable Rails/SaveBang
158159
end
@@ -165,6 +166,21 @@ def administered? = vaccine_method != "none"
165166

166167
def supplied_by_user_id_values = supplied_by_users.pluck(:id)
167168

169+
def psd_created_by_user_id
170+
if healthcare_assistant_using_psd?
171+
patient
172+
.patient_specific_directions
173+
.order(created_at: :desc)
174+
.find_by(
175+
academic_year:,
176+
programme:,
177+
team: current_user.selected_team,
178+
vaccine_method:
179+
)
180+
&.created_by_user_id
181+
end
182+
end
183+
168184
def vaccine_method_options
169185
programme.vaccine_methods + ["none"]
170186
end

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ en:
262262
protocols:
263263
national: National protocol
264264
pgd: Patient Group Direction (PGD)
265+
psd: Patient Specific Direction
265266
sync_statuses:
266267
cannot_sync: Cannot sync
267268
not_synced: Not synced

spec/features/flu_vaccination_hca_psd_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def given_a_flu_session_exists(user_type:, national_protocol_enabled: false)
8989
@programme = create(:programme, :flu)
9090
@programmes = [@programme]
9191
@team = create(:team, user_type, programmes: @programmes)
92-
@nurse = create(:nurse, team: @team)
92+
@user = create(:nurse, team: @team)
9393

9494
@batch =
9595
create(
@@ -224,6 +224,10 @@ def then_i_am_able_to_vaccinate_them_with_nasal_via_psd
224224

225225
choose @batch.name
226226
click_button "Continue"
227+
228+
expect(page).to have_content("ProtocolPatient Specific Direction")
229+
expect(page).to have_content("Supplier#{@user.full_name}")
230+
227231
click_on "Confirm"
228232

229233
expect(page).to have_text("Vaccination outcome recorded for flu")

0 commit comments

Comments
 (0)