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()
|
2026-03-03 22:53:21 -05:00
|
|
|
# set_dependent_fields()
|
2025-12-10 13:22:33 -05:00
|
|
|
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,
|
2026-03-06 10:56:20 -05:00
|
|
|
group_number: @employer.group_number.present? ? @employer.group_number : "999999",
|
2026-01-15 11:37:50 -05:00
|
|
|
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-03-13 08:47:13 -04:00
|
|
|
@employer.id_card_configuration.plans.each do |plan|
|
2025-12-10 13:22:33 -05:00
|
|
|
plan_sample_card = @sample_card.dup
|
2026-03-03 22:53:21 -05:00
|
|
|
plan_name = plan.title.split(/(?<=\d[kK])/).first
|
|
|
|
|
plan_sample_card.family_id = plan_name
|
2025-12-10 13:22:33 -05:00
|
|
|
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",
|
2026-03-06 10:56:20 -05:00
|
|
|
rx_group: @employer.group_number.present? ? @employer.group_number : "999999"
|
2025-12-10 13:22:33 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@sample_card.assign_attributes(selected_attributes)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def set_network_fields
|
2026-03-13 08:47:13 -04:00
|
|
|
selected_attributes = @employer.id_card_configuration.provider_section.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
|
|
|
)
|
2026-03-03 22:53:21 -05:00
|
|
|
if @employer.network_provider == "Cigna"
|
|
|
|
|
@sample_card.provider_code = "5"
|
|
|
|
|
end
|
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
|
2026-03-13 08:47:13 -04:00
|
|
|
selected_attributes = @employer.id_card_configuration.rx_section.attributes.with_indifferent_access.slice(
|
2026-01-15 11:37:50 -05:00
|
|
|
:customer_service,
|
|
|
|
|
:web_url
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@sample_card.assign_attributes(selected_attributes)
|
|
|
|
|
end
|
|
|
|
|
|
2025-12-10 13:22:33 -05:00
|
|
|
def set_dependent_fields
|
2026-03-03 22:53:21 -05:00
|
|
|
@sample_card.dependent_1 = "John Doe"
|
|
|
|
|
@sample_card.dependent_2 = "Molly Doe"
|
|
|
|
|
@sample_card.dependent_3 = "Jonathan Doe"
|
|
|
|
|
@sample_card.dependent_4 = "Calvin Doe"
|
|
|
|
|
@sample_card.dependent_5 = "Richard Doe"
|
|
|
|
|
@sample_card.dependent_6 = "Jannet Doe"
|
|
|
|
|
@sample_card.dependent_7 = "Longername Doe"
|
|
|
|
|
@sample_card.dependent_8 = "Robbert Doe"
|
2025-12-10 13:22:33 -05:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|