Skip to content

Commit 9a8f9f6

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 9a8f9f6

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

app/components/app_patient_page_component.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,27 @@ 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 =
67+
today_pre_screenings
68+
.detect { |ps| ps.feeling_well.present? }
69+
&.feeling_well
70+
not_pregnant =
71+
today_pre_screenings
72+
.detect { |ps| ps.not_pregnant.present? }
73+
&.not_pregnant
6674

6775
VaccinateForm.new(
6876
patient_session:,
6977
programme:,
70-
feeling_well: pre_screening&.feeling_well,
71-
not_pregnant: pre_screening&.not_pregnant
78+
feeling_well: feeling_well,
79+
not_pregnant: not_pregnant
7280
)
7381
end
7482
end

0 commit comments

Comments
 (0)