Skip to content

Commit

Permalink
Remove YearGroupConcern
Browse files Browse the repository at this point in the history
This removes the concern as it's only beind used by one model now.
  • Loading branch information
thomasleese committed Jan 5, 2025
1 parent 2a22bda commit 03c7835
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 32 deletions.
20 changes: 0 additions & 20 deletions app/models/concerns/year_group_concern.rb

This file was deleted.

11 changes: 10 additions & 1 deletion app/models/patient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class Patient < ApplicationRecord
include Invalidatable
include PendingChangesConcern
include Schoolable
include YearGroupConcern

audited

Expand Down Expand Up @@ -140,6 +139,8 @@ class Patient < ApplicationRecord

validates :given_name, :family_name, :date_of_birth, presence: true

validates :birth_academic_year, comparison: { greater_than_or_equal_to: 1990 }

validates :nhs_number,
uniqueness: true,
format: {
Expand Down Expand Up @@ -232,6 +233,14 @@ def self.match_existing(
results
end

def year_group
birth_academic_year.to_year_group
end

def year_group_changed?
birth_academic_year_changed?
end

def relationship_to(parent:)
parent_relationships.find { _1.parent == parent }
end
Expand Down
5 changes: 4 additions & 1 deletion app/models/patient_import_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

class PatientImportRow
include ActiveModel::Model
include YearGroupConcern

validates :date_of_birth, presence: true
validates :existing_patients, length: { maximum: 1 }
Expand Down Expand Up @@ -179,6 +178,10 @@ def birth_academic_year
end
end

def year_group
birth_academic_year&.to_year_group
end

def registration
@data["CHILD_REGISTRATION"]&.strip.presence
end
Expand Down
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ en:
address_line_2: <code>CHILD_ADDRESS_LINE_2</code>
address_postcode: <code>CHILD_POSTCODE</code>
address_town: <code>CHILD_TOWN</code>
birth_academic_year: <code>CHILD_YEAR_GROUP</code>
date_of_birth: <code>CHILD_DATE_OF_BIRTH</code>
first_name: <code>CHILD_FIRST_NAME</code>
gender_code: <code>CHILD_GENDER</code>
Expand All @@ -22,12 +21,12 @@ en:
parent_2_relationship: <code>PARENT_2_RELATIONSHIP</code>
preferred_family_name: <code>CHILD_PREFERRED_LAST_NAME</code>
preferred_given_name: <code>CHILD_PREFERRED_FIRST_NAME</code>
year_group: <code>CHILD_YEAR_GROUP</code>
cohort_import_row:
address_line_1: <code>CHILD_ADDRESS_LINE_1</code>
address_line_2: <code>CHILD_ADDRESS_LINE_2</code>
address_postcode: <code>CHILD_POSTCODE</code>
address_town: <code>CHILD_TOWN</code>
birth_academic_year: <code>CHILD_YEAR_GROUP</code>
date_of_birth: <code>CHILD_DATE_OF_BIRTH</code>
first_name: <code>CHILD_FIRST_NAME</code>
gender_code: <code>CHILD_GENDER</code>
Expand All @@ -44,6 +43,7 @@ en:
preferred_family_name: <code>CHILD_PREFERRED_LAST_NAME</code>
preferred_given_name: <code>CHILD_PREFERRED_FIRST_NAME</code>
school_urn: <code>CHILD_SCHOOL_URN</code>
year_group: <code>CHILD_YEAR_GROUP</code>
immunisation_import_row:
administered: <code>VACCINATED</code>
batch_expiry_date: <code>BATCH_EXPIRY_DATE</code>
Expand Down
5 changes: 1 addition & 4 deletions spec/models/class_import_row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,10 @@

it "is invalid" do
expect(class_import_row).to be_invalid
expect(class_import_row.errors.size).to eq(2)
expect(class_import_row.errors.size).to eq(1)
expect(class_import_row.errors[:date_of_birth]).to contain_exactly(
"is required but missing"
)
expect(
class_import_row.errors[:birth_academic_year]
).to contain_exactly("is required but missing")
end
end
end
Expand Down
5 changes: 1 addition & 4 deletions spec/models/cohort_import_row_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,10 @@

it "is invalid" do
expect(cohort_import_row).to be_invalid
expect(cohort_import_row.errors.size).to eq(2)
expect(cohort_import_row.errors.size).to eq(1)
expect(cohort_import_row.errors[:date_of_birth]).to contain_exactly(
"is required but missing"
)
expect(
cohort_import_row.errors[:birth_academic_year]
).to contain_exactly("is required but missing")
end
end
end
Expand Down

0 comments on commit 03c7835

Please sign in to comment.