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 # View Methods
def index def index
@not_automation_ready = Employer.not_automation_ready @uninitialized = Employer.in_automation_initilization
@missing_keychain_initialization = Employer.missing_keychain_initialization @with_active_id_card_setup = Employer.with_active_id_card_setup
@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
@deactivated = Employer.deactivated @deactivated = Employer.deactivated
end end
+1
View File
@@ -5,6 +5,7 @@ class UpdateEmployerJob < ApplicationJob
if employer_plan_header.present? if employer_plan_header.present?
pl_plan_key = employer_plan_header['PLPlanKey'].to_s pl_plan_key = employer_plan_header['PLPlanKey'].to_s
employer_identifier[:pl_plan_key] = pl_plan_key
elsif employer_identifier[:group_number] elsif employer_identifier[:group_number]
group_number = employer_identifier[:group_number] group_number = employer_identifier[:group_number]
pl_plan_key = Vhcs::PlPlanGroupCode.find_by(group_code: group_number).pl_plan_key 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 extend ActiveSupport::Concern
included do included do
scope :uninitialized, -> {
where(initialized: false)
}
scope :initialized, -> {
where(initialized: true)
}
scope :not_automation_ready, -> { scope :not_automation_ready, -> {
where(pl_plan_key: [nil, ''], group_number: [nil, '']) where(group_number: [nil, ''])
} }
scope :automation_ready, -> { scope :automation_ready, -> {
where.not(pl_plan_key: [nil, '']) where.not(group_number: [nil, ''])
.or(where.not(group_number: [nil, '']))
} }
scope :missing_keychain_values, -> { scope :in_automation_initilization, -> {
where(company_pb_entity_key: [nil, '']) joins(:id_card_setup)
.or(where(plan_id: [nil, ''])) .where(initialized: false)
.or(where(group_number: [nil, ''])) .or(
.or(where(pl_plan_key: [nil, ''])) 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, -> { scope :missing_keychain_initialization, -> {
inactive.automation_ready.missing_keychain_values uninitialized.automation_ready
} }
scope :building_id_card_setup, -> { scope :uninitialized_id_card_setup, -> {
active.left_outer_joins(:id_card_setup) joins(:id_card_setup)
.where(id_card_setup: {active: false}) .where(id_card_setup: {initialized: false})
} }
scope :missing_plans_initialization, -> { scope :missing_plans, -> {
building_id_card_setup where.missing(:plans)
.where.missing(:plans)
.or( .or(
where( where(
id: joins(:plans) id: joins(:plans)
@@ -39,9 +54,8 @@ module EmployerAutomation
) )
} }
scope :missing_members_initialization, -> { scope :has_plans, -> {
building_id_card_setup where.associated(:plans)
.where.associated(:plans)
.where.not( .where.not(
id: joins(:plans) id: joins(:plans)
.where(plans: { pb_product_key: [nil, ''] }) .where(plans: { pb_product_key: [nil, ''] })
@@ -49,22 +63,30 @@ module EmployerAutomation
).distinct ).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) active.left_outer_joins(:id_card_setup)
.where(id_card_setup: {active: true}) .where(id_card_setup: {active: true})
} }
scope :with_keychain_values, -> { # scope :with_keychain_values, -> {
where.not( # where.not(
pl_plan_key: [nil, ''], # pl_plan_key: [nil, ''],
group_number: [nil, ''], # group_number: [nil, ''],
company_pb_entity_key: [nil, ''], # company_pb_entity_key: [nil, ''],
plan_id: [nil, ''] # plan_id: [nil, '']
) # )
} # }
scope :deactivated, -> { scope :deactivated, -> {
inactive.with_keychain_values inactive.initialized
} }
# Employer.joins(:id_card_setup) # Employer.joins(:id_card_setup)
# .left_outer_joins(:plans) # .left_outer_joins(:plans)
+5 -2
View File
@@ -9,14 +9,17 @@ class Employer < ApplicationRecord
scope :inactive, -> { where(active: false) } scope :inactive, -> { where(active: false) }
before_save :create_slug, if: :will_save_change_to_name? 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 def create_slug
self.slug = Employer.employer_trim_name(name).parameterize self.slug = Employer.employer_trim_name(name).parameterize
end end
def deactivation_check def active_initialized_check
if active
self.initialized = true
end
if active == false if active == false
id_card_setup&.update(active: false) id_card_setup&.update(active: false)
end end
+8
View File
@@ -19,6 +19,14 @@ module IdCard
FORM_COLORS = ['atmosphere', 'verdigris', 'bluemana', 'cobalt'] FORM_COLORS = ['atmosphere', 'verdigris', 'bluemana', 'cobalt']
MODULE_COLOR = 'atmosphere' 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 # def employer_logo_filename
# self.employer_logo.filename # self.employer_logo.filename
# end # end
@@ -1,13 +1,16 @@
module AutomationService module AutomationService
class BatchEmployerUpdate class BatchEmployerUpdate
def initialize(pl_plan_keys) def initialize(pl_plan_keys = nil)
@pl_plan_keys = pl_plan_keys @pl_plan_keys = pl_plan_keys
end end
def call def call
sql_query = "SELECT PLPlanKey, PlanId, ShortDesc FROM PLPlanHeader 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_plan_headers = VhcsRecord.connection.select_all(sql_query)
employer_update_futures = employer_plan_headers.map do |employer_plan_header| employer_update_futures = employer_plan_headers.map do |employer_plan_header|
@@ -6,7 +6,20 @@ module IdCardQueueService
end end
def call 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
end end
+4 -4
View File
@@ -9,18 +9,18 @@
<%= f.text_field :name, label: { text: "Employer Name" }, class: "w-full" %> <%= f.text_field :name, label: { text: "Employer Name" }, class: "w-full" %>
</div> </div>
<div class="w-full"> <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>
<div class="w-full"> <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> </div>
<div class="flex space-x-10"> <div class="flex space-x-10">
<div class="w-full"> <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>
<div class="w-full"> <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> </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="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> <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 %> <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">
<%= icon "clipboard-plus", library: "lucide" %> <div class="w-full flex text-3xl">
<% end %> <%= link_to "NEW", new_employer_path %>
</div>
</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> <h2 class="font-bold text-3xl text-brightlava my-5">In Process:</h2>
<% no_employers_text = @not_automation_ready.present? ? "" : " NONE" %> <div class="flex flex-none items-center w-full px-10">
<h3 class="font-bold text-xl text-bronze my-5 ml-10"> <h3 class="flex-none font-bold text-xl text-bronze my-5">
<%= "Waiting for Groups Number/Pl Plan Key:#{no_employers_text}" %> <%= "Waiting for Groups Number Entry" %>
</h2> </h2>
<div class="flex flex-wrap w-full pl-20 pr-10 gap-x-4 gap-y-3"> <% if @uninitialized.not_automation_ready.present? %>
<% @not_automation_ready.each_with_index do |emp, index| %> <div class="flex flex-wrap w-full gap-x-4 gap-y-3">
<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"> <% @uninitialized.not_automation_ready.each do |emp| %>
<div class="w-full flex text-xl"> <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">
<%= link_to emp.name, employer_path(emp.slug), class: "text-bronze hover:text-platinum" %> <div class="w-full flex text-xl">
</div> <%= link_to emp.name, employer_path(emp.slug), class: "text-bronze hover:text-platinum" %>
<div class="w-full flex text-md font-medium"> </div>
<%= "(Effective #{emp.effective_date})" %> <div class="w-full flex text-md font-medium">
</div> <%= "(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> </div>
<div class="ml-2"> <% end %>
<%= "(Effective #{emp.effective_date})" %>
</div>
</div>
</div> </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 %> <% end %>
</div> </div>
<% end %> <% end %>
<h2 class="font-bold text-3xl text-limegreen my-5">Live:</h2> <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"> <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-[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"> <div class="w-full flex text-xl space-x-4">
<%= link_to emp.name, employer_path(emp.slug), class: "text-atmosphere hover:text-platinum" %> <%= link_to emp.name, employer_path(emp.slug), class: "text-atmosphere hover:text-platinum" %>
@@ -101,7 +123,7 @@
</div> </div>
<h2 class="font-bold text-3xl text-[#ADADAD] my-5">Deactivated:</h2> <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"> <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-[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"> <div class="w-full flex text-xl space-x-4">
<%= link_to emp.name, employer_path(emp.slug), class: "text-platinum hover:text-bluemana" %> <%= 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"> <div class="w-full">
<%= f.text_field :name, label: { text: "Employer Name" }, data: { logo_upload_target: "employer" }, class: "w-full" %> <%= f.text_field :name, label: { text: "Employer Name" }, data: { logo_upload_target: "employer" }, class: "w-full" %>
</div> </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"> <div class="w-full">
<%= f.text_field :effective_date, label: { text: "Effective Date" }, class: "w-full" %> <%= f.text_field :effective_date, label: { text: "Effective Date" }, class: "w-full" %>
</div> </div>
<div class="w-full">
<%= f.text_field :group_number, label: { text: "Group/Medical Number" }, class: "w-full" %>
</div>
</div> </div>
</div> </div>
</div> </div>
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
set -e
printenv >> /etc/environment
echo "updating cron..."
bundle exec whenever --update-crontab --set environment=development
# Start cron in foreground
echo "starting cron..."
cron
# bundle exec whenever --update-crontab
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
# Remove a potentially pre-existing server.pid for Rails.
rm -f /usr/src/app/tmp/pids/server.pid
rm -rf /usr/local/bundle/cache/*.gem
echo "bundle install..."
bundle check || bundle install --jobs 4
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
+16 -8
View File
@@ -15,15 +15,13 @@ services:
- HISTFILE=/usr/src/app/log/.bash_history - HISTFILE=/usr/src/app/log/.bash_history
- RAILS_ENV=development - RAILS_ENV=development
- TAILWIND_POLLING=true - TAILWIND_POLLING=true
- PUID=1000 # - PUID=1000
- PGID=100 # - PGID=100
tty: true tty: true
stdin_open: true stdin_open: true
# depends_on: # depends_on:
# db: # db:
# condition: service_healthy # condition: service_healthy
# redis:
# condition: service_started
# db: # db:
# build: # build:
# context: . # context: .
@@ -38,11 +36,21 @@ services:
# timeout: 3s # timeout: 3s
# retries: 10 # retries: 10
# start_period: 10s # start_period: 10s
# redis: # cron:
# image: redis # build:
# context: ./
# dockerfile: development3.Dockerfile
# command: ./bin/cron-entrypoint
# volumes: # volumes:
# - redis_data:/data # - .:/usr/src/app
# - bundle:/usr/local/bundle
# environment:
# - RAILS_ENV=development
# - PUID=1000
# - PGID=1001
# depends_on:
# - web
# - db
volumes: volumes:
# redis_data: # redis_data:
bundle: bundle:
+1 -2
View File
@@ -2,8 +2,7 @@ set :output, "log/cron_log.log"
set :environment, ENV['RAILS_ENV'] || 'development' set :environment, ENV['RAILS_ENV'] || 'development'
every 1.minute do every 1.minute do
runner "Rails.logger.info 'Cron test ran at: ' + Time.now.to_s" rake "employer_automation:employer_initialize_test"
command "echo 'Cron test ran at: ' $(date) >> log/cron_log.log"
end end
every 1.day, at: ['6:00 am', '6:00 pm'] do every 1.day, at: ['6:00 am', '6:00 pm'] do
@@ -9,6 +9,7 @@ class CreateEmployers < ActiveRecord::Migration[7.2]
t.string :group_number t.string :group_number
t.string :effective_date t.string :effective_date
t.boolean :active, default: false t.boolean :active, default: false
t.boolean :initialized, default: false
t.timestamps t.timestamps
end end
@@ -7,9 +7,10 @@ class CreateIdCardSetups < ActiveRecord::Migration[7.2]
t.string :card_color t.string :card_color
t.string :rx_group_number t.string :rx_group_number
t.string :pl_plan_key t.string :pl_plan_key
t.boolean :active, default: false
t.boolean :has_divisions, default: false t.boolean :has_divisions, default: false
t.boolean :has_dental, default: false t.boolean :has_dental, default: false
t.boolean :active, default: false
t.boolean :initialized, default: false
t.belongs_to :employer, null: false, foreign_key: true t.belongs_to :employer, null: false, foreign_key: true
t.belongs_to :employer_logo, null: true, foreign_key: { to_table: :id_card_employer_logos } t.belongs_to :employer_logo, null: true, foreign_key: { to_table: :id_card_employer_logos }
t.belongs_to :network_logo, null: true, foreign_key: { to_table: :id_card_network_logos } t.belongs_to :network_logo, null: true, foreign_key: { to_table: :id_card_network_logos }
+3 -1
View File
@@ -20,6 +20,7 @@ ActiveRecord::Schema[7.2].define(version: 2026_04_08_210447) do
t.string "group_number" t.string "group_number"
t.string "effective_date" t.string "effective_date"
t.boolean "active", default: false t.boolean "active", default: false
t.boolean "initialized", default: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
end end
@@ -239,9 +240,10 @@ ActiveRecord::Schema[7.2].define(version: 2026_04_08_210447) do
t.string "card_color" t.string "card_color"
t.string "rx_group_number" t.string "rx_group_number"
t.string "pl_plan_key" t.string "pl_plan_key"
t.boolean "active", default: false
t.boolean "has_divisions", default: false t.boolean "has_divisions", default: false
t.boolean "has_dental", default: false t.boolean "has_dental", default: false
t.boolean "active", default: false
t.boolean "initialized", default: false
t.bigint "employer_id", null: false t.bigint "employer_id", null: false
t.bigint "employer_logo_id" t.bigint "employer_logo_id"
t.bigint "network_logo_id" t.bigint "network_logo_id"
+1
View File
@@ -15,6 +15,7 @@
"seed_tasks:determine_network_fields", "seed_tasks:determine_network_fields",
"seed_tasks:determine_employer_fields", "seed_tasks:determine_employer_fields",
"seed_tasks:build_plans",
"seed_tasks:build_members" "seed_tasks:build_members"
] ]
+7 -23
View File
@@ -13,6 +13,8 @@ RUN --mount=type=cache,target=/var/cache/apt \
build-essential \ build-essential \
less \ less \
git \ git \
cron \
dos2unix \
tdsodbc \ tdsodbc \
freetds-dev \ freetds-dev \
libvips \ libvips \
@@ -27,34 +29,16 @@ WORKDIR /usr/src/app
RUN gem install foreman RUN gem install foreman
# RUN chmod +x /usr/src/app/bin/jobs # COPY bin/development-entrypoint.sh /bin/development-entrypoint.sh
# RUN chown root:root bin/development-entrypoint.sh && chmod +x bin/development-entrypoint.sh
# Copy runtime Ruby dependencies and the precompiled assets from the builder stage ENTRYPOINT ["./bin/development-entrypoint"]
# COPY --from=builder /usr/local/bundle /usr/local/bundle
# COPY --from=builder /usr/src/app /usr/src/app
# COPY --from=watchman_builder /usr/local/bin/watchman /usr/local/bin/watchman
# COPY --from=watchman_builder /usr/local/bin/watchman-wait /usr/local/bin/watchman-wait
# RUN mkdir -p /usr/local/var/run/watchman \ ENTRYPOINT ["./bin/cron-entrypoint"]
# && touch /usr/local/var/run/watchman/.not-empty \
# && chmod 2777 /usr/local/var/run/watchman
# COPY . .
# 1. Add bin/jobs script to container
COPY bin/jobs /usr/src/bin/jobs
# 2. Make the script executable
RUN chmod +x /usr/src/bin/jobs
# 3. Set it as the entrypoint
# ENTRYPOINT ["/usr/src/bin/jobs"]
# The entrypoint script is a good practice for handling Rails server startup
ENTRYPOINT ["./bin/docker-entrypoint-development"]
# Expose the application port # Expose the application port
EXPOSE 3002 EXPOSE 3002
# Set the default command to run the Rails server # Set the default command to run the Rails server
CMD ["./bin/dev", "bin/jobs start"] CMD ["./bin/dev", "./bin/jobs start"]
+4 -3
View File
@@ -3,9 +3,10 @@ namespace :employer_automation do
desc "Employer Initialization Automation" desc "Employer Initialization Automation"
# rake employer_automation:employer_initialize # rake employer_automation:employer_initialize
task employer_initialize: :environment do task employer_initialize: :environment do
puts "Running Employer Init Automation"
Employer.missing_keychain_initialization.map(&:sync_with_vhcs) Employer.missing_keychain_initialization.map(&:sync_with_vhcs)
Employer.missing_plans_initialization.map(&:sync_plans_with_vhcs) Employer.missing_plans_initialization.map(&:sync_plans_with_vhcs)
Employer.missing_initial_members.map(&:sync_members_with_vhcs) Employer.missing_members_initialization.map(&:sync_members_with_vhcs)
end end
desc "Employer Initialization Automation Test" desc "Employer Initialization Automation Test"
@@ -26,8 +27,8 @@ namespace :employer_automation do
# rake employer_automation:employer_maintenance # rake employer_automation:employer_maintenance
task employer_maintenance: :environment do task employer_maintenance: :environment do
Employer.automation_ready.map(&:sync_with_vhcs) Employer.automation_ready.map(&:sync_with_vhcs)
Employer.active.map(&:sync_plans_with_vhcs) Employer.with_active_id_card_setup.map(&:sync_plans_with_vhcs)
Employer.active.map(&:sync_members_with_vhcs) Employer.with_active_id_card_setup.map(&:sync_members_with_vhcs)
end end
end end
+32 -24
View File
@@ -184,35 +184,44 @@ namespace :seed_tasks do
plan_headers = VhcsRecord.connection.select_all(sql_query) plan_headers = VhcsRecord.connection.select_all(sql_query)
plan_headers.each do |plan_header| plan_headers.each do |plan_header|
employer = UpdateEmployerJob.perform_now(employer_plan_header: plan_header, full_sync: true) UpdateEmployerJob.new.perform(employer_plan_header: plan_header, full_sync: true)
end
end
desc "Build Initial Plans"
# rake seed_tasks:build_plans
task build_plans: :environment do
puts "Importing Plans"
Employer.all.each do |employer|
puts "-- #{employer.name}" puts "-- #{employer.name}"
UpdateEmployerPlansJob.new.perform(employer.pl_plan_key) UpdateEmployerPlansJob.new.perform(employer.pl_plan_key)
# employer_plans = employer.id_card_setup.plans # employer_plans = employer.id_card_setup.plans
vhcs_plans = Vhcs::PbProduct.where(company_pb_entity_key: employer.company_pb_entity_key, is_active: 255)
vhcs_plans.each do |vp| employer.id_card_setup.plans.each do |plan|
# plan = employer_plans.find_by(pb_product_key: vp.pb_product_key)
# if plan.present?
# plan_titles = employer_plans.pluck(:title)
# plan_title_matcher = JaroWinkler.new(vp.short_description)
# closest_title = plan_titles.max_by { |title| plan_title_matcher.match(title) }
# plan = employer_plans.find_by(title: closest_title)
# plan.update(pb_product_key: vp.pb_product_key)
# end
plan = employer.id_card_setup.plans.find_by(pb_product_key: vp.pb_product_key)
puts "---- #{plan.title}" puts "---- #{plan.title}"
# plan.update(
# title: vp.short_description,
# pl_plan_key: employer.pl_plan_key
# )
vhcs_plan_benefits = Vhcs::HlEgglestonCardBenefit.where(plan_id: plan.pb_product_key) vhcs_plan_benefits = Vhcs::HlEgglestonCardBenefit.where(plan_id: plan.pb_product_key)
vhcs_plan_benefits.each do |vb| vhcs_plan_benefits.each do |vpb|
benefit = plan.plan_benefits.find_by(sequence: vb.sequence) if vpb.benefit.present?
benefit.update(benefit: vb.benefit) benefit = plan.plan_benefits.find_by(sequence: vpb.sequence)
benefit.update(benefit: vpb.benefit)
end
end end
end end
if vhcs_plans.empty? # vhcs_plans = Vhcs::PbProduct.where(company_pb_entity_key: employer.company_pb_entity_key, is_active: 255)
employer.active = false # vhcs_plans.each do |vp|
end # plan = employer.id_card_setup.plans.find_by(pb_product_key: vp.pb_product_key)
# puts "---- #{plan.title}"
# vhcs_plan_benefits = Vhcs::HlEgglestonCardBenefit.where(plan_id: plan.pb_product_key)
# vhcs_plan_benefits.each do |vb|
# benefit = plan.plan_benefits.find_by(sequence: vb.sequence)
# benefit.update(benefit: vb.benefit)
# end
# end
# if vhcs_plans.empty?
# employer.active = false
# end
employer.save employer.save
end end
@@ -223,8 +232,7 @@ namespace :seed_tasks do
task build_members: :environment do task build_members: :environment do
puts "Importing Members" puts "Importing Members"
Employer.all.map(&:sync_members_with_vhcs) Employer.all.map(&:sync_members_with_vhcs)
Employer.left_outer_joins(:members) Employer.where.missing(:members)
.where(members: { id: nil })
.update_all(active: false) .update_all(active: false)
end end