Skip to content

Commit 4e2effe

Browse files
committed
Update AppVaccinateFormComponent#dose_sequence to use patient programme_status dose_sequence
1 parent 9f615b2 commit 4e2effe

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

app/components/app_vaccinate_form_component.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def has_patient_specific_direction?(vaccine_method:)
7373

7474
def healthcare_assistant? = current_user.is_healthcare_assistant?
7575

76-
def dose_sequence = programme.default_dose_sequence
76+
def dose_sequence
77+
return if programme.td_ipv? || programme.menacwy?
78+
patient.programme_status(programme, academic_year:).dose_sequence
79+
end
7780

7881
COMMON_DELIVERY_SITES = {
7982
"injection" => %w[left_arm_upper_position right_arm_upper_position],

spec/components/app_vaccinate_form_component_spec.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525

2626
let(:component) { described_class.new(vaccinate_form) }
2727

28+
let(:update_status) do
29+
patient.programme_status(
30+
programme,
31+
academic_year: session.academic_year
32+
).assign
33+
end
34+
35+
before { update_status }
36+
2837
describe "#render" do
2938
subject { render_inline(component) }
3039

@@ -121,6 +130,12 @@
121130
describe "#dose_sequence" do
122131
subject { component.send(:dose_sequence) }
123132

133+
let(:prior_vaccination_records) { nil }
134+
let(:update_status) do
135+
prior_vaccination_records
136+
patient.programme_status(programme, academic_year: session.academic_year).assign
137+
end
138+
124139
context "with HPV programme" do
125140
let(:programme) { Programme.hpv }
126141

@@ -148,7 +163,15 @@
148163
context "with MMR programme" do
149164
let(:programme) { Programme.mmr }
150165

151-
it { should be_nil }
166+
it { should eq(1) }
167+
168+
context "with an existing vaccination record" do
169+
let(:prior_vaccination_records) do
170+
create(:vaccination_record, patient:, programme:, dose_sequence: 1)
171+
end
172+
173+
it { should eq(2) }
174+
end
152175
end
153176
end
154177
end

0 commit comments

Comments
 (0)