186 lines
5.6 KiB
Ruby
186 lines
5.6 KiB
Ruby
def determine_id_card_templates(pl_plan_key)
|
|
pl_plan_key = pl_plan_key.to_i
|
|
|
|
case pl_plan_key
|
|
when 2
|
|
"SmartIDCard"
|
|
when 3
|
|
"TandemlocIDCard"
|
|
when 56
|
|
"QRCodeIDCard"
|
|
else
|
|
"FairosRxIDCard"
|
|
end
|
|
end
|
|
|
|
def determine_id_card_rx(pl_plan_key)
|
|
pl_plan_key = pl_plan_key.to_i
|
|
|
|
if pl_plan_key == 56
|
|
"TheHealthBus"
|
|
else
|
|
"FairosRx"
|
|
end
|
|
end
|
|
|
|
def determine_id_card_network(pl_plan_key)
|
|
pl_plan_key = pl_plan_key.to_i
|
|
|
|
cigna_groups = [13,20,39,48,49,51,53,54,56,58,60,61,62,65,67,68]
|
|
medcost_groups = [4,5,16,23,33,55,57,59,63,66]
|
|
old_cigna_groups = [19,21]
|
|
smart_medcost = [2]
|
|
tan_medcost = [3]
|
|
|
|
case
|
|
when cigna_groups.include?(pl_plan_key)
|
|
{ provider: "Cigna", network_logo: "CignaLogo.png", provider_section: "Cigna" }
|
|
when medcost_groups.include?(pl_plan_key)
|
|
{ provider: "MedCost", network_logo: "MedcostLogo.png", provider_section: "MedCost" }
|
|
when old_cigna_groups.include?(pl_plan_key)
|
|
{ provider: "Cigna", network_logo: "CignaLogo.png", provider_section: "Cigna (Beam/Stevens)" }
|
|
when smart_medcost.include?(pl_plan_key)
|
|
{ provider: "MedCost", network_logo: "MedcostLogo.png", provider_section: "MedCost (smART)" }
|
|
when tan_medcost.include?(pl_plan_key)
|
|
{ provider: "MedCost", network_logo: "MedcostLogo.png", provider_section: "MedCost (Tandemloc)" }
|
|
end
|
|
|
|
end
|
|
|
|
puts "[**** IMPORT ID CARD TABLES ****]"
|
|
|
|
## SET UP DEFAULT LEVEL360 PLANS FOR PLAN PICKER
|
|
|
|
# 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
|
|
|
|
##---------------- Provider/Claims Setup------------------------------------
|
|
|
|
puts "Importing Card Provider/Claims Information"
|
|
default_provider_codes = ["5", "2"]
|
|
needed_codes_mapping = {
|
|
"0": "MedCost VA Plus Network",
|
|
"2": "MedCost",
|
|
"3": "AHA Preferred",
|
|
"5": "Cigna",
|
|
"6": "Cigna (Beam/Stevens)",
|
|
A: "AHA",
|
|
M: "MedCost (smART)",
|
|
T: "MedCost (Tandemloc)"
|
|
}.stringify_keys
|
|
needed_codes = needed_codes_mapping.keys
|
|
vhcs_cp = Vhcs::HlidCardProvider.where(provider_code: needed_codes)
|
|
vhcs_cp.each do |vhcs|
|
|
attributes_hash = vhcs.attributes.except(:provider_code, :group_number)
|
|
attributes_hash.delete_if { |key, value| !key.to_s.include?("_") }
|
|
|
|
if default_provider_codes.include?(vhcs.provider_code)
|
|
attributes_hash[:default] = true
|
|
end
|
|
attributes_hash[:title] = needed_codes_mapping[vhcs.provider_code]
|
|
|
|
puts "-- #{attributes_hash[:title]}"
|
|
IdCard::ProviderSection.find_or_create_by(attributes_hash)
|
|
end
|
|
|
|
##---------------- Rx info Setup------------------------------------
|
|
|
|
puts "Importing Card Rx Information"
|
|
Vhcs::HlrxCrosRef.all.each do |vhcs|
|
|
rx = IdCard::RxSection.find_or_create_by(help_desk: vhcs.help_desk, customer_service: vhcs.customer_service, web_url: vhcs.web_url)
|
|
title = rx.web_url.gsub(/^www\./, '').gsub(/\.com\Z/, '')
|
|
unless title.match?(/\A[A-Z]/)
|
|
title = title.capitalize
|
|
end
|
|
|
|
puts "-- #{title}"
|
|
rx.title = title
|
|
rx.save
|
|
end
|
|
|
|
##---------------- Network Logos Setup------------------------------------
|
|
|
|
puts "Importing Network Logos"
|
|
folder_path = Rails.root.join('logo_files', 'network')
|
|
file_names = Dir.children(folder_path)
|
|
default_network_logos = ["CignaLogo.png", "MedCostLogo.png"]
|
|
|
|
file_names.each do |logo_upload|
|
|
puts "-- #{logo_upload}"
|
|
new_logo = ImageProcessor.new("logo_files/network/#{logo_upload}", "Network").call
|
|
if default_network_logos.include?(logo_upload)
|
|
new_logo.default = true
|
|
end
|
|
new_logo.active = true
|
|
new_logo.save
|
|
end
|
|
|
|
##---------------- Active Employer Logo Setup------------------------------------
|
|
|
|
puts "Importing Employer Logos"
|
|
folder_path = Rails.root.join('logo_files', 'employer')
|
|
file_names = Dir.children(folder_path)
|
|
|
|
file_names.each do |logo_upload|
|
|
puts "-- #{logo_upload}"
|
|
new_logo = ImageProcessor.new("logo_files/employer/#{logo_upload}", "Employer").call
|
|
new_logo.active = true
|
|
new_logo.save
|
|
end
|
|
|
|
##---------------- Import Employer/Member Setup------------------------------------
|
|
|
|
puts "[**** IMPORT EMPLOYERS ****]"
|
|
Rake::Task["employer:vhcs_sync_all"].invoke
|
|
|
|
# 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
|
|
# use rake tasks
|
|
|
|
puts "[**** UPDATE EMPLOYER ID CARDS CONFIGS ****]"
|
|
IdCard::Configuration.all.each do |config|
|
|
config.card_template = determine_id_card_templates(config.pl_plan_key)
|
|
|
|
network_information = determine_id_card_network(config.pl_plan_key)
|
|
config.network_provider = network_information[:provider]
|
|
ps = IdCard::ProviderSection.find_by(title: network_information[:provider_section])
|
|
config.provider_section_id = ps.id
|
|
nl = IdCard::NetworkLogo.find_by(filename: network_information[:network_logo])
|
|
config.network_logo_id = nl.id
|
|
|
|
rx_title = determine_id_card_rx(config.pl_plan_key)
|
|
rs = IdCard::RxSection.find_by(title: rx_title)
|
|
config.rx_section_id = rs.id
|
|
|
|
employer_name = config.employer.employer_trim_name
|
|
name_segments = employer_name.titleize.split
|
|
name_segments.each do |segment|
|
|
logo = IdCard::EmployerLogo.where("filename LIKE ?", "%#{segment}%")
|
|
if logo&.first
|
|
config.employer_logo = logo.first
|
|
break
|
|
end
|
|
end
|
|
|
|
config.active = true
|
|
config.save
|
|
end
|
|
|
|
|
|
|
|
# 15, 18, 19, 20, 13, 21
|
|
|
|
|
|
|
|
|