272 lines
10 KiB
Ruby
272 lines
10 KiB
Ruby
def determine_id_card_templates(pl_plan_key)
|
||
pl_plan_key = pl_plan_key.to_i
|
||
if [13, 19, 20, 48, 49, 50, 51, 52, 53, 54, 58, 59, 61].include?(pl_plan_key)
|
||
single_card_template = 'CignaFairosIDCard'
|
||
elsif [39].include?(pl_plan_key)
|
||
single_card_template = 'CignaFairosIDCard-HALF'
|
||
elsif [4, 5, 16, 23, 33, 55, 57, 63].include?(pl_plan_key)
|
||
single_card_template = 'MedCostFairosIDCard'
|
||
elsif [1, 2].include?(pl_plan_key)
|
||
single_card_template = 'SmartIDCard'
|
||
elsif [10, 17].include?(pl_plan_key)
|
||
single_card_template = 'FirstCallTPAIDCard'
|
||
elsif [15, 18].include?(pl_plan_key)
|
||
single_card_template = 'SRIIDCARD'
|
||
elsif [21].include?(pl_plan_key)
|
||
single_card_template = 'SRIIDCARDFairosRx'
|
||
elsif [3].include?(pl_plan_key)
|
||
single_card_template = 'TPAIDCardTan'
|
||
elsif [56].include?(pl_plan_key)
|
||
single_card_template = 'CignaHealthBusIDCard'
|
||
else
|
||
single_card_template = 'TPAIDCard'
|
||
end
|
||
|
||
if [4, 5, 16, 21, 33, 55, 57, 58, 59, 61].include?(pl_plan_key)
|
||
multiple_card_template = 'AllTPAIDCardFairosRx'
|
||
elsif [13, 19, 20, 39, 48, 49, 50, 52, 53, 54].include?(pl_plan_key)
|
||
multiple_card_template = 'AllHerritageIdCards'
|
||
elsif [15, 18].include?(pl_plan_key)
|
||
multiple_card_template = 'ALLSRIIDCARD'
|
||
elsif [10, 17].include?(pl_plan_key)
|
||
multiple_card_template = 'AllFirstCallTPAIDCard'
|
||
elsif [3].include?(pl_plan_key)
|
||
multiple_card_template = 'AllTPAIDCardTan'
|
||
elsif [56].include?(pl_plan_key)
|
||
multiple_card_template = 'AllCignaHealthBusIDCard'
|
||
else
|
||
multiple_card_template = 'AllTPAIDCard'
|
||
end
|
||
|
||
{
|
||
single_card_template: single_card_template,
|
||
multiple_card_template: multiple_card_template
|
||
}
|
||
end
|
||
|
||
def determine_network_logos(pl_plan_key)
|
||
pl_plan_key = pl_plan_key.to_i
|
||
exception_logos = []
|
||
if [4, 5, 16, 23, 33, 55, 57, 63].include?(pl_plan_key)
|
||
default_net_logo_image = 'Logo_MC_PMS.png'
|
||
elsif [15, 18, 19, 20, 13, 21].include?(pl_plan_key)
|
||
default_net_logo_image = 'CignaLogo.png'
|
||
elsif [62].include?(pl_plan_key)
|
||
default_net_logo_image = 'CignaLogo.png'
|
||
else
|
||
default_net_logo_image = 'CignaLogo.png'
|
||
|
||
|
||
# exception_logos << ProviderNetworkLogo.new(
|
||
# exception_type: 'zip',
|
||
# exception_value: '49420',
|
||
# net_logo: 'CignaPHLogo.jpg'
|
||
# )
|
||
|
||
# exception_logos << ProviderNetworkLogo.new(
|
||
# exception_type: 'zip',
|
||
# exception_value: '48167',
|
||
# net_logo: 'CignaPHLogo.jpg'
|
||
# )
|
||
|
||
# exception_logos << ProviderNetworkLogo.new(
|
||
# exception_type: 'zip',
|
||
# exception_value: '55419',
|
||
# net_logo: 'CignaHPLogo.jpg'
|
||
# )
|
||
|
||
# exception_logos << ProviderNetworkLogo.new(
|
||
# exception_type: 'zip',
|
||
# exception_value: '55379',
|
||
# net_logo: 'CignaHPLogo.jpg'
|
||
# )
|
||
end
|
||
end
|
||
|
||
# benefit_descriptions = ["Primary Visit",
|
||
# "Specialist Visit",
|
||
# "Urgent Care",
|
||
# "INN–Ind Ded",
|
||
# "INN–Family Ded",
|
||
# "OON–Ind Ded",
|
||
# "OON–Family Ded",
|
||
# "Co-Insurance",
|
||
# "INN–Ind OOP",
|
||
# "INN–Family OOP",
|
||
# "OON–Ind OOP",
|
||
# "OON–Family OOP",
|
||
# "Emergency Room",
|
||
# "Preventive Care"]
|
||
|
||
# default = IdCardBenefitsTemplate.create(title: "BLANK")
|
||
# benefit_descriptions.each_with_index do |bene, i|
|
||
# IdCardBenefit.create(sequence: i + 1, benefit_desc: bene, id_card_benefits_template: default)
|
||
# end
|
||
|
||
# temp_2 = IdCardBenefitsTemplate.create(title: "Jason's Template")
|
||
# (1..14).each do |seq|
|
||
# IdCardBenefit.create(sequence: seq, benefit: "#{seq} hit wonder", id_card_benefits_template: temp_2)
|
||
# end
|
||
|
||
# temp_1 = IdCardBenefitsTemplate.create(title: "Rebekah's Template")
|
||
# (1..14).each do |seq|
|
||
# IdCardBenefit.create(sequence: seq, benefit: "greatest hits vol #{seq}", id_card_benefits_template: temp_1)
|
||
# end
|
||
|
||
|
||
# historical_id_card_docs = Dir['tmp/*.docx']
|
||
# historical_id_card_docs.each do |card_doc|
|
||
# puts card_doc
|
||
# BenefitsWordDocProcessor.new(card_doc).call
|
||
# end
|
||
|
||
# acentria = Carrier.find_or_create_by!(name: 'Acentria')
|
||
|
||
# mcswain_broker = Broker.find_or_create_by!(name: 'Tom McSwain') do |mc|
|
||
# mc.carrier = acentria
|
||
# end
|
||
|
||
# mcswain_employers = HebWeb::BrokerXRef.where(pl_plan_key: 99).pluck(:employer_pl_plan_key)
|
||
|
||
|
||
# Imports employers and members from VHCS
|
||
sql_query = "SELECT PLPlanKey, PlanId, ShortDesc FROM PLPlanHeader WHERE ActiveInactive = 'Active' AND PLPlanKey = 65"
|
||
plan_headers = VhcsRecord.connection.select_all(sql_query)
|
||
|
||
plan_headers.each do |ph|
|
||
import_employer = Employer.find_or_create_by!(pl_plan_key: ph['PLPlanKey']) do |em|
|
||
puts "Importing #{ph['ShortDesc'].strip}"
|
||
em.name = ph['ShortDesc'].strip
|
||
em.plan_id = ph['PlanId'].strip.to_i
|
||
|
||
|
||
id_card_templates = determine_id_card_templates(em.pl_plan_key)
|
||
em.single_card_template = id_card_templates[:single_card_template]
|
||
em.multiple_card_template = id_card_templates[:multiple_card_template]
|
||
|
||
plan_code = Vhcs::HlPlanCode.find_by(plan_key: em.pl_plan_key)
|
||
em.group_number = plan_code.group_number
|
||
em.rx_group_number = plan_code.medical_number
|
||
em.effective_date = plan_code.effect_date.strftime("%m/%d/%Y")
|
||
|
||
pb_company_plan = Vhcs::PbCompanyPlans.find_by(pl_plan_key: em.pl_plan_key)
|
||
em.company_pb_entity_key = pb_company_plan.company_pb_entity_key
|
||
|
||
card_display_name = Vhcs::PbEntity.find_by(company_pb_entity_key: em.company_pb_entity_key).last_name
|
||
em.id_card_display_name = em.employer_trim_name(card_display_name)
|
||
|
||
em.default_network_logo = determine_network_logos(em.pl_plan_key)
|
||
end
|
||
|
||
vhcs_plans = Vhcs::PbProduct.where(company_pb_entity_key: import_employer.company_pb_entity_key)
|
||
vhcs_plans.each do |vp|
|
||
puts "~~ Importing #{vp.short_description}"
|
||
import_plan = import_employer.plans.find_or_create_by!(pb_product_key: vp.pb_product_key) do |pl|
|
||
pl.title = vp.short_description
|
||
end
|
||
vhcs_plan_benefits = Vhcs::HlEgglestonCardBenefit.where(plan_id: import_plan.pb_product_key)
|
||
vhcs_plan_benefits.each do |vb|
|
||
import_plan.plan_benefits.find_or_create_by!(benefit_desc: vb.benefit_desc) do |pb|
|
||
pb.sequence = vb.sequence
|
||
pb.benefit = vb.benefit
|
||
end
|
||
end
|
||
end
|
||
|
||
|
||
|
||
# if mcswain_employers.include?(ph['PLPlanKey'])
|
||
# em.broker = mcswain_broker
|
||
# end
|
||
|
||
vw_mb_members = Vhcs::VwmbMember.where(enrollee_type_value_id: 1, pl_plan_key: ph['PLPlanKey']).select(:mb_member_key, :pb_entity_key, :pl_plan_key, :family_id, :full_name_last_name_first)
|
||
vw_mb_members_count = vw_mb_members.length
|
||
|
||
vw_mb_members.each_with_index do |vwm, i|
|
||
import_member = Member.find_or_create_by!(mb_member_key: vwm.mb_member_key) do |me|
|
||
me.name = vwm.full_name_last_name_first.titleize
|
||
me.pb_entity_key = vwm.pb_entity_key
|
||
me.family_id = vwm.family_id
|
||
me.pl_plan_key = vwm.pl_plan_key
|
||
me.employer = import_employer
|
||
|
||
card_display_name = Vhcs::PbEntity.find_by(pb_entity_key: me.pb_entity_key).full_name
|
||
me.id_card_display_name = card_display_name
|
||
|
||
plan_pb_product_key = Vhcs::PbProduct.joins('INNER JOIN "PBProductAvailability" ON "PBProductAvailability"."PBProductKey" = "PBProduct"."PBProductKey" INNER JOIN "PBProductParticipation" ON "PBProductParticipation"."PBProductAvailabilityKey" = "PBProductAvailability"."PBProductAvailabilityKey" INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"').where('"PBCoveredEntities"."PBEntityKey" = ?', me.pb_entity_key).first.pb_product_key
|
||
if plan = Plan.find_by(pb_product_key: plan_pb_product_key)
|
||
me.plan = plan
|
||
end
|
||
end
|
||
puts "Employer #{import_employer.name} (#{i}/#{vw_mb_members_count}) members imported"
|
||
end
|
||
end
|
||
|
||
# Vhcs::HlidCardProvider.all.each do |vhcs|
|
||
# CardProvider.find_or_create_by(provider_code: vhcs.provider_code) do |cp|
|
||
# cp.provider_line_1 = vhcs.provider_line_1
|
||
# cp.provider_line_2 = vhcs.provider_line_2
|
||
# cp.provider_line_3 = vhcs.provider_line_3
|
||
# cp.provider_line_4 = vhcs.provider_line_4
|
||
# cp.provider_line_5 = vhcs.provider_line_5
|
||
# cp.provider_line_6 = vhcs.provider_line_6
|
||
# cp.provider_line_7 = vhcs.provider_line_7
|
||
# cp.provider_line_8 = vhcs.provider_line_8
|
||
# cp.provider_line_9 = vhcs.provider_line_9
|
||
# cp.provider_line_10 = vhcs.provider_line_10
|
||
# cp.provider_line_11 = vhcs.provider_line_11
|
||
# cp.provider_line_12 = vhcs.provider_line_12
|
||
|
||
# cp.claim_to_1 = vhcs.claim_to_1
|
||
# cp.claim_to_2 = vhcs.claim_to_2
|
||
# cp.claim_to_3 = vhcs.claim_to_3
|
||
# cp.claim_to_4 = vhcs.claim_to_4
|
||
# cp.claim_to_5 = vhcs.claim_to_5
|
||
# cp.claim_to_6 = vhcs.claim_to_6
|
||
# cp.claim_to_7 = vhcs.claim_to_7
|
||
# cp.claim_to_8 = vhcs.claim_to_8
|
||
# cp.claim_to_9 = vhcs.claim_to_9
|
||
# cp.claim_to_10 = vhcs.claim_to_10
|
||
# cp.claim_to_11 = vhcs.claim_to_11
|
||
# cp.claim_to_12 = vhcs.claim_to_12
|
||
|
||
# cp.mail_to = vhcs.mail_to
|
||
# cp.mail_to_2 = vhcs.mail_to_2
|
||
|
||
# cp.contact_line_1 = vhcs.contact_line_1
|
||
# cp.contact_line_2 = vhcs.contact_line_2
|
||
# cp.contact_line_3 = vhcs.contact_line_3
|
||
|
||
# cp.group_number = vhcs.group_number
|
||
# cp.rx_group_id = vhcs.rx_group_id
|
||
# cp.rx_contact = vhcs.rx_contact
|
||
|
||
# cp.provider_lookup_1 = vhcs.provider_lookup_1
|
||
# cp.provider_lookup_2 = vhcs.provider_lookup_2
|
||
|
||
# cp.precert_1 = vhcs.precert_1
|
||
# cp.precert_2 = vhcs.precert_2
|
||
# cp.precert_3 = vhcs.precert_3
|
||
# cp.precert_4 = vhcs.precert_4
|
||
# cp.precert_5 = vhcs.precert_5
|
||
# cp.precert_6 = vhcs.precert_6
|
||
|
||
# end
|
||
# end
|
||
|
||
Vhcs::HlrxCrosRef.all.each do |vhcs|
|
||
rx = CardRx.find_or_create_by(help_desk: vhcs.help_desk, customer_service: vhcs.customer_service, web_url: vhcs.web_url)
|
||
emp = Employer.find_by(pl_plan_key: vhcs.pl_plan_key)
|
||
if emp.present?
|
||
emp.card_rx = rx
|
||
emp.save
|
||
end
|
||
end
|
||
|
||
|
||
# 15, 18, 19, 20, 13, 21
|
||
|
||
|
||
|
||
|