Major features finished
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
namespace :employer_automation do
|
||||
|
||||
desc "Update Necessary Employer Values"
|
||||
# rake employer:vhcs_sync_all
|
||||
task employer_update: :environment do
|
||||
Employer.missing_keychain_values.map(&:sync_with_vhcs)
|
||||
Employer.missing_initial_members.map(&:sync_members_with_vhcs)
|
||||
end
|
||||
|
||||
|
||||
|
||||
desc "Update Employer Members"
|
||||
# rake employer:import_members_from_vhcs[67]
|
||||
task employer_members_update: :environment do
|
||||
Employer.active.map(&:sync_members_with_vhcs)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,9 +1,9 @@
|
||||
namespace :employer do
|
||||
namespace :employer_pre_auto do
|
||||
|
||||
desc "TODO"
|
||||
# rake employer:vhcs_sync_all
|
||||
task vhcs_sync_all: :environment do
|
||||
sql_query = "SELECT PLPlanKey, PlanId, ShortDesc FROM PLPlanHeader WHERE ActiveInactive = 'Active'"
|
||||
sql_query = "SELECT PLPlanKey, PlanId, ShortDesc FROM PLPlanHeader WHERE ActiveInactive = 'Active' AND PLPlanKey NOT IN ('50','56')"
|
||||
plan_headers = VhcsRecord.connection.select_all(sql_query)
|
||||
|
||||
plan_headers.each do |ph|
|
||||
@@ -29,8 +29,8 @@ namespace :employer do
|
||||
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_print_name = Vhcs::PbEntity.find_by(company_pb_entity_key: em.company_pb_entity_key).last_name
|
||||
id_card_setup.print_name = em.employer_trim_name(card_print_name)
|
||||
card_print_name = Vhcs::PbEntity.where(company_pb_entity_key: em.company_pb_entity_key, entity_type_id: 1007).last.last_name
|
||||
id_card_setup.print_name = card_print_name
|
||||
|
||||
em.active = true
|
||||
|
||||
@@ -70,13 +70,19 @@ namespace :employer do
|
||||
|
||||
vw_mb_members.each_with_index do |vwm, i|
|
||||
|
||||
participation = Vhcs::PbProductParticipation.joins('INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"').where('"PBCoveredEntities"."PBEntityKey" = ?', vwm.pb_entity_key).last
|
||||
|
||||
if participation.present?
|
||||
in_effect = participation.in_effect
|
||||
out_of_effect = participation.out_of_effect
|
||||
# participation = Vhcs::PbProductParticipation.joins('INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"').where('"PBCoveredEntities"."PBEntityKey" = ?', vwm.pb_entity_key).last
|
||||
|
||||
if in_effect <= (Date.today + 90.days) && (out_of_effect - 1.day) > Date.today && out_of_effect > in_effect
|
||||
pb_products = 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" = ? AND "PBProductParticipation"."InEffect" <= ? AND "PBProductParticipation"."OutOfEffect" > ?', vwm.pb_entity_key, 1.month.from_now , 1.day.ago)
|
||||
|
||||
if pb_products.present?
|
||||
# in_effect = participation.in_effect
|
||||
# out_of_effect = participation.out_of_effect
|
||||
|
||||
# if in_effect <= (Date.today + 90.days) && (out_of_effect - 1.day) > Date.today && out_of_effect > in_effect
|
||||
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
|
||||
@@ -96,16 +102,46 @@ namespace :employer do
|
||||
me.division = division
|
||||
end
|
||||
|
||||
pb_product = 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
|
||||
if pb_product
|
||||
plan_pb_product_key = pb_product.pb_product_key
|
||||
if plan = IdCard::Plan.find_by(pb_product_key: plan_pb_product_key)
|
||||
# if employer.id_card_setup.has_dental
|
||||
# coverage_class = Vhcs::GenLookupTables.joins('
|
||||
# INNER JOIN "PBProductParticipation" ON "PBProductParticipation"."CoverageTypeCode" = "GEN_LookupTables"."RecordID"
|
||||
# INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"
|
||||
# ').where(
|
||||
# '"PBCoveredEntities"."PBEntityKey" = ? AND "PBProductParticipation"."InEffect" <= ? AND "PBProductParticipation"."OutOfEffect" > ?', me.pb_entity_key, 1.month.from_now , 1.day.ago
|
||||
# ).uniq.first.short_desc
|
||||
# end
|
||||
|
||||
# pb_products = 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" = ? AND "PBProductParticipation"."InEffect" <= ? AND "PBProductParticipation"."OutOfEffect" > ?', me.pb_entity_key, 1.month.from_now , 1.day.ago)
|
||||
|
||||
# if pb_products
|
||||
if employer.id_card_setup.has_dental
|
||||
medical_pb_product_key = pb_products.where(short_description: "Medical")&.first&.pb_product_key
|
||||
dental_pb_product_key = pb_products.where(short_description: "Dental")&.first&.pb_product_key
|
||||
if dental_pb_product_key
|
||||
me.dental_plan_key = dental_pb_product_key
|
||||
|
||||
coverage_class = Vhcs::GenLookupTables.joins('
|
||||
INNER JOIN "PBProductParticipation" ON "PBProductParticipation"."CoverageTypeCode" = "GEN_LookupTables"."RecordID"
|
||||
INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"
|
||||
').where(
|
||||
'"PBCoveredEntities"."PBEntityKey" = ? AND "PBProductParticipation"."InEffect" <= ? AND "PBProductParticipation"."OutOfEffect" > ?', me.pb_entity_key, 1.month.from_now , 1.day.ago
|
||||
).uniq.first.short_desc
|
||||
me.coverage_class = coverage_class
|
||||
end
|
||||
else
|
||||
medical_pb_product_key = pb_products.first.pb_product_key
|
||||
end
|
||||
if medical_pb_product_key && plan = IdCard::Plan.find_by(pb_product_key: medical_pb_product_key)
|
||||
me.id_card_plan = plan
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
puts "Employer #{employer.name} (#{i}/#{vw_mb_members_count}) members processed"
|
||||
end
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,121 @@
|
||||
# namespace :export_fes do
|
||||
# desc "Export field exceptions for seed data"
|
||||
# task to_seeds: :environment do
|
||||
# IdCard::FieldExceptions.all.each do |fe|
|
||||
# # Exclude internal metadata like ID and timestamps
|
||||
# attrs = fe.attributes.except("id", "created_at", "updated_at")
|
||||
|
||||
# puts "User.find_or_create_by!(#{attrs})"
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# IdCard::FieldException.includes(:field_exception_items).all.as_json(
|
||||
# except: [:id, :setup_id, :created_at, :updated_at],
|
||||
# include: {
|
||||
# field_exception_items: { except: [:id, :field_exception_id, :created_at, :updated_at] }
|
||||
# }
|
||||
# )
|
||||
|
||||
# {"exception_type" => "state",
|
||||
# "exception_values" => "VA",
|
||||
# "field_exception_items" =>
|
||||
# [{"field_name" => "medical_eff_date", "field_value" => "12/01/2025", "provider_section_id" => nil},
|
||||
# {"field_name" => "provider_section", "field_value" => "", "provider_section_id" => 7},
|
||||
# {"field_name" => "network_logo", "field_value" => "", "network_logo_id" => 10, "provider_section_id" => nil}]}
|
||||
|
||||
|
||||
# {
|
||||
# "3" => [{
|
||||
# "exception_type" => "state",
|
||||
# "exception_values" => ["AZ", "MO", "IL"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "provider_section", "provider_section_id" => 3},
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 8}
|
||||
# ]
|
||||
# }],
|
||||
# "13" => [{
|
||||
# "exception_type" => "zipcode",
|
||||
# "exception_values" => ["14422", "14623", "14624"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 3}
|
||||
# ]
|
||||
# }],
|
||||
# "16" => [{
|
||||
# "exception_type" => "state",
|
||||
# "exception_values" => ["VA"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "medical_eff_date", "field_value" => "12/01/2025"},
|
||||
# {"field_name" => "provider_section", "provider_section_id" => 7},
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 6}
|
||||
# ]
|
||||
# }],
|
||||
# "21" => [{
|
||||
# "exception_type" => "state",
|
||||
# "exception_values" => ["VA"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 3}
|
||||
# ]
|
||||
# }],
|
||||
# "51" => [{
|
||||
# "exception_type" => "zipcode",
|
||||
# "exception_values" => ["41456", "41149", "41124"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 4}
|
||||
# ]
|
||||
# }],
|
||||
# "55" => [{
|
||||
# "exception_type" => "state",
|
||||
# "exception_values" => ["CA", "GA"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 5},
|
||||
# {"field_name" => "provider_section", "provider_section_id" => 8}
|
||||
# ]
|
||||
# }],
|
||||
# "62" => [
|
||||
# {
|
||||
# "exception_type" => "zipcode",
|
||||
# "exception_values" => ["49420", "48167"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 2}
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "exception_type" => "zipcode",
|
||||
# "exception_values" => ["55419", "55379"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 1}
|
||||
# ]
|
||||
# }
|
||||
# ],
|
||||
# "65" => [
|
||||
# {
|
||||
# "exception_type" => "zipcode",
|
||||
# "exception_values" => ["48430", "44842", "48649"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 2}
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "exception_type" => "zipcode",
|
||||
# "exception_values" => ["55372", "55021"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 1}
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "exception_type" => "zipcode",
|
||||
# "exception_values" => ["18042", "18080"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 10}
|
||||
# ]
|
||||
# }
|
||||
# ],
|
||||
# "66" => [{
|
||||
# "exception_type" => "state",
|
||||
# "exception_values" => ["GA"],
|
||||
# "field_exception_items" => [
|
||||
# {"field_name" => "network_logo", "network_logo_id" => 5}
|
||||
# ]
|
||||
# }]
|
||||
# }
|
||||
@@ -0,0 +1,324 @@
|
||||
require 'json'
|
||||
|
||||
namespace :seed_tasks do
|
||||
|
||||
## Build ID Card Information Tables
|
||||
|
||||
desc "Build Initial Plan Templates"
|
||||
# rake seed_tasks:build_plan_templates
|
||||
task build_plan_templates: :environment do
|
||||
puts "Importing Plan Templates"
|
||||
file_path = Rails.root.join('seed_docs', 'Standard Level360 Plans.pdf')
|
||||
reader = PDF::Reader.new(file_path)
|
||||
pages = []
|
||||
reader.pages.each do |page|
|
||||
rows = []
|
||||
text = page.text
|
||||
lines = text.split("\n")
|
||||
|
||||
lines.each do |line|
|
||||
cells = line.strip.split(/\s{2,}|\t/)
|
||||
rows << cells if cells.size > 1
|
||||
end
|
||||
pages << rows
|
||||
end
|
||||
|
||||
pages.each do |page_rows|
|
||||
title_row = page_rows.first
|
||||
title_row.each_with_index do |plan, index|
|
||||
next if index == 0
|
||||
plan_items = page_rows.map { |row| row[index] }
|
||||
plan_items.shift
|
||||
|
||||
plan = IdCard::Plan.create!(title: plan, template: true)
|
||||
doc_to_sequence_map = {
|
||||
0 => 4,
|
||||
1 => 5,
|
||||
2 => 6,
|
||||
3 => 7,
|
||||
4 => 9,
|
||||
5 => 10,
|
||||
6 => 11,
|
||||
7 => 12,
|
||||
10 => 1,
|
||||
11 => 2,
|
||||
12 => 3,
|
||||
13 => 13
|
||||
}
|
||||
# 9 => 8,
|
||||
# 10 => 8,
|
||||
plan_items.each_with_index do |item, i|
|
||||
puts "-- #{item}"
|
||||
sequence = doc_to_sequence_map[i]
|
||||
if sequence.present?
|
||||
benefit = plan.plan_benefits.find_by(sequence: sequence)
|
||||
if item.start_with?("Ded.")
|
||||
item = "Ded & Coin"
|
||||
end
|
||||
benefit.update(benefit: item)
|
||||
elsif i == 8
|
||||
carrier_coins = item.sub(/\/.*/, '')
|
||||
member_coins = plan_items[(i+1)].sub(/\/.*/, '')
|
||||
coins = "#{carrier_coins}/#{member_coins}"
|
||||
benefit = plan.plan_benefits.find_by(sequence: 8)
|
||||
benefit.update(benefit: coins)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Build Initial Provider Sections"
|
||||
# rake seed_tasks:build_provider_sections
|
||||
task build_provider_sections: :environment do
|
||||
puts "Importing Card Provider/Claims Information"
|
||||
default_provider_codes = ["2", "5"]
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
desc "Build Initial Rx Sections"
|
||||
# rake seed_tasks:build_rx_sections
|
||||
task build_rx_sections: :environment do
|
||||
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
|
||||
end
|
||||
|
||||
desc "Build Initial Network Logos"
|
||||
# rake seed_tasks:build_network_logos
|
||||
task build_network_logos: :environment do
|
||||
puts "Importing Network Logos"
|
||||
folder_path = Rails.root.join('seed_docs', '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}"
|
||||
file_path = folder_path.join(logo_upload)
|
||||
new_logo = ImageProcessorService.new(file_path, "Network").call
|
||||
if default_network_logos.include?(logo_upload)
|
||||
new_logo.default = true
|
||||
end
|
||||
new_logo.active = true
|
||||
new_logo.save
|
||||
end
|
||||
end
|
||||
|
||||
desc "Build Initial Employer Logos"
|
||||
# rake seed_tasks:build_employer_logos
|
||||
task build_employer_logos: :environment do
|
||||
puts "Importing Employer Logos"
|
||||
folder_path = Rails.root.join('seed_docs', 'logo_files', 'employer')
|
||||
file_names = Dir.children(folder_path)
|
||||
|
||||
file_names.each do |logo_upload|
|
||||
puts "-- #{logo_upload}"
|
||||
file_path = folder_path.join(logo_upload)
|
||||
new_logo = ImageProcessorService.new(file_path, "Employer").call
|
||||
new_logo.active = true
|
||||
new_logo.save
|
||||
end
|
||||
end
|
||||
|
||||
## Build Entities Tables
|
||||
|
||||
desc "Build Initial Carriers"
|
||||
# rake seed_tasks:build_carriers
|
||||
task build_carriers: :environment do
|
||||
puts "Importing Carriers"
|
||||
end
|
||||
|
||||
desc "Build Initial Brokers"
|
||||
# rake seed_tasks:build_brokers
|
||||
task build_brokers: :environment do
|
||||
puts "Importing Brokers"
|
||||
end
|
||||
|
||||
desc "Build Initial Employers"
|
||||
# rake seed_tasks:build_employers
|
||||
task build_employers: :environment do
|
||||
puts "Importing Employers"
|
||||
sql_query = "SELECT PLPlanKey, PlanId, ShortDesc FROM PLPlanHeader WHERE ActiveInactive = 'Active'" # AND PLPlanKey NOT IN ('50','56')"
|
||||
plan_headers = VhcsRecord.connection.select_all(sql_query)
|
||||
|
||||
plan_headers.each do |plan_header|
|
||||
employer = UpdateEmployerJob.perform_now(plan_header['PLPlanKey'], plan_header, true)
|
||||
puts "-- #{employer.name}"
|
||||
# employer_plans = employer.id_card_setup.plans
|
||||
vhcs_plans = Vhcs::PbProduct.where(company_pb_entity_key: employer.company_pb_entity_key, is_active: 255)
|
||||
vhcs_plans.each do |vp|
|
||||
# plan = employer_plans.find_by(pb_product_key: vp.pb_product_key)
|
||||
# if plan.present?
|
||||
# plan_titles = employer_plans.pluck(:title)
|
||||
# plan_title_matcher = JaroWinkler.new(vp.short_description)
|
||||
# closest_title = plan_titles.max_by { |title| plan_title_matcher.match(title) }
|
||||
# plan = employer_plans.find_by(title: closest_title)
|
||||
# plan.update(pb_product_key: vp.pb_product_key)
|
||||
# end
|
||||
plan = employer.id_card_setup.plans.find_by(pb_product_key: vp.pb_product_key)
|
||||
puts "---- #{plan.title}"
|
||||
# plan.update(
|
||||
# title: vp.short_description,
|
||||
# pl_plan_key: employer.pl_plan_key
|
||||
# )
|
||||
vhcs_plan_benefits = Vhcs::HlEgglestonCardBenefit.where(plan_id: plan.pb_product_key)
|
||||
vhcs_plan_benefits.each do |vb|
|
||||
benefit = plan.plan_benefits.find_by(sequence: vb.sequence)
|
||||
benefit.update(benefit: vb.benefit)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc "Build Initial Members"
|
||||
# rake seed_tasks:build_members
|
||||
task build_members: :environment do
|
||||
puts "Importing Members"
|
||||
Employer.all.map(&:sync_members_with_vhcs)
|
||||
end
|
||||
|
||||
## Build Employer ID Card Setups
|
||||
|
||||
desc "Determine Initial Card Templates"
|
||||
# rake seed_tasks:determine_card_templates
|
||||
task determine_card_templates: :environment do
|
||||
puts "Updating Card Templates"
|
||||
IdCard::Setup.all.each do |setup|
|
||||
setup_update_attrs = case setup.pl_plan_key
|
||||
when "2"
|
||||
{
|
||||
card_template: "SmartIDCard",
|
||||
card_color: "white",
|
||||
rx_title: "FairosRx",
|
||||
has_divisions: true,
|
||||
has_dental: true
|
||||
}
|
||||
when "3"
|
||||
{
|
||||
card_template: "TandemlocIDCard",
|
||||
card_color: "blue",
|
||||
rx_title: "FairosRx",
|
||||
has_dental: true
|
||||
}
|
||||
when "56"
|
||||
{
|
||||
card_template: "QRCodeIDCard",
|
||||
card_color: "white",
|
||||
rx_title: "TheHealthBus"
|
||||
}
|
||||
else
|
||||
{
|
||||
card_template: "FairosRxIDCard",
|
||||
card_color: "white",
|
||||
rx_title: "FairosRx"
|
||||
}
|
||||
end
|
||||
rx_title = setup_update_attrs.delete(:rx_title)
|
||||
rx_section_id = IdCard::RxSection.find_by(title: rx_title).id
|
||||
setup_update_attrs.merge!(rx_section_id: rx_section_id)
|
||||
|
||||
setup.update(setup_update_attrs)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc "Determine Initial Network Fields"
|
||||
# rake seed_tasks:determine_network_fields
|
||||
task determine_network_fields: :environment do
|
||||
puts "Updating Network Fields"
|
||||
cigna_groups = ["13","20","39","48","49","51","53","54","56","58","60","61","62","65","67","68","69"]
|
||||
medcost_groups = ["4","5","16","23","33","55","57","59","63","66"]
|
||||
old_cigna_groups = ["19","21"]
|
||||
smart_medcost = ["2"]
|
||||
tan_medcost = ["3"]
|
||||
|
||||
IdCard::Setup.all.each do |setup|
|
||||
pl_plan_key = setup.pl_plan_key
|
||||
setup_update_attrs = case
|
||||
when cigna_groups.include?(pl_plan_key) || pl_plan_key.blank?
|
||||
{ network_provider: "Cigna", network_logo: "CignaLogo.png", provider_section: "Cigna" }
|
||||
when medcost_groups.include?(pl_plan_key)
|
||||
{ network_provider: "MedCost", network_logo: "MedcostLogo.png", provider_section: "MedCost" }
|
||||
when old_cigna_groups.include?(pl_plan_key)
|
||||
{ network_provider: "Cigna", network_logo: "CignaLogo.png", provider_section: "Cigna (Beam/Stevens)" }
|
||||
when smart_medcost.include?(pl_plan_key)
|
||||
{ network_provider: "MedCost", network_logo: "MedcostLogo.png", provider_section: "MedCost (smART)" }
|
||||
when tan_medcost.include?(pl_plan_key)
|
||||
{ network_provider: "MedCost", network_logo: "MedcostLogo.png", provider_section: "MedCost (Tandemloc)" }
|
||||
end
|
||||
|
||||
provider_section_title = setup_update_attrs.delete(:provider_section)
|
||||
provider_section_id = IdCard::ProviderSection.find_by(title: provider_section_title).id
|
||||
setup_update_attrs.merge!(provider_section_id: provider_section_id)
|
||||
|
||||
network_logo_filename = setup_update_attrs.delete(:network_logo)
|
||||
network_logo_id = IdCard::NetworkLogo.find_by(filename: network_logo_filename).id
|
||||
setup_update_attrs.merge!(network_logo_id: network_logo_id)
|
||||
|
||||
setup.update(setup_update_attrs)
|
||||
end
|
||||
end
|
||||
|
||||
desc "Determine Initial Employer Fields"
|
||||
# rake seed_tasks:determine_employer_fields
|
||||
task determine_employer_fields: :environment do
|
||||
puts "Updating Employer Fields"
|
||||
IdCard::Setup.all.each do |setup|
|
||||
setup_update_attrs = {}
|
||||
employer_name = Employer.employer_trim_name(setup.employer.name)
|
||||
name_segments = employer_name.titleize.split
|
||||
name_segments.each do |segment|
|
||||
logo = IdCard::EmployerLogo.where("filename LIKE ?", "%#{segment}%")
|
||||
if logo&.first
|
||||
# setup_update_attrs.merge!(employer_logo_id: logo.first.id)
|
||||
setup.employer_logo = logo.first
|
||||
break
|
||||
end
|
||||
end
|
||||
json_file_path = Rails.root.join('seed_docs', 'json_files', 'card_exceptions.json')
|
||||
file_content = File.read(json_file_path)
|
||||
card_exceptions_map = JSON.parse(file_content)
|
||||
if card_exceptions_map[pl_plan_key].present?
|
||||
setup.field_exceptions.create(card_exceptions_map[pl_plan_key])
|
||||
end
|
||||
|
||||
setup.save
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user