Skip to content

Commit bc9c446

Browse files
committed
Fix: don’t require attendance when session registration is disabled
A recent change (e9290c8) added a patient must be attending today validation to the vaccination recording flow to prevent recording vaccinations for patients marked absent. That validation looked for an `AttendanceRecord` and treated missing record the same as not attending. In sessions where registration is turned off, attendance records are not expected to exist, so vaccination recording was blocked even though registration is optional for that session.
1 parent 716cabe commit bc9c446

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

app/models/draft_vaccination_record.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ def delivery_site_matches_delivery_method
501501
def validate_patient_attendance
502502
return unless new_record?
503503
return unless session&.today?
504+
return unless session&.requires_registration?
504505
return if patient.blank?
505506

506507
attendance_record =

spec/models/draft_vaccination_record_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,29 @@
128128
it { should validate_length_of(:notes).is_at_most(1000).on(:update) }
129129
end
130130

131+
context "when registration is disabled for the session" do
132+
let(:session) do
133+
create(
134+
:session,
135+
team:,
136+
programmes: [programme],
137+
requires_registration: false
138+
)
139+
end
140+
141+
let(:patient) { create(:patient, session:) }
142+
let(:attributes) { valid_administered_attributes }
143+
144+
before { draft_vaccination_record.wizard_step = :confirm }
145+
146+
it "does not require an attendance record to record a vaccination" do
147+
expect(draft_vaccination_record.save(context: :update)).to be(true)
148+
expect(draft_vaccination_record.errors[:base]).not_to include(
149+
"Child is marked as not attending this session. Mark them as attending to record a vaccination."
150+
)
151+
end
152+
end
153+
131154
context "when the patient is marked not attending" do
132155
let(:attributes) { valid_administered_attributes }
133156
let(:patient) { create(:patient, session:) }

0 commit comments

Comments
 (0)