Skip to content

Commit 70ab79a

Browse files
committed
Update pre-screening logic to use last available answer for each question
Update pre-screening initialisation logic to retrieve the most recent answer for each question from the same day, instead of only using the last pre-screening performed. This ensures that relevant answers are translated across pre-screenings, even if a specific vaccine does not have a particular question.
1 parent 555504c commit 70ab79a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/components/app_patient_page_component.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,21 @@ def vaccination_records
5656
end
5757

5858
def default_vaccinate_form
59-
pre_screening =
59+
today_pre_screenings =
6060
patient_session
6161
.pre_screenings
6262
.joins(:session_date)
6363
.merge(SessionDate.today)
6464
.order(created_at: :desc)
65-
.first
65+
66+
feeling_well = today_pre_screenings.any?(&:feeling_well) || nil
67+
not_pregnant = today_pre_screenings.any?(&:not_pregnant) || nil
6668

6769
VaccinateForm.new(
6870
patient_session:,
6971
programme:,
70-
feeling_well: pre_screening&.feeling_well,
71-
not_pregnant: pre_screening&.not_pregnant
72+
feeling_well: feeling_well,
73+
not_pregnant: not_pregnant
7274
)
7375
end
7476
end

0 commit comments

Comments
 (0)