Employer form mostly working with persist to db

This commit is contained in:
Jason Jordan
2025-12-10 13:22:33 -05:00
parent 78ce415b94
commit 0464ba8929
68 changed files with 3071 additions and 365 deletions
@@ -0,0 +1,81 @@
module SampleCard
class DataFormatter
def initialize(process)
@process = process
end
def call
@sample_card = BrittonWeb::SampleIdCard.new()
set_process_fields()
set_generic_fields()
set_network_fields()
sample_cards = set_plan_fields()
sample_cards.each(&:save!)
end
private
def set_process_fields
selected_attributes = {
employer_name: @process.employer_name,
group_number: @process.group_number,
medical_eff_date: @process.effective_date,
network_image: @process.logo_filename,
status: "imported"
}
@sample_card.assign_attributes(selected_attributes)
end
def set_plan_fields
plans_sample_cards = []
@process.plans.each do |plan|
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",
primary_mb_member_key: "99999",
rx_group: "99999"
}
@sample_card.assign_attributes(selected_attributes)
end
def set_network_fields
provider_code = @process.network_provider.includes?("Cigna") ? "5" : "2"
# if @process.network_provider.includes?("Cigna")
# provider_code = "5"
# network_image = "CignaLogo.png"
# else
# provider_code = "2"
# network_image = "Logo_MC_PMS.png"
# end
provider_information = Vhcs::HLIDCardProvider.find_by(provider_code: provider_code)
selected_attributes = provider_information.attributes.slice(
:provider_line_1, :provider_line_2, :provider_line_3, :provider_line_4, :provider_line_5, :provider_line_6,
:provider_line_7, :provider_line_8, :provider_line_9, :provider_line_10, :provider_line_11,
:claim_to_1, :claim_to_2, :claim_to_3, :claim_to_4, :claim_to_5, :claim_to_6,
:claim_to_7, :claim_to_8, :claim_to_9, :claim_to_10, :claim_to_11
)
@sample_card.assign_attributes(selected_attributes)
end
def set_dependent_fields
# Not needed for sample card
end
end
end