jasper print speed refactor working
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
class ProcessIdCardDataJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(member_key, field_exception_ids, has_divisions = false)
|
||||
member = Member.find_by(pb_entity_key: member_key)
|
||||
|
||||
effect_date = determine_eff_date(member)
|
||||
if effect_date
|
||||
member_card = @base_card.dup
|
||||
member_attributes = {
|
||||
full_name: member.id_card_display_name,
|
||||
full_name_last_name_first: member.name,
|
||||
primary_mb_member_key: member.pb_entity_key,
|
||||
family_id: member.family_id,
|
||||
plan_id: member.id_card_plan_id,
|
||||
medical_eff_date: effect_date.strftime("%m/%d/%Y")
|
||||
}
|
||||
|
||||
dependent_attributes = get_dependent_fields(member)
|
||||
if dependent_attributes.present?
|
||||
member_attributes.merge!(dependent_attributes)
|
||||
end
|
||||
|
||||
if has_divisions
|
||||
member_attributes.merge!({employer_name: member.division})
|
||||
end
|
||||
|
||||
if field_exception_ids.present?
|
||||
exceptions_attributes = {}
|
||||
field_exceptions = IdCard::FieldException.where(id: field_exception_ids)
|
||||
member_exception_values = member.id_card_field_exception_values
|
||||
field_exceptions.each do |fe|
|
||||
if member_exception_values[fe.field_type] == fe.field_value
|
||||
fe.field_exception_items.each do |fei|
|
||||
if fei.field_value.present?
|
||||
exceptions_attributes[fei.field_name] = fei.field_value
|
||||
elsif fei.provider_section_id.present?
|
||||
provider_attributes = IdCard::ProviderSection.find(fei.provider_section_id).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
|
||||
)
|
||||
exceptions_attributes.merge!(provider_attributes)
|
||||
elsif fei.network_logo_id.present?
|
||||
exceptions_attributes.merge!(network_logo_id: fei.network_logo_id)
|
||||
exceptions_attributes.merge!(network_logo_filename: fei.network_logo.filename)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
member_attributes.merge!(exceptions_attributes)
|
||||
end
|
||||
|
||||
member_card = IdCard::PrintData.find_by(pl_plan_key: member.pl_plan_key, plan_id: member.id_card_plan_id, primary_mb_member_key: nil).dup
|
||||
member_card.assign_attributes(member_attributes)
|
||||
member_card.save
|
||||
end
|
||||
|
||||
true
|
||||
|
||||
# BatchProcess.increment_counter(:completed_jobs, batch_process_id)
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
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 = Vhcs::VwmbMember.where(pl_plan_key: member.pl_plan_key, 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
|
||||
Reference in New Issue
Block a user