stable, before a refactor

This commit is contained in:
Jason Jordan
2026-03-03 22:53:21 -05:00
parent 4fac3b1036
commit 942d60c3e0
66 changed files with 1321 additions and 194 deletions
+47 -8
View File
@@ -6,7 +6,7 @@ module EmployerCards
end
def call
@members = @employer.members
@members = @employer.members.order(:name)
@employer_cards = []
init_cards_and_set_member_fields
@@ -19,6 +19,31 @@ module EmployerCards
private
def init_cards_and_set_common_fields
employer_attributes = {
employer_name: @employer.id_card_display_name,
group_number: @employer.group_number,
rx_group: @employer.rx_group_number
}
rx_attributes = @employer.card_rx.attributes.with_indifferent_access.slice(
:customer_service,
:web_url
)
provider_attributes = @employer.card_provider.attributes.with_indifferent_access.slice(
:provider_code, :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, :provider_line_12,
: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, :claim_to_12
)
selected_attributes = employer_attributes.merge(rx_attributes).merge(provider_attributes)
@employer_cards.each do |card|
card.assign_attributes(selected_attributes)
end
end
def set_common_fields
employer_attributes = {
employer_name: @employer.id_card_display_name,
@@ -32,7 +57,7 @@ module EmployerCards
)
provider_attributes = @employer.card_provider.attributes.with_indifferent_access.slice(
:provider_line_1, :provider_line_2, :provider_line_3, :provider_line_4, :provider_line_5, :provider_line_6,
:provider_code, :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, :provider_line_12,
: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, :claim_to_12
@@ -58,21 +83,29 @@ module EmployerCards
end
def init_cards_and_set_member_fields
@group_dependents = Vhcs::VwmbMember.where(pl_plan_key: @employer.pl_plan_key)
@members.each do |me|
effect_date = determine_eff_date(me)
if effect_date
member_card = SampleIdCard.new()
selected_attributes = {
member_attributes = {
full_name: me.id_card_display_name,
primary_mb_member_key: me.mb_member_key,
name: me.name,
primary_mb_member_key: me.pb_entity_key,
family_id: me.family_id,
plan_id: me.plan_id,
medical_eff_date: effect_date.strftime("%m/%d/%Y")
}
dependent_attributes = get_dependent_fields(me)
selected_attributes = member_attributes.merge(dependent_attributes)
member_card.assign_attributes(selected_attributes)
@employer_cards.push(member_card)
if dependent_attributes.present?
@employer_cards.push(member_card)
end
end
end
end
@@ -102,7 +135,7 @@ module EmployerCards
def determine_eff_date(member)
participation = Vhcs::PbProductParticipation.joins('INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"').where('"PBCoveredEntities"."PBEntityKey" = ?', member.pb_entity_key).first
participation = Vhcs::PbProductParticipation.joins('INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"').where('"PBCoveredEntities"."PBEntityKey" = ?', member.pb_entity_key).last
in_effect = participation.in_effect
out_of_effect = participation.out_of_effect
@@ -114,8 +147,14 @@ module EmployerCards
end
def set_dependent_fields
# Not needed for sample card
def get_dependent_fields(member)
dependent_attributes = {}
dependents = @group_dependents.where(family_id: member.family_id).where.not(pb_entity_key: member.pb_entity_key)
dependents.each do |dep|
dependent_name = dep.first_name + ' ' + dep.last_name
dependent_attributes["dependent_#{dep.sequence_number - 1}".to_sym] = dependent_name
end
dependent_attributes
end
end
end