before adding users

This commit is contained in:
Jason Jordan
2026-04-20 12:12:52 -04:00
parent 7ab1143db8
commit 1d9025276d
21 changed files with 286 additions and 185 deletions
+2 -5
View File
@@ -2,11 +2,8 @@ class EmployersController < ApplicationController
# View Methods
def index
@not_automation_ready = Employer.not_automation_ready
@missing_keychain_initialization = Employer.missing_keychain_initialization
@missing_plans_initialization = Employer.missing_plans_initialization
@missing_members_initialization = Employer.missing_members_initialization
@active_with_active_id_card_setup = Employer.active_with_active_id_card_setup
@uninitialized = Employer.in_automation_initilization
@with_active_id_card_setup = Employer.with_active_id_card_setup
@deactivated = Employer.deactivated
end
+1
View File
@@ -5,6 +5,7 @@ class UpdateEmployerJob < ApplicationJob
if employer_plan_header.present?
pl_plan_key = employer_plan_header['PLPlanKey'].to_s
employer_identifier[:pl_plan_key] = pl_plan_key
elsif employer_identifier[:group_number]
group_number = employer_identifier[:group_number]
pl_plan_key = Vhcs::PlPlanGroupCode.find_by(group_code: group_number).pl_plan_key
+50 -28
View File
@@ -2,34 +2,49 @@ module EmployerAutomation
extend ActiveSupport::Concern
included do
scope :uninitialized, -> {
where(initialized: false)
}
scope :initialized, -> {
where(initialized: true)
}
scope :not_automation_ready, -> {
where(pl_plan_key: [nil, ''], group_number: [nil, ''])
where(group_number: [nil, ''])
}
scope :automation_ready, -> {
where.not(pl_plan_key: [nil, ''])
.or(where.not(group_number: [nil, '']))
where.not(group_number: [nil, ''])
}
scope :missing_keychain_values, -> {
where(company_pb_entity_key: [nil, ''])
.or(where(plan_id: [nil, '']))
.or(where(group_number: [nil, '']))
.or(where(pl_plan_key: [nil, '']))
scope :in_automation_initilization, -> {
joins(:id_card_setup)
.where(initialized: false)
.or(
where(id_card_setup: {initialized: false})
)
}
# scope :missing_keychain_values, -> {
# where(company_pb_entity_key: [nil, ''])
# .or(where(plan_id: [nil, '']))
# .or(where(group_number: [nil, '']))
# .or(where(pl_plan_key: [nil, '']))
# }
scope :missing_keychain_initialization, -> {
inactive.automation_ready.missing_keychain_values
uninitialized.automation_ready
}
scope :building_id_card_setup, -> {
active.left_outer_joins(:id_card_setup)
.where(id_card_setup: {active: false})
scope :uninitialized_id_card_setup, -> {
joins(:id_card_setup)
.where(id_card_setup: {initialized: false})
}
scope :missing_plans_initialization, -> {
building_id_card_setup
.where.missing(:plans)
scope :missing_plans, -> {
where.missing(:plans)
.or(
where(
id: joins(:plans)
@@ -39,9 +54,8 @@ module EmployerAutomation
)
}
scope :missing_members_initialization, -> {
building_id_card_setup
.where.associated(:plans)
scope :has_plans, -> {
where.associated(:plans)
.where.not(
id: joins(:plans)
.where(plans: { pb_product_key: [nil, ''] })
@@ -49,22 +63,30 @@ module EmployerAutomation
).distinct
}
scope :active_with_active_id_card_setup, -> {
scope :missing_plans_initialization, -> {
uninitialized_id_card_setup.missing_plans
}
scope :missing_members_initialization, -> {
uninitialized_id_card_setup.has_plans
}
scope :with_active_id_card_setup, -> {
active.left_outer_joins(:id_card_setup)
.where(id_card_setup: {active: true})
}
scope :with_keychain_values, -> {
where.not(
pl_plan_key: [nil, ''],
group_number: [nil, ''],
company_pb_entity_key: [nil, ''],
plan_id: [nil, '']
)
}
# scope :with_keychain_values, -> {
# where.not(
# pl_plan_key: [nil, ''],
# group_number: [nil, ''],
# company_pb_entity_key: [nil, ''],
# plan_id: [nil, '']
# )
# }
scope :deactivated, -> {
inactive.with_keychain_values
inactive.initialized
}
# Employer.joins(:id_card_setup)
# .left_outer_joins(:plans)
+5 -2
View File
@@ -9,14 +9,17 @@ class Employer < ApplicationRecord
scope :inactive, -> { where(active: false) }
before_save :create_slug, if: :will_save_change_to_name?
before_save :deactivation_check, if: :will_save_change_to_active?
before_save :active_initialized_check, if: :will_save_change_to_active?
def create_slug
self.slug = Employer.employer_trim_name(name).parameterize
end
def deactivation_check
def active_initialized_check
if active
self.initialized = true
end
if active == false
id_card_setup&.update(active: false)
end
+8
View File
@@ -19,6 +19,14 @@ module IdCard
FORM_COLORS = ['atmosphere', 'verdigris', 'bluemana', 'cobalt']
MODULE_COLOR = 'atmosphere'
before_save :active_initialized_check, if: :will_save_change_to_active?
def active_initialized_check
if active
self.initialized = true
end
end
# def employer_logo_filename
# self.employer_logo.filename
# end
@@ -1,13 +1,16 @@
module AutomationService
class BatchEmployerUpdate
def initialize(pl_plan_keys)
def initialize(pl_plan_keys = nil)
@pl_plan_keys = pl_plan_keys
end
def call
sql_query = "SELECT PLPlanKey, PlanId, ShortDesc FROM PLPlanHeader
WHERE ActiveInactive = 'Active' AND PLPlanKey IN (#{@pl_plan_keys.join(',')})"
WHERE ActiveInactive = 'Active'"
if @pl_plan_keys.present?
sql_query = sql_query.concat(" AND PLPlanKey IN (#{@pl_plan_keys.join(',')})")
end
employer_plan_headers = VhcsRecord.connection.select_all(sql_query)
employer_update_futures = employer_plan_headers.map do |employer_plan_header|
@@ -6,7 +6,20 @@ module IdCardQueueService
end
def call
CallStoredProc.new('BrittonGetQueuedIdCardCountsTPA', { PLPlanKeys: @employer_pl_plan_keys }).call.to_ary
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
+4 -4
View File
@@ -9,18 +9,18 @@
<%= f.text_field :name, label: { text: "Employer Name" }, class: "w-full" %>
</div>
<div class="w-full">
<%= f.text_field :slug, label: { text: "Slug" }, class: "w-full" %>
<%= f.text_field :effective_date, label: { text: "Effective Date" }, class: "w-full" %>
</div>
<div class="w-full">
<%= f.text_field :pl_plan_key, label: { text: "Pl Plan Key" }, class: "w-full" %>
<%= f.text_field :group_number, label: { text: "Group/Medical Number" }, class: "w-full" %>
</div>
</div>
<div class="flex space-x-10">
<div class="w-full">
<%= f.text_field :group_number, label: { text: "Group/Medical Number" }, class: "w-full" %>
<%= f.text_field :slug, label: { text: "Slug" }, class: "w-full" %>
</div>
<div class="w-full">
<%= f.text_field :effective_date, label: { text: "Effective Date" }, class: "w-full" %>
<%= f.text_field :pl_plan_key, label: { text: "Pl Plan Key" }, class: "w-full" %>
</div>
</div>
</div>
+98 -76
View File
@@ -1,89 +1,111 @@
<div class="bg-deepcove h-full w-full flex flex-col justify-start">
<div class="flex items-center">
<div class="flex items-center justify-between">
<h1 class="font-bold text-4xl text-platinum my-5">Employers</h1>
<%= link_to new_employer_path, class: "flex justify-center items-center h-8 w-8 ml-2 mb-6 text-sm text-bronze bg-deepcove hover:bg-cobalt font-semibold p-1 -l border-2 border-cobalt" do %>
<%= icon "clipboard-plus", library: "lucide" %>
<% end %>
<div class="w-30 inline-flex flex-col text-platinum hover:text-limegreen font-bold px-4 mr-20 rounded-l-lg border-l-5 border-b-2 border-limegreen">
<div class="w-full flex text-3xl">
<%= link_to "NEW", new_employer_path %>
</div>
</div>
</div>
<% if @not_automation_ready.present? || @missing_keychain_initialization.present? || @missing_plans_initialization.present? || @missing_members_initialization.present? %>
<% if @uninitialized.present? %>
<h2 class="font-bold text-3xl text-brightlava my-5">In Process:</h2>
<% no_employers_text = @not_automation_ready.present? ? "" : " NONE" %>
<h3 class="font-bold text-xl text-bronze my-5 ml-10">
<%= "Waiting for Groups Number/Pl Plan Key:#{no_employers_text}" %>
</h2>
<div class="flex flex-wrap w-full pl-20 pr-10 gap-x-4 gap-y-3">
<% @not_automation_ready.each_with_index do |emp, index| %>
<div class="w-[23%] inline-flex flex-col text-platinum font-bold px-4 rounded-l-lg border-l-5 border-b-2 border-bronze">
<div class="w-full flex text-xl">
<%= link_to emp.name, employer_path(emp.slug), class: "text-bronze hover:text-platinum" %>
</div>
<div class="w-full flex text-md font-medium">
<%= "(Effective #{emp.effective_date})" %>
</div>
</div>
<% end %>
</div>
<% no_employers_text = @missing_keychain_initialization.present? ? "" : " NONE" %>
<h3 class="font-bold text-xl text-verdigris-vivid my-5 ml-10">
<%= "Waiting for Employer to be created in VHCS:#{no_employers_text}" %>
</h2>
<div class="flex flex-wrap w-full pl-20 pr-10 gap-x-4 gap-y-3">
<% @missing_keychain_initialization.each_with_index do |emp, index| %>
<div class="w-[23%] inline-flex flex-col text-platinum font-bold px-4 rounded-l-lg border-l-5 border-b-2 border-verdigris-vivid">
<div class="w-full flex text-xl">
<%= link_to emp.name, employer_path(emp.slug), class: "text-verdigris-vivid hover:text-platinum" %>
</div>
<div class="w-full flex text-md font-medium">
<%= "(Effective #{emp.effective_date})" %>
</div>
</div>
<% end %>
</div>
<% no_employers_text = @missing_plans_initialization.present? ? "" : " NONE" %>
<h3 class="font-bold text-xl text-copper my-5 ml-10">
<%= "Waiting for Plans to be created in VHCS:#{no_employers_text}" %>
</h2>
<div class="flex flex-wrap w-full pl-20 pr-10 gap-x-4 gap-y-3">
<% @missing_plans_initialization.each_with_index do |emp, index| %>
<div class="w-[23%] inline-flex flex-col text-platinum font-bold px-4 rounded-l-lg border-l-5 border-b-2 border-copper">
<div class="w-full flex text-xl">
<%= link_to emp.name, employer_path(emp.slug), class: "text-copper hover:text-platinum" %>
</div>
<div class="w-full flex text-md font-medium">
<%= "(Effective #{emp.effective_date})" %>
</div>
</div>
<% end %>
</div>
<% no_employers_text = @missing_members_initialization.present? ? "" : " NONE" %>
<h3 class="font-bold text-xl text-bluemana my-5 ml-10">
<%= "Waiting for Inital Members to be created in VHCS:#{no_employers_text}" %>
</h2>
<div class="flex flex-wrap w-full pl-20 pr-10 gap-x-4 gap-y-3">
<% @missing_members_initialization.each_with_index do |emp, index| %>
<div class="w-[32%] inline-flex flex-col text-platinum font-bold px-4 rounded-l-lg border-l-5 border-b-2 border-bluemana">
<div class="w-full flex">
<%= link_to emp.name, employer_path(emp.slug), class: "text-bluemana hover:text-platinum" %>
</div>
<div class="w-full flex justify-between text-md font-medium">
<% member_counter_color = "text-".concat(emp.members.present? ? "limegreen" : "brightlava") %>
<div>
Members:
<span class="ml-2 <%= member_counter_color %>">
<%= emp.members.count %>
</span>
<div class="flex flex-none items-center w-full px-10">
<h3 class="flex-none font-bold text-xl text-bronze my-5">
<%= "Waiting for Groups Number Entry" %>
</h2>
<% if @uninitialized.not_automation_ready.present? %>
<div class="flex flex-wrap w-full gap-x-4 gap-y-3">
<% @uninitialized.not_automation_ready.each do |emp| %>
<div class="w-[23%] inline-flex flex-col text-platinum font-bold px-4 rounded-l-lg border-l-5 border-b-2 border-bronze">
<div class="w-full flex text-xl">
<%= link_to emp.name, employer_path(emp.slug), class: "text-bronze hover:text-platinum" %>
</div>
<div class="w-full flex text-md font-medium">
<%= "(Effective #{emp.effective_date})" %>
</div>
</div>
<div class="ml-2">
<%= "(Effective #{emp.effective_date})" %>
</div>
</div>
<% end %>
</div>
<% else %>
<div class="grow h-[1px] mt-2 ml-1 bg-bronze"></div>
<% end %>
</div>
<div class="flex flex-none items-center w-full px-10">
<h3 class="font-bold text-xl text-verdigris-vivid my-5">
<%= "Waiting for Employer to be created in VHCS" %>
</h3>
<% if @uninitialized.missing_keychain_initialization.present? %>
<div class="flex flex-wrap w-full pl-20 pr-10 gap-x-4 gap-y-3">
<% @uninitialized.missing_keychain_initialization.each do |emp| %>
<div class="w-[23%] inline-flex flex-col text-platinum font-bold px-4 rounded-l-lg border-l-5 border-b-2 border-verdigris-vivid">
<div class="w-full flex text-xl">
<%= link_to emp.name, employer_path(emp.slug), class: "text-verdigris-vivid hover:text-platinum" %>
</div>
<div class="w-full flex text-md font-medium">
<%= "(Effective #{emp.effective_date})" %>
</div>
</div>
<% end %>
</div>
<% else %>
<div class="grow h-[1px] mt-2 ml-1 bg-verdigris-vivid"></div>
<% end %>
</div>
<div class="flex flex-none items-center w-full px-10">
<h3 class="font-bold text-xl text-copper my-5">
<%= "Waiting for Plans to be created in VHCS" %>
</h3>
<% if @uninitialized.missing_plans_initialization.present? %>
<div class="flex flex-wrap w-full pl-20 pr-10 gap-x-4 gap-y-3">
<% @uninitialized.missing_plans_initialization.each do |emp| %>
<div class="w-[23%] inline-flex flex-col text-platinum font-bold px-4 rounded-l-lg border-l-5 border-b-2 border-copper">
<div class="w-full flex text-xl">
<%= link_to emp.name, employer_path(emp.slug), class: "text-copper hover:text-platinum" %>
</div>
<div class="w-full flex text-md font-medium">
<%= "(Effective #{emp.effective_date})" %>
</div>
</div>
<% end %>
</div>
<% else %>
<div class="grow h-[1px] mt-2 ml-1 bg-copper"></div>
<% end %>
</div>
<div class="flex flex-none items-center w-full px-10">
<h3 class="flex flex-none font-bold text-xl text-bluemana my-5">
<%= "Waiting for Inital Members to be created in VHCS" %>
</h3>
<% if @uninitialized.missing_members_initialization.present? %>
<div class="flex flex-wrap w-full pl-20 pr-10 gap-x-4 gap-y-3">
<% @uninitialized.missing_members_initialization.each do |emp| %>
<div class="w-[23%] inline-flex flex-col text-platinum font-bold px-4 rounded-l-lg border-l-5 border-b-2 border-bluemana">
<div class="w-full flex">
<%= link_to emp.name, employer_path(emp.slug), class: "text-bluemana hover:text-platinum" %>
</div>
<div class="w-full flex justify-between text-md font-medium">
<% member_counter_color = "text-".concat(emp.members.present? ? "limegreen" : "brightlava") %>
<div>
Members:
<span class="ml-2 <%= member_counter_color %>">
<%= emp.members.count %>
</span>
</div>
<div class="ml-2">
<%= "(Effective #{emp.effective_date})" %>
</div>
</div>
</div>
<% end %>
</div>
<% else %>
<div class="grow h-[1px] mt-2 ml-1 bg-bluemana"></div>
<% end %>
</div>
<% end %>
<h2 class="font-bold text-3xl text-limegreen my-5">Live:</h2>
<div class="flex flex-wrap w-full px-10 gap-x-4 gap-y-3">
<% @active_with_active_id_card_setup.order(:name).each_with_index do |emp, index| %>
<% @with_active_id_card_setup.order(:name).each do |emp| %>
<div class="w-[23%] inline-flex flex-col text-platinum font-bold px-4 rounded-l-lg border-l-5 border-b-2 border-atmosphere">
<div class="w-full flex text-xl space-x-4">
<%= link_to emp.name, employer_path(emp.slug), class: "text-atmosphere hover:text-platinum" %>
@@ -101,7 +123,7 @@
</div>
<h2 class="font-bold text-3xl text-[#ADADAD] my-5">Deactivated:</h2>
<div class="flex flex-wrap w-full px-10 gap-x-4 gap-y-3">
<% @deactivated.each_with_index do |emp, index| %>
<% @deactivated.each do |emp| %>
<div class="w-[23%] inline-flex flex-col text-[#ADADAD] font-bold px-4 rounded-l-lg border-l-5 border-b-2 border-[#ADADAD]">
<div class="w-full flex text-xl space-x-4">
<%= link_to emp.name, employer_path(emp.slug), class: "text-platinum hover:text-bluemana" %>
+3 -5
View File
@@ -19,14 +19,12 @@
<div class="w-full">
<%= f.text_field :name, label: { text: "Employer Name" }, data: { logo_upload_target: "employer" }, class: "w-full" %>
</div>
<div class="w-full">
<%= f.text_field :group_number, label: { text: "Group/Medical Number" }, class: "w-full" %>
</div>
</div>
<div class="flex space-x-10">
<div class="w-full">
<%= f.text_field :effective_date, label: { text: "Effective Date" }, class: "w-full" %>
</div>
<div class="w-full">
<%= f.text_field :group_number, label: { text: "Group/Medical Number" }, class: "w-full" %>
</div>
</div>
</div>
</div>