Skip to content

Commit c7078c7

Browse files
committed
Fix triage delay not being created for invalid MMR doses
When an invalid MMR dose is recorded (given too early), the triage delay for the next dose was not being created. This occurred because the `NextDoseTriageFactory` incorrectly assumed that if a patient reached the maximum dose sequence (2 for MMR), no further triage was required. This change ensures that a 28-day delay triage is created if the patient is not yet considered fully vaccinated, regardless of the current dose sequence count. This adheres to clinical guidance that the 28-day interval should reset from the most recent dose even if that dose was invalid.
1 parent e521d90 commit c7078c7

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

app/lib/next_dose_triage_factory.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ def should_create?
3232

3333
return false if next_date.past?
3434

35-
dose_sequence =
36-
patient.vaccination_status(programme:, academic_year:).dose_sequence
35+
status = patient.vaccination_status(programme:, academic_year:)
3736

38-
dose_sequence != programme.maximum_dose_sequence
37+
!status.vaccinated?
3938
end
4039

4140
def next_date = vaccination_record.performed_at + 28.days

spec/lib/next_dose_triage_factory_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,37 @@
3737
expect { call }.not_to(change(Triage, :count))
3838
end
3939
end
40+
41+
context "when it is an invalid second MMR dose (too early)" do
42+
let(:patient) do
43+
create(
44+
:patient,
45+
:consent_given_triage_safe_to_vaccinate,
46+
year_group: 9,
47+
session:
48+
)
49+
end
50+
let(:session) { create(:session, programmes: [programme]) }
51+
52+
it "shows delay vaccination 28 days after last vaccine" do
53+
create(
54+
:vaccination_record,
55+
programme:,
56+
patient:,
57+
session:,
58+
performed_at: 20.days.ago
59+
)
60+
second_dose =
61+
create(:vaccination_record, programme:, session:, patient:)
62+
63+
StatusUpdater.call(patient:)
64+
65+
described_class.call(vaccination_record: second_dose.reload)
66+
67+
triage = second_dose.reload.next_dose_delay_triage
68+
69+
expect(triage.delay_vaccination_until).to eq(28.days.from_now.to_date)
70+
end
71+
end
4072
end
4173
end

0 commit comments

Comments
 (0)