Skip to content

Commit ea36ec7

Browse files
authored
Set session outcome to absent from session (#3238)
If the patient's attendance has been marked as absent, the session outcome for that day should show as "absent from session". Currently, the only way for a patient outcome to be "absent from session" would be if the vaccination was recorded as not administered for that reason, however we don't present "Absent from session" as one of the options available to the nurses. Instead, the expectation is that they would use the registration status. In theory, you could import a vaccination record with this status, so we still need to support that, but it's not the usual way this would work. Potentially we could remove "absent from school" and "absent from session" as vaccination record outcomes.
2 parents d989917 + 5756ed0 commit ea36ec7

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

app/components/app_outcome_banner_component.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def triage
6161
@triage ||= patient.triage_outcome.latest[programme]
6262
end
6363

64+
def session_attendance
65+
@session_attendance ||= patient_session.register_outcome.latest
66+
end
67+
6468
def show_location?
6569
# location only makes sense if an attempt to vaccinate on site was made
6670
vaccination_record.present?
@@ -87,6 +91,8 @@ def reason_do_not_vaccinate
8791
key =
8892
if vaccination_record&.not_administered?
8993
"patient_session_statuses.unable_to_vaccinate.banner_explanation.#{vaccination_record.outcome}"
94+
elsif session_attendance&.attending == false
95+
"patient_session_statuses.unable_to_vaccinate.banner_explanation.absent_from_session"
9096
else
9197
"patient_session_statuses.unable_to_vaccinate.banner_explanation.#{status}"
9298
end
@@ -102,7 +108,7 @@ def clinician_name
102108
end
103109

104110
def clinician
105-
@clinician ||= (vaccination_record || triage).performed_by
111+
@clinician ||= (vaccination_record || triage)&.performed_by
106112
end
107113

108114
def location
@@ -125,7 +131,9 @@ def date_summary
125131
end
126132

127133
def last_action_time
128-
@last_action_time ||= vaccination_record&.performed_at || triage&.created_at
134+
@last_action_time ||=
135+
vaccination_record&.performed_at || triage&.created_at ||
136+
session_attendance&.created_at
129137
end
130138

131139
def heading

app/models/patient_session/register_outcome.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ def session_date
5656
end
5757

5858
def all_programmes_have_outcome?
59-
programmes.none? { session_outcome.none_yet?(it) }
59+
programmes.none? { session_outcome.latest[it].nil? }
6060
end
6161
end

app/models/patient_session/session_outcome.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ def latest
4747

4848
attr_reader :patient_session
4949

50-
delegate :patient, :session, :programmes, to: :patient_session
50+
delegate :patient,
51+
:programmes,
52+
:register_outcome,
53+
:session,
54+
to: :patient_session
5155
delegate :consent_outcome, :triage_outcome, to: :patient
5256

5357
def programme_status(programme)
@@ -57,6 +61,8 @@ def programme_status(programme)
5761
REFUSED
5862
elsif triage_outcome.do_not_vaccinate?(programme)
5963
HAD_CONTRAINDICATIONS
64+
elsif register_outcome.not_attending?
65+
ABSENT_FROM_SESSION
6066
else
6167
NONE_YET
6268
end

spec/features/manage_attendance_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
when_i_register_a_patient_as_absent
1818
then_i_see_the_absent_flash
1919

20+
when_i_go_to_the_session_outcomes
21+
then_i_see_a_patient_is_absent
22+
2023
when_i_go_to_a_patient
2124
then_the_patient_is_not_registered_yet
2225
and_i_am_not_able_to_vaccinate
@@ -87,7 +90,21 @@ def when_i_register_a_patient_as_absent
8790
click_button "Absent", match: :first
8891
end
8992

93+
def when_i_go_to_the_session_outcomes
94+
click_on "Session outcomes"
95+
end
96+
97+
def then_i_see_a_patient_is_absent
98+
choose "Absent from session"
99+
click_on "Update results"
100+
101+
expect(page).to have_content("Showing 1 to 1 of 1 children")
102+
end
103+
90104
def when_i_go_to_a_patient
105+
choose "Any"
106+
click_on "Update results"
107+
91108
click_link PatientSession
92109
.where
93110
.missing(:session_attendances)

spec/models/patient_session/session_outcome_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656

5757
it { should be(described_class::HAD_CONTRAINDICATIONS) }
5858
end
59+
60+
context "when not attending the session" do
61+
before { create(:session_attendance, :absent, patient_session:) }
62+
63+
it { should be(described_class::ABSENT_FROM_SESSION) }
64+
end
5965
end
6066

6167
describe "#all" do

0 commit comments

Comments
 (0)