Files
api/app/models/baclight/member.rb
T

58 lines
1.9 KiB
Ruby
Raw Normal View History

2026-07-23 10:41:46 -04:00
module Baclight
class Member < BaclightRecord
self.table_name = 'Members'
belongs_to :baclight_employer, class_name: "Baclight::Employer", foreign_key: "employer_id"
scope :active, -> {
2026-09-16 12:41:44 -04:00
where(active: true)
2026-07-23 10:41:46 -04:00
}
# alias_attribute :id, :id
# alias_attribute :name, :name
# alias_attribute :family_id, :family_id
# alias_attribute :mb_member_key, :mb_member_key
# alias_attribute :pb_entity_key, :pb_entity_key
# alias_attribute :pl_plan_key, :pl_plan_key
# alias_attribute :id_card_display_name, :id_card_display_name
# alias_attribute :coverage_class, :coverage_class
# alias_attribute :division, :division
# alias_attribute :dental_plan_key, :dental_plan_key
# alias_attribute :dependents, :dependents
# alias_attribute :employer_id, :employer_id
# alias_attribute :id_card_plan_id, :id_card_plan_id
# alias_attribute :created_at, :created_at
# alias_attribute :updated_at, :updated_at
# def member_belongs_to
# {
# broker_id: baclight_employer&.broker_id,
# carrier_id: baclight_employer&.baclight_broker&.carrier_id
# }
# end
def broker_id
baclight_employer&.broker_id
end
def carrier_id
baclight_employer&.baclight_broker&.carrier_id
end
2026-09-16 12:41:44 -04:00
def eff_date
participation = Vhcs::PbProductParticipation.joins('INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"').where('"PBCoveredEntities"."PBEntityKey" = ?', pb_entity_key).order(out_of_effect: :desc).first
eff_date = nil
if participation
in_effect = participation.in_effect
out_of_effect = participation.out_of_effect
if in_effect <= (Date.today + 90.days) && (out_of_effect - 1.day) > Date.today && out_of_effect > in_effect
eff_date = in_effect.strftime("%m/%d/%Y")
end
end
eff_date
end
2026-07-23 10:41:46 -04:00
end
end