2026-03-20 10:46:53 -04:00
|
|
|
module IdCardQueueService
|
2026-04-15 08:12:47 -04:00
|
|
|
class GetQueuedMembers
|
2026-03-16 12:09:45 -04:00
|
|
|
|
2026-03-19 00:42:27 -04:00
|
|
|
def initialize(pl_plan_keys = nil)
|
2026-03-16 12:09:45 -04:00
|
|
|
if pl_plan_keys
|
2026-07-23 10:32:51 -04:00
|
|
|
@employer_pl_plan_keys = Array.wrap(pl_plan_keys)
|
2026-03-16 12:09:45 -04:00
|
|
|
else
|
2026-07-23 10:32:51 -04:00
|
|
|
@employer_pl_plan_keys = IdCard::Setup.active.pluck(:pl_plan_key)
|
2026-03-16 12:09:45 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def call
|
2026-03-27 08:04:37 -04:00
|
|
|
|
2026-07-23 10:32:51 -04:00
|
|
|
employer_member_keys = @employer_pl_plan_keys.map do |pl_plan_key|
|
|
|
|
|
queued_employer_members = Vhcs::VwmbMember.joins('
|
|
|
|
|
INNER JOIN "CLDocument" ON "CLDocument"."RecipientKey" = "VWMBMember"."MBMemberKey"
|
|
|
|
|
').select('
|
|
|
|
|
"VWMBMember"."PBEntityKey"
|
|
|
|
|
').where('
|
|
|
|
|
"CLDocument"."DocStatus" <> ?
|
|
|
|
|
AND "CLDocument"."PLPlanKey" = ?
|
|
|
|
|
AND "CLDocument"."PrintDate" IS NULL
|
|
|
|
|
AND "CLDocument"."CreateDate" > ?',
|
|
|
|
|
"Printed", pl_plan_key, Date.new(2026, 7, 17)
|
|
|
|
|
).pluck(:pb_entity_key)
|
|
|
|
|
|
|
|
|
|
if queued_employer_members.present?
|
|
|
|
|
{
|
|
|
|
|
pl_plan_key: pl_plan_key,
|
|
|
|
|
member_keys: queued_employer_members
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
""
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
employer_member_keys.compact_blank
|
2026-03-27 08:04:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def format_employers_member_keys(raw_employers_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
|
2026-03-16 12:09:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|