2025-12-10 13:22:33 -05:00
|
|
|
module SampleCard
|
|
|
|
|
class DataFormatter
|
|
|
|
|
|
2026-01-15 11:37:50 -05:00
|
|
|
def initialize(employer)
|
|
|
|
|
@employer = employer
|
2025-12-10 13:22:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def call
|
2026-01-15 11:37:50 -05:00
|
|
|
@sample_card = SampleIdCard.new()
|
2025-12-10 13:22:33 -05:00
|
|
|
|
2026-01-15 11:37:50 -05:00
|
|
|
set_employer_fields()
|
2025-12-10 13:22:33 -05:00
|
|
|
set_generic_fields()
|
2026-01-15 11:37:50 -05:00
|
|
|
set_rx_fields()
|
2025-12-10 13:22:33 -05:00
|
|
|
set_network_fields()
|
|
|
|
|
sample_cards = set_plan_fields()
|
|
|
|
|
sample_cards.each(&:save!)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
2026-01-15 11:37:50 -05:00
|
|
|
def set_employer_fields
|
2025-12-10 13:22:33 -05:00
|
|
|
selected_attributes = {
|
2026-01-15 11:37:50 -05:00
|
|
|
employer_name: @employer.name,
|
|
|
|
|
group_number: @employer.group_number || "999999",
|
|
|
|
|
medical_eff_date: @employer.effective_date
|
2025-12-10 13:22:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@sample_card.assign_attributes(selected_attributes)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def set_plan_fields
|
|
|
|
|
plans_sample_cards = []
|
2026-01-15 11:37:50 -05:00
|
|
|
@employer.plans.each do |plan|
|
2025-12-10 13:22:33 -05:00
|
|
|
plan_sample_card = @sample_card.dup
|
|
|
|
|
plan_sample_card.family_id = plan.title
|
|
|
|
|
plan.plan_benefits.each do |bene|
|
|
|
|
|
plan_sample_card["benefit_desc_#{bene.sequence}".to_sym] = bene.benefit_desc
|
|
|
|
|
plan_sample_card["benefit_#{bene.sequence}".to_sym] = bene.benefit
|
|
|
|
|
end
|
|
|
|
|
plans_sample_cards.push(plan_sample_card)
|
|
|
|
|
end
|
|
|
|
|
plans_sample_cards
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def set_generic_fields
|
|
|
|
|
selected_attributes = {
|
|
|
|
|
full_name: "JANE DOE",
|
2026-01-15 11:37:50 -05:00
|
|
|
primary_mb_member_key: "888888",
|
|
|
|
|
rx_group: @employer.group_number || "999999"
|
2025-12-10 13:22:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@sample_card.assign_attributes(selected_attributes)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def set_network_fields
|
2026-01-15 11:37:50 -05:00
|
|
|
selected_attributes = @employer.card_provider.attributes.with_indifferent_access.slice(
|
2025-12-10 13:22:33 -05:00
|
|
|
:provider_line_1, :provider_line_2, :provider_line_3, :provider_line_4, :provider_line_5, :provider_line_6,
|
2026-01-15 11:37:50 -05:00
|
|
|
:provider_line_7, :provider_line_8, :provider_line_9, :provider_line_10, :provider_line_11, :provider_line_12,
|
2025-12-10 13:22:33 -05:00
|
|
|
:claim_to_1, :claim_to_2, :claim_to_3, :claim_to_4, :claim_to_5, :claim_to_6,
|
2026-01-15 11:37:50 -05:00
|
|
|
:claim_to_7, :claim_to_8, :claim_to_9, :claim_to_10, :claim_to_11, :claim_to_12
|
2025-12-10 13:22:33 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@sample_card.assign_attributes(selected_attributes)
|
|
|
|
|
end
|
|
|
|
|
|
2026-01-15 11:37:50 -05:00
|
|
|
def set_rx_fields
|
|
|
|
|
# fairos_information = Vhcs::HlrxCrosRef.where(pl_plan_key: 52).first
|
|
|
|
|
selected_attributes = @employer.card_rx.attributes.with_indifferent_access.slice(
|
|
|
|
|
:customer_service,
|
|
|
|
|
:web_url
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@sample_card.assign_attributes(selected_attributes)
|
|
|
|
|
end
|
|
|
|
|
|
2025-12-10 13:22:33 -05:00
|
|
|
def set_dependent_fields
|
|
|
|
|
# Not needed for sample card
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|