class PDSSearchResult
Schema Information
Table name: pds_search_results
id :bigint not null, primary key import_type :string nhs_number :string result :integer not null step :integer not null created_at :datetime not null updated_at :datetime not null import_id :bigint patient_id :bigint not null
Indexes
index_pds_search_results_on_import (import_type,import_id) index_pds_search_results_on_patient_id (patient_id)
Foreign Keys
fk_rails_... (patient_id => patients.id) ON DELETE => cascade
Public Class Methods
Source
# File app/models/pds_search_result.rb, line 53 def self.grouped_sets records = all.to_a grouped_records = records.group_by do |record| if record.import_id.present? [:import, record.import_type, record.import_id] else [:date, record.created_at.to_date] end end grouped_records.values end
Source
# File app/models/pds_search_result.rb, line 66 def self.latest_set grouped_sets.max_by { |set| set.map(&:created_at).max } end
Public Instance Methods
Source
# File app/models/pds_search_result.rb, line 74 def changeset return unless import_id PatientChangeset.find_by( import_type: import_type, import_id: import_id, patient_id: patient_id ) end
Source
# File app/models/pds_search_result.rb, line 70 def pds_nhs_number changeset&.pds_nhs_number end
Source
# File app/models/pds_search_result.rb, line 84 def timeline_item { is_past_item: true, heading_text: human_enum_name(:step), description: I18n.t( "activerecord.attributes.#{self.class.model_name.i18n_key}.results.#{result}", nhs_number: nhs_number ) } end