module Vhcs
  class PbEntity < VhcsRecord

    self.table_name = 'PBEntity'

    alias_attribute :pb_entity_key, :PBEntityKey
    alias_attribute :company_pb_entity_key, :CompanyPBEntityKey
    alias_attribute :entity_type_id, :EntityTypeID
    alias_attribute :prefix_id, :PrefixID
    alias_attribute :first_name, :FirstName
    alias_attribute :middle_name, :MiddleName
    alias_attribute :last_name, :LastName
    alias_attribute :suffix_id, :SuffixID
    alias_attribute :title, :Title
    alias_attribute :letter_tag_bit_flags, :LetterTagBitFlags
    alias_attribute :when_last_changed, :WhenLastChanged
    alias_attribute :who_last_changed, :WhoLastChanged
    alias_attribute :full_name_last_name_first, :FullNameLastNameFirst
    alias_attribute :alternate_key, :AlternateKey

    def attributes
      rails_like = {
          pb_entity_key: self.pb_entity_key,
          company_pb_entity_key: self.company_pb_entity_key,
          entity_type_id: self.entity_type_id,
          prefix_id: self.prefix_id,
          first_name: self.first_name,
          middle_name: self.middle_name,
          last_name: self.last_name,
          suffix_id: self.suffix_id,
          title: self.title,
          letter_tag_bit_flags: self.letter_tag_bit_flags,
          when_last_changed: self.when_last_changed,
          who_last_changed: self.who_last_changed,
          full_name_last_name_first: self.full_name_last_name_first,
          alternate_key: self.alternate_key,
      }
      super.merge(rails_like)
    end

    def full_name
      [self.first_name, self.middle_name, self.last_name].join(" ").squish
    end


  end
end