class Patient

Schema Information

Table name: patients

id                         :bigint           not null, primary key
address_line_1             :string
address_line_2             :string
address_postcode           :string
address_town               :string
birth_academic_year        :integer          not null
date_of_birth              :date             not null
date_of_death              :date
date_of_death_recorded_at  :datetime
ethnic_background          :integer
ethnic_background_other    :string
ethnic_group               :integer
family_name                :string           not null
gender_code                :integer          default("not_known"), not null
given_name                 :string           not null
invalidated_at             :datetime
local_authority_mhclg_code :string
nhs_number                 :string
pending_changes            :jsonb            not null
preferred_family_name      :string
preferred_given_name       :string
registration               :string
registration_academic_year :integer
restricted_at              :datetime
updated_from_pds_at        :datetime
created_at                 :datetime         not null
updated_at                 :datetime         not null
gp_practice_id             :bigint
school_id                  :bigint

Indexes

index_patients_on_family_name_trigram                  (family_name) USING gin
index_patients_on_given_name_trigram                   (given_name) USING gin
index_patients_on_gp_practice_id                       (gp_practice_id)
index_patients_on_local_authority_mhclg_code           (local_authority_mhclg_code)
index_patients_on_lower_family_name_dob_address        (date_of_birth, address_postcode, lower((family_name)::text))
index_patients_on_lower_given_name_dob_address         (address_postcode, date_of_birth, lower((given_name)::text))
index_patients_on_lower_names_family_first_address     (lower((family_name)::text), lower((given_name)::text), address_postcode)
index_patients_on_lower_names_given_first_dob_address  (lower((given_name)::text), lower((family_name)::text), date_of_birth, address_postcode)
index_patients_on_names_family_first                   (family_name,given_name)
index_patients_on_names_given_first                    (given_name,family_name)
index_patients_on_nhs_number                           (nhs_number) UNIQUE
index_patients_on_pending_changes_not_empty            (id) WHERE (pending_changes <> '{}'::jsonb)
index_patients_on_school_id                            (school_id)

Foreign Keys

fk_rails_...  (gp_practice_id => locations.id)
fk_rails_...  (school_id => locations.id)