Prod build process
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
module IdCard
|
||||
class EmployerLogo < ApplicationRecord
|
||||
# before_validation :resize_logo, if: :image_data_changed?
|
||||
# before_validation :calculate_aspect_ratio, if: :image_data_changed?
|
||||
belongs_to :setup, optional: true
|
||||
validates :filename, :image_data, :content_type, :aspect_ratio, presence: true
|
||||
validates :filename, uniqueness: true
|
||||
|
||||
before_validation :process_image, if: :image_data_changed?
|
||||
|
||||
private
|
||||
@@ -27,24 +29,5 @@ module IdCard
|
||||
end
|
||||
end
|
||||
|
||||
# def resize_logo
|
||||
# image = Vips::Image.new_from_buffer(self.image_data, "")
|
||||
|
||||
# processed_image = ImageProcessing::Vips
|
||||
# .source(image)
|
||||
# .resize_to_limit(nil, 200)
|
||||
# .call
|
||||
|
||||
# self.image_data = processed_image.read
|
||||
# end
|
||||
|
||||
# def calculate_aspect_ratio
|
||||
# image_io = StringIO.new(self.image_data)
|
||||
# width, height = FastImage.size(image_io)
|
||||
# image_ratio = width.to_f / height
|
||||
# if image_ratio
|
||||
# self.aspect_ratio = image_ratio.round(2)
|
||||
# end
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,8 @@ module IdCard
|
||||
|
||||
serialize :exception_values, coder: JSON
|
||||
|
||||
validates :exception_type, :exception_values, presence: true
|
||||
|
||||
VALID_TYPES = ['family_id', 'zipcode', 'state'].freeze
|
||||
|
||||
before_validation :format_exception_values, if: :exception_values_changed?
|
||||
|
||||
@@ -5,6 +5,8 @@ module IdCard
|
||||
belongs_to :provider_section, optional: true
|
||||
|
||||
validate :only_one_exception_field_present
|
||||
validates :field_name, presence: true
|
||||
validates :field_name, uniqueness: { scope: :field_exception_id }
|
||||
|
||||
FIELDS_TO_VALIDATE = [:field_value, :network_logo_id, :provider_section_id].freeze
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
module IdCard
|
||||
class NetworkLogo < ApplicationRecord
|
||||
# before_validation :resize_logo, if: :image_data_changed?
|
||||
# before_validation :calculate_aspect_ratio, if: :image_data_changed?
|
||||
validates :filename, :image_data, :content_type, :aspect_ratio, presence: true
|
||||
validates :filename, uniqueness: true
|
||||
|
||||
before_validation :process_image, if: :image_data_changed?
|
||||
|
||||
scope :defaults, -> { where(default: true) }
|
||||
@@ -41,25 +42,5 @@ module IdCard
|
||||
end
|
||||
end
|
||||
|
||||
# def resize_logo
|
||||
# image = Vips::Image.new_from_buffer(self.image_data, "")
|
||||
|
||||
# processed_image = ImageProcessing::Vips
|
||||
# .source(image)
|
||||
# .resize_to_limit(nil, 400)
|
||||
# .call
|
||||
|
||||
# self.image_data = processed_image.read
|
||||
# end
|
||||
|
||||
# def calculate_aspect_ratio
|
||||
# image_io = StringIO.new(image_data)
|
||||
# width, height = FastImage.size(image_io)
|
||||
# image_ratio = width.to_f / height
|
||||
# if image_ratio
|
||||
# self.aspect_ratio = image_ratio.round(2)
|
||||
# end
|
||||
# end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,6 +4,11 @@ module IdCard
|
||||
has_many :plan_benefits, dependent: :destroy
|
||||
accepts_nested_attributes_for :plan_benefits, allow_destroy: true, reject_if: :all_blank
|
||||
|
||||
validates :title, presence: true
|
||||
validates :pb_product_key, :pl_plan_key, presence: true, if: -> { setup&.active }
|
||||
validates :pb_product_key, uniqueness: true, allow_nil: true
|
||||
validate :validate_plan_benefits_count, unless: -> { template }
|
||||
|
||||
scope :templates, -> { where(template: true) }
|
||||
|
||||
FARIOS_BENEFIT_FIELDS = ["Primary Visit", "Specialist Visit", "Urgent Care", "INN-Ind Ded", "INN-Family Ded", "OON-Ind Ded", "OON-Family Ded", "Co-Insurance", "INN-Ind OOP", "INN-Family OOP", "OON-Ind OOP", "OON-Family OOP", "Emergency Room", "Preventive Care"].freeze
|
||||
@@ -39,10 +44,6 @@ module IdCard
|
||||
|
||||
class << self
|
||||
|
||||
# def templates
|
||||
# active_templates.map(&:format_template)
|
||||
# end
|
||||
|
||||
def permitted_params(params)
|
||||
params.require(:id_card_setup).permit(
|
||||
plans_attributes: [
|
||||
@@ -66,11 +67,20 @@ module IdCard
|
||||
|
||||
private
|
||||
|
||||
def build_and_create_default_benefits
|
||||
benefits = IdCardBenefitsTemplate.find_by(title: "BLANK").id_card_benefits.sort_by(&:sequence)
|
||||
benefits.each do |ben|
|
||||
id_card_plan_benefits.new(benefit_desc: ben.benefit_desc, sequence: ben.sequence)
|
||||
def validate_plan_benefits_count
|
||||
plan_benefits_size = plan_benefits.size
|
||||
template_benefits_size = case setup&.card_template
|
||||
when "TandemlocIDCard"
|
||||
TANDEMLOC_BENEFIT_FIELDS.size
|
||||
when "SmartIDCard"
|
||||
SMART_BENEFIT_FIELDS.size
|
||||
else
|
||||
FARIOS_BENEFIT_FIELDS.size
|
||||
end
|
||||
unless plan_benefits_size == template_benefits_size
|
||||
errors.add(:base, "Plan Benefits size (#{plan_benefits_size}) does not match ID Card Template (#{template_benefits_size})")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,8 @@
|
||||
module IdCard
|
||||
class PlanBenefit < ApplicationRecord
|
||||
belongs_to :plan
|
||||
|
||||
validates :benefit_desc, :sequence, presence: true
|
||||
validates :benefit, presence: true, unless: :new_record?
|
||||
end
|
||||
end
|
||||
@@ -1,14 +1,25 @@
|
||||
module IdCard
|
||||
class PrintData < ApplicationRecord
|
||||
belongs_to :employer, class_name: 'Employer'
|
||||
|
||||
STRING_ATTRIBUTES = %w[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 dependent_1 dependent_2 dependent_3 dependent_4 dependent_5 dependent_6 dependent_7 dependent_8 dental_coverage]
|
||||
|
||||
before_validation :assign_blank_strings_to_unassigned_params
|
||||
|
||||
private
|
||||
|
||||
def has_jasper_sorting_fields
|
||||
missing_sample_card_fields = sample_plan_title.blank?
|
||||
missing_member_card_fields = employer_name.blank? || full_name_last_name_first.blank?
|
||||
|
||||
if missing_sample_card_fields || missing_member_card_fields
|
||||
errors.add(:base, "Required field for Jasper Server is missing")
|
||||
end
|
||||
end
|
||||
|
||||
def assign_blank_strings_to_unassigned_params
|
||||
STRING_ATTRIBUTES.each do |attr|
|
||||
# Use the blank? method which checks for nil, false, empty, or whitespace strings
|
||||
self[attr] = "" if self[attr].blank?
|
||||
self[attr] = "" if self[attr].blank?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,7 @@ module IdCard
|
||||
|
||||
def self.permitted_params(params)
|
||||
params.require(:id_card_setup).require(:provider_section).permit(
|
||||
:title,
|
||||
:provider_line_1,
|
||||
:provider_line_2,
|
||||
:provider_line_3,
|
||||
@@ -30,7 +31,15 @@ module IdCard
|
||||
:claim_to_11,
|
||||
:claim_to_12
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def display_title
|
||||
if self.default
|
||||
"Default #{self.title}"
|
||||
else
|
||||
self.title
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
+40
-23
@@ -1,14 +1,21 @@
|
||||
module IdCard
|
||||
class Setup < ApplicationRecord
|
||||
belongs_to :employer, class_name: 'Employer'
|
||||
belongs_to :employer_logo, optional: true
|
||||
belongs_to :network_logo, optional: true
|
||||
belongs_to :provider_section, optional: true
|
||||
belongs_to :rx_section, optional: true
|
||||
has_one :employer_logo, dependent: :destroy
|
||||
|
||||
has_many :plans, dependent: :destroy
|
||||
has_many :field_exceptions, dependent: :destroy
|
||||
|
||||
validates :print_name, :network_provider, :card_template, :employer_logo, :network_logo_id,
|
||||
:provider_section_id, :rx_section_id, presence: true, unless: :new_record?
|
||||
validates :pl_plan_key, :rx_group_number, presence: true, if: -> { initialized }
|
||||
validate :validate_print_name_fits_on_card
|
||||
|
||||
attr_accessor :print_name_pixel_width
|
||||
|
||||
accepts_nested_attributes_for :plans, allow_destroy: true, reject_if: :all_blank
|
||||
accepts_nested_attributes_for :field_exceptions, allow_destroy: true, reject_if: :all_blank
|
||||
|
||||
@@ -16,7 +23,7 @@ module IdCard
|
||||
|
||||
scope :active, -> { where(active: true) }
|
||||
|
||||
FORM_COLORS = ['atmosphere', 'verdigris', 'bluemana', 'cobalt']
|
||||
FORM_COLORS = ['atmosphere', 'verdigris-vivid', 'cobalt-vivid', 'bluemana']
|
||||
MODULE_COLOR = 'atmosphere'
|
||||
|
||||
before_save :active_initialized_check, if: :will_save_change_to_active?
|
||||
@@ -27,14 +34,6 @@ module IdCard
|
||||
end
|
||||
end
|
||||
|
||||
# def employer_logo_filename
|
||||
# self.employer_logo.filename
|
||||
# end
|
||||
|
||||
# def network_logo_filename
|
||||
# self.network_logo.filename
|
||||
# end
|
||||
|
||||
def build_plan_with_default_benefits(attributes = {})
|
||||
plan = plans.new(attributes)
|
||||
benefits = IdCardBenefitsTemplate.find_by(title: "BLANK").id_card_benefits.sort_by(&:sequence)
|
||||
@@ -45,7 +44,28 @@ module IdCard
|
||||
end
|
||||
|
||||
def has_field_exceptions?
|
||||
self.field_exceptions.present?
|
||||
field_exceptions.present?
|
||||
end
|
||||
|
||||
def sample_card_print_ready?
|
||||
print_name.present? &&
|
||||
card_template.present? &&
|
||||
employer_logo.present? &&
|
||||
network_logo_id.present? &&
|
||||
provider_section_id.present? &&
|
||||
rx_section_id.present? &&
|
||||
plans.present?
|
||||
end
|
||||
|
||||
def member_cards_print_ready?
|
||||
sample_card_print_ready? &&
|
||||
plans.present? &&
|
||||
plans.all? { |plan| plan.pb_product_key.present? } &&
|
||||
employer.members.present?
|
||||
end
|
||||
|
||||
def activation_ready?
|
||||
member_cards_print_ready? && !active
|
||||
end
|
||||
|
||||
def field_exceptions_card_attributes_by_member_id(member_array = nil)
|
||||
@@ -54,17 +74,6 @@ module IdCard
|
||||
end
|
||||
|
||||
card_fes = self.field_exceptions.includes(:field_exception_items).in_order_of(:exception_type, IdCard::FieldException::VALID_TYPES)
|
||||
# fe_by_value = card_fes.in_order_of(:exception_type, IdCard::FieldException::VALID_TYPES).group_by(&:exception_type)
|
||||
# .transform_values { |fes| fes.map { |fe| [fe.id, fe.exception_values] }.to_h }
|
||||
# .compact_blank
|
||||
|
||||
# field_exception_types = card_fes.pluck(:exception_type).uniq
|
||||
# if field_exception_types.include?("family_id")
|
||||
# members = Member.where(pb_entity_key: member_array)
|
||||
# end
|
||||
# if field_exception_types.intersect?(["state", "zipcode"])
|
||||
# member_addresses = Vhcs::PbEntityAddress.where(pb_entity_key: member_array)
|
||||
# end
|
||||
card_exceptions_map = {}
|
||||
card_fes.each do |fe|
|
||||
if fe.exception_type == "family_id"
|
||||
@@ -90,14 +99,22 @@ module IdCard
|
||||
def self.permitted_params(params)
|
||||
params.require(:id_card_setup).permit(
|
||||
:print_name,
|
||||
:print_name_pixel_width,
|
||||
:network_provider,
|
||||
:card_template,
|
||||
:rx_group_number,
|
||||
:employer_logo_id,
|
||||
:network_logo_id,
|
||||
:rx_section_id,
|
||||
:provider_section_id
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_print_name_fits_on_card
|
||||
if print_name_pixel_width.to_i > 100
|
||||
errors.add(:print_name, "Too Long For Card")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user