working on data printer
This commit is contained in:
+7
-7
@@ -6,9 +6,9 @@ module IdCard
|
||||
def edit
|
||||
@employer = Employer.find_by(slug: params[:employer_id])
|
||||
if @employer.id_card_enabled?
|
||||
@setup = @employer.id_card_setup
|
||||
@setup = @employer.id_card_configuration
|
||||
else
|
||||
@setup = @employer.create_id_card_setup
|
||||
@setup = @employer.create_id_card_configuration
|
||||
end
|
||||
render :edit
|
||||
end
|
||||
@@ -39,10 +39,10 @@ module IdCard
|
||||
end
|
||||
|
||||
def update_general
|
||||
if params[:id_card_setup]["provider_section_id"].include?("new|")
|
||||
if params[:id_card_configuration]["provider_section_id"].include?("new|")
|
||||
new_provider_section_params = IdCard::ProviderSection.permitted_params(params)
|
||||
new_provider_section = IdCard::ProviderSection.create(new_provider_section_params)
|
||||
params[:id_card_setup]["provider_section_id"] = new_provider_section.id
|
||||
params[:id_card_configuration]["provider_section_id"] = new_provider_section.id
|
||||
end
|
||||
general_params = IdCard::Configuration.permitted_params(params)
|
||||
if @setup.update(general_params)
|
||||
@@ -99,10 +99,10 @@ module IdCard
|
||||
|
||||
def set_employer_and_setup
|
||||
@employer = Employer.find_by(slug: params[:employer_id])
|
||||
if @employer.id_card_setup.present?
|
||||
@setup = @employer.id_card_setup
|
||||
if @employer.id_card_configuration.present?
|
||||
@setup = @employer.id_card_configuration
|
||||
else
|
||||
@setup = @employer.create_id_card_setup
|
||||
@setup = @employer.create_id_card_configuration
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,11 +10,16 @@ module IdCard
|
||||
|
||||
# API Methods
|
||||
|
||||
def print_queued
|
||||
@queue_counts = EmployerCards::GetQueuedCards.new().call
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
def add_queued_count_to_card_configuration
|
||||
@queue_counts = EmployerCards::QueueCounter.new().call
|
||||
@queue_counts = EmployerCards::GetQueuedCounts.new().call
|
||||
@queue_counts.each do |qc|
|
||||
match = @employer_configurations.find { |configuration| configuration.pl_plan_key == qc["PLPlanKey"] }
|
||||
if match.present?
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
module EmployerCards
|
||||
class GetQueuedCards
|
||||
|
||||
def initialize(pl_plan_keys)
|
||||
if pl_plan_keys
|
||||
@employer_pl_plan_keys = pl_plan_keys
|
||||
else
|
||||
@employer_pl_plan_keys = IdCard::Configuration.active.pluck(:pl_plan_key).join(',')
|
||||
end
|
||||
end
|
||||
|
||||
def call
|
||||
CallStoredProc.new('BrittonGetQueuedIdCardMemberKeysTPA', { PLPlanKeys: @employer_pl_plan_keys }).call.to_ary
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
module EmployerCards
|
||||
class QueueCounter
|
||||
class GetQueuedCounts
|
||||
|
||||
def initialize()
|
||||
@employer_pl_plan_keys = IdCard::Configuration.active.pluck(:pl_plan_key).join(',')
|
||||
end
|
||||
|
||||
def call
|
||||
CallStoredProc.new('HLGetQueuedIdCardsTPANewCount', { PLPlanKeys: @employer_pl_plan_keys }).call.to_ary
|
||||
CallStoredProc.new('BrittonGetQueuedIdCardCountsTPA', { PLPlanKeys: @employer_pl_plan_keys }).call.to_ary
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,10 +1,11 @@
|
||||
module EmployerCards
|
||||
class JasperUrlGenerator
|
||||
|
||||
def initialize(employer, family_id, layout)
|
||||
def initialize(pl_plan_key, family_id, layout)
|
||||
@pl_plan_key = pl_plan_key
|
||||
@family_id = family_id
|
||||
@employer = employer
|
||||
@layout = layout
|
||||
@card_config = IdCard::Configuration.find_by(pl_plan_key: pl_plan_key)
|
||||
end
|
||||
|
||||
def call
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
module IdCardPrinter
|
||||
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_configuration.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_configuration.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_configuration.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
|
||||
@@ -0,0 +1,17 @@
|
||||
module IdCardPrinter
|
||||
class EmployerCardsGenerator
|
||||
|
||||
def initialize(pl_plan_key, layout, zip=false)
|
||||
@pl_plan_key = pl_plan_key
|
||||
@layout = layout
|
||||
@zip = zip
|
||||
end
|
||||
|
||||
def call
|
||||
IdCard::PrintData.where(pl_plan_key: @pl_plan_key).destroy_all
|
||||
EmployerCards::DataFormatter.new(@pl_plan_key).call
|
||||
|
||||
IdCardPrinter::PdfProcessor.new(@pl_plan_key, @layout, @zip).call
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
module IdCardPrinter
|
||||
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
|
||||
@@ -0,0 +1,41 @@
|
||||
module IdCardPrinter
|
||||
class JasperUrlGenerator
|
||||
|
||||
def initialize(pl_plan_key, family_id, layout)
|
||||
@pl_plan_key = pl_plan_key
|
||||
@family_id = family_id
|
||||
@layout = layout
|
||||
@card_config = IdCard::Configuration.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
|
||||
@card_config.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_config.card_template}&printType=#{@layout}&family_id=#{@family_id }&employer_logo=#{@card_config.employer_logo.filename}&network_logo=#{determine_network_logo}&FileType=PDF"
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,40 @@
|
||||
module IdCardPrinter
|
||||
class PdfProcessor
|
||||
|
||||
def initialize(pl_plan_key, layout, zip)
|
||||
@pl_plan_key = pl_plan_key
|
||||
@employer_card_config = Employer.find_by(pl_plan_key: pl_plan_key).id_card_configuration
|
||||
@layout = layout
|
||||
@zip = zip
|
||||
end
|
||||
|
||||
def call
|
||||
group_cards_pdf_array = []
|
||||
IdCard::PrintData.where(pl_plan_key: @pl_plan_key).each do |card|
|
||||
url = IdCardPrinter::JasperUrlGenerator.new(@pl_plan_key, card.family_id, @layout).call
|
||||
puts url
|
||||
card_pdf = IdCardPrinter::JasperPdfGenerator.new(url).call
|
||||
if @zip
|
||||
card_filename = "#{card.name.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
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -13,7 +13,7 @@
|
||||
<%= es.pl_plan_key %> -
|
||||
<%= es.employer.name %>
|
||||
(
|
||||
<div class="mx-1 text-<%= es.queued_card_count > 0 ? "brightlava" : "limegreen" %>">
|
||||
<div class="mx-1 text-<%= es.queued_card_count > 0 ? "bronze" : "bluetang" %>">
|
||||
<%= es.queued_card_count %>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user