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,33 +0,0 @@
class BenefitsWordDocProcessor
def initialize(word_doc, employer=nil)
@word_doc = word_doc
if employer
@employer = employer
else
@employer = Employer.new
@employer.build_id_card_configuration
end
end
def call
doc = Docx::Document.open(@word_doc)
data_lines = doc.paragraphs.map { |p| p.to_s.squish }.reject!(&:empty?)
employer_information, plans_and_network = data_lines.split("Medical Plan")
plan_information, network_information = plans_and_network.split("Claims Submission")
# employer_information = data_lines.slice(0, start_of_plans_index)
# plan_information = data_lines.slice(start_of_plans_index + 1..)
# network_information = data_lines.slice(start_of_network_index + 1..)
@employer = BenefitsWordDoc::MapEmployerInformation.new(@employer, employer_information).call
@employer = BenefitsWordDoc::MapEmployerLogo.new(@employer, @word_doc).call
@employer = BenefitsWordDoc::MapPlansInformation.new(@employer, plan_information).call
@employer = BenefitsWordDoc::MapNetworkInformation.new(@employer, network_information).call
@employer
end
end
@@ -1,4 +1,4 @@
class BenefitsWordDocProcessorOld
class WordDocProcessorOld
def initialize(word_doc, process=nil)
@word_doc = word_doc
@@ -1,9 +1,9 @@
module BenefitsWordDoc
module BenefitsWordDocService
class MapEmployerInformation
def initialize(employer, word_doc_section)
@employer = employer
@card_config = @employer.id_card_configuration
@card_setup = @employer.id_card_setup
@word_doc_section = word_doc_section
end
@@ -28,7 +28,9 @@ module BenefitsWordDoc
end
end
end
@card_config.rx_group_number = @employer.group_number
@card_setup.print_name = @employer.name
@employer.name = @employer.name.titleize
@card_setup.rx_group_number = @employer.group_number
@employer
end
@@ -1,9 +1,9 @@
module BenefitsWordDoc
module BenefitsWordDocService
class MapEmployerLogo
def initialize(employer, word_doc)
@employer = employer
@card_config = @employer.id_card_configuration
@card_setup = @employer.id_card_setup
@word_doc = word_doc
end
@@ -41,7 +41,7 @@ module BenefitsWordDoc
# @employer.single_card_template = "FairosRxIDCard"
# end
@card_config.employer_logo = logo
@card_setup.employer_logo = logo
end
end
@employer
@@ -1,9 +1,9 @@
module BenefitsWordDoc
module BenefitsWordDocService
class MapNetworkInformation
def initialize(employer, word_doc_section)
@employer = employer
@card_config = @employer.id_card_configuration
@card_setup = @employer.id_card_setup
@word_doc_section = word_doc_section
end
@@ -29,11 +29,11 @@ module BenefitsWordDoc
# end
if network
@card_config.network_provider = network
@card_setup.network_provider = network
logo_name = "#{network}Logo.png"
@card_config.network_logo = IdCard::NetworkLogo.find_by(filename: logo_name)
@card_config.provider_section = IdCard::ProviderSection.find_by(title: network)
@card_config.rx_section = IdCard::RxSection.find_by(title: "FairosRx")
@card_setup.network_logo = IdCard::NetworkLogo.find_by(filename: logo_name)
@card_setup.provider_section = IdCard::ProviderSection.find_by(title: network)
@card_setup.rx_section = IdCard::RxSection.find_by(title: "FairosRx")
end
@@ -1,9 +1,9 @@
module BenefitsWordDoc
module BenefitsWordDocService
class MapPlansInformation
def initialize(employer, word_doc_section)
@employer = employer
@card_config = @employer.id_card_configuration
@card_setup = @employer.id_card_setup
@word_doc_section = word_doc_section
end
@@ -12,7 +12,7 @@ module BenefitsWordDoc
plans_indexes = @word_doc_section.each_index.select { |index| @word_doc_section[index].match?(/\d*\.?\d+k/i) }
plans_indexes.each do |plan_index|
new_plan = @card_config.plans.build(title: @word_doc_section[plan_index])
new_plan = @card_setup.plans.build(title: @word_doc_section[plan_index])
plan_lines = @word_doc_section.slice(plan_index + 1, 14)
plan_lines.each_with_index do |line, i|
field_mapping = mapping_array[i]
@@ -0,0 +1,35 @@
module BenefitsWordDocService
class WordDocProcessor
def initialize(word_doc, employer=nil)
@word_doc = word_doc
if employer
@employer = employer
else
@employer = Employer.new
@employer.build_id_card_setup
end
end
def call
doc = Docx::Document.open(@word_doc)
data_lines = doc.paragraphs.map { |p| p.to_s.squish }.reject!(&:empty?)
employer_information, plans_and_network = data_lines.split("Medical Plan")
plan_information, network_information = plans_and_network.split("Claims Submission")
# employer_information = data_lines.slice(0, start_of_plans_index)
# plan_information = data_lines.slice(start_of_plans_index + 1..)
# network_information = data_lines.slice(start_of_network_index + 1..)
@employer = BenefitsWordDocService::MapEmployerInformation.new(@employer, employer_information).call
@employer = BenefitsWordDocService::MapEmployerLogo.new(@employer, @word_doc).call
@employer = BenefitsWordDocService::MapPlansInformation.new(@employer, plan_information).call
@employer = BenefitsWordDocService::MapNetworkInformation.new(@employer, network_information).call
@employer
end
end
end
@@ -5,7 +5,7 @@ module EmployerCards
@pl_plan_key = pl_plan_key
@family_id = family_id
@layout = layout
@card_config = IdCard::Configuration.find_by(pl_plan_key: pl_plan_key)
@card_setup = IdCard::Setup.find_by(pl_plan_key: pl_plan_key)
end
def call
@@ -1,4 +1,4 @@
module IdCardPrinter
module IdCardPrinterService
class EmployerCardsGenerator
def initialize(employer, layout, zip=false)
@@ -9,9 +9,9 @@ module IdCardPrinter
def call
IdCard::PrintData.where(pl_plan_key: @employer.pl_plan_key).destroy_all
IdCardPrinter::EmployerDataFormatter.new(@employer).call
IdCardPrinterService::EmployerDataFormatter.new(@employer).call
pdf_array = IdCardPrinter::PdfProcessor.new(@employer, @layout, @zip).call
pdf_array = IdCardPrinterService::PdfProcessor.new(@employer, @layout, @zip).call
group_pdfs = combine_pdfs(pdf_array)
group_pdfs
@@ -1,9 +1,9 @@
module IdCardPrinter
module IdCardPrinterService
class EmployerDataFormatter
def initialize(employer, member_keys = nil)
@employer = employer
@card_config = @employer.id_card_configuration
@card_setup = @employer.id_card_setup
if member_keys
@members = @employer.members.where(pb_entity_key: member_keys).order(:name)
@@ -29,20 +29,23 @@ module IdCardPrinter
private
def set_common_fields
employer_attributes = {
employer_name: @card_config.print_name,
pl_plan_key: @card_config.pl_plan_key,
group_number: @employer.group_number,
rx_group: @card_config.rx_group_number,
network_provider: @card_config.network_provider
}
rx_attributes = @card_config.rx_section.attributes.with_indifferent_access.slice(
employer_attributes = {
pl_plan_key: @card_setup.pl_plan_key,
group_number: @employer.group_number,
rx_group: @card_setup.rx_group_number,
network_provider: @card_setup.network_provider
}
unless @card_setup.has_divisions
employer_attributes.merge!({employer_name: @card_setup.print_name})
end
rx_attributes = @card_setup.rx_section.attributes.with_indifferent_access.slice(
:customer_service,
:web_url
)
provider_attributes = @card_config.provider_section.attributes.with_indifferent_access.slice(
provider_attributes = @card_setup.provider_section.attributes.with_indifferent_access.slice(
:provider_line_1, :provider_line_2, :provider_line_3, :provider_line_4, :provider_line_5, :provider_line_6,
:provider_line_7, :provider_line_8, :provider_line_9, :provider_line_10, :provider_line_11, :provider_line_12,
:claim_to_1, :claim_to_2, :claim_to_3, :claim_to_4, :claim_to_5, :claim_to_6,
@@ -53,33 +56,8 @@ module IdCardPrinter
@base_card.assign_attributes(selected_attributes)
end
def set_common_fields_old
employer_attributes = {
employer_name: @card_config.print_name,
group_number: @employer.group_number,
rx_group: @card_config.rx_group_number
}
rx_attributes = @card_config.rx_section.attributes.with_indifferent_access.slice(
:customer_service,
:web_url
)
provider_attributes = @card_config.provider_section.attributes.with_indifferent_access.slice(
:provider_code, :provider_line_1, :provider_line_2, :provider_line_3, :provider_line_4, :provider_line_5, :provider_line_6,
:provider_line_7, :provider_line_8, :provider_line_9, :provider_line_10, :provider_line_11, :provider_line_12,
:claim_to_1, :claim_to_2, :claim_to_3, :claim_to_4, :claim_to_5, :claim_to_6,
:claim_to_7, :claim_to_8, :claim_to_9, :claim_to_10, :claim_to_11, :claim_to_12
)
selected_attributes = employer_attributes.merge(rx_attributes).merge(provider_attributes)
@employer_cards.each do |card|
card.assign_attributes(selected_attributes)
end
end
def set_plan_fields
@card_config.plans.each do |plan|
@card_setup.plans.each do |plan|
selected_attributes = {}
plan.plan_benefits.each do |bene|
selected_attributes["benefit_desc_#{bene.sequence}".to_sym] = bene.benefit_desc
@@ -106,6 +84,10 @@ module IdCardPrinter
medical_eff_date: effect_date.strftime("%m/%d/%Y")
}
if @card_setup.has_divisions
member_attributes.merge!({employer_name: me.division})
end
dependent_attributes = get_dependent_fields(me)
if dependent_attributes.present?
selected_attributes = member_attributes.merge(dependent_attributes)
@@ -1,4 +1,4 @@
module IdCardPrinter
module IdCardPrinterService
class JasperPdfGenerator
def initialize(jasper_url)
@@ -1,9 +1,9 @@
module IdCardPrinter
module IdCardPrinterService
class JasperUrlGenerator
def initialize(pl_plan_key, family_id, layout)
@pl_plan_key = pl_plan_key
@card_config = IdCard::Configuration.find_by(pl_plan_key: pl_plan_key)
@card_setup = IdCard::Setup.find_by(pl_plan_key: pl_plan_key)
@family_id = family_id
@layout = layout
end
@@ -24,7 +24,7 @@ module IdCardPrinter
# end
# end
# @network_logos.find_by(default: true).net_logo
@card_config.network_logo.filename
@card_setup.network_logo.filename
end
# http://localhost:8080/trunk/PdfServlet?reportConn=BrittonConnect&id=&reportName=FairosRxSampleIDCard-Half&family_id=Classic%202K&employer_logo=BryanPestControl.jpeg&network_logo=CignaLogo.png&reportDir=secure/Documents&SUBREPORT_DIR=/&ImageDir=secure/Documents&netToken=3a4a8b03f4dfb0e6e3fc82dd369f70ef&FileType=PDF
# http://localhost:8080/trunk/PdfServlet?reportConn=BrittonConnect&id=&reportName=FairosRxSampleIDCard-Half&family_id=Classic%202K&employer_logo=BryanPestControl.jpeg&network_logo=CignaLogo.png&reportDir=secure/Documents&SUBREPORT_DIR=/&ImageDir=secure/Documents&netToken=3a4a8b03f4dfb0e6e3fc82dd369f70ef&FileType=PDF
@@ -33,7 +33,7 @@ module IdCardPrinter
host: '10.41.1.115',
port: 8080,
path: '/trunk/IdCardsServlet',
query: "reportConn=BrittonConnect&cardTemplate=#{@card_config.card_template}&printType=#{@layout}&family_id=#{@family_id }&employer_logo=#{@card_config.employer_logo.filename}&network_logo=#{determine_network_logo}&FileType=PDF"
query: "reportConn=BrittonConnect&cardTemplate=#{@card_setup.card_template}&printType=#{@layout}&family_id=#{@family_id }&employer_logo=#{@card_setup.employer_logo.filename}&network_logo=#{determine_network_logo}&FileType=PDF"
}
end
@@ -1,4 +1,4 @@
module IdCardPrinter
module IdCardPrinterService
class MemberCardsGenerator
def initialize(member_keys, layout)
@@ -10,9 +10,9 @@ module IdCardPrinter
def call
IdCard::PrintData.where(mb_member_key: @employer.pl_plan_key).destroy_all
IdCardPrinter::EmployerDataFormatter.new(@employer).call
IdCardPrinterService::EmployerDataFormatter.new(@employer).call
pdf_array = IdCardPrinter::PdfProcessor.new(@employer, @layout, @zip).call
pdf_array = IdCardPrinterService::PdfProcessor.new(@employer, @layout, @zip).call
group_pdfs = combine_pdfs(pdf_array)
group_pdfs
@@ -1,9 +1,9 @@
module IdCardPrinter
module IdCardPrinterService
class PdfProcessor
def initialize(employer, layout, zip = false)
@employer = employer
@card_config = @employer.id_card_configuration
@card_setup = @employer.id_card_setup
@layout = layout
@zip = zip
end
@@ -16,9 +16,9 @@ module IdCardPrinter
# end
group_cards_pdf_array = []
IdCard::PrintData.where(pl_plan_key: @employer.pl_plan_key).each do |card|
url = IdCardPrinter::JasperUrlGenerator.new(@employer.pl_plan_key, card.family_id, @layout).call
url = IdCardPrinterService::JasperUrlGenerator.new(@employer.pl_plan_key, card.family_id, @layout).call
puts url
card_pdf = IdCardPrinter::JasperPdfGenerator.new(url).call
card_pdf = IdCardPrinterService::JasperPdfGenerator.new(url).call
if @zip
card_filename = "#{card.full_name_last_name_first.gsub(", ", "_")}_digital_card_#{Date.today}.pdf"
group_cards_pdf_array << { name: card_filename, data: card_pdf.to_pdf }
@@ -1,4 +1,4 @@
module IdCardPrinter
module IdCardPrinterService
class QueuedCardsGenerator
def initialize(employer_member_keys)
@@ -13,12 +13,13 @@ module IdCardPrinter
IdCard::PrintData.where(pl_plan_key: @pl_plan_keys).destroy_all
@employer_member_keys.each do |emk|
employer = Employer.find_by(pl_plan_key: emk["PlanKey"])
card_setup = employer.id_card_setup
member_keys = emk["MemberKeys"].split(", ").map(&:to_i)
IdCardPrinter::EmployerDataFormatter.new(employer, member_keys).call
if emk["PlanKey"] == "3"
blue_card_array = IdCardPrinter::PdfProcessor.new(employer, @layout).call
IdCardPrinterService::EmployerDataFormatter.new(employer, member_keys).call
if card_setup.card_color = "blue"
blue_card_array = IdCardPrinterService::PdfProcessor.new(employer, @layout).call
else
white_card_array = IdCardPrinter::PdfProcessor.new(employer, @layout).call
white_card_array = IdCardPrinterService::PdfProcessor.new(employer, @layout).call
end
end
@@ -1,4 +1,4 @@
module IdCardPrinter
module IdCardPrinterService
class SampleCardsGenerator
def initialize(employer)
@@ -7,9 +7,9 @@ module IdCardPrinter
def call
IdCard::PrintData.where(employer_name: @employer.name).destroy_all
IdCardPrinter::SampleDataFormatter.new(@employer).call
IdCardPrinterService::SampleDataFormatter.new(@employer).call
IdCardPrinter::SamplePdfProcessor.new(@employer).call
IdCardPrinterService::SamplePdfProcessor.new(@employer).call
end
end
end
@@ -1,9 +1,9 @@
module IdCardPrinter
module IdCardPrinterService
class SampleDataFormatter
def initialize(employer)
@employer = employer
@card_config = @employer.id_card_configuration
@card_setup = @employer.id_card_setup
end
def call
@@ -33,8 +33,8 @@ module IdCardPrinter
def set_plan_fields
plans_base_cards = []
@card_config.plans.each do |plan|
@base_card.sample_key = @card_config.print_name.titleize.split.map(&:first).push(plan.id).join
@card_setup.plans.each do |plan|
@base_card.sample_key = @card_setup.print_name.titleize.split.map(&:first).push(plan.id).join
plan_base_card = @base_card.dup
plan_name = plan.title.split(/(?<=\d[kK])/).first
plan.plan_benefits.each do |bene|
@@ -58,23 +58,23 @@ module IdCardPrinter
end
def set_network_fields
selected_attributes = @card_config.provider_section.attributes.with_indifferent_access.slice(
selected_attributes = @card_setup.provider_section.attributes.with_indifferent_access.slice(
:provider_line_1, :provider_line_2, :provider_line_3, :provider_line_4, :provider_line_5, :provider_line_6,
:provider_line_7, :provider_line_8, :provider_line_9, :provider_line_10, :provider_line_11, :provider_line_12,
:claim_to_1, :claim_to_2, :claim_to_3, :claim_to_4, :claim_to_5, :claim_to_6,
:claim_to_7, :claim_to_8, :claim_to_9, :claim_to_10, :claim_to_11, :claim_to_12
)
# if @card_config.network_provider == "Cigna"
# if @card_setup.network_provider == "Cigna"
# @base_card.provider_code = "5"
# end
@base_card.network_provider = @card_config.network_provider
@base_card.network_provider = @card_setup.network_provider
@base_card.assign_attributes(selected_attributes)
end
def set_rx_fields
# fairos_information = Vhcs::HlrxCrosRef.where(pl_plan_key: 52).first
selected_attributes = @card_config.rx_section.attributes.with_indifferent_access.slice(
selected_attributes = @card_setup.rx_section.attributes.with_indifferent_access.slice(
:customer_service,
:web_url
)
@@ -1,10 +1,10 @@
module IdCardPrinter
module IdCardPrinterService
class SampleJasperUrlGenerator
def initialize(employer, sample_key, sample_title)
@sample_key = sample_key
@sample_title = sample_title
@card_config = employer.id_card_configuration
@card_setup = employer.id_card_setup
end
def call
@@ -25,7 +25,7 @@ module IdCardPrinter
# end
# end
# @network_logos.find_by(default: true).net_logo
@card_config.network_logo.filename
@card_setup.network_logo.filename
end
# http://localhost:8080/trunk/PdfServlet?reportConn=BrittonConnect&id=&reportName=FairosRxSampleIDCard-Half&family_id=Classic%202K&employer_logo=BryanPestControl.jpeg&network_logo=CignaLogo.png&reportDir=secure/Documents&SUBREPORT_DIR=/&ImageDir=secure/Documents&netToken=3a4a8b03f4dfb0e6e3fc82dd369f70ef&FileType=PDF
# http://localhost:8080/trunk/PdfServlet?reportConn=BrittonConnect&id=&reportName=FairosRxSampleIDCard-Half&family_id=Classic%202K&employer_logo=BryanPestControl.jpeg&network_logo=CignaLogo.png&reportDir=secure/Documents&SUBREPORT_DIR=/&ImageDir=secure/Documents&netToken=3a4a8b03f4dfb0e6e3fc82dd369f70ef&FileType=PDF
@@ -34,7 +34,7 @@ module IdCardPrinter
host: '10.41.1.115',
port: 8080,
path: '/trunk/IdCardsServlet',
query: "reportConn=BrittonConnect&cardTemplate=#{@card_config.card_template}&printType=SampleCard&sample_key=#{@sample_key}&sample_plan_title=#{@sample_title}&employer_logo=#{@card_config.employer_logo.filename}&network_logo=#{determine_network_logo}&FileType=PDF"
query: "reportConn=BrittonConnect&cardTemplate=#{@card_setup.card_template}&printType=SampleCard&sample_key=#{@sample_key}&sample_plan_title=#{@sample_title}&employer_logo=#{@card_setup.employer_logo.filename}&network_logo=#{determine_network_logo}&FileType=PDF"
}
end
@@ -1,17 +1,17 @@
module IdCardPrinter
module IdCardPrinterService
class SamplePdfProcessor
def initialize(employer)
@employer = employer
@card_config = @employer.id_card_configuration
@card_setup = @employer.id_card_setup
end
def call
group_cards_pdf = CombinePDF.new
IdCard::PrintData.where(employer_name: @employer.name).each do |card|
url = IdCardPrinter::SampleJasperUrlGenerator.new(@employer, card.sample_key, card.sample_plan_title).call
url = IdCardPrinterService::SampleJasperUrlGenerator.new(@employer, card.sample_key, card.sample_plan_title).call
puts url
card_pdf = IdCardPrinter::JasperPdfGenerator.new(url).call
card_pdf = IdCardPrinterService::JasperPdfGenerator.new(url).call
group_cards_pdf << card_pdf
end
@@ -1,11 +1,11 @@
module EmployerCards
module IdCardQueueService
class GetQueuedCards
def initialize(pl_plan_keys = nil)
if pl_plan_keys
@employer_pl_plan_keys = pl_plan_keys
else
@employer_pl_plan_keys = IdCard::Configuration.active.pluck(:pl_plan_key).join(',')
@employer_pl_plan_keys = IdCard::Setup.active.pluck(:pl_plan_key).join(',')
end
end
@@ -1,8 +1,8 @@
module EmployerCards
module IdCardQueueService
class GetQueuedCounts
def initialize()
@employer_pl_plan_keys = IdCard::Configuration.active.pluck(:pl_plan_key).join(',')
@employer_pl_plan_keys = IdCard::Setup.active.pluck(:pl_plan_key).join(',')
end
def call
@@ -1,4 +1,4 @@
class ImageProcessor
class ImageProcessorService
ALLOWED_LOGO_TYPES = ['Network', 'Employer'].freeze
def initialize(image_path, logo_type, new_filename = nil)
+3 -3
View File
@@ -32,7 +32,7 @@ module SampleCard
def set_plan_fields
plans_sample_cards = []
@employer.id_card_configuration.plans.each do |plan|
@employer.id_card_setup.plans.each do |plan|
plan_sample_card = @sample_card.dup
plan_name = plan.title.split(/(?<=\d[kK])/).first
plan_sample_card.family_id = plan_name
@@ -56,7 +56,7 @@ module SampleCard
end
def set_network_fields
selected_attributes = @employer.id_card_configuration.provider_section.attributes.with_indifferent_access.slice(
selected_attributes = @employer.id_card_setup.provider_section.attributes.with_indifferent_access.slice(
:provider_line_1, :provider_line_2, :provider_line_3, :provider_line_4, :provider_line_5, :provider_line_6,
:provider_line_7, :provider_line_8, :provider_line_9, :provider_line_10, :provider_line_11, :provider_line_12,
:claim_to_1, :claim_to_2, :claim_to_3, :claim_to_4, :claim_to_5, :claim_to_6,
@@ -71,7 +71,7 @@ module SampleCard
def set_rx_fields
# fairos_information = Vhcs::HlrxCrosRef.where(pl_plan_key: 52).first
selected_attributes = @employer.id_card_configuration.rx_section.attributes.with_indifferent_access.slice(
selected_attributes = @employer.id_card_setup.rx_section.attributes.with_indifferent_access.slice(
:customer_service,
:web_url
)