working on data printer
This commit is contained in:
+32
-32
@@ -24,6 +24,27 @@ 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"
|
||||
@@ -50,10 +71,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 "setup_id", null: false
|
||||
t.bigint "configuration_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["setup_id"], name: "index_id_card_field_exceptions_on_setup_id"
|
||||
t.index ["configuration_id"], name: "index_id_card_field_exceptions_on_configuration_id"
|
||||
end
|
||||
|
||||
create_table "id_card_network_logos", force: :cascade do |t|
|
||||
@@ -82,10 +103,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 "setup_id"
|
||||
t.bigint "configuration_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["setup_id"], name: "index_id_card_plans_on_setup_id"
|
||||
t.index ["configuration_id"], name: "index_id_card_plans_on_configuration_id"
|
||||
end
|
||||
|
||||
create_table "id_card_print_data", force: :cascade do |t|
|
||||
@@ -223,27 +244,6 @@ 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 "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_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 "id_card_display_name"
|
||||
@@ -259,17 +259,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_setups", column: "setup_id"
|
||||
add_foreign_key "id_card_field_exceptions", "id_card_configurations", column: "configuration_id"
|
||||
add_foreign_key "id_card_plan_benefits", "id_card_plans", column: "plan_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 "id_card_plans", "id_card_configurations", column: "configuration_id"
|
||||
add_foreign_key "members", "employers"
|
||||
add_foreign_key "members", "id_card_plans"
|
||||
end
|
||||
|
||||
+68
-157
@@ -1,47 +1,40 @@
|
||||
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'
|
||||
|
||||
case pl_plan_key
|
||||
when 2
|
||||
"SmartIDCard"
|
||||
when 3
|
||||
"TPAIDCardTan"
|
||||
when 56
|
||||
"HealthBusIDCard"
|
||||
else
|
||||
single_card_template = 'TPAIDCard'
|
||||
"FairosIDCard"
|
||||
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
|
||||
|
||||
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)
|
||||
@@ -131,131 +124,31 @@ end
|
||||
|
||||
|
||||
# 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)
|
||||
# use rake tasks
|
||||
|
||||
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
|
||||
|
||||
base_cp_provider_codes = ["5", "2"]
|
||||
needed_codes = %w(M T A I 8 7 1 6 3 P C V Y Z)
|
||||
# provider_code_map = {}
|
||||
vhcs_cp = Vhcs::HlidCardProvider.where(provider_code: base_cp_provider_codes).to_a + Vhcs::HlidCardProvider.where(provider_code: needed_codes).order(:provider_code).to_a
|
||||
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?("_") }
|
||||
existing_cp = IdCard::ProviderSection.find_by(attributes_hash)
|
||||
|
||||
if existing_cp
|
||||
existing_cp.title = existing_cp.title.concat(vhcs.provider_code)
|
||||
existing_cp.save
|
||||
else
|
||||
title = case
|
||||
when vhcs.provider_line_1 == "PO Box 188061"
|
||||
"Cigna #{vhcs.provider_code}"
|
||||
when vhcs.provider_line_1.present?
|
||||
"#{vhcs.provider_line_1} #{vhcs.provider_code}"
|
||||
else
|
||||
"Medcost #{vhcs.provider_code}"
|
||||
end
|
||||
|
||||
if base_cp_provider_codes.include?(vhcs.provider_code)
|
||||
attributes_hash[:default] = true
|
||||
end
|
||||
attributes_hash[:title] = title
|
||||
attributes_hash[:provider_code] = vhcs.provider_code
|
||||
|
||||
IdCard::ProviderSection.find_or_create_by(attributes_hash)
|
||||
if default_provider_codes.include?(vhcs.provider_code)
|
||||
attributes_hash[:default] = true
|
||||
end
|
||||
attributes_hash[:title] = needed_codes_mapping[vhcs.provider_code]
|
||||
|
||||
end
|
||||
|
||||
base_cp_provider_codes = ["5", "2"]
|
||||
needed_codes = %w(M T A I 8 7 1 6 3 P C V Y Z)
|
||||
# provider_code_map = {}
|
||||
vhcs_cp = Vhcs::HlidCardProvider.where(provider_code: base_cp_provider_codes).to_a + Vhcs::HlidCardProvider.where(provider_code: needed_codes).order(:provider_code).to_a
|
||||
vhcs_cp.each do |vhcs|
|
||||
attributes_hash = vhcs.attributes.except(:provider_code)
|
||||
attributes_hash.delete_if { |key, value| !key.to_s.include?("_") }
|
||||
existing_cp = IdCard::ProviderSection.find_by(attributes_hash)
|
||||
|
||||
if existing_cp
|
||||
existing_cp
|
||||
# if provider_code_map[existing_cp.provider_code]
|
||||
# provider_code_map[existing_cp.provider_code].push(vhcs.provider_code)
|
||||
# else
|
||||
# provider_code_map[existing_cp.provider_code] = [vhcs.provider_code]
|
||||
# end
|
||||
else
|
||||
attributes_hash[:provider_code] = vhcs.provider_code
|
||||
IdCard::ProviderSection.find_or_create_by(attributes_hash)
|
||||
end
|
||||
IdCard::ProviderSection.find_or_create_by(attributes_hash)
|
||||
end
|
||||
|
||||
Vhcs::HlrxCrosRef.all.each do |vhcs|
|
||||
@@ -276,6 +169,24 @@ end
|
||||
new_logo.save
|
||||
end
|
||||
|
||||
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_id = IdCard::ProviderSection.find_by(title: network_information[:provider_section]).id
|
||||
config.provider_section_id = ps_id
|
||||
nl_id = IdCard::NetworkLogo.find_by(filename: network_information[:network_logo]).id
|
||||
config.network_logo_id = nl_id
|
||||
|
||||
employer_name = configuration.employer.name
|
||||
logo_name = employer_name.titleize.gsub(' ', '')
|
||||
|
||||
logo = IdCard::EmployerLogo.where("filename LIKE ?", "%#{logo_name}%")
|
||||
if logo
|
||||
config.employer_logo_id = logo.first.id
|
||||
end
|
||||
end
|
||||
|
||||
# 15, 18, 19, 20, 13, 21
|
||||
|
||||
|
||||
Reference in New Issue
Block a user