Skip to content

Commit eefc994

Browse files
Allow users to sort offline sheet by consent time
This moves the date to the start of the consent string, allowing it to be sorted alphabetically. Also, the newest consents must be shown first.
1 parent 9fc95a1 commit eefc994

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/lib/reports/export_formatters.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ def consent_status(patient:, programme:, academic_year:)
5050

5151
def consent_details(consents:)
5252
values =
53-
consents.map do |consent|
54-
"#{consent.response.humanize} by #{consent.name} at #{consent.created_at}"
53+
consents.sort_by(&:created_at).reverse.map do |consent|
54+
"On #{consent.created_at.to_date} at #{consent.created_at.strftime('%H:%M')} " \
55+
"#{consent.response.humanize.upcase} by #{consent.name}"
5556
end
5657

5758
values.join(", ")

spec/lib/reports/programme_vaccinations_exporter_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,7 @@
460460

461461
it "includes the information" do
462462
expect(rows.first.to_hash).to include(
463-
"CONSENT_DETAILS" =>
464-
"Given by John Smith at 2024-01-01 12:05:20 +0000",
463+
"CONSENT_DETAILS" => "On 2024-01-01 at 12:05 GIVEN by John Smith",
465464
"CONSENT_STATUS" => expected_consent_status,
466465
"HEALTH_QUESTION_ANSWERS" =>
467466
consent

0 commit comments

Comments
 (0)