Before adding workers

This commit is contained in:
Jason Jordan
2026-03-20 10:46:53 -04:00
parent 3300819ed5
commit a43c8bf6b5
70 changed files with 533 additions and 457 deletions
@@ -1,12 +1,14 @@
class CreateIdCardConfigurations < ActiveRecord::Migration[7.2]
class CreateIdCardSetups < ActiveRecord::Migration[7.2]
def change
create_table :id_card_configurations do |t|
create_table :id_card_setups do |t|
t.string :print_name
t.string :network_provider
t.string :card_template
t.string :card_color
t.string :rx_group_number
t.string :pl_plan_key
t.boolean :active, default: false
t.boolean :has_divisions, default: false
t.belongs_to :employer, null: false, foreign_key: true
t.belongs_to :employer_logo, null: true, foreign_key: { to_table: :id_card_employer_logos }
t.belongs_to :network_logo, null: true, foreign_key: { to_table: :id_card_network_logos }
@@ -5,7 +5,7 @@ class CreateIdCardPlans < ActiveRecord::Migration[7.2]
t.integer :pb_product_key
t.string :pl_plan_key
t.boolean :template
t.belongs_to :configuration, null: true, foreign_key: { to_table: :id_card_configurations }
t.belongs_to :setup, null: true, foreign_key: { to_table: :id_card_setups }
t.timestamps
end
@@ -3,7 +3,7 @@ class CreateIdCardFieldExceptions < ActiveRecord::Migration[7.2]
create_table :id_card_field_exceptions do |t|
t.string :exception_type
t.string :exception_value
t.belongs_to :configuration, null: false, foreign_key: { to_table: :id_card_configurations }
t.belongs_to :setup, null: false, foreign_key: { to_table: :id_card_setups }
t.timestamps
end
+34 -32
View File
@@ -24,27 +24,6 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_16_182836) do
t.datetime "updated_at", null: false
end
create_table "id_card_configurations", force: :cascade do |t|
t.string "print_name"
t.string "network_provider"
t.string "card_template"
t.string "rx_group_number"
t.string "pl_plan_key"
t.boolean "active", default: false
t.bigint "employer_id", null: false
t.bigint "employer_logo_id"
t.bigint "network_logo_id"
t.bigint "provider_section_id"
t.bigint "rx_section_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["employer_id"], name: "index_id_card_configurations_on_employer_id"
t.index ["employer_logo_id"], name: "index_id_card_configurations_on_employer_logo_id"
t.index ["network_logo_id"], name: "index_id_card_configurations_on_network_logo_id"
t.index ["provider_section_id"], name: "index_id_card_configurations_on_provider_section_id"
t.index ["rx_section_id"], name: "index_id_card_configurations_on_rx_section_id"
end
create_table "id_card_employer_logos", force: :cascade do |t|
t.string "filename"
t.binary "image_data"
@@ -71,10 +50,10 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_16_182836) do
create_table "id_card_field_exceptions", force: :cascade do |t|
t.string "exception_type"
t.string "exception_value"
t.bigint "configuration_id", null: false
t.bigint "setup_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["configuration_id"], name: "index_id_card_field_exceptions_on_configuration_id"
t.index ["setup_id"], name: "index_id_card_field_exceptions_on_setup_id"
end
create_table "id_card_network_logos", force: :cascade do |t|
@@ -103,10 +82,10 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_16_182836) do
t.integer "pb_product_key"
t.string "pl_plan_key"
t.boolean "template"
t.bigint "configuration_id"
t.bigint "setup_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["configuration_id"], name: "index_id_card_plans_on_configuration_id"
t.index ["setup_id"], name: "index_id_card_plans_on_setup_id"
end
create_table "id_card_print_data", force: :cascade do |t|
@@ -247,6 +226,29 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_16_182836) do
t.datetime "updated_at", null: false
end
create_table "id_card_setups", force: :cascade do |t|
t.string "print_name"
t.string "network_provider"
t.string "card_template"
t.string "card_color"
t.string "rx_group_number"
t.string "pl_plan_key"
t.boolean "active", default: false
t.boolean "has_divisions", default: false
t.bigint "employer_id", null: false
t.bigint "employer_logo_id"
t.bigint "network_logo_id"
t.bigint "provider_section_id"
t.bigint "rx_section_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["employer_id"], name: "index_id_card_setups_on_employer_id"
t.index ["employer_logo_id"], name: "index_id_card_setups_on_employer_logo_id"
t.index ["network_logo_id"], name: "index_id_card_setups_on_network_logo_id"
t.index ["provider_section_id"], name: "index_id_card_setups_on_provider_section_id"
t.index ["rx_section_id"], name: "index_id_card_setups_on_rx_section_id"
end
create_table "members", force: :cascade do |t|
t.string "name"
t.string "family_id"
@@ -263,17 +265,17 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_16_182836) do
t.index ["id_card_plan_id"], name: "index_members_on_id_card_plan_id"
end
add_foreign_key "id_card_configurations", "employers"
add_foreign_key "id_card_configurations", "id_card_employer_logos", column: "employer_logo_id"
add_foreign_key "id_card_configurations", "id_card_network_logos", column: "network_logo_id"
add_foreign_key "id_card_configurations", "id_card_provider_sections", column: "provider_section_id"
add_foreign_key "id_card_configurations", "id_card_rx_sections", column: "rx_section_id"
add_foreign_key "id_card_field_exception_items", "id_card_field_exceptions", column: "field_exception_id"
add_foreign_key "id_card_field_exception_items", "id_card_network_logos", column: "network_logo_id"
add_foreign_key "id_card_field_exception_items", "id_card_provider_sections", column: "provider_section_id"
add_foreign_key "id_card_field_exceptions", "id_card_configurations", column: "configuration_id"
add_foreign_key "id_card_field_exceptions", "id_card_setups", column: "setup_id"
add_foreign_key "id_card_plan_benefits", "id_card_plans", column: "plan_id"
add_foreign_key "id_card_plans", "id_card_configurations", column: "configuration_id"
add_foreign_key "id_card_plans", "id_card_setups", column: "setup_id"
add_foreign_key "id_card_setups", "employers"
add_foreign_key "id_card_setups", "id_card_employer_logos", column: "employer_logo_id"
add_foreign_key "id_card_setups", "id_card_network_logos", column: "network_logo_id"
add_foreign_key "id_card_setups", "id_card_provider_sections", column: "provider_section_id"
add_foreign_key "id_card_setups", "id_card_rx_sections", column: "rx_section_id"
add_foreign_key "members", "employers"
add_foreign_key "members", "id_card_plans"
end
+66 -33
View File
@@ -1,12 +1,10 @@
def determine_id_card_templates(pl_plan_key)
pl_plan_key = pl_plan_key.to_i
case pl_plan_key
when 2
when "2"
"SmartIDCard"
when 3
when "3"
"TandemlocIDCard"
when 56
when "56"
"QRCodeIDCard"
else
"FairosRxIDCard"
@@ -14,9 +12,7 @@ def determine_id_card_templates(pl_plan_key)
end
def determine_id_card_rx(pl_plan_key)
pl_plan_key = pl_plan_key.to_i
if pl_plan_key == 56
if pl_plan_key == "56"
"TheHealthBus"
else
"FairosRx"
@@ -24,16 +20,14 @@ def determine_id_card_rx(pl_plan_key)
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]
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"]
case
when cigna_groups.include?(pl_plan_key)
when cigna_groups.include?(pl_plan_key) || pl_plan_key.blank?
{ 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" }
@@ -47,6 +41,22 @@ def determine_id_card_network(pl_plan_key)
end
def determine_divisions(pl_plan_key)
if pl_plan_key == "16"
true
else
false
end
end
def determine_card_color(pl_plan_key)
if pl_plan_key == "3"
"blue"
else
"white"
end
end
puts "[**** IMPORT ID CARD TABLES ****]"
## SET UP DEFAULT LEVEL360 PLANS FOR PLAN PICKER
@@ -109,7 +119,7 @@ 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
new_logo = ImageProcessorService.new("logo_files/network/#{logo_upload}", "Network").call
if default_network_logos.include?(logo_upload)
new_logo.default = true
end
@@ -125,14 +135,15 @@ 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 = ImageProcessorService.new("logo_files/employer/#{logo_upload}", "Employer").call
new_logo.active = true
new_logo.save
end
##---------------- Import Employer/Member Setup------------------------------------
puts "[**** IMPORT EMPLOYERS ****]"
##---------------- Import Employer/Member (VHCS) ------------------------------------
puts "Importing Employers From VHCS"
Rake::Task["employer:vhcs_sync_all"].invoke
# acentria = Carrier.find_or_create_by!(name: 'Acentria')
@@ -147,33 +158,55 @@ Rake::Task["employer:vhcs_sync_all"].invoke
# 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)
##---------------- Import Employers (Word Docs) ------------------------------------
network_information = determine_id_card_network(config.pl_plan_key)
config.network_provider = network_information[:provider]
puts "Importing Employers From Word Docs"
folder_path = Rails.root.join('employer_word_docs')
file_names = Dir.children(folder_path)
file_names.each do |word_doc|
puts "-- Processing #{word_doc}"
new_employer = BenefitsWordDocService::WordDocProcessor.new("employer_word_docs/#{word_doc}").call
if new_employer.save
puts "Imported #{new_employer.name}"
end
end
##---------------- Update ID Card Setups------------------------------------
puts "[**** UPDATE EMPLOYER ID CARD SETUPS ****]"
IdCard::Setup.all.each do |setup|
setup.card_template = determine_id_card_templates(setup.pl_plan_key)
setup.card_color = determine_card_color(setup.pl_plan_key)
setup.has_divisions = determine_divisions(setup.pl_plan_key)
network_information = determine_id_card_network(setup.pl_plan_key)
setup.network_provider = network_information[:provider]
ps = IdCard::ProviderSection.find_by(title: network_information[:provider_section])
config.provider_section_id = ps.id
setup.provider_section_id = ps.id
nl = IdCard::NetworkLogo.find_by(filename: network_information[:network_logo])
config.network_logo_id = nl.id
setup.network_logo_id = nl.id
rx_title = determine_id_card_rx(config.pl_plan_key)
rx_title = determine_id_card_rx(setup.pl_plan_key)
rs = IdCard::RxSection.find_by(title: rx_title)
config.rx_section_id = rs.id
setup.rx_section_id = rs.id
employer_name = config.employer.employer_trim_name
employer_name = setup.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
setup.employer_logo = logo.first
break
end
end
config.active = true
config.save
if setup.pl_plan_key.present?
setup.active = true
end
setup.save
end