index
int64 0
0
| repo_id
stringclasses 829
values | file_path
stringlengths 34
254
| content
stringlengths 6
5.38M
|
|---|---|---|---|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/va_10215.rb
|
# frozen_string_literal: true
class FormProfiles::VA10215 < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/applicant/information'
}
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/va_2122a.rb
|
# frozen_string_literal: true
require 'vets/model'
module VA2122a
class IdentityValidation
include Vets::Model
attribute :has_icn, Bool
attribute :has_participant_id, Bool
attribute :is_loa3, Bool
end
end
class FormProfiles::VA2122a < FormProfile
attribute :identity_validation, VA2122a::IdentityValidation
def prefill
prefill_identity_validation
super
end
def metadata
{
version: 0,
prefill: true,
returnUrl: '/claimant-type'
}
end
private
def prefill_identity_validation
@identity_validation = VA2122::IdentityValidation.new(
has_icn: user.icn.present?,
has_participant_id: user.participant_id.present?,
is_loa3: user.loa3?
)
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/va_210966.rb
|
# frozen_string_literal: true
class FormProfiles::VA210966 < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/personal-information-1'
}
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/va_21p0537.rb
|
# frozen_string_literal: true
class FormProfiles::VA21p0537 < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/name'
}
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/va_686c674.rb
|
# frozen_string_literal: true
require 'vets/model'
class FormProfiles::VA686c674 < FormProfile
class FormAddress
include Vets::Model
attribute :country_name, String
attribute :address_line1, String
attribute :address_line2, String
attribute :address_line3, String
attribute :city, String
attribute :state_code, String
attribute :province, String
attribute :zip_code, String
attribute :international_postal_code, String
end
attribute :form_address, FormAddress
def prefill
prefill_form_address
super
end
def metadata
{
version: 0,
prefill: true,
returnUrl: '/686-options-selection'
}
end
private
def prefill_form_address
redis_prefill = VAProfileRedis::V2::ContactInformation.for_user(user)
mailing_address = redis_prefill&.mailing_address if user.icn.present? || user.vet360_id.present?
return if mailing_address.blank?
@form_address = FormAddress.new(
mailing_address.to_h.slice(
:address_line1,
:address_line2,
:address_line3,
:city,
:state_code,
:province,
:zip_code,
:international_postal_code
).merge(country_name: mailing_address.country_code_iso3)
)
end
def va_file_number_last_four
response = BGS::People::Request.new.find_person_by_participant_id(user:)
(
response.file_number.presence || user.ssn.presence
)&.last(4)
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/va_21p601.rb
|
# frozen_string_literal: true
class FormProfiles::VA21p601 < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/personal-information'
}
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/va_2122.rb
|
# frozen_string_literal: true
require 'vets/model'
module VA2122
class IdentityValidation
include Vets::Model
attribute :has_icn, Bool
attribute :has_participant_id, Bool
attribute :is_loa3, Bool
end
end
class FormProfiles::VA2122 < FormProfile
attribute :identity_validation, VA2122::IdentityValidation
def prefill
prefill_identity_validation
super
end
def metadata
{
version: 0,
prefill: true,
returnUrl: '/claimant-type'
}
end
private
def prefill_identity_validation
@identity_validation = VA2122::IdentityValidation.new(
has_icn: user.icn.present?,
has_participant_id: user.participant_id.present?,
is_loa3: user.loa3?
)
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/va_264555.rb
|
# frozen_string_literal: true
class FormProfiles::VA264555 < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/personal-information-1'
}
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/dispute_debt.rb
|
# frozen_string_literal: true
class FormProfiles::DisputeDebt < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/personal-information'
}
end
private
def va_file_number_last_four
return unless user.authorize :debt, :access?
file_number =
begin
response = BGS::People::Request.new.find_person_by_participant_id(user:)
response.file_number.presence || user.ssn
rescue
user.ssn
end
file_number&.last(4)
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/va_288832.rb
|
# frozen_string_literal: true
class FormProfiles::VA288832 < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/claimant-information'
}
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/vha_10_10d.rb
|
# frozen_string_literal: true
class FormProfiles::VHA1010d < FormProfile
FORM_ID = '10-10D'
def metadata
{
version: 0,
prefill: true,
returnUrl: '/signer-type'
}
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/va_4010007.rb
|
# frozen_string_literal: true
class FormProfiles::VA4010007 < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/applicant-information'
}
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/form_profiles/form_mock_ae_design_patterns.rb
|
# frozen_string_literal: true
class FormProfiles::FormMockAeDesignPatterns < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/veteran-details'
}
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/lighthouse/submission.rb
|
# frozen_string_literal: true
class Lighthouse::Submission < Submission
self.table_name = 'lighthouse_submissions'
include SubmissionEncryption
has_many :submission_attempts, class_name: 'Lighthouse::SubmissionAttempt', dependent: :destroy,
foreign_key: :lighthouse_submission_id, inverse_of: :submission
belongs_to :saved_claim, optional: true
def self.with_intake_uuid_for_user(user_account)
joins(:saved_claim, :submission_attempts)
.includes(:submission_attempts)
.where(saved_claims: { user_account_id: user_account.id })
.where.not(lighthouse_submission_attempts: { benefits_intake_uuid: nil })
end
def latest_attempt
submission_attempts.order(created_at: :asc).last
end
def latest_pending_attempt
submission_attempts.where(status: 'pending').order(created_at: :asc).last
end
def non_failure_attempt
submission_attempts.where(status: %w[pending submitted]).first
end
def latest_benefits_intake_uuid
submission_attempts.order(created_at: :desc).limit(1).pick(:benefits_intake_uuid)
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/lighthouse/submission_attempt.rb
|
# frozen_string_literal: true
class Lighthouse::SubmissionAttempt < SubmissionAttempt
self.table_name = 'lighthouse_submission_attempts'
include SubmissionAttemptEncryption
belongs_to :submission, class_name: 'Lighthouse::Submission', foreign_key: :lighthouse_submission_id,
inverse_of: :submission_attempts
has_one :saved_claim, through: :submission
enum :status, {
pending: 'pending',
submitted: 'submitted',
vbms: 'vbms',
failure: 'failure',
manually: 'manually'
}
STATS_KEY = 'api.lighthouse.submission_attempt'
def fail!
failure!
log_hash = status_change_hash
log_hash[:message] = 'Lighthouse Submission Attempt failed'
monitor.track_request(:error, log_hash[:message], STATS_KEY, **log_hash)
end
def manual!
manually!
log_hash = status_change_hash
log_hash[:message] = 'Lighthouse Submission Attempt is being manually remediated'
monitor.track_request(:warn, log_hash[:message], STATS_KEY, **log_hash)
end
def vbms!
update(status: :vbms)
log_hash = status_change_hash
log_hash[:message] = 'Lighthouse Submission Attempt went to vbms'
monitor.track_request(:info, log_hash[:message], STATS_KEY, **log_hash)
end
def pending!
update(status: :pending)
log_hash = status_change_hash
log_hash[:message] = 'Lighthouse Submission Attempt is pending'
monitor.track_request(:info, log_hash[:message], STATS_KEY, **log_hash)
end
def success!
submitted!
log_hash = status_change_hash
log_hash[:message] = 'Lighthouse Submission Attempt is submitted'
monitor.track_request(:info, log_hash[:message], STATS_KEY, **log_hash)
end
def monitor
@monitor ||= Logging::Monitor.new('lighthouse_submission_attempt')
end
def status_change_hash
{
submission_id: submission.id,
claim_id: submission.saved_claim_id,
form_type: submission.form_id,
from_state: previous_changes[:status]&.first,
to_state: status,
benefits_intake_uuid:
}
end
end
|
0
|
code_files/vets-api-private/app/models/lighthouse
|
code_files/vets-api-private/app/models/lighthouse/hcc/invoice.rb
|
# frozen_string_literal: true
module Lighthouse
module HCC
class Invoice
include Vets::Model
attribute :external_id, String
attribute :facility, String
attribute :latest_billing_ref, String
attribute :current_balance, Float
attribute :previous_balance, String
attribute :previous_unpaid_balance, String
attribute :last_updated_at, String
attribute :last_credit_debit, Float
attribute :url, String
def initialize(params)
@params = params
assign_attributes
end
def assign_attributes
line_item = @params.dig('resource', 'lineItem')&.first
@facility = @params.dig('resource', 'issuer', 'display')
@latest_billing_ref = line_item
&.dig('chargeItemReference', 'reference')
&.split('/')
&.last
@last_credit_debit = line_item&.dig('priceComponent', 0, 'amount', 'value')
@last_updated_at = @params.dig('resource', 'meta', 'lastUpdated')
@current_balance = calculate_current_balance ? calculate_current_balance.compact.sum : 0.0
@previous_balance = @params['resource']['totalPriceComponent'].find do |c|
c['type'] == 'informational' && c.dig('code', 'text') == 'Original Amount'
end&.dig('amount', 'value')&.to_f
@previous_unpaid_balance = @params['resource']['totalPriceComponent']
.select { |c| %w[base surcharge].include?(c['type']) }
.sum { |c| c.dig('amount', 'value').to_f }
@url = @params.dig('resource', 'fullUrl')
@external_id = @params.dig('resource', 'id')
end
def calculate_current_balance
@params.dig('resource', 'totalPriceComponent')&.map do |tpc|
next if tpc['type'] == 'informational'
tpc['amount']['value']
end
end
end
end
end
|
0
|
code_files/vets-api-private/app/models/lighthouse
|
code_files/vets-api-private/app/models/lighthouse/hcc/copay_detail.rb
|
# frozen_string_literal: true
module Lighthouse
module HCC
class CopayDetail
include Vets::Model
PAYMENT_DUE_DAYS = 30
attribute :external_id, String
attribute :facility, String
attribute :bill_number, String
attribute :status, String
attribute :status_description, String
attribute :invoice_date, String
attribute :payment_due_date, String
attribute :account_number, String
attribute :original_amount, Float
attribute :principal_balance, Float
attribute :interest_balance, Float
attribute :administrative_cost_balance, Float
attribute :principal_paid, Float
attribute :interest_paid, Float
attribute :administrative_cost_paid, Float
attribute :line_items, Hash, array: true
attribute :payments, Hash, array: true
def initialize(attrs = {})
@invoice_data = attrs[:invoice_data]
@account_data = attrs[:account_data]
@charge_items = attrs[:charge_items] || {}
@encounters = attrs[:encounters] || {}
@medication_dispenses = attrs[:medication_dispenses] || {}
@medications = attrs[:medications] || {}
@payments_data = attrs[:payments] || []
assign_attributes
end
private
def assign_attributes
@external_id = @invoice_data['id']
@facility = @invoice_data.dig('issuer', 'display')
@bill_number = @invoice_data.dig('identifier', 0, 'value')
@status = @invoice_data['status']
@status_description = @invoice_data.dig('_status', 'valueCodeableConcept', 'text')
@invoice_date = @invoice_data['date']
@payment_due_date = calculate_payment_due_date
@account_number = @account_data&.dig('identifier', 0, 'value')
assign_balances
assign_line_items
assign_payments
end
def assign_balances
total_price_components = @invoice_data['totalPriceComponent'] || []
@original_amount = find_amount(total_price_components, 'Original Amount')
@principal_balance = find_amount(total_price_components, 'Principal Balance')
@interest_balance = find_amount(total_price_components, 'Interest Balance')
@administrative_cost_balance = find_amount(total_price_components, 'Administrative Cost Balance')
@principal_paid = find_amount(total_price_components, 'Principal Paid')
@interest_paid = find_amount(total_price_components, 'Interest Paid')
@administrative_cost_paid = find_amount(total_price_components, 'Administrative Cost Paid')
end
def assign_line_items
invoice_line_items = @invoice_data['lineItem'] || []
@line_items = invoice_line_items.map { |li| build_line_item(li) }
end
def build_line_item(invoice_line_item)
charge_item_id = extract_id_from_reference(invoice_line_item.dig('chargeItemReference', 'reference'))
charge_item = @charge_items[charge_item_id] || {}
{
billing_reference: charge_item_id,
date_posted: extract_date_posted(charge_item),
description: charge_item.dig('code', 'text'),
provider_name: extract_provider_name(charge_item),
price_components: build_price_components(invoice_line_item),
medication: build_medication(charge_item)
}.compact
end
def extract_date_posted(charge_item)
charge_item['occurrenceDateTime'] ||
charge_item.dig('occurrencePeriod', 'start') ||
charge_item['enteredDate']
end
def extract_provider_name(charge_item)
encounter_ref = charge_item.dig('context', 'reference')
return nil unless encounter_ref
encounter_id = extract_id_from_reference(encounter_ref)
encounter = @encounters[encounter_id]
encounter&.dig('serviceProvider', 'display')
end
def build_price_components(invoice_line_item)
components = invoice_line_item['priceComponent'] || []
components.map do |pc|
{
type: pc['type'],
code: pc.dig('code', 'text'),
amount: pc.dig('amount', 'value')&.to_f
}
end
end
def build_medication(charge_item)
services = charge_item['service'] || []
dispense_ref = services.find { |s| s['reference']&.include?('MedicationDispense') }&.dig('reference')
return nil unless dispense_ref
dispense_id = extract_id_from_reference(dispense_ref)
dispense = @medication_dispenses[dispense_id]
return nil unless dispense
medication_ref = dispense.dig('medicationReference', 'reference')
medication_id = extract_id_from_reference(medication_ref)
medication = @medications[medication_id]
{
medication_name: dispense.dig('medicationReference', 'display') ||
dispense.dig('medicationCodeableConcept', 'text'),
rx_number: medication&.dig('identifier', 0, 'id'),
quantity: dispense.dig('quantity', 'value'),
days_supply: dispense.dig('daysSupply', 'value')
}
end
def assign_payments
@payments = @payments_data.map { |p| build_payment(p) }
end
def build_payment(payment_data)
{
payment_id: payment_data['id'],
payment_date: payment_data['paymentDate'],
payment_amount: payment_data.dig('paymentAmount', 'value')&.to_f,
transaction_number: extract_transaction_number(payment_data),
bill_number: extract_bill_number(payment_data),
invoice_reference: extract_invoice_reference(payment_data),
disposition: payment_data['disposition'],
detail: build_payment_detail(payment_data)
}
end
def extract_transaction_number(payment_data)
identifiers = payment_data['identifier'] || []
identifiers.find { |i| i.dig('type', 'text') == 'Transaction Number' }&.dig('value')
end
def extract_bill_number(payment_data)
identifiers = payment_data['identifier'] || []
identifiers.find { |i| i.dig('type', 'text') == 'Bill Number' }&.dig('value')
end
def extract_invoice_reference(payment_data)
extensions = payment_data['extension'] || []
target_ext = extensions.find { |e| e['url']&.include?('allocation.target') }
return nil unless target_ext
extract_id_from_reference(target_ext.dig('valueReference', 'reference'))
end
def build_payment_detail(payment_data)
details = payment_data['detail'] || []
details.map do |d|
{
type: d.dig('type', 'text'),
amount: d.dig('amount', 'value')&.to_f
}
end
end
def find_amount(components, code_text)
components.find { |c| c.dig('code', 'text') == code_text }&.dig('amount', 'value')&.to_f
end
def calculate_payment_due_date
return nil unless @invoice_date
(Date.parse(@invoice_date) + PAYMENT_DUE_DAYS.days).iso8601
rescue Date::Error
nil
end
def extract_id_from_reference(reference)
return nil unless reference
reference.split('/').last
end
end
end
end
|
0
|
code_files/vets-api-private/app/models/lighthouse
|
code_files/vets-api-private/app/models/lighthouse/hcc/bundle.rb
|
# frozen_string_literal: true
module Lighthouse
module HCC
class Bundle
include Vets::Model
attribute :entries, Array
attribute :links, Hash
attribute :meta, Hash
attribute :total, Integer
attribute :page, Integer
attribute :per_page, Integer
def initialize(bundle_hash, entries)
@bundle = bundle_hash
@entries = entries
@links = build_links
@meta = build_meta
@total = @meta[:total]
@page = @meta[:page]
@per_page = @meta[:per_page]
end
private
def build_links
raw_links = @bundle['link']
return {} if raw_links.empty?
relations = raw_links.index_by { |l| l['relation'] }
lh_links = {
self: relations['self']&.dig('url'),
first: relations['first']&.dig('url'),
prev: (relations['previous'] || relations['prev'])&.dig('url'),
next: relations['next']&.dig('url'),
last: relations['last']&.dig('url')
}.compact
lh_links.transform_values { |u| rewrite_to_vets_api(u) }.compact
end
def rewrite_to_vets_api(lh_url)
uri = URI(lh_url)
base = URI(api_base_uri)
uri.scheme = base.scheme
uri.host = base.host
uri.port = base.port
uri.to_s
end
def api_base_uri
"#{Rails.application.config.protocol}://#{Rails.application.config.hostname}"
end
def build_meta
relations = @bundle['link'].index_by { |l| l['relation'] }
self_url = relations['self']&.dig('url')
query_string = CGI.parse(URI(self_url).query.to_s)
base_meta = {
total: @bundle['total'].to_i,
page: query_string['page']&.first.to_i,
per_page: query_string['_count']&.first.to_i
}
base_meta.merge(copay_summary_meta)
end
def copay_summary_meta
total_current_balance = @entries.reduce(BigDecimal('0')) do |sum, entry|
sum + BigDecimal(entry.current_balance.to_s)
end
copay_bill_count = @entries.size
last_updated_on = @entries.maximum(:last_updated_at)
{
copay_summary: {
total_current_balance: total_current_balance.to_f,
copay_bill_count:,
last_updated_on:
}
}
end
end
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/concerns/redis_form.rb
|
# frozen_string_literal: true
module RedisForm
extend ActiveSupport::Concern
included do |base|
# i tried to make this module a class but it didn't work because of how RedisStore was defined
raise 'must be a subclass of Common::RedisStore' unless base < Common::RedisStore
include SetGuid
include AsyncRequest
attr_accessor(:user)
attr_accessor(:form)
redis_store(name.underscore)
redis_ttl(86_400)
redis_key(:guid)
attribute(:state, String, default: 'pending')
attribute(:guid, String)
attribute(:response, String)
alias_method :id, :guid
validate(:form_matches_schema, unless: :persisted?)
validates(:form, presence: true, unless: :persisted?)
end
def parsed_form
@parsed_form ||= JSON.parse(form)
end
def parsed_response
return if response.blank?
@parsed_response ||= JSON.parse(response)
end
def save
originally_persisted = @persisted
saved = super
create_submission_job if saved && !originally_persisted
saved
end
private
def form_matches_schema
if form.present?
JSON::Validator.fully_validate(VetsJsonSchema::SCHEMAS[self.class::FORM_ID], parsed_form).each do |v|
errors.add(:form, v.to_s)
end
end
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/concerns/set_guid.rb
|
# frozen_string_literal: true
module SetGuid
extend ActiveSupport::Concern
included do
after_initialize do
self.guid ||= SecureRandom.uuid
end
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/concerns/temp_form_validation.rb
|
# frozen_string_literal: true
module TempFormValidation
extend ActiveSupport::Concern
included do
attr_accessor(:form)
validates(:form, presence: true, on: :create)
validate(:form_matches_schema, on: :create)
end
def parsed_form
@parsed_form ||= JSON.parse(form)
end
private
def form_matches_schema
if form.present?
JSON::Validator.fully_validate(VetsJsonSchema::SCHEMAS[self.class::FORM_ID], parsed_form).each do |v|
errors.add(:form, v.to_s)
end
end
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/concerns/async_request.rb
|
# frozen_string_literal: true
module AsyncRequest
extend ActiveSupport::Concern
include ActiveModel::Validations::Callbacks
included do
validates(:state, presence: true, inclusion: %w[success failed pending])
validates(:response, presence: true, if: :success?)
end
def success?
state == 'success'
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/concerns/authorization.rb
|
# frozen_string_literal: true
module Authorization
extend ActiveSupport::Concern
def authorize(policy, method)
Pundit.policy!(self, policy).send(method)
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/concerns/form526_mpi_concern.rb
|
# frozen_string_literal: true
module Form526MPIConcern
extend ActiveSupport::Concern
def mpi_service
@mpi_service ||= MPI::Service.new
end
def get_icn_from_mpi
edipi_response_profile = edipi_mpi_profile_query(auth_headers['va_eauth_dodedipnid'])
if edipi_response_profile&.icn.present?
OpenStruct.new(icn: edipi_response_profile.icn)
else
Rails.logger.info('Form526Submission::account - unable to look up MPI profile with EDIPI', log_payload)
attributes_response_profile = attributes_mpi_profile_query(auth_headers)
if attributes_response_profile&.icn.present?
OpenStruct.new(icn: attributes_response_profile.icn)
else
Rails.logger.info('Form526Submission::account - no ICN present', log_payload)
OpenStruct.new(icn: nil)
end
end
end
def edipi_mpi_profile_query(edipi)
return unless edipi
edipi_response = mpi_service.find_profile_by_edipi(edipi:)
edipi_response.profile if edipi_response.ok? && edipi_response.profile.icn.present?
end
def attributes_mpi_profile_query(auth_headers)
required_attributes = %w[va_eauth_firstName va_eauth_lastName va_eauth_birthdate va_eauth_pnid]
return unless required_attributes.all? { |attr| auth_headers[attr].present? }
attributes_response = mpi_service.find_profile_by_attributes(
first_name: auth_headers['va_eauth_firstName'],
last_name: auth_headers['va_eauth_lastName'],
birth_date: auth_headers['va_eauth_birthdate']&.to_date.to_s,
ssn: auth_headers['va_eauth_pnid']
)
attributes_response.profile if attributes_response.ok? && attributes_response.profile.icn.present?
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/concerns/redis_caching.rb
|
# frozen_string_literal: true
module RedisCaching
extend ActiveSupport::Concern
class_methods do
def redis_config(config)
@redis_namespace = config[:namespace]
@redis_ttl = config[:each_ttl]
@redis = Redis::Namespace.new(@redis_namespace, redis: $redis)
end
def get_cached(key)
result = @redis.get(key)
return nil unless result
data = JSON.parse(result)
data.map { |i| new(i.deep_symbolize_keys) }
end
def set_cached(key, data)
if data
@redis.set(key, data.to_json)
@redis.expire(key, @redis_ttl)
else
Rails.logger.info('Attempted to set nil data in redis cache')
end
end
def clear_cache(key)
@redis.del(key)
end
def time_until_5am_utc
now = Time.now.utc
five_am_utc = Time.utc(now.year, now.month, now.day, 5)
five_am_utc += 1.day if now >= five_am_utc
five_am_utc - now
end
end
end
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/concerns/form526_claim_fast_tracking_concern.rb
|
# frozen_string_literal: true
require 'mail_automation/client'
require 'lighthouse/veterans_health/client'
require 'contention_classification/client'
# rubocop:disable Metrics/ModuleLength
# For use with Form526Submission
module Form526ClaimFastTrackingConcern
extend ActiveSupport::Concern
RRD_STATSD_KEY_PREFIX = 'worker.rapid_ready_for_decision'
MAX_CFI_STATSD_KEY_PREFIX = 'api.max_cfi'
FLASHES_STATSD_KEY = 'worker.flashes'
DOCUMENT_TYPE_METRICS_STATSD_KEY_PREFIX = 'worker.document_type_metrics'
FLASH_PROTOTYPES = ['Amyotrophic Lateral Sclerosis'].freeze
OPEN_STATUSES = [
'CLAIM RECEIVED',
'UNDER REVIEW',
'GATHERING OF EVIDENCE',
'REVIEW OF EVIDENCE',
'CLAIM_RECEIVED',
'INITIAL_REVIEW'
].freeze
def claim_age_in_days(pending_ep)
date = if pending_ep.respond_to?(:claim_date)
Date.strptime(pending_ep.claim_date, '%Y-%m-%d')
else
Date.strptime(pending_ep['date'], '%m/%d/%Y')
end
(Time.zone.today - date).round
end
def send_rrd_alert_email(subject, message, error = nil, to = Settings.rrd.alerts.recipients)
RrdAlertMailer.build(self, subject, message, error, to).deliver_now
end
def read_metadata(key)
form.dig('rrd_metadata', key.to_s)
end
# @param metadata_hash [Hash] to be merged into form_json['rrd_metadata']
def save_metadata(metadata_hash)
form['rrd_metadata'] ||= {}
form['rrd_metadata'].deep_merge!(metadata_hash)
update!(form_json: JSON.dump(form))
invalidate_form_hash
self
end
# TODO: Remove? This is unused.
def rrd_status
return 'processed' if rrd_claim_processed?
offramp_reason = read_metadata(:offramp_reason)
return offramp_reason if offramp_reason.present?
return 'error' if read_metadata(:error).present?
'unknown'
end
# Fetch all claims from EVSS
# @return [Boolean] whether there are any open EP 020's
def pending_eps?
pending = open_claims.any? do |claim|
claim.base_end_product_code == '020' && claim.status.upcase != 'COMPLETE'
end
save_metadata(offramp_reason: 'pending_ep') if pending
pending
end
def rrd_pdf_created?
read_metadata(:pdf_created) || false
end
def rrd_pdf_uploaded_to_s3?
read_metadata(:pdf_guid).present?
end
DOCUMENT_NAME_PREFIX = 'VAMC'
DOCUMENT_NAME_SUFFIX = 'Rapid_Decision_Evidence'
PDF_FILENAME_REGEX = /#{DOCUMENT_NAME_PREFIX}.*#{DOCUMENT_NAME_SUFFIX}/
RRD_CODE = 'RRD'
# @return if an RRD pdf has been included as a file to upload
def rrd_pdf_added_for_uploading?
form['form526_uploads']&.any? do |upload|
upload['name']&.match? PDF_FILENAME_REGEX
end
end
def rrd_special_issue_set?
disabilities.any? do |disability|
disability['specialIssues']&.include?(RRD_CODE)
end
end
def flashes
form['flashes'] || []
end
def disabilities
form.dig('form526', 'form526', 'disabilities')
end
def increase_disabilities
disabilities.select { |disability| disability['disabilityActionType']&.upcase == 'INCREASE' }
end
def diagnostic_codes
disabilities.pluck('diagnosticCode')
end
def prepare_for_evss!
begin
update_contention_classification_all!
log_mst_metrics
rescue => e
Rails.logger.error("Contention Classification failed #{e.message}.")
Rails.logger.error(e.backtrace.join('\n'))
end
return if pending_eps? || disabilities_not_service_connected?
save_metadata(forward_to_mas_all_claims: true)
end
def update_form_with_classification_codes(classified_contentions)
classified_contentions.each_with_index do |classified_contention, index|
if classified_contention['classification_code'].present?
classification_code = classified_contention['classification_code']
disabilities[index]['classificationCode'] = classification_code
end
end
update!(form_json: form.to_json)
invalidate_form_hash
end
def classify_vagov_contentions(params)
cc_client = ContentionClassification::Client.new
current_user = OpenStruct.new({ flipper_id: user_uuid })
response = if Flipper.enabled?(:contention_classification_ml_classifier, current_user)
cc_client.classify_vagov_contentions_hybrid(params)
else
cc_client.classify_vagov_contentions_expanded(params)
end
response.body
end
def format_contention_for_request(disability)
contention = {
contention_text: disability['name'],
contention_type: disability['disabilityActionType']
}
contention['diagnostic_code'] = disability['diagnosticCode'] if disability['diagnosticCode']
contention
end
def log_claim_level_metrics(response_body)
response_body['is_multi_contention_claim'] = disabilities.count > 1
Rails.logger.info('classifier response for 526Submission', payload: response_body)
end
def log_and_halt_if_no_disabilities
Rails.logger.info("No disabilities found for classification on claim #{id}")
false
end
# Submits contention information to the Contention Classification API service
# adds classification to the form for each contention provided a classification
def update_contention_classification_all!
return log_and_halt_if_no_disabilities if disabilities.blank?
contentions_array = disabilities.map { |disability| format_contention_for_request(disability) }
params = { claim_id: saved_claim_id, form526_submission_id: id, contentions: contentions_array }
classifier_response = classify_vagov_contentions(params)
log_claim_level_metrics(classifier_response)
classifier_response['contentions'].each do |contention|
classification = nil
if contention.key?('classification_code') && contention.key?('classification_name')
classification = {
classification_code: contention['classification_code'],
classification_name: contention['classification_name']
}
end
# NOTE: claim_type is actually type of contention, but formatting
# preserved in order to match existing datadog dashboard
Rails.logger.info('Classified 526Submission',
id:, saved_claim_id:, classification:,
claim_type: contention['contention_type'])
end
update_form_with_classification_codes(classifier_response['contentions'])
classifier_response['is_fully_classified']
end
def log_max_cfi_metrics_on_submit
max_rated_diagnostic_codes_from_ipf.each do |diagnostic_code|
disability_claimed = diagnostic_codes.include?(diagnostic_code)
StatsD.increment("#{MAX_CFI_STATSD_KEY_PREFIX}.submit",
tags: ["diagnostic_code:#{diagnostic_code}", "claimed:#{disability_claimed}"])
end
claimed_max_rated_dcs = max_rated_diagnostic_codes_from_ipf & diagnostic_codes
Rails.logger.info('Max CFI form526 submission',
id:,
num_max_rated: max_rated_diagnostic_codes_from_ipf.count,
num_max_rated_cfi: claimed_max_rated_dcs.count,
total_cfi: increase_disabilities.count,
cfi_checkbox_was_selected: cfi_checkbox_was_selected?)
StatsD.increment("#{MAX_CFI_STATSD_KEY_PREFIX}.on_submit",
tags: ["claimed:#{claimed_max_rated_dcs.any?}",
"has_max_rated:#{max_rated_diagnostic_codes_from_ipf.any?}"])
rescue => e
# Log the exception but but do not fail, otherwise form will not be submitted
log_error(e)
end
def send_post_evss_notifications!
conditionally_notify_mas
log_flashes
Rails.logger.info('Submitted 526Submission to eVSS', id:, saved_claim_id:, submitted_claim_id:)
end
# return whether all disabilities on this form are rated as not service-connected
def disabilities_not_service_connected?
disabilities.pluck('ratedDisabilityId').all? do |rated_id|
rated_id.present? && (all_rated_disabilities
.find { |rated| rated_id == rated.rated_disability_id }
&.decision_code == 'NOTSVCCON')
end
end
# return whether the associated InProgressForm ever logged that the CFI checkbox was selected
def cfi_checkbox_was_selected?
return false if in_progress_form.nil?
ClaimFastTracking::MaxCfiMetrics.new(in_progress_form, {}).create_or_load_metadata['cfiLogged']
end
private
def log_error(error)
Rails.logger.error(
"Form526ClaimsFastTrackingConcern #{id} encountered an error",
submission_id: id,
error_message: error.message
)
rescue
# We need this to not ever fail or it blocks submission
# So no variables or methods called in this block, to reduce chance of further errors
Rails.logger.error('Form526ClaimsFastTrackingConcern Failed to log error')
end
def in_progress_form
@in_progress_form ||= InProgressForm.find_by(form_id: '21-526EZ', user_uuid:)
end
def max_rated_disabilities_from_ipf
return [] if in_progress_form.nil?
fd = in_progress_form.form_data
fd = JSON.parse(fd) if fd.is_a?(String)
rated_disabilities = fd['rated_disabilities'] || []
rated_disabilities.select do |dis|
dis['maximum_rating_percentage'].present? && dis['maximum_rating_percentage'] == dis['rating_percentage']
end
end
def max_rated_diagnostic_codes_from_ipf
max_rated_disabilities_from_ipf.pluck('diagnostic_code')
end
# Fetch and memoize all of the veteran's open EPs. Establishing a new EP will make the memoized
# value outdated if using the same Form526Submission instance.
def open_claims
@open_claims ||= begin
icn = account.icn
api_provider = ApiProviderFactory.call(
type: ApiProviderFactory::FACTORIES[:claims],
provider: ApiProviderFactory::API_PROVIDER[:lighthouse],
options: { auth_headers:, icn: },
# Flipper id is needed to check if the feature toggle works for this user
current_user: OpenStruct.new({ flipper_id: user_account_id }),
feature_toggle: nil
)
all_claims = api_provider.all_claims
all_claims.open_claims
end
end
# fetch, memoize, and return all of the veteran's rated disabilities from EVSS
def all_rated_disabilities
settings = Settings.lighthouse.veteran_verification.form526
icn = account&.icn
invoker = 'Form526ClaimFastTrackingConcern#all_rated_disabilities'
api_provider = ApiProviderFactory.call(
type: ApiProviderFactory::FACTORIES[:rated_disabilities],
provider: :lighthouse,
options: { auth_headers:, icn: },
# Flipper id is needed to check if the feature toggle works for this user
current_user: OpenStruct.new({ flipper_id: user_uuid }),
feature_toggle: nil
)
@all_rated_disabilities ||= begin
response = api_provider.get_rated_disabilities(
settings.access_token.client_id,
settings.access_token.rsa_key,
{ invoker: }
)
response.rated_disabilities
end
end
# @return if this claim submission was processed and fast-tracked by RRD
def rrd_claim_processed?
rrd_pdf_added_for_uploading? && rrd_special_issue_set?
end
def notify_mas_all_claims_tracking
RrdMasNotificationMailer.build(self, Settings.rrd.mas_all_claims_tracking.recipients).deliver_now
end
def conditionally_notify_mas
return unless read_metadata(:forward_to_mas_all_claims)
notify_mas_all_claims_tracking
client = MailAutomation::Client.new({
file_number: birls_id,
claim_id: submitted_claim_id,
form526: form
})
response = client.initiate_apcas_processing
mas_packet_id = response&.body ? response.body['packetId'] : nil
save_metadata(mas_packetId: mas_packet_id)
StatsD.increment("#{RRD_STATSD_KEY_PREFIX}.notify_mas.success")
rescue => e
send_rrd_alert_email("Failure: MA claim - #{submitted_claim_id}", e.to_s, nil,
Settings.rrd.mas_tracking.recipients)
StatsD.increment("#{RRD_STATSD_KEY_PREFIX}.notify_mas.failure")
end
def log_flashes
flash_prototypes = FLASH_PROTOTYPES & flashes
Rails.logger.info('Flash Prototype Added', { submitted_claim_id:, flashes: }) if flash_prototypes.any?
flashes.each do |flash|
StatsD.increment(FLASHES_STATSD_KEY, tags: ["flash:#{flash}", "prototype:#{flash_prototypes.include?(flash)}"])
end
rescue => e
Rails.logger.error("Failed to log Flash Prototypes #{e.message}.", backtrace: e.backtrace)
end
def log_document_type_metrics
return if in_progress_form.blank?
fd = in_progress_form.form_data
fd = JSON.parse(fd) if fd.is_a?(String)
additional_docs_by_type = get_doc_type_counts(fd, 'additionalDocuments')
private_medical_docs_by_type = get_doc_type_counts(fd, 'privateMedicalRecordAttachments')
return if additional_docs_by_type.blank? && private_medical_docs_by_type.blank?
log_doc_type_metrics_for_group(additional_docs_by_type, 'additionalDocuments')
log_doc_type_metrics_for_group(private_medical_docs_by_type, 'privateMedicalRecordAttachments')
Rails.logger.info('Form526 evidence document type metrics',
id:,
additional_docs_by_type:,
private_medical_docs_by_type:)
rescue => e
# Log the exception but do not fail
log_error(e)
end
def get_group_docs(form_data, group_key)
return [] unless form_data.is_a?(Hash)
form_data.fetch(group_key, form_data.fetch(group_key.underscore, []))
end
def get_doc_type_counts(form_data, group_key)
docs = get_group_docs(form_data, group_key)
return {} if docs.nil? || !docs.is_a?(Array)
docs.map do |doc|
next nil if doc.blank?
next 'unknown' unless doc.is_a?(Hash)
doc.fetch('attachmentId', doc.fetch('attachment_id', 'unknown'))
end.compact
.group_by(&:itself)
.transform_values(&:count)
end
def log_doc_type_metrics_for_group(doc_type_counts, group_name)
doc_type_counts.each do |doc_type, count|
StatsD.increment("#{DOCUMENT_TYPE_METRICS_STATSD_KEY_PREFIX}.#{group_name.underscore}_document_type",
count,
tags: ["document_type:#{doc_type}", 'source:form526'])
end
end
def log_mst_metrics
return if form.dig('form0781', 'form0781v2').blank?
mst_checkbox_selected = form.dig('form0781', 'form0781v2', 'eventTypes', 'mst') == true
return unless mst_checkbox_selected
Rails.logger.info('Form526-0781 MST selected',
id:,
disabilities: extract_disability_summary)
rescue => e
# Log the exception but do not fail
log_error(e)
end
def extract_disability_summary
return [] if disabilities.blank?
# If the disability does not have a classificationCode, then it was not able to get the classification from the
# contention classification service, which means it is a free text input which could contain PII, and should be
# marked as unclassifiable.
disabilities.map do |disability|
{
name: disability['classificationCode'].present? ? disability['name'] : 'unclassifiable',
disabilityActionType: disability['disabilityActionType'],
diagnosticCode: disability['diagnosticCode'],
classificationCode: disability['classificationCode']
}
end
end
end
# rubocop:enable Metrics/ModuleLength
|
0
|
code_files/vets-api-private/app/models
|
code_files/vets-api-private/app/models/concerns/kms_encrypted_model_patch.rb
|
# frozen_string_literal: true
module KmsEncryptedModelPatch
extend self
# Update #kms_key_rotation_date method if rotation date changes from 10/12
def has_kms_key(**args)
# implicitly calls #has_kms_key with specified options, so that we don't need to require it
# of future encrypted models
super(**args.merge(kms_options))
end
def kms_version
Time.zone.today < kms_key_rotation_date ? Time.zone.today.year - 1 : Time.zone.today.year
end
private
def kms_key_rotation_date
Date.new(Time.zone.today.year, 10, 12)
end
def kms_options
# Enumerate key_ids so that all years/previous versions are accounted for. Every
# version should point to the same key_id
previous_versions = Hash.new do |hash, key|
hash[key] = { key_id: KmsEncrypted.key_id }
end
{
version: kms_version,
previous_versions:
}
end
end
|
0
|
code_files/vets-api-private/app/openapi
|
code_files/vets-api-private/app/openapi/openapi/components.rb
|
# frozen_string_literal: true
module Openapi
module Components
ALL = {
schemas: {
Errors: Openapi::Components::Errors::ERRORS,
Error: Openapi::Components::Errors::ERROR,
FirstMiddleLastName: Openapi::Components::Name::FIRST_MIDDLE_LAST,
SimpleAddress: Openapi::Components::Address::SIMPLE_ADDRESS
}
}.freeze
end
end
|
0
|
code_files/vets-api-private/app/openapi/openapi
|
code_files/vets-api-private/app/openapi/openapi/responses/benefits_intake_submission_response.rb
|
# frozen_string_literal: true
module Openapi
module Responses
class BenefitsIntakeSubmissionResponse
# Valid response from Benefits Intake API (called via Lighthouse::SubmitBenefitsIntakeClaim)
BENEFITS_INTAKE_SUBMISSION_RESPONSE = {
type: :object,
properties: {
data: {
type: :object,
properties: {
id: { type: :string },
type: { type: :string, example: 'saved_claims' },
attributes: {
type: :object,
properties: {
submitted_at: {
type: :string,
format: 'date-time',
description: 'ISO 8601 timestamp of when the form was submitted'
},
regional_office: {
type: :array,
items: { type: :string },
description: 'Array of strings representing the regional office address',
example: [
'Department of Veterans Affairs',
'Pension Management Center',
'P.O. Box 5365',
'Janesville, WI 53547-5365'
]
},
confirmation_number: {
type: :string,
description: 'Confirmation number (GUID) for tracking the submission'
},
guid: {
type: :string,
description: 'Unique identifier (same as confirmation_number)'
},
form: {
type: :string,
description: 'Form identifier (e.g., "21P-530a", "21-4192")'
}
}
}
}
}
},
required: [:data]
}.freeze
end
end
end
|
0
|
code_files/vets-api-private/app/openapi/openapi
|
code_files/vets-api-private/app/openapi/openapi/requests/form214192.rb
|
# frozen_string_literal: true
module Openapi
module Requests
class Form214192
FORM_SCHEMA = {
'$schema': 'json-schemer://openapi30/schema',
type: :object,
properties: {
veteranInformation: {
type: :object,
required: %i[fullName dateOfBirth],
properties: {
fullName: { '$ref' => '#/components/schemas/FirstMiddleLastName' },
ssn: {
type: :string,
pattern: '^\d{9}$',
description: 'Social Security Number (9 digits)',
example: '123456789'
},
vaFileNumber: { type: :string, example: '987654321' },
dateOfBirth: { type: :string, format: :date, example: '1980-01-01' },
address: { '$ref' => '#/components/schemas/SimpleAddress' }
}
},
employmentInformation: {
type: :object,
required: %i[employerName employerAddress typeOfWorkPerformed
beginningDateOfEmployment],
properties: {
employerName: { type: :string },
employerAddress: { '$ref' => '#/components/schemas/SimpleAddress' },
typeOfWorkPerformed: { type: :string },
beginningDateOfEmployment: { type: :string, format: :date },
endingDateOfEmployment: { type: :string, format: :date },
amountEarnedLast12MonthsOfEmployment: { type: :number },
timeLostLast12MonthsOfEmployment: { type: :string },
hoursWorkedDaily: { type: :number },
hoursWorkedWeekly: { type: :number },
concessions: { type: :string },
terminationReason: { type: :string },
dateLastWorked: { type: :string, format: :date },
lastPaymentDate: { type: :string, format: :date },
lastPaymentGrossAmount: { type: :number },
lumpSumPaymentMade: { type: :boolean },
grossAmountPaid: { type: :number },
datePaid: { type: :string, format: :date }
}
},
militaryDutyStatus: {
type: :object,
properties: {
currentDutyStatus: { type: :string },
veteranDisabilitiesPreventMilitaryDuties: { type: :boolean }
}
},
benefitEntitlementPayments: {
type: :object,
properties: {
sickRetirementOtherBenefits: { type: :boolean },
typeOfBenefit: { type: :string },
grossMonthlyAmountOfBenefit: { type: :number },
dateBenefitBegan: { type: :string, format: :date },
dateFirstPaymentIssued: { type: :string, format: :date },
dateBenefitWillStop: { type: :string, format: :date },
remarks: { type: :string }
}
},
certification: {
type: :object,
required: %i[signature certified],
properties: {
signature: {
type: :string,
description: 'Signature of employer or supervisor',
example: 'John Doe'
},
certified: {
type: :boolean,
enum: [true],
description: 'Certified by the employer or supervisor (must be true)',
example: true
}
}
}
},
required: %i[veteranInformation employmentInformation certification]
}.freeze
end
end
end
|
0
|
code_files/vets-api-private/app/openapi/openapi
|
code_files/vets-api-private/app/openapi/openapi/requests/form21p530a.rb
|
# frozen_string_literal: true
module Openapi
module Requests
class Form21p530a
FORM_SCHEMA = {
'$schema': 'json-schemer://openapi30/schema',
type: :object,
properties: {
veteranInformation: {
type: :object,
required: %i[fullName dateOfBirth dateOfDeath],
properties: {
fullName: { '$ref' => '#/components/schemas/FirstMiddleLastName' },
ssn: {
type: :string,
pattern: '^\d{9}$',
description: 'Social Security Number (9 digits)',
example: '123456789'
},
vaServiceNumber: { type: :string, example: '987654321' },
vaFileNumber: { type: :string, example: '987654321' },
dateOfBirth: { type: :string, format: :date, example: '1980-01-01' },
dateOfDeath: { type: :string, format: :date, example: '1980-01-01' },
placeOfBirth: {
type: :object,
properties: {
city: { type: :string, example: 'Kansas City' },
state: { type: :string, example: 'MO' }
}
}
}
},
veteranServicePeriods: {
type: :object,
properties: {
periods: {
type: :array,
items: {
type: :object,
properties: {
serviceBranch: { type: :string, example: 'Army' },
dateEnteredService: { type: :string, format: :date, example: '1968-06-01' },
placeEnteredService: { type: :string, example: 'Fort Benning, GA' },
rankAtSeparation: { type: :string, example: 'Sergeant' },
dateLeftService: { type: :string, format: :date, example: '1972-05-31' },
placeLeftService: { type: :string, example: 'Fort Hood, TX' }
}
}
},
servedUnderDifferentName: {
type: :string,
description: 'Name the veteran served under, if different from veteranInformation/fullName',
example: 'John Smith'
}
}
},
burialInformation: {
type: :object,
properties: {
nameOfStateCemeteryOrTribalOrganization: {
type: :string,
description: 'Name of state cemetery or tribal organization claiming interment allowance',
example: 'Missouri State Veterans Cemetery'
},
placeOfBurial: {
type: :object,
properties: {
stateCemeteryOrTribalCemeteryName: {
type: :string,
description: 'State cemetery or tribal cemetery name',
example: 'Missouri State Veterans Cemetery'
},
stateCemeteryOrTribalCemeteryLocation: {
type: :string,
description: 'State cemetery or tribal cemetery location',
example: 'Higginsville, MO'
}
}
},
dateOfBurial: {
type: :string,
format: :date,
example: '2024-01-15'
},
recipientOrganization: {
type: :object,
properties: {
name: {
type: :string,
example: 'Missouri Veterans Commission'
},
phoneNumber: {
type: :string,
example: '555-123-4567'
},
address: {
type: :object,
properties: {
streetAndNumber: {
type: :string,
example: '2400 Veterans Memorial Drive'
},
aptOrUnitNumber: {
type: :string,
maxLength: 5,
description: 'Apartment or unit number (max 5 characters)',
example: 'Suite'
},
city: {
type: :string,
example: 'Higginsville'
},
state: {
type: :string,
example: 'MO'
},
country: {
type: :string,
maxLength: 3,
description: 'Country code (ISO 3166-1 Alpha-2 or Alpha-3, max 3 characters)',
example: 'US'
},
postalCode: {
type: :string,
example: '64037'
},
postalCodeExtension: {
type: :string,
pattern: '^\d{4}$',
description: '4-digit postal code extension (ZIP+4)',
example: '1234'
}
}
}
}
}
}
},
certification: {
type: :object,
required: %i[titleOfStateOrTribalOfficial signature certified],
properties: {
titleOfStateOrTribalOfficial: {
type: :string,
description: 'Title of state or tribal official delegated responsibility to apply for federal funds',
example: 'Director of Veterans Services'
},
signature: {
type: :string,
description: 'Signature of state or tribal official',
example: 'John Doe'
},
certified: {
type: :boolean,
enum: [true],
description: 'Certified by the state or tribal official (must be true)',
example: true
}
}
},
remarks: { type: :string }
},
required: %i[veteranInformation burialInformation certification]
}.freeze
end
end
end
|
0
|
code_files/vets-api-private/app/openapi/openapi
|
code_files/vets-api-private/app/openapi/openapi/components/errors.rb
|
# frozen_string_literal: true
module Openapi
module Components
class Errors
ERRORS = { required: ['errors'],
properties: { errors: { type: 'array', items: { :$ref => '#/components/schemas/Error' } } } }.freeze
ERROR =
{ required: %w[title detail code status],
properties: { title: { type: 'string', example: 'Bad Request', description: 'error class name' },
detail: { type: 'string', example: 'Received a bad request response from the upstream server',
description: 'possibly some additional info, or just the class name again' },
code: {
type: 'string',
example: 'EVSS400',
description: 'Sometimes just the http code again, sometimes something like ' \
'"EVSS400", where the code can be found in config/locales/exceptions.en.yml'
},
source: { type: %w[string object], example: 'EVSS::DisabilityCompensationForm::Service',
description: 'error source class' },
status: { type: 'string', example: '400', description: 'http status code' },
meta: { type: 'object', description: 'additional info, like a backtrace' } } }.freeze
end
end
end
|
0
|
code_files/vets-api-private/app/openapi/openapi
|
code_files/vets-api-private/app/openapi/openapi/components/name.rb
|
# frozen_string_literal: true
module Openapi
module Components
class Name
FIRST_MIDDLE_LAST =
{ type: 'object',
required: %w[first last],
properties: { first: { type: 'string', example: 'John', maxLength: 12 },
middle: { type: 'string', example: 'A', maxLength: 1 },
last: { type: 'string', example: 'Doe', maxLength: 18 } } }.freeze
end
end
end
|
0
|
code_files/vets-api-private/app/openapi/openapi
|
code_files/vets-api-private/app/openapi/openapi/components/address.rb
|
# frozen_string_literal: true
module Openapi
module Components
class Address
SIMPLE_ADDRESS =
{ type: 'object',
required: %w[street city state postalCode country],
properties: { street: { type: 'string', example: '123 Main St', maxLength: 30 },
street2: { type: 'string', example: '4B', maxLength: 30 },
city: { type: 'string', example: 'Springfield', maxLength: 18 },
state: { type: 'string', example: 'IL', maxLength: 2 },
postalCode: { type: 'string', example: '62701', maxLength: 9 },
country: { type: 'string', example: 'US', maxLength: 2 } } }.freeze
end
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/demographics_policy.rb
|
# frozen_string_literal: true
DemographicsPolicy = Struct.new(:user, :gender_identity) do
def access?
user&.idme_uuid.present? || user&.logingov_uuid.present?
end
def access_update?
user&.idme_uuid.present? || user&.logingov_uuid.present?
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/mhv_messaging_policy.rb
|
# frozen_string_literal: true
require 'sm/client'
MHVMessagingPolicy = Struct.new(:user, :mhv_messaging) do
def access?
return false unless user.mhv_correlation_id
return false if Flipper.enabled?(:mhv_secure_messaging_policy_va_patient) && !user.va_patient?
client = SM::Client.new(session: { user_id: user.mhv_correlation_id, user_uuid: user.uuid })
validate_client(client)
end
def mobile_access?
return false unless user.mhv_correlation_id && user.va_patient?
client = Mobile::V0::Messaging::Client.new(session: { user_id: user.mhv_correlation_id, user_uuid: user.uuid })
validate_client(client)
end
private
def validate_client(client)
if client.session.expired?
client.authenticate
!client.session.expired?
else
true
end
rescue
log_denial_details
false
end
def log_denial_details
Rails.logger.info('SM ACCESS DENIED IN MOBILE POLICY',
mhv_id: user.mhv_correlation_id.presence || 'false',
sign_in_service: user.identity.sign_in[:service_name],
va_facilities: user.va_treatment_facility_ids.length,
va_patient: user.va_patient?)
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/mpi_policy.rb
|
# frozen_string_literal: true
MPIPolicy = Struct.new(:user, :mvi) do
def access_add_person_proxy?
user.icn.present? && user.edipi.present? && user.ssn.present? &&
(user.birls_id.blank? || user.participant_id.blank?)
end
def queryable?
user.icn.present? || required_attrs_present?(user)
end
private
def required_attrs_present?(user)
return false if user.first_name.blank?
return false if user.last_name.blank?
return false if user.birth_date.blank?
return false if user.ssn.blank?
return false if user.gender.blank?
true
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/coe_policy.rb
|
# frozen_string_literal: true
CoePolicy = Struct.new(:user, :coe) do
def access?
user.loa3? && user.edipi.present?
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/mhv_medical_records_policy.rb
|
# frozen_string_literal: true
MHVMedicalRecordsPolicy = Struct.new(:user, :mhv_medical_records) do
MR_ACCOUNT_TYPES = %w[Premium].freeze
def access?
if Flipper.enabled?(:mhv_medical_records_new_eligibility_check)
user.loa3? && mhv_user_account&.patient
else
MR_ACCOUNT_TYPES.include?(user.mhv_account_type) && user.va_patient?
end
end
private
def mhv_user_account
user.mhv_user_account(from_cache_only: false)
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/medical_copays_policy.rb
|
# frozen_string_literal: true
MedicalCopaysPolicy = Struct.new(:user, :medical_copays) do
##
# Determines if the authenticated user has
# access to the Medical Copays feature
#
# @return [Boolean]
#
def access?
accessible = user.edipi.present? && user.icn.present?
StatsD.increment("api.mcp.policy.#{accessible ? 'success' : 'failure'}")
accessible
end
def access_notifications?
accessible = Flipper.enabled?('medical_copay_notifications')
if accessible
StatsD.increment('api.mcp.notification_policy.success')
else
StatsD.increment('api.mcp.notification_policy.failure')
end
accessible
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/hca_disability_rating_policy.rb
|
# frozen_string_literal: true
HCADisabilityRatingPolicy = Struct.new(:user, :hca_disability_rating) do
def access?
user.loa3? && user.ssn.present?
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/power_of_attorney_policy.rb
|
# frozen_string_literal: true
PowerOfAttorneyPolicy = Struct.new(:user, :power_of_attorney) do
def access?
user.loa3? && user.icn.present? && user.participant_id.present?
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/bgs_policy.rb
|
# frozen_string_literal: true
BGSPolicy = Struct.new(:user, :bgs) do
def access?(log_stats: true)
accessible = user.icn.present? && user.ssn.present? && user.participant_id.present?
increment_statsd(accessible) if user.loa3? && log_stats
accessible
end
def increment_statsd(accessible)
if accessible
StatsD.increment('api.bgs.policy.success')
else
StatsD.increment('api.bgs.policy.failure')
end
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/form1095_policy.rb
|
# frozen_string_literal: true
Form1095Policy = Struct.new(:user, :form1095) do
def access?
user.present? && user.loa3? && user.icn.present?
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/appeals_policy.rb
|
# frozen_string_literal: true
AppealsPolicy = Struct.new(:user, :appeals) do
def access?
user.loa3? && user.ssn.present?
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/mhv_prescriptions_policy.rb
|
# frozen_string_literal: true
require 'rx/client'
MHVPrescriptionsPolicy = Struct.new(:user, :mhv_prescriptions) do
RX_ACCESS_LOG_MESSAGE = 'RX ACCESS DENIED'
def access?
return true if user.loa3? && (mhv_user_account&.patient || mhv_user_account&.champ_va)
log_access_denied(RX_ACCESS_LOG_MESSAGE)
false
end
private
def mhv_user_account
user.mhv_user_account(from_cache_only: false)
end
def log_access_denied(message)
Rails.logger.info(message,
mhv_id: user.mhv_correlation_id.presence || 'false',
sign_in_service: user.identity.sign_in[:service_name],
va_facilities: user.va_treatment_facility_ids.length,
va_patient: user.va_patient?)
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/vye_policy.rb
|
# frozen_string_literal: true
VyePolicy = Struct.new(:user, :user_info) do
def access?
user.present?
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/vet360_policy.rb
|
# frozen_string_literal: true
Vet360Policy = Struct.new(:user, :vet360) do
def access?
user.vet360_id.present?
end
def military_access?
user.edipi.present?
end
def profile_access?
user.icn.present?
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/debt_letters_policy.rb
|
# frozen_string_literal: true
DebtLettersPolicy = Struct.new(:user, :debt_letters) do
def access?
Flipper.enabled?(:debt_letters_show_letters_vbms, user)
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/mhv_user_account_policy.rb
|
# frozen_string_literal: true
class MHVUserAccountPolicy
attr_reader :user
def initialize(user, _record)
@user = user
end
def show?
user.present? && user.can_create_mhv_account?
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/enrollment_periods_policy.rb
|
# frozen_string_literal: true
EnrollmentPeriodsPolicy = Struct.new(:user, :enrollment_periods) do
def access?
user.present? && user.loa3? && user.icn.present?
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/lighthouse_policy.rb
|
# frozen_string_literal: true
LighthousePolicy = Struct.new(:user, :lighthouse) do
def access?
user.icn.present? && user.participant_id.present?
end
def direct_deposit_access?
user.loa3? &&
allowed_providers.include?(user.identity.sign_in[:service_name]) &&
user.icn.present? && user.participant_id.present?
end
def itf_access?
# Need to check for first name as Lighthouse will check for it
# and throw an error if it's nil
user.participant_id.present? && user.ssn.present? && user.last_name.present? && user.first_name
end
def access_update?
user.loa3? &&
allowed_providers.include?(user.identity.sign_in[:service_name]) &&
user.icn.present? && user.participant_id.present?
end
def access_vet_status?
user.icn.present?
end
alias_method :mobile_access?, :access_update?
alias_method :rating_info_access?, :access?
private
def allowed_providers
%w[
idme
oauth_IDME
logingov
oauth_LOGINGOV
].freeze
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/dgi_policy.rb
|
# frozen_string_literal: true
DGIPolicy = Struct.new(:user, :dgi) do
def access?
accessible = user.icn.present? && user.ssn.present? && user.loa3?
increment_statsd(accessible)
accessible
end
def increment_statsd(accessible)
if accessible
StatsD.increment('api.dgi.policy.success')
else
StatsD.increment('api.dgi.policy.failure')
end
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/debt_policy.rb
|
# frozen_string_literal: true
DebtPolicy = Struct.new(:user, :debt) do
def access?
accessible = user.icn.present? && user.ssn.present? && user.loa3?
increment_statsd(accessible)
accessible
end
def increment_statsd(accessible)
if accessible
StatsD.increment('api.debt.policy.success')
else
StatsD.increment('api.debt.policy.failure')
end
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/meb_policy.rb
|
# frozen_string_literal: true
MebPolicy = Struct.new(:user, :my_education_benefits) do
def access?
accessible = user.icn.present? && user.ssn.present? && user.loa3?
increment_statsd(accessible)
accessible
end
def increment_statsd(accessible)
if accessible
StatsD.increment('api.my_education_benefits.policy.success')
else
StatsD.increment('api.my_education_benefits.policy.failure')
end
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/communication_preferences_policy.rb
|
# frozen_string_literal: true
CommunicationPreferencesPolicy = Struct.new(:user, :communication_preferences) do
def access?
Flipper.enabled?(:communication_preferences, user)
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/mhv_health_records_policy.rb
|
# frozen_string_literal: true
MHVHealthRecordsPolicy = Struct.new(:user, :mhv_health_records) do
BB_ACCOUNT_TYPES = %w[Premium Advanced Basic].freeze
def access?
BB_ACCOUNT_TYPES.include?(user.mhv_account_type)
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/evss_policy.rb
|
# frozen_string_literal: true
EVSSPolicy = Struct.new(:user, :evss) do
def access?
if user.edipi.present? && user.ssn.present? && user.participant_id.present?
log_success('access')
else
log_failure('access')
end
end
def access_letters?
if user.edipi.present? && user.ssn.present? && user.participant_id.present? &&
user&.vet360_contact_info&.mailing_address&.address_line1
log_success('letters')
else
log_failure('letters')
end
end
def access_form526?
if user.edipi.present? && user.ssn.present? && user.birls_id.present? && user.participant_id.present? &&
user.birth_date.present?
log_success('form526')
else
log_failure('form526')
end
end
alias_method :rating_info_access?, :access?
private
def log_success(policy)
StatsD.increment('api.evss.policy.success', tags: ["policy:#{policy}"]) if user.loa3?
true
end
def log_failure(policy)
StatsD.increment('api.evss.policy.failure', tags: ["policy:#{policy}"]) if user.loa3?
false
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/policies/va_profile_policy.rb
|
# frozen_string_literal: true
VAProfilePolicy = Struct.new(:user, :va_profile) do
def access?
user.edipi.present?
end
def access_to_v2?
user.icn.present?
end
end
|
0
|
code_files/vets-api-private/app/policies
|
code_files/vets-api-private/app/policies/sign_in/user_info_policy.rb
|
# frozen_string_literal: true
module SignIn
class UserInfoPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
end
def show?
user.present? && client_id.in?(IdentitySettings.sign_in.user_info_clients)
end
private
def client_id
record.client_id
end
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/onsite_notification_serializer.rb
|
# frozen_string_literal: true
class OnsiteNotificationSerializer
include JSONAPI::Serializer
attributes :template_id, :va_profile_id, :dismissed, :created_at, :updated_at
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/search_serializer.rb
|
# frozen_string_literal: true
class SearchSerializer
include JSONAPI::Serializer
set_id { '' }
attribute :body
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/dependents_verifications_serializer.rb
|
# frozen_string_literal: true
class DependentsVerificationsSerializer
include JSONAPI::Serializer
set_id { '' }
set_type :dependency_decs
attribute :dependency_verifications
attribute :dependency_verifications do |object|
dependency_decs = object[:dependency_decs]
ensured_array = dependency_decs.instance_of?(Hash) ? [dependency_decs] : dependency_decs
ensured_array.map { |hash| hash.except(:social_security_number) }
end
attribute :prompt_renewal do |object|
diaries = object[:diaries]
diary_entries = diaries.is_a?(Hash) ? [diaries] : diaries
diary_entries.any? do |diary_entry|
diary_entry[:diary_lc_status_type] == 'PEND' &&
diary_entry[:diary_reason_type] == '24' &&
diary_entry[:diary_due_date] < 7.years.from_now
end
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/separation_location_serializer.rb
|
# frozen_string_literal: true
class SeparationLocationSerializer
def initialize(resource)
@resource = resource
end
def to_json(*)
Oj.dump(serializable_hash, mode: :compat, time_format: :ruby)
end
def serializable_hash
{
status: @resource.status,
separation_locations: @resource.separation_locations
}
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/lighthouse_rating_info_serializer.rb
|
# frozen_string_literal: true
class LighthouseRatingInfoSerializer
include JSONAPI::Serializer
set_id { '' }
attribute :user_percent_of_disability do |object|
attr = :user_percent_of_disability
object.respond_to?(attr) ? object.send(attr) : object[attr]
end
attribute :source_system do |_|
'Lighthouse'
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/rated_disabilities_serializer.rb
|
# frozen_string_literal: true
class RatedDisabilitiesSerializer
include JSONAPI::Serializer
set_id { '' }
attribute :rated_disabilities
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/user_serializer.rb
|
# frozen_string_literal: true
require 'backend_services'
require 'common/client/concerns/service_status'
class UserSerializer
include JSONAPI::Serializer
include Common::Client::Concerns::ServiceStatus
set_id { '' }
attributes :services, :user_account, :profile, :va_profile, :veteran_status,
:in_progress_forms, :prefills_available, :vet360_contact_information,
:session, :onboarding
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/persistent_attachment_va_form_serializer.rb
|
# frozen_string_literal: true
class PersistentAttachmentVAFormSerializer
include JSONAPI::Serializer
attribute :confirmation_code, &:guid
attribute :name, &:original_filename
attribute :size
attribute :warnings
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/supporting_evidence_attachment_serializer.rb
|
# frozen_string_literal: true
class SupportingEvidenceAttachmentSerializer
include JSONAPI::Serializer
set_type :supporting_evidence_attachments
attribute :guid
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/full_name_serializer.rb
|
# frozen_string_literal: true
class FullNameSerializer
include JSONAPI::Serializer
set_id { '' }
attribute :first do |object|
object[:first]
end
attribute :middle do |object|
object[:middle]
end
attribute :last do |object|
object[:last]
end
attribute :suffix do |object|
object[:suffix]
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/benefits_intake_submission_serializer.rb
|
# frozen_string_literal: true
class BenefitsIntakeSubmissionSerializer
include JSONAPI::Serializer
attribute :state
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/in_progress_form_serializer.rb
|
# frozen_string_literal: true
class InProgressFormSerializer
include JSONAPI::Serializer
set_id { '' }
set_type :in_progress_forms
# ensures that the attribute keys are camelCase, whether or not the Inflection header is sent
# NOTE: camelCasing all keys (deep transform) is *not* the goal. (see the InProgressFormsController for more details)
attribute :formId, &:form_id
attribute :createdAt, &:created_at
attribute :updatedAt, &:updated_at
attribute :metadata, &:metadata
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/mhv_user_account_serializer.rb
|
# frozen_string_literal: true
class MHVUserAccountSerializer
include JSONAPI::Serializer
set_id(&:user_profile_id)
attributes :user_profile_id, :premium, :champ_va, :patient, :sm_account_created, :message
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/eligible_data_classes_serializer.rb
|
# frozen_string_literal: true
require 'digest'
class EligibleDataClassesSerializer
include JSONAPI::Serializer
set_id { '' }
set_type 'eligible_data_classes'
attribute :data_classes do |object|
object.map(&:name)
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/user_action_serializer.rb
|
# frozen_string_literal: true
class UserActionSerializer
include JSONAPI::Serializer
attribute :user_action_event_id, :status, :subject_user_verification_id, :acting_ip_address,
:acting_user_agent, :created_at, :updated_at, :acting_user_verification_id
belongs_to :user_action_event
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/backend_statuses_serializer.rb
|
# frozen_string_literal: true
class BackendStatusesSerializer
include JSONAPI::Serializer
set_id { '' }
attributes :reported_at, :statuses, :maintenance_windows
attribute :maintenance_windows do |_object, params|
maintenance_windows = params[:maintenance_windows]
if maintenance_windows
serializer = MaintenanceWindowSerializer.new(maintenance_windows)
serializer.serializable_hash[:data].pluck(:attributes)
else
[]
end
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/extract_status_serializer.rb
|
# frozen_string_literal: true
class ExtractStatusSerializer
include JSONAPI::Serializer
set_type :extract_statuses
attributes :extract_type, :last_updated, :status, :created_on, :station_number
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/scheduling_preferences_serializer.rb
|
# frozen_string_literal: true
class SchedulingPreferencesSerializer
include JSONAPI::Serializer
set_id { '' }
set_type :scheduling_preferences
attribute :preferences do |object|
object[:preferences]
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/personal_information_serializer.rb
|
# frozen_string_literal: true
class PersonalInformationSerializer
include JSONAPI::Serializer
set_id { '' }
attribute :gender do |object|
object.demographics&.gender
end
# Returns the veteran's birth date. Object is an instance
# of the MPI::Models::MviProfile class.
#
# @return [String] For example, '1949-03-04'
#
attribute :birth_date do |object|
object.demographics&.birth_date&.to_date&.to_s
end
# Returns the veteran's preferred name.
#
# @return [String] For example, 'SAM'
#
attribute :preferred_name do |object|
object.demographics&.preferred_name&.text
end
# Returns the veteran's gender identity.
#
# @return [Object] For example, code: 'F', name: 'Female'
#
attribute :gender_identity do |object|
return {} if object.demographics&.gender_identity&.nil?
{
code: object.demographics&.gender_identity&.code,
name: object.demographics&.gender_identity&.name
}
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/evss_claim_detail_serializer.rb
|
# frozen_string_literal: true
class EVSSClaimDetailSerializer
include JSONAPI::Serializer
extend EVSSClaimTimelineHelper
extend EVSSClaimBaseHelper
# Our IDs are not stable due to 24 hour expiration, use EVSS IDs for consistency
# This can be removed if our IDs become stable
set_id :evss_id
set_type :evss_claims
attribute :evss_id
# Hide updated_at if we're bypassing the database like the services endpoint
attribute :updated_at, if: proc { |object| !object.updated_at.nil? }
attribute :contention_list do |object|
object.data['contention_list']
end
attribute :va_representative do |object|
va_rep = object.data['poa']
va_rep = ActionView::Base.full_sanitizer.sanitize(va_rep)
va_rep&.gsub(/&[^ ;]+;/, '')
end
attribute :events_timeline do |object|
events_timeline(object)
end
attribute :phase do |object|
status = object.data.dig('claim_phase_dates', 'latest_phase_type')
phase_from_keys(status)
end
attribute :date_filed do |object|
date_attr(object.data['date'])
end
attribute :phase_change_date do |object|
date_attr(object.data.dig('claim_phase_dates', 'phase_change_date'))
end
attribute :min_est_date do |object|
date_attr(object.data['min_est_claim_date'])
end
attribute :max_est_date do |object|
date_attr(object.data['max_est_claim_date'])
end
attribute :development_letter_sent do |object|
value = object.data['development_letter_sent']
yes_no_attr(value, 'development_letter_sent')
end
attribute :decision_letter_sent do |object|
value = object.data['decision_notification_sent']
yes_no_attr(value, 'decision_notification_sent')
end
attribute :documents_needed do |object|
value = object.data['attention_needed']
yes_no_attr(value, 'attention_needed')
end
attribute :ever_phase_back do |object|
object.data.dig('claim_phase_dates', 'ever_phase_back')
end
attribute :current_phase_back do |object|
object.data.dig('claim_phase_dates', 'current_phase_back')
end
attribute :open do |object|
object.data['claim_complete_date'].blank?
end
attribute :requested_decision do |object|
object.requested_decision || object.data['waiver5103_submitted']
end
# TODO: (CMJ) Remove once front end is integrated
attribute :waiver_submitted do |object|
object.requested_decision || object.data['waiver5103_submitted']
end
attribute :claim_type do |object|
object.data['status_type']
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/preneed_attachment_serializer.rb
|
# frozen_string_literal: true
class PreneedAttachmentSerializer
include JSONAPI::Serializer
set_type :preneeds_preneed_attachments
attribute :guid
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/contact_serializer.rb
|
# frozen_string_literal: true
class ContactSerializer
include JSONAPI::Serializer
set_id :contact_type
set_type :contact
attributes :contact_type, :given_name, :middle_name, :family_name, :relationship,
:address_line1, :address_line2, :address_line3, :city, :state, :zip_code, :primary_phone
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/form526_job_status_serializer.rb
|
# frozen_string_literal: true
class Form526JobStatusSerializer
include JSONAPI::Serializer
set_id { '' }
set_type :form526_job_statuses
attribute :claim_id do |object|
object.submission.submitted_claim_id
end
attributes :job_id
attribute :submission_id do |object|
object.submission.id
end
attributes :status
attribute :ancillary_item_statuses do |object|
if object.job_class.include?('526')
object.submission.form526_job_statuses.map do |status|
status.attributes.except('form526_submission_id') unless status.id == object.id
end.compact
end
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/health_care_application_serializer.rb
|
# frozen_string_literal: true
class HealthCareApplicationSerializer
include JSONAPI::Serializer
set_type :health_care_applications
attributes :state, :form_submission_id, :timestamp
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/gender_identity_serializer.rb
|
# frozen_string_literal: true
class GenderIdentitySerializer
include JSONAPI::Serializer
set_id { '' }
attribute :gender_identity
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/valid_va_file_number_serializer.rb
|
# frozen_string_literal: true
class ValidVAFileNumberSerializer
include JSONAPI::Serializer
set_id { '' }
set_type :valid_va_file_number
attribute :valid_va_file_number do |object|
# Settings default is false, override in local to a 'true' value to bypass
object[:file_nbr] || Settings.valid_va_file_number
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/user_verification_serializer.rb
|
# frozen_string_literal: true
class UserVerificationSerializer
attr_reader :user_verification
def initialize(user_verification:)
@user_verification = user_verification
end
def perform
serialize_response
end
private
def serialize_response
{
type: user_verification.credential_type,
credential_id: user_verification.credential_identifier,
locked: user_verification.locked
}
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/evss_claim_list_serializer.rb
|
# frozen_string_literal: true
class EVSSClaimListSerializer
include JSONAPI::Serializer
extend EVSSClaimBaseHelper
# Our IDs are not stable due to 24 hour expiration, use EVSS IDs for consistency
# This can be removed if our IDs become stable
set_id :evss_id
set_type :evss_claims
attribute :evss_id
# Hide updated_at if we're bypassing the database like the services endpoint
attribute :updated_at, if: proc { |object| !object.updated_at.nil? }
attribute :date_filed do |object|
date_attr(object.list_data['date'])
end
attribute :phase_change_date do |object|
date_attr(object.list_data.dig('claim_phase_dates', 'phase_change_date'))
end
attribute :min_est_date do |object|
date_attr(object.list_data['min_est_claim_date'])
end
attribute :max_est_date do |object|
date_attr(object.list_data['max_est_claim_date'])
end
attribute :development_letter_sent do |object|
value = object.list_data['development_letter_sent']
yes_no_attr(value, 'development_letter_sent')
end
attribute :decision_letter_sent do |object|
value = object.list_data['decision_notification_sent']
yes_no_attr(value, 'decision_notification_sent')
end
attribute :documents_needed do |object|
value = object.list_data['attention_needed']
yes_no_attr(value, 'attention_needed')
end
attribute :ever_phase_back do |object|
object.list_data.dig('claim_phase_dates', 'ever_phase_back')
end
attribute :current_phase_back do |object|
object.list_data.dig('claim_phase_dates', 'current_phase_back')
end
attribute :open do |object|
object.list_data['claim_complete_date'].blank?
end
attribute :requested_decision do |object|
object.requested_decision || object.list_data['waiver5103_submitted']
end
# TODO: (CMJ) Remove once front end is integrated
attribute :waiver_submitted do |object|
object.requested_decision || object.list_data['waiver5103_submitted']
end
attribute :claim_type do |object|
object.list_data['status_type']
end
attribute :phase do |object|
status = object.list_data['status']
phase_from_keys(status)
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/hca_attachment_serializer.rb
|
# frozen_string_literal: true
class HCAAttachmentSerializer
include JSONAPI::Serializer
set_type :hca_attachments
attribute :guid
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/post911_gi_bill_status_serializer.rb
|
# frozen_string_literal: true
class Post911GIBillStatusSerializer
include JSONAPI::Serializer
set_id { '' }
attribute :first_name
attribute :last_name
attribute :name_suffix
attribute :date_of_birth
attribute :va_file_number
attribute :regional_processing_office
attribute :eligibility_date
attribute :delimiting_date
attribute :percentage_benefit
attribute :original_entitlement
attribute :used_entitlement
attribute :remaining_entitlement
attribute :active_duty
attribute :veteran_is_eligible
attribute :enrollments
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/saved_claim_serializer.rb
|
# frozen_string_literal: true
class SavedClaimSerializer
include JSONAPI::Serializer
set_type :saved_claims
attributes :submitted_at, :regional_office, :confirmation_number, :guid
attribute :form, &:form_id
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/form1010_ezr_attachment_serializer.rb
|
# frozen_string_literal: true
class Form1010EzrAttachmentSerializer
include JSONAPI::Serializer
set_type :form1010_ezr_attachments
attribute :guid
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/direct_deposits_serializer.rb
|
# frozen_string_literal: true
class DirectDepositsSerializer
include JSONAPI::Serializer
set_id { '' }
set_type 'direct_deposits'
attributes :control_information, :payment_account, :veteran_status
attribute :control_information do |object|
object[:control_information]
end
attribute :payment_account do |object|
next nil unless object.key?(:payment_account)
payment_account = object[:payment_account]
account_number = payment_account&.dig(:account_number)
payment_account[:account_number] = StringHelpers.mask_sensitive(account_number) if account_number
routing_number = payment_account&.dig(:routing_number)
payment_account[:routing_number] = StringHelpers.mask_sensitive(routing_number) if routing_number
payment_account
end
attribute :veteran_status do |object|
object[:veteran_status]
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/hca_rating_info_serializer.rb
|
# frozen_string_literal: true
class HCARatingInfoSerializer
include JSONAPI::Serializer
set_id { '' }
attribute :user_percent_of_disability do |object|
object[:user_percent_of_disability].to_i
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/evss_claim_timeline_helper.rb
|
# frozen_string_literal: true
module EVSSClaimTimelineHelper
def events_timeline(object)
events = [
create_event_from_string_date(:filed, object.data['date']),
create_event_from_string_date(:completed, object.data['claim_complete_date'])
]
# Do the 8 phases
(1..8).each do |n|
date = object.data.dig('claim_phase_dates', "phase#{n}_complete_date")
events << create_event_from_string_date("phase#{n}", date)
end
# Add tracked items
events += create_events_for_tracked_items(object)
# Add documents not associated with a tracked item
events += create_events_for_documents(object)
# Make reverse chron with nil date items at the end
events.compact.sort_by { |h| h[:date] || Date.new }.reverse
end
private
def create_event_from_string_date(type, date)
return nil unless date
{
type:,
date: Date.strptime(date, '%m/%d/%Y')
}
end
TRACKED_ITEM_FIELDS = %w[
never_received_from_others_list never_received_from_you_list received_from_others_list
received_from_you_list still_need_from_you_list still_need_from_others_list
].freeze
def create_events_for_tracked_items(object)
TRACKED_ITEM_FIELDS.map do |field|
sub_objects_of(object, 'claim_tracked_items', field).map do |obj|
create_tracked_item_event(field.underscore, obj)
end
end.flatten
end
def create_events_for_documents(object)
# Objects with trackedItemId are part of other events, so don't duplicate them
docs = sub_objects_of(object, 'vba_document_list').select { |obj| obj['tracked_item_id'].nil? }
docs = create_documents docs
docs.map do |obj|
obj.merge(type: :other_documents_list, date: obj[:upload_date])
end
end
# Order of EVENT_DATE_FIELDS determines which date trumps in timeline sorting
EVENT_DATE_FIELDS = %i[
closed_date
received_date
upload_date
opened_date
requested_date
suspense_date
].freeze
def create_tracked_item_event(type, obj)
documents = create_documents(obj['vba_documents'] || [])
event = {
type:,
tracked_item_id: obj['tracked_item_id'],
description: ActionView::Base.full_sanitizer.sanitize(obj['description']),
display_name: obj['displayed_name'],
overdue: obj['overdue'],
status: obj['tracked_item_status'],
uploaded: obj['uploaded'],
uploads_allowed: obj['uploads_allowed'],
opened_date: date_or_nil_from(obj, 'opened_date'),
requested_date: date_or_nil_from(obj, 'requested_date'),
received_date: date_or_nil_from(obj, 'received_date'),
closed_date: date_or_nil_from(obj, 'closed_date'),
suspense_date: date_or_nil_from(obj, 'suspense_date'),
documents:,
upload_date: latest_upload_date(documents)
}
event[:date] = event.slice(*EVENT_DATE_FIELDS).values.compact.first
event
end
def create_documents(objs)
objs.map do |obj|
{
tracked_item_id: obj['tracked_item_id'],
file_type: obj['document_type_label'],
document_type: obj['document_type_code'],
filename: obj['original_file_name'],
# %Q is the C-strftime flag for milliseconds since Unix epoch.
# For date-times recording a computer event and therefore known
# to the second EVSS uses a UNIX timestamp in milliseconds.
# Round it to the day. Not sure what timezone they're using,
# so could be off by 1 day.
upload_date: date_or_nil_from(obj, 'upload_date', format: '%Q')
}
end
end
def sub_objects_of(object, *)
items = object.data.dig(*) || []
items.compact
end
def date_or_nil_from(obj, key, format: '%m/%d/%Y')
date = obj[key]
return nil if date.blank?
Date.strptime(date.to_s, format)
end
def latest_upload_date(documents)
documents.pluck(:upload_date).sort.reverse.first
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/communication_groups_serializer.rb
|
# frozen_string_literal: true
class CommunicationGroupsSerializer
include JSONAPI::Serializer
set_id { '' }
set_type :hashes
attribute :communication_groups do |object|
object[:communication_groups]
end
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/payment_history_serializer.rb
|
# frozen_string_literal: true
class PaymentHistorySerializer
include JSONAPI::Serializer
set_id { '' }
set_type :payment_history
attribute :payments
attribute :return_payments
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/education_stem_claim_status_serializer.rb
|
# frozen_string_literal: true
class EducationStemClaimStatusSerializer
include JSONAPI::Serializer
attribute :confirmation_number
attribute :is_enrolled_stem do |object|
object.saved_claim.parsed_form['isEnrolledStem']
end
attribute :is_pursuing_teaching_cert do |object|
object.saved_claim.parsed_form['isPursuingTeachingCert']
end
attribute :benefit_left do |object|
object.saved_claim.parsed_form['benefitLeft']
end
attribute :remaining_entitlement do |object|
object.education_stem_automated_decision.remaining_entitlement
end
attribute :automated_denial do |object|
object.education_stem_automated_decision.automated_decision_state == 'denied'
end
attribute :denied_at do |object|
next nil if object.education_stem_automated_decision.automated_decision_state != 'denied'
object.education_stem_automated_decision.updated_at
end
attribute :submitted_at, &:created_at
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/persistent_attachment_serializer.rb
|
# frozen_string_literal: true
class PersistentAttachmentSerializer
include JSONAPI::Serializer
attribute :confirmation_code, &:guid
attribute :name, &:original_filename
attribute :size
end
|
0
|
code_files/vets-api-private/app
|
code_files/vets-api-private/app/serializers/receive_application_serializer.rb
|
# frozen_string_literal: true
class ReceiveApplicationSerializer
include JSONAPI::Serializer
set_id :receive_application_id
set_type :preneeds_receive_applications
attribute :receive_application_id
attribute :tracking_number
attribute :return_code
attribute :application_uuid
attribute :return_description
attribute :submitted_at
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.