Its been a while
CI / scan_ruby (push) Failing after 2m13s
CI / lint (push) Failing after 20s

This commit is contained in:
Jason Jordan
2026-07-23 10:41:46 -04:00
parent 16fadfd529
commit 9853d58469
83 changed files with 1978 additions and 243 deletions
+2
View File
@@ -1,3 +1,5 @@
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
establish_connection :primary
end
+19
View File
@@ -0,0 +1,19 @@
module Baclight
class Broker < BaclightRecord
self.table_name = 'Brokers'
belongs_to :baclight_carrier, class_name: "Baclight::Carrier", foreign_key: "carrier_id"
has_many :baclight_employers, class_name: "Baclight::Employer", foreign_key: "broker_id", primary_key: "id"
has_many :baclight_members,
through: :baclight_employers,
source: :baclight_member
alias_attribute :id, :id
alias_attribute :name, :name
alias_attribute :carrier_id, :carrier_id
alias_attribute :created_at, :created_at
alias_attribute :updated_at, :updated_at
end
end
+20
View File
@@ -0,0 +1,20 @@
module Baclight
class Carrier < BaclightRecord
self.table_name = 'Carriers'
has_many :baclight_brokers, class_name: "Baclight::Broker", foreign_key: "carrier_id", primary_key: "id"
has_many :baclight_employers,
through: :baclight_brokers,
source: :baclight_employer
has_many :baclight_members,
through: :baclight_employers,
source: :baclight_member
alias_attribute :id, :id
alias_attribute :name, :name
alias_attribute :created_at, :created_at
alias_attribute :updated_at, :updated_at
end
end
+31
View File
@@ -0,0 +1,31 @@
module Baclight
class Employer < BaclightRecord
self.table_name = 'Employers'
belongs_to :baclight_broker, class_name: "Baclight::Broker", foreign_key: "broker_id"
has_many :baclight_members, class_name: "Baclight::Member", foreign_key: "employer_id", primary_key: "id"
alias_attribute :id, :id
alias_attribute :name, :name
alias_attribute :slug, :slug
alias_attribute :pl_plan_key, :pl_plan_key
alias_attribute :company_pb_entity_key, :company_pb_entity_key
alias_attribute :plan_id, :plan_id
alias_attribute :group_number, :group_number
alias_attribute :effective_date, :effective_date
alias_attribute :active, :active
alias_attribute :initialized, :initialized
alias_attribute :broker_id, :broker_id
alias_attribute :created_at, :created_at
alias_attribute :updated_at, :updated_at
def belongs_to_levels
self.joins(baclight_broker: :baclight_carrier).select(
'baclight_broker.id AS broker_id',
'baclight_carrier.id AS carrier_id'
)
end
end
end
+18
View File
@@ -0,0 +1,18 @@
module Baclight
class IdCardPlan < BaclightRecord
self.table_name = 'id_card_plans'
has_many :baclight_id_card_plan_benefits, class_name: "Baclight::IdCardPlanBenefit", foreign_key: "plan_id", primary_key: "id"
alias_attribute :id, :id
alias_attribute :title, :title
alias_attribute :pb_product_key, :pb_product_key
alias_attribute :pl_plan_key, :pl_plan_key
alias_attribute :template, :template
alias_attribute :setup_id, :setup_id
alias_attribute :created_at, :created_at
alias_attribute :updated_at, :updated_at
end
end
@@ -0,0 +1,17 @@
module Baclight
class IdCardPlanBenefit < BaclightRecord
self.table_name = 'id_card_plan_benefits'
belongs_to :baclight_id_card_plan, class_name: "Baclight::IdCardPlan", foreign_key: "plan_id"
alias_attribute :id, :id
alias_attribute :benefit_desc, :benefit_desc
alias_attribute :benefit, :benefit
alias_attribute :sequence, :sequence
alias_attribute :plan_id, :plan_id
alias_attribute :created_at, :created_at
alias_attribute :updated_at, :updated_at
end
end
+25
View File
@@ -0,0 +1,25 @@
module Baclight
class IdCardSetup < BaclightRecord
self.table_name = 'id_card_setups'
alias_attribute :id, :id
alias_attribute :print_name, :print_name
alias_attribute :network_provider, :network_provider
alias_attribute :card_template, :card_template
alias_attribute :card_color, :card_color
alias_attribute :rx_group_number, :rx_group_number
alias_attribute :pl_plan_key, :pl_plan_key
alias_attribute :has_divisions, :has_divisions
alias_attribute :has_dental, :has_dental
alias_attribute :active, :active
alias_attribute :initialized, :initialized
alias_attribute :employer_id, :employer_id
alias_attribute :network_logo_id, :network_logo_id
alias_attribute :provider_section_id, :provider_section_id
alias_attribute :rx_section_id, :rx_section_id
alias_attribute :created_at, :created_at
alias_attribute :updated_at, :updated_at
end
end
+44
View File
@@ -0,0 +1,44 @@
module Baclight
class Member < BaclightRecord
self.table_name = 'Members'
belongs_to :baclight_employer, class_name: "Baclight::Employer", foreign_key: "employer_id"
scope :active, -> {
where(active: true)
}
# 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
end
end
+16
View File
@@ -0,0 +1,16 @@
module Baclight
class Provider < BaclightRecord
self.table_name = 'Providers'
alias_attribute :id, :id
alias_attribute :name, :name
alias_attribute :pb_entity_key, :pb_entity_key
alias_attribute :tax_id, :tax_id
alias_attribute :family_id, :family_id
alias_attribute :provider_group_id, :provider_group_id
alias_attribute :created_at, :created_at
alias_attribute :updated_at, :updated_at
end
end
+4
View File
@@ -0,0 +1,4 @@
class BaclightRecord < ActiveRecord::Base
self.abstract_class = true
connects_to database: { writing: :baclight, reading: :baclight }
end
@@ -1,11 +1,11 @@
class BlacklistedToken < ApplicationRecord
class RetiredToken < ApplicationRecord
belongs_to :user
validates :jti, presence: true, uniqueness: true
validates :exp, presence: true
# check if a token is blacklisted
def self.blacklisted?(jti)
# check if a token is retired
def self.retired?(jti)
exists?(jti: jti)
end
+127 -12
View File
@@ -1,17 +1,132 @@
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :recoverable, :rememberable, :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:validatable
include Devise::JWT::RevocationStrategies::JTIMatcher
# associations
has_many :blacklisted_tokens, dependent: :destroy
has_many :refresh_tokens, dependent: :destroy
devise :database_authenticatable, :registerable,
:validatable, :jwt_authenticatable, jwt_revocation_strategy: self
# Include default devise modules. Others available are:
# :recoverable, :rememberable, :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
# role-based authorization
enum :role, { user: 0, admin: 1, moderator: 2 }
# role-based authorization
enum :role, { member: 0, employer: 1, broker: 2, provider: 3, carrier: 4, admin: 5 }
attr_accessor :keychain
attr_accessor :date_of_birth
attr_accessor :last_four_ssn
# validations so your db doesn't turn into a trash can
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
validates :password, presence: true, length: { minimum: 6 }, if: -> { new_record? || !password.nil? }
validates :role, presence: true
validates :role_id, presence: true
validate :role_entity_exists, on: :create
# after_initialize :keychain
before_validation :sync_role_entity, on: :create
def keychain
@keychain ||= case role
when "member"
if role_entity.present?
# belongs_to = {
# employer_id: role_entity.employer_id,
# broker_id: role_entity&.baclight_employer.broker_id,
# carrier_id:role_entity&.baclight_employer&.baclight_broker&.carrier_id
# }
keys = role_entity.attributes.with_indifferent_access.slice(
:id, :name, :family_id, :mb_member_key, :pb_entity_key, :pl_plan_key
)
keys #.merge(belongs_to)
end
when "employer"
if role_entity.present?
belongs_to = role_entity.joins(broker: :carrier).select(
'brokers.id AS broker_id',
'carriers.id AS carrier_id'
)
keys = role_entity.attributes.with_indifferent_access.slice(
:name, :pl_plan_key, :company_pb_entity_key, :plan_id, :group_number
)
keys.merge(belongs_to)
end
when "broker"
if role_entity.present?
belongs_to = role_entity.joins(:carrier).select(
'carriers.id AS carrier_id'
)
role_entity.attributes.with_indifferent_access.slice(
:name, :id
).merge(belongs_to)
end
when "provider"
if role_entity.present?
role_entity.attributes.with_indifferent_access.slice(
:name, :pb_entity_key, :tax_id, :family_id
)
end
when "carrier"
if role_entity.present?
role_entity.attributes.with_indifferent_access.slice(
:name, :id
)
end
# when "admin"
end
end
private
def role_entity
@role_entity = case role
when "member"
if self.persisted?
Baclight::Member.find_by(pb_entity_key: role_id)
else
find_initial_member
end
when "employer"
Baclight::Employer.find_by(company_pb_entity_key: role_id)
when "broker"
Baclight::Broker.find_by(broker_id: role_id)
when "provider"
Baclight::Provider.find_by(tax_id: role_id)
when "carrier"
Baclight::Carrier.find_by(carrier_id: role_id)
# when "admin"
end
end
def sync_role_entity
if role == "member"
self.name = role_entity.name.split(",").reverse.join(" ").squish
else
self.name = role_entity.name
end
end
def role_entity_exists
if role_entity.blank?
errors.add(:role, "#{role} with id #{role_id} was not found.")
end
if role == "member"
dob = Vhcs::VwmbMember.find_by(pb_entity_key: role_id).date_of_birth
unless dob == date_of_birth
errors.add(:role, "#{role} with id #{role_id} and #{date_of_birth} was not found.")
end
end
end
def find_initial_member
initial_member = Vhcs::VwmbMember.where("RIGHT(SocialSecurityNumber, 4) = ? AND DateOfBirth = ?", last_four_ssn, date_of_birth).first
self.role_id = initial_member&.pb_entity_key
member = Baclight::Member.find_by(pb_entity_key: role_id)
member.presence
end
# validations so your db doesn't turn into a trash can
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
validates :password, presence: true, length: { minimum: 6 }, if: -> { new_record? || !password.nil? }
end
+103
View File
@@ -0,0 +1,103 @@
module Vhcs
class VwmbMember < VhcsRecord
self.table_name = 'VwmbMember'
alias_attribute :mb_member_key, :MBMemberKey
alias_attribute :pb_entity_key, :PBEntityKey
alias_attribute :pl_plan_key, :PLPlanKey
alias_attribute :mbr_class, :MbrClass
alias_attribute :mbr_type, :MbrType
alias_attribute :mbr_ap_vendor_key, :MbrAPVendorKey
alias_attribute :alt_ap_vendor_key, :AltAPVendorKey
alias_attribute :use_alt_payee, :UseAltPayee
alias_attribute :send_eob_primary, :SendEOBPrimary
alias_attribute :send_eob_dependent, :SendEOBDependent
alias_attribute :send_eob_third_party, :SendEOBThirdParty
alias_attribute :student_flag, :StudentFlag
alias_attribute :disabled_dependent_flag, :DisabledDependentFlag
alias_attribute :is_restricted, :IsRestricted
alias_attribute :third_party_pb_entity_key, :ThirdPartyPBEntityKey
alias_attribute :user_def_1, :UserDef1
alias_attribute :user_def_2, :UserDef2
alias_attribute :family_id, :FamilyID
alias_attribute :sequence_number, :SequenceNumber
alias_attribute :enrollee_type_key, :EnrolleeTypeKey
alias_attribute :enrollee_type, :EnrolleeType
alias_attribute :enrollee_type_value_id, :EnrolleeTypeValueID
alias_attribute :sex_key, :SexKey
alias_attribute :use_primary_address, :UsePrimaryAddress
alias_attribute :birth_date, :BirthDate
alias_attribute :birth_sequence_number, :BirthSequenceNumber
alias_attribute :death_date, :DeathDate
alias_attribute :date_of_birth, :DateOfBirth
alias_attribute :date_of_death, :DateOfDeath
alias_attribute :social_security_number, :SocialSecurityNumber
alias_attribute :hipaaid, :HIPAAID
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 :full_name_last_name_first, :FullNameLastNameFirst
alias_attribute :policy_number, :PolicyNumber
alias_attribute :send_eob_alt_payee, :SendEOBAltPayee
alias_attribute :send_eob_alt_payee_only, :SendEOBAltPayeeOnly
def attributes
rails_like = {
mb_member_key: self.mb_member_key,
pb_entity_key: self.pb_entity_key,
pl_plan_key: self.pl_plan_key,
mbr_class: self.mbr_class,
mbr_type: self.mbr_type,
mbr_ap_vendor_key: self.mbr_ap_vendor_key,
alt_ap_vendor_key: self.alt_ap_vendor_key,
use_alt_payee: self.use_alt_payee,
send_eob_primary: self.send_eob_primary,
send_eob_dependent: self.send_eob_dependent,
send_eob_third_party: self.send_eob_third_party,
student_flag: self.student_flag,
disabled_dependent_flag: self.disabled_dependent_flag,
is_restricted: self.is_restricted,
third_party_pb_entity_key: self.third_party_pb_entity_key,
user_def_1: self.user_def_1,
user_def_2: self.user_def_2,
family_id: self.family_id,
sequence_number: self.sequence_number,
enrollee_type_key: self.enrollee_type_key,
enrollee_type: self.enrollee_type,
enrollee_type_value_id: self.enrollee_type_value_id,
sex_key: self.sex_key,
use_primary_address: self.use_primary_address,
birth_date: self.birth_date,
birth_sequence_number: self.birth_sequence_number,
death_date: self.death_date,
date_of_birth: self.date_of_birth,
date_of_death: self.date_of_death,
social_security_number: self.social_security_number,
hipaaid: self.hipaaid,
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,
full_name_last_name_first: self.full_name_last_name_first,
policy_number: self.policy_number,
send_eob_alt_payee: self.send_eob_alt_payee,
send_eob_alt_payee_only: self.send_eob_alt_payee_only,
}
super.merge(rails_like)
end
end
end
+4
View File
@@ -0,0 +1,4 @@
class VhcsRecord < ActiveRecord::Base
self.abstract_class = true
connects_to database: { writing: :vhcs, reading: :vhcs }
end