Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions app/helpers/patients_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,25 @@ def patient_school(patient)
end

def patient_year_group(patient, academic_year:)
parts = [
format_year_group(patient.year_group(academic_year:)),
if patient.registration_academic_year == academic_year &&
patient.registration.present?
"(#{patient.registration})"
end,
if academic_year != AcademicYear.current
"(#{format_academic_year(academic_year)} academic year)"
end
]
str = format_year_group(patient.year_group(academic_year:))

include_registration =
patient.registration_academic_year == academic_year &&
patient.registration.present?

include_academic_year =
academic_year != AcademicYear.current ||
AcademicYear.current != AcademicYear.pending

str = str.dup if include_registration || include_academic_year

str << ", #{patient.registration}" if include_registration

if include_academic_year
str << " (#{format_academic_year(academic_year)} academic year)"
end

parts.compact.join(" ")
str
end

def patient_parents(patient)
Expand Down
4 changes: 2 additions & 2 deletions spec/features/import_child_records_with_duplicates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ def then_i_should_see_the_third_duplicate_record
expect(page).to have_content("Full nameDOE, Mark")
expect(page).to have_content("Date of birth3 January 2010 (aged 14)")
expect(page).to have_content("Date of birth3 March 2013 (aged 11)")
expect(page).to have_content("Year groupYear 10 (")
expect(page).to have_content("Year groupYear 8 (")
expect(page).to have_content("Year groupYear 10, ")
expect(page).to have_content("Year groupYear 8, ")
end

def when_i_go_to_the_import_page
Expand Down
18 changes: 17 additions & 1 deletion spec/helpers/patients_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
patient.registration_academic_year = today.academic_year
end

it { should eq("Year 9 (9AB)") }
it { should eq("Year 9, 9AB") }
end
end

Expand All @@ -120,5 +120,21 @@
it { should eq("Year 10 (2024 to 2025 academic year)") }
end
end

context "during the preparation period" do
let(:today) { Date.new(2024, 8, 1) }
let(:academic_year) { today.academic_year }

it { should eq("Year 9 (2023 to 2024 academic year)") }

context "with a registration" do
before do
patient.registration = "9AB"
patient.registration_academic_year = today.academic_year
end

it { should eq("Year 9, 9AB (2023 to 2024 academic year)") }
end
end
end
end