Prod build process

This commit is contained in:
Jason Jordan
2026-05-06 13:28:16 -04:00
parent 1d9025276d
commit e0101be567
223 changed files with 1861 additions and 7105 deletions
@@ -1,8 +1,9 @@
module AutomationService
class BatchEmployerUpdate
def initialize(pl_plan_keys = nil)
def initialize(pl_plan_keys = nil, full_sync = false)
@pl_plan_keys = pl_plan_keys
@full_sync = full_sync
end
def call
@@ -16,7 +17,7 @@ module AutomationService
employer_update_futures = employer_plan_headers.map do |employer_plan_header|
Concurrent::Future.execute do
ActiveRecord::Base.connection_pool.with_connection do
UpdateEmployerJob.perform_later(employer_plan_header: employer_plan_header)
UpdateEmployerJob.perform_later(employer_plan_header: employer_plan_header, full_sync: @full_sync)
end
end
end
@@ -10,13 +10,7 @@ module AutomationService
card_setup = employer.id_card_setup
puts "-- #{employer.name}"
# employer_members =[]
vw_mb_members = Vhcs::VwmbMember.where(enrollee_type_value_id: 1, pl_plan_key: @pl_plan_key).select(:mb_member_key, :pb_entity_key, :pl_plan_key, :family_id, :full_name_last_name_first, :social_security_number)
# vw_mb_members.each do |vw_mb_member|
# member = UpdateMemberJob.perform_now(@pb_entity_key, employer.id, card_setup.has_divisions, card_setup.has_dental, true, vw_mb_member)
# end
# employer.members = employer_members
# employer.save
member_update_futures = vw_mb_members.map do |vw_mb_member|
Concurrent::Future.execute do
@@ -28,7 +22,7 @@ module AutomationService
member_updates = member_update_futures.map(&:value).compact
employer.members = member_updates
if member_updates.empty? && employer.id_card_setup.active
if employer.initialized && card_setup.initialized && member_updates.empty?
employer.active = false
end
employer.save
@@ -6,14 +6,7 @@ module AutomationService
end
def call
# employer = Employer.includes(:id_card_setup).find_by(pl_plan_key: @pl_plan_key)
# card_setup = employer.id_card_setup
UpdateEmployerPlansJob.new.perform(@pl_plan_key)
# if employer.present?
# employer.save
# else
# Member.find_by(pb_entity_key: vw_mb_member[:pb_entity_key]).destroy
# end
end
end
@@ -7,17 +7,8 @@ module AutomationService
end
def call
# employer = Employer.includes(:id_card_setup).find_by(employer_identifier: @employer_identifier)
# card_setup = employer.id_card_setup
UpdateEmployerJob.new.perform(employer_identifier: @employer_identifier, full_sync: @full_sync)
# if employer.present?
# employer.save
# else
# Member.find_by(pb_entity_key: vw_mb_member[:pb_entity_key]).destroy
# end
end
end
end
# AutomationService::MemberUpdate('13', 337710)
end
@@ -19,5 +19,3 @@ module AutomationService
end
end
# AutomationService::MemberUpdate('13', 337710)
@@ -1,163 +0,0 @@
class WordDocProcessorOld
def initialize(word_doc, process=nil)
@word_doc = word_doc
if process
@process = process
else
@process = EmployerSetupProcess.new
end
end
def call
doc = Docx::Document.open(@word_doc)
index = 40
general_information = doc.paragraphs.slice(0, index)
plan_information = doc.paragraphs.slice(index + 1..)
general_fields(general_information)
plans(plan_information)
employer_logo()
@process
end
private
def general_fields(general_information)
fields = ['Group Number:', 'Employer Name:', 'Group Effective Date:']
general_information.each do |gi|
field_string = gi.to_s
if field_string.include?('Group Number:')
value = field_string.delete_prefix('Group Number:').strip
if is_number?(value)
@process.group_number = value
end
elsif field_string.include?('Employer Name:')
value = field_string.delete_prefix('Employer Name:').strip
@process.name = value
elsif field_string.include?('Group Effective Date:')
value = field_string.delete_prefix('Group Effective Date:').strip
@process.effective_date = value
end
end
end
def employer_logo
extracted_images = []
Zip::File.open(@word_doc) do |zip_file|
zip_file.each do |entry|
if entry.name.start_with?('word/media/') && !entry.directory?
filename = File.basename(entry.name)
image_data = entry.get_input_stream.read
extracted_images << { filename: filename, data: image_data }
end
end
end
if extracted_images.length > 1
@process.employer_logo = @process.name.titleize.gsub(/\s+/, '').concat("Logo.png")
# same file logic
end
end
def plans(plan_information)
plans_array = []
plan_information.each_with_index do |pin, i|
if pin.to_s.match?(/\d*\.?\d+k/i)
new_plan = {title: pin.to_s.strip, start_index: i, benefits: []}
plans_array.push(new_plan)
end
end
plans_array.each do |pl|
new_plan = Plan.create(title: pl[:title], employer_setup_process: @process)
plan_fields = plan_information.slice(pl[:start_index] + 1, 14)
plan_fields.each_with_index do |pf, i|
field_string = pf.to_s
if field_string.strip.length > 1
case field_string
when ->(string) { string.include?("Physician Visit") }
value = field_string.delete_prefix("Physician Visit")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "Primary Visit")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Specialist Visit") }
value = field_string.delete_prefix("Specialist Visit")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "Specialist Visit")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Urgent Care") }
value = field_string.delete_prefix("Urgent Care")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "Urgent Care")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Individual Deductible (in network )") }
value = field_string.delete_prefix("Individual Deductible (in network )")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "INNInd Ded")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Family Deductible(in network )") }
value = field_string.delete_prefix("Family Deductible(in network )")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "INNFamily Ded")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Individual Deductible (out of network)") }
value = field_string.delete_prefix("Individual Deductible (out of network)")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "OONInd Ded")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Family Deductible (out of network) ") }
value = field_string.delete_prefix("Family Deductible (out of network) ")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "OONFamily Ded")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Co-Insurance") }
value = field_string.delete_prefix("Co-Insurance")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "Co-Insurance")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Out-of-Pocket(in network) ") }
value = field_string.delete_prefix("Out-of-Pocket(in network) ")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "INNInd OOP")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Out-of-Pocket Family(in network) ") }
value = field_string.delete_prefix("Out-of-Pocket Family(in network) ")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "INNFamily OOP")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Out-of-Pocket(out of network) ") }
value = field_string.delete_prefix("Out-of-Pocket(out of network) ")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "OONInd OOP")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Out-of-Pocket Family (out of network) ") }
value = field_string.delete_prefix("Out-of-Pocket Family (out of network) ")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "OONFamily OOP")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Emergency Room ") }
value = field_string.delete_prefix("Emergency Room ")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "Emergency Room")
new_benefit.benefit = value
new_benefit.save
when ->(string) { string.include?("Preventive Care") }
value = field_string.delete_prefix("Preventive Care")
new_benefit = new_plan.plan_benefits.find_by(benefit_desc: "Preventive Care")
new_benefit.benefit = value
new_benefit.save
end
end
end
end
end
def is_number?(string)
true if Float(string) rescue false
end
end
@@ -1,76 +0,0 @@
module BenefitsWordDocService
class MapEmployerInformation
def initialize(employer, word_doc_section)
@employer = employer
@card_setup = @employer.id_card_setup
@word_doc_section = word_doc_section
end
def call
search_fields = mapping_hash.keys.to_set
@word_doc_section.each do |line|
matching_field = search_fields.detect { |field| line.include?(field) }
if matching_field
field_mapping = mapping_hash[matching_field]
field_regex = field_mapping[:doc_to_employer_regex]
field_value = line.match(field_regex)[1].strip
employer_field = field_mapping[:employer_field]
if field_mapping[:validation].present?
validation_type = field_mapping[:validation]
if send("is_#{validation_type}?".to_sym, field_value)
@employer[employer_field] = field_value
end
else
@employer[employer_field] = field_value
end
end
end
@card_setup.print_name = @employer.name
@employer.name = @employer.name.titleize
@card_setup.rx_group_number = @employer.group_number
@employer
end
private
def mapping_hash
{
'Employer Name' => {
employer_field: :name,
doc_field: 'Employer Name',
doc_field_desc: 'Follows pattern - Employer Name:New Employer',
doc_to_employer_regex: /.*:(.*)/,
regex_desc: 'Grabs everything after colon'
},
'Group Number' => {
employer_field: :group_number,
doc_field: 'Group Number',
doc_field_desc: 'Follows pattern - Group Number:099999',
doc_to_employer_regex: /.*:(.*)/,
regex_desc: 'Grabs everything after colon',
validation: 'number'
},
'Group Effective Date' => {
employer_field: :effective_date,
doc_field: 'Group Effective Date',
doc_field_desc: 'Follows pattern - Group Effective Date:12/1/2025',
doc_to_employer_regex: /.*:(.*)/,
regex_desc: 'Grabs everything after colon',
validation: 'date'
}
}
end
def is_number?(string)
true if Float(string) rescue false
end
def is_date?(string)
true if Date.parse rescue false
end
end
end
@@ -1,78 +0,0 @@
module BenefitsWordDocService
class MapEmployerLogo
def initialize(employer, word_doc)
@employer = employer
@card_setup = @employer.id_card_setup
@word_doc = word_doc
end
def call
Zip::File.open(@word_doc) do |zip_file|
media_files = zip_file.select { |entry| entry.name.start_with?('word/media/') && !entry.directory? }
if media_files.length > 1
logo = media_files.last
file_extension = File.extname(logo.name)
meme_type = Marcel::MimeType.for(logo.get_input_stream)
image_binary = logo.get_input_stream.read
# image_binary = File.binread(logo.get_input_stream.read)
filename = @employer.name_to_logo_filename(file_extension)
logo = IdCard::EmployerLogo.find_or_create_by(filename: filename) do |clf|
clf.image_data = image_binary
clf.content_type = meme_type
end
# new_logo = CardLogoFile.create!(
# filename: filename,
# image_data: image_binary,
# content_type: meme_type,
# logo_type: "employer"
# )
# image_io = StringIO.new(image_binary)
# width, height = FastImage.size(image_io)
# image_ratio = width.to_f / height
# if (0.8..1.2).cover?(image_ratio)
# @employer.single_card_template = "FairosRxIDCard-Half"
# else
# @employer.single_card_template = "FairosRxIDCard"
# end
@card_setup.employer_logo = logo
end
end
@employer
end
# def call
# extracted_images = []
# Zip::File.open(@word_doc) do |zip_file|
# zip_file.each do |entry|
# if entry.name.start_with?('word/media/') && !entry.directory?
# file_extension = File.extname(entry.name)
# image_data = entry.get_input_stream.read
# extracted_images << { file_extension: file_extension, data: image_data }
# end
# end
# end
# if extracted_images.length > 1
# logo = extracted_images.last
# filename = @employer.employer_name_to_logo_filename(logo[:file_extension])
# employer_logo_binary = logo[:data]
# new_logo = @employer.card_logo_files.create(
# filename: filename,
# image: employer_logo_binary,
# logo_type: "employer"
# )
# @employer.employer_logo = new_logo.filename
# # same file logic
# end
# @employer.save
# end
end
end
@@ -1,44 +0,0 @@
module BenefitsWordDocService
class MapNetworkInformation
def initialize(employer, word_doc_section)
@employer = employer
@card_setup = @employer.id_card_setup
@word_doc_section = word_doc_section
end
def call
# network = @word_doc_section.each do |line|
# if line.match?(/cigna/i)
# return "Cigna"
# elsif line.match?(/medcost/i)
# return "Medcost"
# end
# end
network = @word_doc_section.find do |line|
if line.match?(/cigna/i)
break "Cigna"
elsif line.match?(/medcost/i)
break "MedCost"
end
end
# yellow_fruit_names_filtered = @word_doc_section.filter_map do |line|
# item[:name] if item[:color] == 'yellow'
# end
if network
@card_setup.network_provider = network
logo_name = "#{network}Logo.png"
@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
@employer
end
end
end
@@ -1,278 +0,0 @@
module BenefitsWordDocService
class MapPlansInformation
def initialize(employer, word_doc_section)
@employer = employer
@card_setup = @employer.id_card_setup
@word_doc_section = word_doc_section
end
def call
search_fields = mapping_hash.keys.to_set
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_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]
if line.match(/(?<=:).+/)
field_value = line.match(/(?<=:).+/)[0].strip
else
field_regex = field_mapping[:doc_to_employer_regex]
if line.match(field_regex)
field_value = line.match(field_regex)[0].strip
elsif line.match(default_benefit_regex(field_mapping[:employer_benefit_desc_field]))
field_value = line.match(default_benefit_regex(field_mapping[:employer_benefit_desc_field]))[0].strip
else
field_value = line
end
end
employer_benefit_desc_field = field_mapping[:employer_benefit_desc_field]
new_benefit = new_plan.plan_benefits[i]
new_benefit.benefit = field_value
# matching_field = search_fields.detect { |field| line.include?(field) }
# if matching_field
# field_mapping = mapping_hash[matching_field]
# field_regex = field_mapping[:doc_to_employer_regex]
# if line.match(field_regex)
# field_value = line.match(field_regex)[0].strip
# elsif line.match(default_benefit_regex(field_mapping[:employer_benefit_desc_field]))
# field_value = line.match(default_benefit_regex(field_mapping[:employer_benefit_desc_field]))[0].strip
# else
# field_value = ""
# end
# employer_benefit_desc_field = field_mapping[:employer_benefit_desc_field]
# new_benefit = new_plan.plan_benefits.find_by(benefit_desc: employer_benefit_desc_field)
# new_benefit.benefit = field_value
# new_benefit.save
# end
end
end
@employer
end
private
def mapping_array
[
{
employer_benefit_sequence: 1,
employer_benefit_desc_field: 'Primary Visit',
doc_field_desc: 'Follows pattern - Physician Visit$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 2,
employer_benefit_desc_field: 'Specialist Visit',
doc_field_desc: 'Follows pattern - Specialist Visit$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 3,
employer_benefit_desc_field: 'Urgent Care',
doc_field_desc: 'Follows pattern - Urgent Care$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 4,
employer_benefit_desc_field: 'INNInd Ded',
doc_field_desc: 'Follows pattern - Individual Deductible (in network )$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 5,
employer_benefit_desc_field: 'INNFamily Ded',
doc_field_desc: 'Follows pattern - Family Deductible(in network )$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 6,
employer_benefit_desc_field: 'OONInd Ded',
doc_field_desc: 'Follows pattern - Individual Deductible (out of network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 7,
employer_benefit_desc_field: 'OONFamily Ded',
doc_field_desc: 'Follows pattern - Family Deductible (out of network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 8,
employer_benefit_desc_field: 'Co-Insurance',
doc_field_desc: 'Follows pattern - Co-Insurance70%/30%',
doc_to_employer_regex: /(?<=Co-Insurance).*/,
regex_desc: 'Grabs everything after field name'
},
{
employer_benefit_sequence: 9,
employer_benefit_desc_field: 'INNInd OOP',
doc_field_desc: 'Follows pattern - Out-of-Pocket(in network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 10,
employer_benefit_desc_field: 'INNFamily OOP',
doc_field_desc: 'Follows pattern - Out-of-Pocket Family(in network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 11,
employer_benefit_desc_field: 'OONInd OOP',
doc_field_desc: 'Follows pattern - Out-of-Pocket(out of network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 12,
employer_benefit_desc_field: 'OONFamily OOP',
doc_field_desc: 'Follows pattern - Out-of-Pocket Family (out of network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
{
employer_benefit_sequence: 13,
employer_benefit_desc_field: 'Emergency Room',
doc_field_desc: 'Follows pattern - Emergency RoomXxxxx',
doc_to_employer_regex: /(?<=Emergency Room).*/,
regex_desc: 'Grabs everything after field name'
},
{
employer_benefit_sequence: 14,
employer_benefit_desc_field: 'Preventive Care',
doc_field_desc: 'Follows pattern - Preventive Care100%',
doc_to_employer_regex: /(?<=Preventive Care).*/,
regex_desc: 'Grabs everything after field name'
}
]
end
def mapping_hash
{
'Physician Visit' => {
employer_benefit_sequence: 1,
employer_benefit_desc_field: 'Primary Visit',
doc_field_desc: 'Follows pattern - Physician Visit$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Specialist Visit' => {
employer_benefit_sequence: 2,
employer_benefit_desc_field: 'Specialist Visit',
doc_field_desc: 'Follows pattern - Specialist Visit$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Urgent Care' => {
employer_benefit_sequence: 3,
employer_benefit_desc_field: 'Urgent Care',
doc_field_desc: 'Follows pattern - Urgent Care$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Individual Deductible' => {
employer_benefit_sequence: 4,
employer_benefit_desc_field: 'INNInd Ded',
doc_field_desc: 'Follows pattern - Individual Deductible (in network )$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Family Deductible' => {
employer_benefit_sequence: 5,
employer_benefit_desc_field: 'INNFamily Ded',
doc_field_desc: 'Follows pattern - Family Deductible(in network )$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Individual Deductible' => {
employer_benefit_sequence: 6,
employer_benefit_desc_field: 'OONInd Ded',
doc_field_desc: 'Follows pattern - Individual Deductible (out of network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Family Deductible' => {
employer_benefit_sequence: 7,
employer_benefit_desc_field: 'OONFamily Ded',
doc_field_desc: 'Follows pattern - Family Deductible (out of network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Co-Insurance' => {
employer_benefit_sequence: 8,
employer_benefit_desc_field: 'Co-Insurance',
doc_field_desc: 'Follows pattern - Co-Insurance70%/30%',
doc_to_employer_regex: /(?<=Co-Insurance).*/,
regex_desc: 'Grabs everything after field name'
},
'Out-of-Pocket' => {
employer_benefit_sequence: 9,
employer_benefit_desc_field: 'INNInd OOP',
doc_field_desc: 'Follows pattern - Out-of-Pocket(in network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Out-of-Pocket Family' => {
employer_benefit_sequence: 10,
employer_benefit_desc_field: 'INNFamily OOP',
doc_field_desc: 'Follows pattern - Out-of-Pocket Family(in network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Out-of-Pocket' => {
employer_benefit_sequence: 11,
employer_benefit_desc_field: 'OONInd OOP',
doc_field_desc: 'Follows pattern - Out-of-Pocket(out of network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Out-of-Pocket Family' => {
employer_benefit_sequence: 12,
employer_benefit_desc_field: 'OONFamily OOP',
doc_field_desc: 'Follows pattern - Out-of-Pocket Family (out of network)$x,xxx',
doc_to_employer_regex: /\$.*/,
regex_desc: 'Grabs dollar sign and everything after'
},
'Emergency Room' => {
employer_benefit_sequence: 13,
employer_benefit_desc_field: 'Emergency Room',
doc_field_desc: 'Follows pattern - Emergency RoomXxxxx',
doc_to_employer_regex: /(?<=Emergency Room).*/,
regex_desc: 'Grabs everything after field name'
},
'Preventive Care' => {
employer_benefit_sequence: 14,
employer_benefit_desc_field: 'Preventive Care',
doc_field_desc: 'Follows pattern - Preventive Care100%',
doc_to_employer_regex: /(?<=Preventive Care).*/,
regex_desc: 'Grabs everything after field name'
},
}
end
def default_benefit_regex(field)
/(?<=#{field}).*/
end
def is_number?(string)
true if Float(string) rescue false
end
def is_date?(string)
true if Date.parse rescue false
end
end
end
@@ -1,35 +0,0 @@
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
@@ -0,0 +1,8 @@
class BetaAutomationSimulationService
def initialize()
end
def call
Rails::Command.invoke('employer_automation:employer_initialize_test')
end
end
@@ -1,160 +0,0 @@
module EmployerCards
class DataFormatter
def initialize(employer)
@employer = employer
end
def call
@members = @employer.members.order(:name)
@employer_cards = []
init_cards_and_set_member_fields
set_plan_fields
set_common_fields
@employer_cards.each(&:save!)
end
private
def init_cards_and_set_common_fields
employer_attributes = {
employer_name: @employer.id_card_display_name,
group_number: @employer.group_number,
rx_group: @employer.rx_group_number
}
rx_attributes = @employer.card_rx.attributes.with_indifferent_access.slice(
:customer_service,
:web_url
)
provider_attributes = @employer.card_provider.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_common_fields
employer_attributes = {
employer_name: @employer.id_card_display_name,
group_number: @employer.group_number,
rx_group: @employer.rx_group_number
}
rx_attributes = @employer.card_rx.attributes.with_indifferent_access.slice(
:customer_service,
:web_url
)
provider_attributes = @employer.card_provider.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
@employer.plans.each do |plan|
selected_attributes = {}
plan.plan_benefits.each do |bene|
selected_attributes["benefit_desc_#{bene.sequence}".to_sym] = bene.benefit_desc
selected_attributes["benefit_#{bene.sequence}".to_sym] = bene.benefit
end
@employer_cards.find_all { |card| card.plan_id == plan.id.to_s }.each do |card|
card.assign_attributes(selected_attributes)
end
end
end
def init_cards_and_set_member_fields
@group_dependents = Vhcs::VwmbMember.where(pl_plan_key: @employer.pl_plan_key)
@members.each do |me|
effect_date = determine_eff_date(me)
if effect_date
member_card = SampleIdCard.new()
member_attributes = {
full_name: me.id_card_display_name,
name: me.name,
primary_mb_member_key: me.pb_entity_key,
family_id: me.family_id,
plan_id: me.plan_id,
medical_eff_date: effect_date.strftime("%m/%d/%Y")
}
dependent_attributes = get_dependent_fields(me)
selected_attributes = member_attributes.merge(dependent_attributes)
member_card.assign_attributes(selected_attributes)
@employer_cards.push(member_card)
if dependent_attributes.present?
@employer_cards.push(member_card)
end
end
end
end
# def set_network_fields
# selected_attributes = @employer.card_provider.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
# )
# @employer_cards.all do |card|
# card.assign_attributes(selected_attributes)
# end
# end
# def set_rx_fields
# # fairos_information = Vhcs::HlrxCrosRef.where(pl_plan_key: 52).first
# selected_attributes = @employer.card_rx.attributes.with_indifferent_access.slice(
# :customer_service,
# :web_url
# )
# @employer_cards.all do |card|
# card.assign_attributes(selected_attributes)
# end
# end
def determine_eff_date(member)
participation = Vhcs::PbProductParticipation.joins('INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"').where('"PBCoveredEntities"."PBEntityKey" = ?', member.pb_entity_key).last
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
in_effect
else
false
end
end
def get_dependent_fields(member)
dependent_attributes = {}
dependents = @group_dependents.where(family_id: member.family_id).where.not(pb_entity_key: member.pb_entity_key)
dependents.each do |dep|
dependent_name = dep.first_name + ' ' + dep.last_name
dependent_attributes["dependent_#{dep.sequence_number - 1}".to_sym] = dependent_name
end
dependent_attributes
end
end
end
@@ -1,41 +0,0 @@
module EmployerCards
class JasperUrlGenerator
def initialize(pl_plan_key, family_id, layout)
@pl_plan_key = pl_plan_key
@family_id = family_id
@layout = layout
@card_setup = IdCard::Setup.find_by(pl_plan_key: pl_plan_key)
end
def call
URI::HTTP.build(url_components)
end
private
def determine_network_logo
# if @network_logos.length > 1
# member_geographic_info = Vhcs::PbEntityAddress.joins("INNER JOIN vwMBMember ON PBEntityAddress.PBEntityKey = vwMBMember.PBEntityKey AND PBEntityAddress.AddressTypeID = 1137").where("vwMBMember.FamilyID = ?", @family_id).first
# @network_logos.where.not(default: true).each do |pnl|
# if member_geographic_info[pnl.exception_type] == pnl.exception_value
# return pnl.net_logo
# end
# end
# end
# @network_logos.find_by(default: true).net_logo
@employer.default_network_logo
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
def url_components
{
host: '10.41.1.115',
port: 8080,
path: '/trunk/IdCardsServlet',
query: "reportConn=BrittonConnect&cardTemplate=#{@employer.single_card_template}&printType=#{@layout}&family_id=#{@family_id }&employer_logo=#{@employer.employer_logo_filename}&network_logo=#{determine_network_logo}&FileType=PDF"
}
end
end
end
-53
View File
@@ -1,53 +0,0 @@
class EmployerCardsGenerator
def initialize(employer, layout)
@employer = employer
@layout = layout
end
def call
SampleIdCard.where(employer_name: @employer.id_card_display_name).destroy_all
EmployerCards::DataFormatter.new(@employer).call
if @layout == "FullPageCard"
group_cards_pdf_array = []
reprint = Vhcs::HlidCardEggData.where(group_number: @employer.group_number).pluck(:family_id)
SampleIdCard.where(employer_name: @employer.id_card_display_name).each do |card|
if reprint.include?(card.family_id)
url = EmployerCards::JasperUrlGenerator.new(@employer, card.family_id, @layout).call
puts url
card_pdf = SampleCard::JasperPdfGenerator.new(url).call
card_filename = "#{card.name.gsub(", ","_")}_digital_card_#{Date.today}.pdf"
# group_cards_pdf_array.add(card_filename, pdf_object.to_pdf)
group_cards_pdf_array << { name: card_filename, data: card_pdf.to_pdf }
end
end
# Initialize a string-based IO object
group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
group_cards_pdf_array.each do |file|
zio.put_next_entry(file[:name])
zio.write(file[:data])
end
end
else
group_cards_pdf = CombinePDF.new
reprint = Vhcs::HlidCardEggData.where(group_number: @employer.group_number).pluck(:family_id)
SampleIdCard.where(employer_name: @employer.id_card_display_name).each do |card|
if reprint.include?(card.family_id)
url = EmployerCards::JasperUrlGenerator.new(@employer, card.family_id, @layout).call
puts url
card_pdf = SampleCard::JasperPdfGenerator.new(url).call
group_cards_pdf << card_pdf
end
end
end
# todays_date = DateTime.current.strftime('%Y%m%d%H%M%S')
# group_cards_pdf.save("tmp/#{@employer.name}_print_cards_#{todays_date}.pdf")
group_cards_pdf
end
end
@@ -2,16 +2,10 @@ module IdCardPrinterService
class CardDataFormatter
def initialize(employers_member_keys)
# @employer = employer
@employers_member_keys = Array.wrap(employers_member_keys)
# @employer = Employer.includes(id_card_setup: [:provider_section, :rx_section]).find_by(pl_plan_key: pl_plan_key)
# @card_setup = @employer.id_card_setup
end
def call
# blank_card = IdCard::PrintData.new()
# @employer_cards = []
print_card_futures = []
@employers_member_keys.each do |emk|
pl_plan_key = emk[:pl_plan_key]
@@ -37,6 +31,7 @@ module IdCardPrinterService
def initialize_employer_base_card
employer_attributes = {
employer_id: @employer.id,
pl_plan_key: @employer.pl_plan_key,
group_number: @employer.group_number,
rx_group: @card_setup.rx_group_number,
@@ -62,7 +57,6 @@ module IdCardPrinterService
)
selected_attributes = employer_attributes.merge(rx_attributes).merge(provider_attributes)
# blank_card.assign_attributes(selected_attributes)
IdCard::PrintData.new(selected_attributes)
end
@@ -98,88 +92,7 @@ module IdCardPrinterService
end
mmember_card_futures
# batch_process = BatchProcess.create!(total_jobs: @member_keys.count)
# @member_keys.each do |member_key|
# ProcessIdCardDataJob.perform_later(member_key, @card_setup.has_divisions, batch_process.id)
# end
# @batch_id = batch_process.id
# @members.each do |me|
# effect_date = determine_eff_date(me)
# if effect_date
# member_card = @base_card.dup
# member_attributes = {
# full_name: me.id_card_display_name,
# full_name_last_name_first: me.name,
# primary_mb_member_key: me.pb_entity_key,
# family_id: me.family_id,
# plan_id: me.id_card_plan_id,
# 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)
# else
# selected_attributes = member_attributes
# end
# member_card.assign_attributes(selected_attributes)
# @employer_cards.push(member_card)
# end
# end
end
# def set_network_fields
# selected_attributes = @employer.card_provider.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
# )
# @employer_cards.all do |card|
# card.assign_attributes(selected_attributes)
# end
# end
# def set_rx_fields
# # fairos_information = Vhcs::HlrxCrosRef.where(pl_plan_key: 52).first
# selected_attributes = @employer.card_rx.attributes.with_indifferent_access.slice(
# :customer_service,
# :web_url
# )
# @employer_cards.all do |card|
# card.assign_attributes(selected_attributes)
# end
# end
def determine_eff_date(member)
participation = Vhcs::PbProductParticipation.joins('INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"').where('"PBCoveredEntities"."PBEntityKey" = ?', member.pb_entity_key).last
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
in_effect
else
false
end
end
def get_dependent_fields(member)
dependent_attributes = {}
dependents = @group_dependents.where(family_id: member.family_id).where.not(pb_entity_key: member.pb_entity_key)
dependents.each do |dep|
dependent_name = dep.first_name + ' ' + dep.last_name
dependent_attributes["dependent_#{dep.sequence_number - 1}".to_sym] = dependent_name
end
dependent_attributes
end
end
end
@@ -18,41 +18,14 @@ module IdCardPrinterService
template_groups = break_up_by_template(pl_plan_keys)
template_groups.each do |card_template, template_pl_plan_keys|
batch = IdCard::PrintData.where(pl_plan_key: template_pl_plan_keys)
# all_template_cards.in_batches(of: 75).each_with_index do |batch, index|
jasper_batch_id = "#{template_pl_plan_keys.join('_')}-#{Time.current.utc.to_i}"
# binding.pry
batch.update!(jasper_batch_id: jasper_batch_id)
if @layout == "PrintCard"
add_dependent_cards(batch)
end
batch_pdf = IdCardPrinterService::PdfBatchProcessor.new(card_template, jasper_batch_id, @layout).call
pdf_array << batch_pdf
# end
# jasper_batches = break_into_jasper_batches(group_pl_plan_keys)
# jasper_batches.each_with_index do |batch, index|
# jasper_batch_id = "#{group_pl_plan_keys.join('_')}-#{index + 1}-#{Time.current.utc.to_i}"
# binding.pry
# batch.update!(jasper_batch_id: jasper_batch_id)
# if @layout == "PrintCard"
# add_dependent_cards(batch)
# end
# batch_pdf = IdCardPrinterService::PdfBatchProcessor.new(card_template, jasper_batch_id, @layout).call
# pdf_array << batch_pdf
# end
jasper_batch_id = "#{template_pl_plan_keys.join('_')}-#{Time.current.utc.to_i}"
batch.update!(jasper_batch_id: jasper_batch_id)
if @layout == "PrintCard"
add_dependent_cards(batch)
end
batch_pdf = IdCardPrinterService::PdfBatchProcessor.new(card_template, jasper_batch_id, @layout).call
pdf_array << batch_pdf
end
# @employers_member_keys.each do |emk|
# employer_jasper_batches = IdCard::PrintData.where(pl_plan_key: emk[:pl_plan_key]).pluck(:network_logo_id).uniq
# employer_jasper_batches.each do |batch_network_logo|
# jasper_batch_id = "#{emk[:pl_plan_key]}-#{Time.current.utc.to_i}"
# batch = IdCard::PrintData.where(pl_plan_key: emk[:pl_plan_key], network_logo_id: batch_network_logo)
# # batch = employer_card_data.where(network_logo_id: batch_network_logo)
# batch.update!(jasper_batch_id: jasper_batch_id)
# batch_pdf = IdCardPrinterService::PdfBatchProcessor.new(emk[:pl_plan_key], batch_network_logo, jasper_batch_id, @layout).call
# pdf_array << batch_pdf
# end
# end
group_pdfs = combine_pdfs(pdf_array)
group_pdfs
@@ -67,13 +40,6 @@ module IdCardPrinterService
.compact_blank
end
def break_into_jasper_batches(pl_plan_keys)
all_cards = IdCard::PrintData.where(pl_plan_key: pl_plan_keys)
binding.pry
jasper_batches = all_cards.each_slice(75).to_a
jasper_batches
end
def add_dependent_cards(batch)
batch.where.not(dependent_1: [nil, ""]).find_each do |member_card|
dependent_card = member_card.dup
@@ -1,61 +0,0 @@
module IdCardPrinterService
class EmployerCardsGenerator
def initialize(employer, layout, zip=false)
@employer = employer
@member_keys = @employer.members.pluck(:pb_entity_key)
@layout = layout
@zip = zip
end
def call
IdCard::PrintData.where(pl_plan_key: @employer.pl_plan_key).destroy_all
IdCardPrinterService::EmployerDataFormatter.new(@employer.pl_plan_key, @member_keys).call
# card_futures.each(&:value)
# max_retries = 60
# retries = 0
# finished = false
# batch_process = BatchProcess.find(batch_id)
# until finished || retries > max_retries
# # Solid Queue stores finished jobs here if preserve_finished_jobs = true
# if batch_process.completed_jobs < batch_process.total_jobs
# sleep 0.5
# retries += 1
# else
# batch_process.destroy!
# finished = true
# end
# end
IdCard::PrintData.where(pl_plan_key: @employer.pl_plan_key, primary_mb_member_key: nil).destroy_all
pdf_array = IdCardPrinterService::PdfProcessor.new(@employer, @layout, @zip).call
group_pdfs = combine_pdfs(pdf_array)
group_pdfs
end
private
def combine_pdfs(pdf_array)
if @zip
group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
pdf_array.each do |file|
zio.put_next_entry(file[:name])
zio.write(file[:data])
end
end
else
group_cards_pdf = CombinePDF.new
pdf_array.each { |pdf| group_cards_pdf << pdf }
end
group_cards_pdf
end
end
end
@@ -1,167 +0,0 @@
module IdCardPrinterService
class EmployerDataFormatter
def initialize(pl_plan_key, member_keys)
# @employer = employer
@member_keys = member_keys
@employer = Employer.includes(id_card_setup: [:provider_section, :rx_section]).find_by(pl_plan_key: pl_plan_key)
@card_setup = @employer.id_card_setup
@batch_id
end
def call
# blank_card = IdCard::PrintData.new()
# @employer_cards = []
base_card = initialize_employer_base_card()
create_plan_base_cards(base_card)
card_futures = create_member_cards_async()
card_futures
end
private
def initialize_employer_base_card
employer_attributes = {
pl_plan_key: @employer.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_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
)
selected_attributes = employer_attributes.merge(rx_attributes).merge(provider_attributes)
# blank_card.assign_attributes(selected_attributes)
IdCard::PrintData.new(selected_attributes)
end
def create_plan_base_cards(common_fields_card)
needed_plans_ids = @employer.members.where(pb_entity_key: @member_keys).distinct.pluck(:id_card_plan_id)
needed_plans = @card_setup.plans.where(id: needed_plans_ids)
needed_plans.each do |plan|
selected_attributes = { plan_id: plan.id }
plan.plan_benefits.each do |bene|
selected_attributes["benefit_desc_#{bene.sequence}".to_sym] = bene.benefit_desc
selected_attributes["benefit_#{bene.sequence}".to_sym] = bene.benefit
end
plan_base_card = common_fields_card.dup
plan_base_card.assign_attributes(selected_attributes)
plan_base_card.save
end
end
def create_member_cards_async
mmember_card_futures = @member_keys.map do |member_key|
Concurrent::Future.execute do
ActiveRecord::Base.connection_pool.with_connection do
ProcessIdCardDataJob.perform_now(member_key, @card_setup.has_divisions)
end
end
end
mmember_card_futures
# batch_process = BatchProcess.create!(total_jobs: @member_keys.count)
# @member_keys.each do |member_key|
# ProcessIdCardDataJob.perform_later(member_key, @card_setup.has_divisions, batch_process.id)
# end
# @batch_id = batch_process.id
# @members.each do |me|
# effect_date = determine_eff_date(me)
# if effect_date
# member_card = @base_card.dup
# member_attributes = {
# full_name: me.id_card_display_name,
# full_name_last_name_first: me.name,
# primary_mb_member_key: me.pb_entity_key,
# family_id: me.family_id,
# plan_id: me.id_card_plan_id,
# 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)
# else
# selected_attributes = member_attributes
# end
# member_card.assign_attributes(selected_attributes)
# @employer_cards.push(member_card)
# end
# end
end
# def set_network_fields
# selected_attributes = @employer.card_provider.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
# )
# @employer_cards.all do |card|
# card.assign_attributes(selected_attributes)
# end
# end
# def set_rx_fields
# # fairos_information = Vhcs::HlrxCrosRef.where(pl_plan_key: 52).first
# selected_attributes = @employer.card_rx.attributes.with_indifferent_access.slice(
# :customer_service,
# :web_url
# )
# @employer_cards.all do |card|
# card.assign_attributes(selected_attributes)
# end
# end
def determine_eff_date(member)
participation = Vhcs::PbProductParticipation.joins('INNER JOIN "PBCoveredEntities" ON "PBProductParticipation"."PBProductParticipationKey" = "PBCoveredEntities"."PBProductParticipationKey"').where('"PBCoveredEntities"."PBEntityKey" = ?', member.pb_entity_key).last
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
in_effect
else
false
end
end
def get_dependent_fields(member)
dependent_attributes = {}
dependents = @group_dependents.where(family_id: member.family_id).where.not(pb_entity_key: member.pb_entity_key)
dependents.each do |dep|
dependent_name = dep.first_name + ' ' + dep.last_name
dependent_attributes["dependent_#{dep.sequence_number - 1}".to_sym] = dependent_name
end
dependent_attributes
end
end
end
@@ -28,13 +28,15 @@ module IdCardPrinterService
# 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
def url_components
{
host: '10.41.1.115',
port: 8080,
path: '/trunk/IdCardsServlet',
components = {
host: ENV["JASPER_SERVER_HOST"],
path: '/IdCardsServlet',
query: "reportConn=BrittonConnect&cardTemplate=#{@card_template}&printType=#{@layout}&jasper_batch_id=#{@jasper_batch_id}&FileType=PDF"
}
if ENV["JASPER_SERVER_PORT"].present?
components.merge!(port: ENV["JASPER_SERVER_PORT"])
end
components
end
end
end
@@ -9,7 +9,6 @@ module IdCardPrinterService
def call
response = HTTParty.get(@jasper_url)
# response.body
CombinePDF.parse(response.body)
end
@@ -1,41 +0,0 @@
module IdCardPrinterService
class JasperUrlGenerator
def initialize(pl_plan_key, family_id, layout)
@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
def call
URI::HTTP.build(url_components)
end
private
def determine_network_logo
# if @network_logos.length > 1
# member_geographic_info = Vhcs::PbEntityAddress.joins("INNER JOIN vwMBMember ON PBEntityAddress.PBEntityKey = vwMBMember.PBEntityKey AND PBEntityAddress.AddressTypeID = 1137").where("vwMBMember.FamilyID = ?", @family_id).first
# @network_logos.where.not(default: true).each do |pnl|
# if member_geographic_info[pnl.exception_type] == pnl.exception_value
# return pnl.net_logo
# end
# end
# end
# @network_logos.find_by(default: true).net_logo
@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
def url_components
{
host: '10.41.1.115',
port: 8080,
path: '/trunk/IdCardsServlet',
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
end
end
@@ -1,38 +0,0 @@
module IdCardPrinterService
class MemberCardsGenerator
def initialize(member_keys, layout)
@member_keys = Array.wrap(member_keys)
@employer = employer
@layout = layout
@zip = zip
end
def call
IdCard::PrintData.where(mb_member_key: @employer.pl_plan_key).destroy_all
IdCardPrinterService::EmployerDataFormatter.new(@employer).call
pdf_array = IdCardPrinterService::PdfProcessor.new(@employer, @layout, @zip).call
group_pdfs = combine_pdfs(pdf_array)
group_pdfs
end
private
def combine_pdfs(pdf_array)
if @zip
group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
pdf_array.each do |file|
zio.put_next_entry(file[:name])
zio.write(file[:data])
end
end
else
group_cards_pdf = CombinePDF.new
pdf_array.each { |pdf| group_cards_pdf << pdf }
end
end
end
end
@@ -8,28 +8,10 @@ module IdCardPrinterService
end
def call
# if @zip
# group_cards_pdf_array = []
# else
# group_cards_pdf = CombinePDF.new
# end
url = IdCardPrinterService::JasperBatchUrlGenerator.new(@card_template, @jasper_batch_id, @layout).call
puts url
batch_pdf = IdCardPrinterService::JasperPdfGenerator.new(url).call
# if @zip
# group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
# group_cards_pdf_array.each do |file|
# zio.put_next_entry(file[:name])
# zio.write(file[:data])
# end
# end
# # else
# # todays_date = DateTime.current.strftime('%Y%m%d%H%M%S')
# # group_cards_pdf.save("tmp/#{@employer.name}_print_cards_#{todays_date}.pdf")
# end
batch_pdf
end
end
@@ -1,118 +0,0 @@
module IdCardPrinterService
class PdfFormatter
def initialize(pdf_array ,layout, zip=false)
@pdf_array = pdf_array
@layout = layout
@zip = zip
end
def call
if @layout == "FullPageCard"
pdf_file = @pdf_array.first
puts "-- CombinePdfPages --"
puts pdf_file.pages.count
pdf_file.pages.reverse.each do |page|
page_pdf = CombinePDF.new
page_pdf << page
page_data = page_pdf.to_pdf
full_name_last_name_first = get_watermark_field(page_data)
if full_name_last_name_first.present?
page_filename = "#{full_name_last_name_first.gsub(", ", "_")}_digital_card_#{Date.today}.pdf"
group_cards_pdf_array << { name: page_filename, data: page_data }
end
end
group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
pdf_file = pdf_array.first
puts "-- CombinePdfPages --"
puts pdf_file.pages.count
pdf_file.pages.reverse.each do |page|
page_pdf = CombinePDF.new
page_pdf << page
page_data = page_pdf.to_pdf
full_name_last_name_first = get_watermark_field(page_data)
if full_name_last_name_first.present?
page_filename = "#{full_name_last_name_first.gsub(", ", "_")}_digital_card_#{Date.today}.pdf"
puts "-- Filename --"
puts page_filename
zio.put_next_entry(page_filename)
zio.write(page_data)
end
end
end
else
group_cards_pdf = CombinePDF.new
pdf_array.each { |pdf| group_cards_pdf << pdf }
end
group_cards_pdf
end
private
def get_watermark_field(page_data)
watermark_field = ""
reader = PDF::Reader.new(StringIO.new(page_data))
puts "-- ReaderPages --"
puts reader.pages.count
page = reader.pages.first
if watermark_match = page.text.match(/:WATERMARK:([^:]*):/)
watermark_field = page.text.match(/:WATERMARK:([^:]*):/)[1].strip
else
puts "blank page"
end
watermark_field
end
def break_into_batches(pl_plan_keys)
batches_by_card_template = IdCard::Setup.where(pl_plan_key: pl_plan_keys).group_by(&:card_template)
.transform_values { |setups| setups.map(&:pl_plan_key) }
.compact_blank
end
def combine_pdfs(pdf_array)
if @zip
group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
pdf_file = pdf_array.first
puts "-- CombinePdfPages --"
puts pdf_file.pages.count
pdf_file.pages.reverse.each do |page|
page_pdf = CombinePDF.new
page_pdf << page
page_data = page_pdf.to_pdf
full_name_last_name_first = get_watermark_field(page_data)
if full_name_last_name_first.present?
page_filename = "#{full_name_last_name_first.gsub(", ", "_")}_digital_card_#{Date.today}.pdf"
puts "-- Filename --"
puts page_filename
zio.put_next_entry(page_filename)
zio.write(page_data)
end
end
end
else
group_cards_pdf = CombinePDF.new
pdf_array.each { |pdf| group_cards_pdf << pdf }
end
group_cards_pdf
end
def get_watermark_field(page_data)
watermark_field = ""
reader = PDF::Reader.new(StringIO.new(page_data))
puts "-- ReaderPages --"
puts reader.pages.count
page = reader.pages.first
if watermark_match = page.text.match(/:WATERMARK:([^:]*):/)
watermark_field = page.text.match(/:WATERMARK:([^:]*):/)[1].strip
else
puts "blank page"
end
watermark_field
end
end
end
@@ -1,44 +0,0 @@
module IdCardPrinterService
class PdfProcessor
def initialize(employer, layout, zip = false)
@employer = employer
@layout = layout
@zip = zip
end
def call
# if @zip
# group_cards_pdf_array = []
# else
# group_cards_pdf = CombinePDF.new
# end
group_cards_pdf_array = []
IdCard::PrintData.where(pl_plan_key: @employer.pl_plan_key).each do |card|
url = IdCardPrinterService::JasperUrlGenerator.new(@employer.pl_plan_key, card.family_id, @layout).call
puts url
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 }
else
group_cards_pdf_array << card_pdf
end
end
# if @zip
# group_cards_pdf = Zip::OutputStream.write_buffer do |zio|
# group_cards_pdf_array.each do |file|
# zio.put_next_entry(file[:name])
# zio.write(file[:data])
# end
# end
# # else
# # todays_date = DateTime.current.strftime('%Y%m%d%H%M%S')
# # group_cards_pdf.save("tmp/#{@employer.name}_print_cards_#{todays_date}.pdf")
# end
group_cards_pdf_array
end
end
end
@@ -1,62 +0,0 @@
module IdCardPrinterService
class QueuedCardsGenerator
def initialize(employer_member_keys)
@employer_member_keys = Array.wrap(employer_member_keys)
@layout = 'PrintCard'
@pl_plan_keys = @employer_member_keys.map { |emk| emk["PlanKey"].to_s }
end
def call
white_card_array = []
blue_card_array = []
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)
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 = IdCardPrinterService::PdfProcessor.new(employer, @layout).call
end
end
combine_pdfs(blue_card_array, white_card_array)
end
private
def combine_pdfs(blue_cards, white_cards)
if blue_cards.present? && white_cards.present?
combined_pdfs = []
blue_filename = "queued_blue_cards_#{Date.today}.pdf"
combined_pdfs << { name: blue_filename, data: blue_cards.to_pdf }
white_filename = "queued_white_cards_#{Date.today}.pdf"
combined_pdfs << { name: white_filename, data: white_cards.to_pdf }
output_file = zip_cards(combined_pdfs)
elsif blue_cards.present?
output_file = CombinePDF.new
blue_cards.each { |pdf| output_file << pdf }
elsif white_cards.present?
output_file = CombinePDF.new
white_cards.each { |pdf| output_file << pdf }
end
output_file
end
def zip_cards(pdf_array)
Zip::OutputStream.write_buffer do |zio|
pdf_array.each do |file|
zio.put_next_entry(file[:name])
zio.write(file[:data])
end
end
end
end
end
@@ -1,15 +1,22 @@
module IdCardPrinterService
class SampleCardsGenerator
def initialize(employer)
@employer = employer
def initialize(employer_id)
@employer_id = employer_id
@employer = Employer.includes(id_card_setup: [:provider_section, :rx_section]).find(@employer_id)
@card_setup = @employer.id_card_setup
end
def call
IdCard::PrintData.where(employer_name: @employer.id_card_setup.print_name).destroy_all
IdCard::PrintData.where(employer_id: @employer.id).destroy_all
IdCardPrinterService::SampleDataFormatter.new(@employer).call
IdCardPrinterService::SamplePdfProcessor.new(@employer).call
batch = IdCard::PrintData.where(employer_id: @employer.id).where.not(plan_id: nil)
jasper_batch_id = "#{@employer.name.delete(" ")}Samples-#{Time.current.utc.to_i}"
batch.update!(jasper_batch_id: jasper_batch_id)
batch_pdf = IdCardPrinterService::PdfBatchProcessor.new(@card_setup.card_template, jasper_batch_id, "SampleCard").call
batch_pdf
end
end
end
@@ -7,79 +7,64 @@ module IdCardPrinterService
end
def call
@base_card = IdCard::PrintData.new(sample: true)
set_employer_fields()
set_sample_fields()
set_rx_fields()
set_network_fields()
set_dependent_fields()
sample_cards = set_plan_fields()
sample_cards.each(&:save!)
base_card = initialize_sample_base_card()
create_plan_base_cards(base_card)
end
private
def set_employer_fields
selected_attributes = {
def initialize_sample_base_card
sample_member_attributes = {
full_name: "JANE DOE",
primary_mb_member_key: "888888"
}
employer_attributes = {
employer_name: @card_setup.print_name,
employer_id: @employer.id,
group_number: @employer.group_number.present? ? @employer.group_number : "999999",
rx_group: @employer.group_number.present? ? @employer.group_number : "999999",
network_provider: @card_setup.network_provider,
network_logo_filename: @card_setup.network_logo.filename,
employer_logo_filename: @card_setup.employer_logo.filename,
medical_eff_date: @employer.effective_date
}
@base_card.assign_attributes(selected_attributes)
rx_attributes = @card_setup.rx_section.attributes.with_indifferent_access.slice(
:customer_service,
:web_url
)
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,
:claim_to_7, :claim_to_8, :claim_to_9, :claim_to_10, :claim_to_11, :claim_to_12,
:precert_1, :precert_2, :precert_3, :precert_4
)
selected_attributes = sample_member_attributes.merge(employer_attributes).merge(rx_attributes).merge(provider_attributes)
IdCard::PrintData.new(selected_attributes)
end
def set_plan_fields
plans_base_cards = []
@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
def create_plan_base_cards(common_fields_card)
plans = @card_setup.plans
plans.each do |plan|
selected_attributes = {
plan_id: plan.id,
sample_plan_title: plan.title
}
plan.plan_benefits.each do |bene|
plan_base_card["benefit_desc_#{bene.sequence}".to_sym] = bene.benefit_desc
plan_base_card["benefit_#{bene.sequence}".to_sym] = bene.benefit
selected_attributes["benefit_desc_#{bene.sequence}".to_sym] = bene.benefit_desc
selected_attributes["benefit_#{bene.sequence}".to_sym] = bene.benefit
end
plan_base_card.sample_plan_title = plan_name
plans_base_cards.push(plan_base_card)
plan_base_card = common_fields_card.dup
plan_base_card.assign_attributes(selected_attributes)
plan_base_card.save
end
plans_base_cards
end
def set_sample_fields
selected_attributes = {
full_name: "JANE DOE",
primary_mb_member_key: "888888",
rx_group: @employer.group_number.present? ? @employer.group_number : "999999"
}
@base_card.assign_attributes(selected_attributes)
end
def set_network_fields
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_setup.network_provider == "Cigna"
# @base_card.provider_code = "5"
# end
@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_setup.rx_section.attributes.with_indifferent_access.slice(
:customer_service,
:web_url
)
@base_card.assign_attributes(selected_attributes)
end
def set_dependent_fields
@@ -1,42 +0,0 @@
module IdCardPrinterService
class SampleJasperUrlGenerator
def initialize(employer, sample_key, sample_title)
@sample_key = sample_key
@sample_title = sample_title
@card_setup = employer.id_card_setup
end
def call
# @net_logo = determine_network_logo
URI::HTTP.build(url_components)
end
private
def determine_network_logo
# if @network_logos.length > 1
# member_geographic_info = Vhcs::PbEntityAddress.joins("INNER JOIN vwMBMember ON PBEntityAddress.PBEntityKey = vwMBMember.PBEntityKey AND PBEntityAddress.AddressTypeID = 1137").where("vwMBMember.FamilyID = ?", @family_id).first
# @network_logos.where.not(default: true).each do |pnl|
# if member_geographic_info[pnl.exception_type] == pnl.exception_value
# return pnl.net_logo
# end
# end
# end
# @network_logos.find_by(default: true).net_logo
@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
def url_components
{
host: '10.41.1.115',
port: 8080,
path: '/trunk/IdCardsServlet',
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
end
end
@@ -1,25 +0,0 @@
module IdCardPrinterService
class SamplePdfProcessor
def initialize(employer)
@employer = employer
@card_setup = @employer.id_card_setup
end
def call
group_cards_pdf = CombinePDF.new
IdCard::PrintData.where(employer_name: @card_setup.print_name).each do |card|
url = IdCardPrinterService::SampleJasperUrlGenerator.new(@employer, card.sample_key, card.sample_plan_title).call
puts url
card_pdf = IdCardPrinterService::JasperPdfGenerator.new(url).call
group_cards_pdf << card_pdf
end
# todays_date = DateTime.current.strftime('%Y%m%d%H%M%S')
# group_cards_pdf.save("tmp/#{@employer.name}_print_cards_#{todays_date}.pdf")
group_cards_pdf
end
end
end
@@ -1,26 +0,0 @@
module IdCardQueueService
class GetQueuedCounts
def initialize()
@employer_pl_plan_keys = IdCard::Setup.active.pluck(:pl_plan_key).join(',')
end
def call
raw_employers_member_keys = CallStoredProc.new('HLGetQueuedIdCardMemberKeysTPA', { PLPlanKeys: @employer_pl_plan_keys }).call.to_ary
end
private
def format_employers_member_keys(raw_employers_member_keys)
key_map = { "PlanKey" => :pl_plan_key, "MemberKeys" => :member_keys }
raw_employers_member_keys.map do |hash|
hash["PlanKey"] = hash["PlanKey"].to_s
hash["MemberKeys"] = hash["MemberKeys"].split(", ").map(&:to_i)
hash.transform_keys(key_map)
end
end
end
end
-33
View File
@@ -1,33 +0,0 @@
class ImageProcessorService
ALLOWED_LOGO_TYPES = ['Network', 'Employer'].freeze
def initialize(image_path, logo_type, new_filename = nil)
@image_path = image_path
@logo_type = logo_type.capitalize
@new_filename = new_filename
unless ALLOWED_LOGO_TYPES.include?(@logo_type)
raise ArgumentError, "Invalid logo type: #{@logo_type}. Must be one of: #{ALLOWED_LOGO_TYPES.join(', ')}"
end
end
def call
if @new_filename
filename = @new_filename
else
filename = File.basename(@image_path)
end
binary_data = File.binread(@image_path)
# binary_data = File.open(@image_path, 'rb').read
meme_type = Marcel::MimeType.for Pathname.new(@image_path)
logo_model = "IdCard::#{@logo_type}Logo".constantize
logo_model.find_or_create_by(filename: filename) do |logo|
logo.image_data = binary_data
logo.content_type = meme_type
end
end
end
@@ -1,93 +0,0 @@
module SampleCard
class DataFormatter
def initialize(employer)
@employer = employer
end
def call
@sample_card = SampleIdCard.new()
set_employer_fields()
set_generic_fields()
set_rx_fields()
set_network_fields()
# set_dependent_fields()
sample_cards = set_plan_fields()
sample_cards.each(&:save!)
end
private
def set_employer_fields
selected_attributes = {
employer_name: @employer.name,
group_number: @employer.group_number.present? ? @employer.group_number : "999999",
medical_eff_date: @employer.effective_date
}
@sample_card.assign_attributes(selected_attributes)
end
def set_plan_fields
plans_sample_cards = []
@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
plan.plan_benefits.each do |bene|
plan_sample_card["benefit_desc_#{bene.sequence}".to_sym] = bene.benefit_desc
plan_sample_card["benefit_#{bene.sequence}".to_sym] = bene.benefit
end
plans_sample_cards.push(plan_sample_card)
end
plans_sample_cards
end
def set_generic_fields
selected_attributes = {
full_name: "JANE DOE",
primary_mb_member_key: "888888",
rx_group: @employer.group_number.present? ? @employer.group_number : "999999"
}
@sample_card.assign_attributes(selected_attributes)
end
def set_network_fields
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,
:claim_to_7, :claim_to_8, :claim_to_9, :claim_to_10, :claim_to_11, :claim_to_12
)
if @employer.network_provider == "Cigna"
@sample_card.provider_code = "5"
end
@sample_card.assign_attributes(selected_attributes)
end
def set_rx_fields
# fairos_information = Vhcs::HlrxCrosRef.where(pl_plan_key: 52).first
selected_attributes = @employer.id_card_setup.rx_section.attributes.with_indifferent_access.slice(
:customer_service,
:web_url
)
@sample_card.assign_attributes(selected_attributes)
end
def set_dependent_fields
@sample_card.dependent_1 = "John Doe"
@sample_card.dependent_2 = "Molly Doe"
@sample_card.dependent_3 = "Jonathan Doe"
@sample_card.dependent_4 = "Calvin Doe"
@sample_card.dependent_5 = "Richard Doe"
@sample_card.dependent_6 = "Jannet Doe"
@sample_card.dependent_7 = "Longername Doe"
@sample_card.dependent_8 = "Robbert Doe"
end
end
end
@@ -1,17 +0,0 @@
module SampleCard
class JasperPdfGenerator
def initialize(jasper_url)
@jasper_url = jasper_url
end
def call
response = HTTParty.get(@jasper_url)
CombinePDF.parse(response.body)
end
end
end
-27
View File
@@ -1,27 +0,0 @@
module SampleCard
class PdfPrinter
def initialize(process, sample_cards)
@process = process
@sample_cards = sample_cards
end
def call
group_cards_pdf = CombinePDF.new
@sample_cards.each do |sample_card|
url = SampleCard::JasperUrlGenerator.new(@process, sample_card.family_id).call
puts url
sample_card_pdf = SampleCard::JasperPdfGenerator.new(url).call
group_cards_pdf << sample_card_pdf
end
employer_name = @process.employer_name.downcase.tr(" ", "_")
todays_date = Date.today.strftime("%m/%d/%Y")
group_cards_pdf.save("tmp/#{employer_name}_sample_cards_#{todays_date}.pdf")
group_cards_pdf
end
end
end
-23
View File
@@ -1,23 +0,0 @@
class SampleCardGenerator
def initialize(employer)
@employer = employer
end
def call
SampleIdCard.where(employer_name: @employer.name).destroy_all
SampleCard::DataFormatter.new(@employer).call
group_sample_cards_pdf = CombinePDF.new
SampleIdCard.where(employer_name: @employer.name).each do |card|
url = SampleCard::JasperUrlGenerator.new(@employer, card.family_id).call
puts url
card_pdf = SampleCard::JasperPdfGenerator.new(url).call
group_sample_cards_pdf << card_pdf
end
group_sample_cards_pdf
end
end
@@ -1,26 +0,0 @@
class SampleCardGeneratorLocal
def initialize(process)
@process = process
end
def call
# SampleCard::DataFormatter.new(@process).call
group_sample_cards_pdf = CombinePDF.new
SampleIdCard.where(employer_name: @process.employer_name).each do |card|
url = SampleCard::JasperUrlGenerator.new(@process, card.family_id).call
puts url
card_pdf = SampleCard::JasperPdfGenerator.new(url).call
group_sample_cards_pdf << card_pdf
end
todays_date = DateTime.current.strftime('%Y%m%d%H%M%S')
group_sample_cards_pdf.save("tmp/#{@process.employer_name}_sample_cards_#{todays_date}.pdf")
group_sample_cards_pdf
end
end