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/saved_claim/higher_level_review.rb
# frozen_string_literal: true class SavedClaim::HigherLevelReview < SavedClaim has_one :appeal_submission, class_name: 'AppealSubmission', foreign_key: :submitted_appeal_uuid, primary_key: :guid, dependent: nil, inverse_of: :saved_claim_hlr, required: false FORM = '20-0996' def form_matches_schema return unless form_is_string schema = VetsJsonSchema::SCHEMAS['HLR-CREATE-REQUEST-BODY_V1'] schema.delete '$schema' # workaround for JSON::Schema::SchemaError (Schema not found) errors = JSON::Validator.fully_validate(schema, parsed_form) unless errors.empty? Rails.logger.warn("SavedClaim: schema validation errors detected for form #{FORM}", guid:, count: errors.count) end true # allow storage of all requests for debugging rescue JSON::Schema::ReadFailed => e Rails.logger.warn("SavedClaim: form_matches_schema error raised for form #{FORM}", guid:, error: e.message) true end def process_attachments! # Inherited from SavedClaim. Disabling since this claim handles attachments separately. raise NotImplementedError, 'Not Implemented for Form 20-0996' end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/saved_claim/form210779.rb
# frozen_string_literal: true class SavedClaim::Form210779 < SavedClaim FORM = '21-0779' NURSING_HOME_DOCUMENT_TYPE = 222 def process_attachments! # Form 21-0779 does not support user-uploaded attachments in MVP Lighthouse::SubmitBenefitsIntakeClaim.perform_async(id) end # Required for Lighthouse Benefits Intake API submission # CMP = Compensation (for disability claims) def business_line 'CMP' end # VA Form 21-0779 - Request for Nursing Home Information in Connection with Claim for Aid & Attendance # see LighthouseDocument::DOCUMENT_TYPES def document_type NURSING_HOME_DOCUMENT_TYPE end def send_confirmation_email # Email functionality not included in MVP # VANotify::EmailJob.perform_async( # employer_email, # Settings.vanotify.services.va_gov.template_id.form210779_confirmation, # {} # ) end # Override to_pdf to add nursing home official signature stamp def to_pdf(file_name = nil, fill_options = {}) pdf_path = PdfFill::Filler.fill_form(self, file_name, fill_options) PdfFill::Forms::Va210779.stamp_signature(pdf_path, parsed_form) end def veteran_name first = parsed_form.dig('veteranInformation', 'fullName', 'first') last = parsed_form.dig('veteranInformation', 'fullName', 'last') "#{first} #{last}".strip.presence || 'Veteran' end def metadata_for_benefits_intake { veteranFirstName: parsed_form.dig('veteranInformation', 'fullName', 'first'), veteranLastName: parsed_form.dig('veteranInformation', 'fullName', 'last'), fileNumber: parsed_form.dig('veteranInformation', 'veteranId', 'ssn'), zipCode: parsed_form.dig('nursingHomeInformation', 'nursingHomeAddress', 'postalCode'), businessLine: business_line } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/saved_claim/veteran_readiness_employment_claim.rb
# frozen_string_literal: true require 'res/ch31_form' require 'vets/shared_logging' require 'vre/notification_email' class SavedClaim::VeteranReadinessEmploymentClaim < SavedClaim include Vets::SharedLogging FORM = '28-1900' # We will be adding numbers here and eventually completeley removing this and the caller to open up VRE submissions # to all vets PERMITTED_OFFICE_LOCATIONS = %w[].freeze VBMS_CONFIRMATION = :confirmation_vbms LIGHTHOUSE_CONFIRMATION = :confirmation_lighthouse CONFIRMATION_EMAIL_TEMPLATES = { VBMS_CONFIRMATION => Settings.vanotify.services.veteran_readiness_and_employment .email.confirmation_vbms.template_id, LIGHTHOUSE_CONFIRMATION => Settings.vanotify.services.veteran_readiness_and_employment .email.confirmation_lighthouse.template_id }.freeze ERROR_EMAIL_TEMPLATE = Settings.vanotify.services.veteran_readiness_and_employment .email.error.template_id REGIONAL_OFFICE_EMAILS = { '301' => 'VRC.VBABOS@va.gov', '304' => 'VRE.VBAPRO@va.gov', '306' => 'VRE.VBANYN@va.gov', '307' => 'VRC.VBABUF@va.gov', '308' => 'VRE.VBAHAR@va.gov', '309' => 'vre.vbanew@va.gov', '310' => 'VREBDD.VBAPHI@va.gov', '311' => 'VRE.VBAPIT@va.gov', '313' => 'VRE.VBABAL@va.gov', '314' => 'VRE.VBAROA@va.gov', '315' => 'VRE.VBAHUN@va.gov', '316' => 'VRETMP.VBAATG@va.gov', '317' => 'VRE281900.VBASPT@va.gov', '318' => 'VRC.VBAWIN@va.gov', '319' => 'VRC.VBACMS@va.gov', '320' => 'VREAPPS.VBANAS@va.gov', '321' => 'VRC.VBANOL@va.gov', '322' => 'VRE.VBAMGY@va.gov', '323' => 'VRE.VBAJAC@va.gov', '325' => 'VRE.VBACLE@va.gov', '326' => 'VRE.VBAIND@va.gov', '327' => 'VRE.VBALOU@va.gov', '328' => 'VAVBACHI.VRE@va.gov', '329' => 'VRE.VBADET@va.gov', '330' => 'VREApplications.VBAMIW@va.gov', '331' => 'VRC.VBASTL@va.gov', '333' => 'VRE.VBADES@va.gov', '334' => 'VRE.VBALIN@va.gov', '335' => 'VRC.VBASPL@va.gov', '339' => 'VRE.VBADEN@va.gov', '340' => 'VRC.VBAALB@va.gov', '341' => 'VRE.VBASLC@va.gov', '343' => 'VRC.VBAOAK@va.gov', '344' => 'ROVRC.VBALAN@va.gov', '345' => 'VRE.VBAPHO@va.gov', '346' => 'VRE.VBASEA@va.gov', '347' => 'VRE.VBABOI@va.gov', '348' => 'VRE.VBAPOR@va.gov', '349' => 'VREAPPS.VBAWAC@va.gov', '350' => 'VRE.VBALIT@va.gov', '351' => 'VREBDD.VBAMUS@va.gov', '354' => 'VRE.VBAREN@va.gov', '355' => 'MBVRE.VBASAJ@va.gov', '358' => 'VRE.VBAMPI@va.gov', '362' => 'VRE.VBAHOU@va.gov', '372' => 'VRE.VBAWAS@va.gov', '373' => 'VRE.VBAMAN@va.gov', '377' => 'EBENAPPS.VBASDC@va.gov', '402' => 'VRE.VBATOG@va.gov', '405' => 'VRE.VBAMAN@va.gov', '436' => 'VRC.VBAFHM@va.gov', '437' => 'VRC.VBAFAR@va.gov', '438' => 'VRC.VBAFAR@va.gov', '442' => 'VRE.VBADEN@va.gov', '452' => 'VRE.VBAWIC@va.gov', '459' => 'VRC.VBAHON@va.gov', '460' => 'VAVBA/WIM/RO/VR&E@vba.va.gov', '463' => 'VRE.VBAANC@va.gov', '000' => 'VRE.VBAPIT@va.gov' }.freeze after_initialize do if form.present? self.form_id = [true, false].include?(parsed_form['useEva']) ? self.class::FORM : '28-1900-V2' end end def initialize(args) @sent_to_lighthouse = false super end def add_claimant_info(user) if form.blank? Rails.logger.info('VRE claim form is blank, skipping adding veteran info', { user_uuid: user&.uuid }) return end updated_form = parsed_form add_veteran_info(updated_form, user) if user&.loa3? add_office_location(updated_form) if updated_form['veteranInformation'].present? update!(form: updated_form.to_json) end def add_veteran_info(updated_form, user) updated_form['veteranInformation'].merge!( { 'VAFileNumber' => veteran_va_file_number(user), 'pid' => user.participant_id, 'edipi' => user.edipi, 'vet360ID' => user.vet360_id, 'dob' => user.birth_date, 'ssn' => user.ssn } ).except!('vaFileNumber') end def add_office_location(updated_form) regional_office = check_office_location @office_location = regional_office[0] office_name = regional_office[1] updated_form['veteranInformation']&.merge!({ 'regionalOffice' => "#{@office_location} - #{office_name}", 'regionalOfficeName' => office_name, 'stationId' => @office_location }) end # Common method for VRE form submission: # * Adds information from user to payload # * Submits to VBMS if participant ID is there, to Lighthouse if not. # * Sends email if user is present # * Sends to RES service # @param user [User] user account of submitting user # @return [Hash] Response payload of service that was used (RES) def send_to_vre(user) add_claimant_info(user) if user&.participant_id upload_to_vbms(user:) else Rails.logger.warn('Participant id is blank when submitting VRE claim, sending to Lighthouse', { user_uuid: user&.uuid }) send_to_lighthouse!(user) end email_addr = REGIONAL_OFFICE_EMAILS[@office_location] || 'VRE.VBACO@va.gov' Rails.logger.info('VRE claim sending email:', { email: email_addr, user_uuid: user&.uuid }) VeteranReadinessEmploymentMailer.build(user.participant_id, email_addr, @sent_to_lighthouse).deliver_later send_to_res(user) Flipper.enabled?(:vre_use_new_vfs_notification_library) && send_email(@sent_to_lighthouse ? LIGHTHOUSE_CONFIRMATION : VBMS_CONFIRMATION) end # Submit claim into VBMS service, uploading document directly to VBMS, # adds document ID from VBMS to form info, and sends confirmation email to user # Submits to Lighthouse on failure # @param user [User] user account of submitting user # @return None def upload_to_vbms(user:, doc_type: '1167') form_path = PdfFill::Filler.fill_form(self, nil, { created_at: }) uploader = ClaimsApi::VBMSUploader.new( filepath: Rails.root.join(form_path), file_number: parsed_form['veteranInformation']['VAFileNumber'] || parsed_form['veteranInformation']['ssn'], doc_type: ) log_to_statsd('vbms') do response = uploader.upload! if response[:vbms_document_series_ref_id].present? updated_form = parsed_form updated_form['documentId'] = response[:vbms_document_series_ref_id] update!(form: updated_form.to_json) end end !Flipper.enabled?(:vre_use_new_vfs_notification_library) && send_vbms_lighthouse_confirmation_email('VBMS', CONFIRMATION_EMAIL_TEMPLATES[VBMS_CONFIRMATION]) rescue => e Rails.logger.error('Error uploading VRE claim to VBMS.', { user_uuid: user&.uuid, messsage: e.message }) send_to_lighthouse!(user) end def to_pdf(file_name = nil) PdfFill::Filler.fill_form(self, file_name, { created_at: }) end # Submit claim into lighthouse service, adds veteran info to top level of form, # and sends confirmation email to user # @param user [User] user account of submitting user # @return None def send_to_lighthouse!(user) form_copy = parsed_form.clone form_copy['veteranSocialSecurityNumber'] = parsed_form.dig('veteranInformation', 'ssn') form_copy['veteranFullName'] = parsed_form.dig('veteranInformation', 'fullName') form_copy['vaFileNumber'] = parsed_form.dig('veteranInformation', 'VAFileNumber') unless form_copy['veteranSocialSecurityNumber'] if user&.loa3? Rails.logger.warn('VRE: No SSN found for LOA3 user', { user_uuid: user&.uuid }) else Rails.logger.info('VRE: No SSN found for LOA1 user', { user_uuid: user&.uuid }) end end update!(form: form_copy.to_json) process_attachments! @sent_to_lighthouse = true !Flipper.enabled?(:vre_use_new_vfs_notification_library) && send_vbms_lighthouse_confirmation_email('Lighthouse', CONFIRMATION_EMAIL_TEMPLATES[LIGHTHOUSE_CONFIRMATION]) rescue => e Rails.logger.error('Error uploading VRE claim to Benefits Intake API', { user_uuid: user&.uuid, e: }) raise end # Send claim via RES service # @param user [User] user account of submitting user # @return [Hash] Response payload of RES service def send_to_res(user) Rails.logger.info('VRE claim sending to RES service', { user_uuid: user&.uuid, was_sent: @sent_to_lighthouse, user_present: user.present? }) service = RES::Ch31Form.new(user:, claim: self) service.submit end def add_errors_from_form_validation(form_errors) form_errors.each do |e| errors.add(e[:fragment], e[:message]) e[:errors]&.flatten(2)&.each { |nested| errors.add(nested[:fragment], nested[:message]) if nested.is_a? Hash } end unless form_errors.empty? Rails.logger.error('SavedClaim form did not pass validation', { form_id:, guid:, errors: form_errors }) end end def form_matches_schema return unless form_is_string validate_form end def validate_form validate_required_fields validate_string_fields validate_boolean_fields validate_name_length validate_email validate_phone_numbers validate_dob validate_addresses unless errors.empty? Rails.logger.error('SavedClaim form did not pass validation', { form_id:, guid:, errors: }) end end # SavedClaims require regional_office to be defined def regional_office [] end # Lighthouse::SubmitBenefitsIntakeClaim will call the function `send_confirmation_email` (if it exists). # Do not name a function `send_confirmation_email`, unless it accepts 0 arguments. def send_vbms_lighthouse_confirmation_email(service, email_template) VANotify::EmailJob.perform_async( email, email_template, { 'first_name' => parsed_form.dig('veteranInformation', 'fullName', 'first'), 'date' => Time.zone.today.strftime('%B %d, %Y') } ) Rails.logger.info("VRE Submit1900Job successful. #{service} confirmation email sent.") end def send_email(email_type) if CONFIRMATION_EMAIL_TEMPLATES.key?(email_type) VRE::NotificationEmail.new(id).deliver(CONFIRMATION_EMAIL_TEMPLATES[email_type]) Rails.logger.info("VRE Submit1900Job successful. #{email_type} confirmation email sent.") else VRE::NotificationEmail.new(id).deliver(ERROR_EMAIL_TEMPLATE) Rails.logger.info('VRE Submit1900Job retries exhausted, failure email sent to veteran.') end end def process_attachments! refs = attachment_keys.map { |key| Array(open_struct_form.send(key)) }.flatten files = PersistentAttachment.where(guid: refs.map(&:confirmationCode)) files.find_each { |f| f.update(saved_claim_id: id) } Rails.logger.info('VRE claim submitting to Benefits Intake API') # On success, this class will call claim.send_confirmation_email() # if a function of that name exists. If you need to implement # function `send_confirmation_email()`, ensure it accepts 0 arguments Lighthouse::SubmitBenefitsIntakeClaim.new.perform(id) end def business_line 'VRE' end def email @email ||= parsed_form['email'] end def send_failure_email(email_override = nil) recipient_email = email_override || email if recipient_email.present? VANotify::EmailJob.perform_async( recipient_email, Settings.vanotify.services.va_gov.template_id.form1900_action_needed_email, { 'first_name' => parsed_form.dig('veteranInformation', 'fullName', 'first'), 'date_submitted' => Time.zone.today.strftime('%B %d, %Y'), 'confirmation_number' => confirmation_number } ) Rails.logger.info('VRE Submit1900Job retries exhausted, failure email sent to veteran.') else Rails.logger.warn('VRE claim failure email not sent: email not present.') end end private def check_office_location service = bgs_client vet_info = parsed_form['veteranAddress'] Rails.logger.warn('VRE claim: Veteran address is missing, cannot determine regional office.') if vet_info.blank? regional_office_response = service.routing.get_regional_office_by_zip_code( vet_info['postalCode'], vet_info['country'], vet_info['state'], 'VRE', parsed_form['veteranInformation']['ssn'] ) [ regional_office_response[:regional_office][:number], regional_office_response[:regional_office][:name] ] rescue => e Rails.logger.warn(e.message) ['000', 'Not Found'] end def bgs_client @service ||= BGS::Services.new( external_uid: email, external_key: ) end def external_key parsed_form.dig('veteranInformation', 'fullName', 'first') || email end def veteran_information errors.add(:form, 'Veteran Information is missing from form') if parsed_form['veteranInformation'].blank? end def veteran_va_file_number(user) response = BGS::People::Request.new.find_person_by_participant_id(user:) response.file_number rescue Rails.logger.warn('VRE claim unable to add VA File Number.', { user_uuid: user&.uuid }) nil end def log_to_statsd(service) start_time = Time.current yield elapsed_time = Time.current - start_time StatsD.measure("api.1900.#{service}.response_time", elapsed_time, tags: {}) end def validate_required_fields required_fields = %w[email isMoving yearsOfEducation veteranInformation/fullName veteranInformation/fullName/first veteranInformation/fullName/last veteranInformation/dob privacyAgreementAccepted] required_fields.each do |field| value = parsed_form.dig(*field.split('/')) value = value.to_s if [true, false].include?(value) errors.add("/#{field}", 'is required') if value.blank? end end def validate_string_fields string_fields = %w[mainPhone cellPhone internationalNumber email yearsOfEducation veteranInformation/fullName/first veteranInformation/fullName/middle veteranInformation/fullName/last veteranInformation/dob] string_fields.each do |field| value = parsed_form.dig(*field.split('/')) errors.add("/#{field}", 'must be a string') if value.present? && !value.is_a?(String) end end def validate_boolean_fields boolean_fields = %w[isMoving privacyAgreementAccepted] boolean_fields.each do |field| errors.add("/#{field}", 'must be a boolean') unless [true, false].include?(parsed_form[field]) end end def validate_name_length max_30_fields = %w[veteranInformation/fullName/first veteranInformation/fullName/middle veteranInformation/fullName/last] max_30_fields.each do |field| value = parsed_form.dig(*field.split('/')) if value.present? && value.is_a?(String) && value.length > 30 errors.add("/#{field}", 'must be 30 characters or less') end end end def validate_email if email.present? && email.is_a?(String) && email.length > 256 errors.add('/email', 'must be 256 characters or less') end if email.present? && email.is_a?(String) && !email.match?(/.+@.+\..+/i) # pulled from profile email model errors.add('/email', 'must be a valid email address') end end def validate_phone_numbers phone_fields = %w[mainPhone cellPhone] phone_fields.each do |field| value = parsed_form[field] if value.present? && value.is_a?(String) && !value.match?(/^\d{10}$/) errors.add("/#{field}", 'must be a valid phone number with 10 digits only') end end end def validate_dob value = parsed_form.dig('veteranInformation', 'dob') if value.present? && value.is_a?(String) && !value.match?( /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/ ) errors.add('/veteranInformation/dob', 'must be a valid date in YYYY-MM-DD format') end end def validate_addresses address_fields = %w[newAddress veteranAddress] address_fields.each do |field| address = parsed_form[field] next if address.blank? || !address.is_a?(Hash) %w[country street city state postalCode].each do |sub_field| value = address[sub_field] if %w[street city].include?(sub_field) && value.blank? errors.add("/#{field}/#{sub_field}", 'is required') elsif !value.is_a?(String) && value.present? errors.add("/#{field}/#{sub_field}", 'must be a string') # elsif sub_field == 'postalCode' && value.present? && !value.match?(/^\d{5}(-\d{4})?$/) # errors.add("/#{field}/#{sub_field}", 'must be a valid postal code in XXXXX or XXXXX-XXXX format') elsif %w[state city].include?(sub_field) && value.present? && value.length > 100 errors.add("/#{field}/#{sub_field}", 'must be 100 characters or less') end end end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/saved_claim/ask.rb
# frozen_string_literal: true class SavedClaim::Ask < SavedClaim FORM = '0873' end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/saved_claim/supplemental_claim.rb
# frozen_string_literal: true class SavedClaim::SupplementalClaim < SavedClaim has_one :appeal_submission, class_name: 'AppealSubmission', foreign_key: :submitted_appeal_uuid, primary_key: :guid, dependent: nil, inverse_of: :saved_claim_sc, required: false FORM = '20-0995' def form_matches_schema return unless form_is_string schema = VetsJsonSchema::SCHEMAS['SC-CREATE-REQUEST-BODY_V1'] schema.delete '$schema' # workaround for JSON::Schema::SchemaError (Schema not found) errors = JSON::Validator.fully_validate(schema, parsed_form) unless errors.empty? Rails.logger.warn("SavedClaim: schema validation errors detected for form #{FORM}", guid:, count: errors.count) end true # allow storage of all requests for debugging rescue JSON::Schema::ReadFailed => e Rails.logger.warn("SavedClaim: form_matches_schema error raised for form #{FORM}", guid:, error: e.message) true end def process_attachments! # Inherited from SavedClaim. Disabling since this claim handles attachments separately. raise NotImplementedError, 'Not Implemented for Form 20-0995' end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/saved_claim/form21p530a.rb
# frozen_string_literal: true class SavedClaim::Form21p530a < SavedClaim FORM = '21P-530a' DEFAULT_ZIP_CODE = '00000' validates :form, presence: true def form_schema schema = JSON.parse(Openapi::Requests::Form21p530a::FORM_SCHEMA.to_json) schema['components'] = JSON.parse(Openapi::Components::ALL.to_json) schema end def process_attachments! Lighthouse::SubmitBenefitsIntakeClaim.perform_async(id) end def send_confirmation_email # Email functionality not included in MVP # recipient_email = parsed_form.dig('burialInformation', 'recipientOrganization', 'email') # return unless recipient_email # VANotify::EmailJob.perform_async( # recipient_email, # Settings.vanotify.services.va_gov.template_id.form21p530a_confirmation, # { # 'organization_name' => organization_name, # 'veteran_name' => veteran_name, # 'confirmation_number' => confirmation_number, # 'date_submitted' => created_at.strftime('%B %d, %Y') # } # ) end # SavedClaims require regional_office to be defined def regional_office [ 'Department of Veterans Affairs', 'Pension Management Center', 'P.O. Box 5365', 'Janesville, WI 53547-5365' ].freeze end # Required for Lighthouse Benefits Intake API submission # PMC = Pension Management Center (handles burial benefits) def business_line 'PMC' end # VBMS document type for burial allowance applications def document_type 540 # Burial/Memorial Benefits end def attachment_keys # Form 21P-530a does not support attachments in MVP [].freeze end # Override to_pdf to add official signature stamp # This ensures the signature is included in both the download_pdf endpoint # and the Lighthouse Benefits Intake submission def to_pdf(file_name = nil, fill_options = {}) PdfFill::Filler.fill_form(self, file_name, fill_options) # TODO: Add signature stamping when PdfFill::Forms::Va21p530a is implemented # PdfFill::Forms::Va21p530a.stamp_signature(pdf_path, parsed_form) end # Required metadata format for Lighthouse Benefits Intake API submission # This method extracts veteran identity information and organization address # to ensure proper routing and indexing in VBMS def metadata_for_benefits_intake { veteranFirstName: parsed_form.dig('veteranInformation', 'fullName', 'first'), veteranLastName: parsed_form.dig('veteranInformation', 'fullName', 'last'), fileNumber: parsed_form.dig('veteranInformation', 'vaFileNumber') || parsed_form.dig('veteranInformation', 'ssn'), zipCode: zip_code_for_metadata, businessLine: business_line } end private def zip_code_for_metadata parsed_form.dig('burialInformation', 'recipientOrganization', 'address', 'postalCode') || DEFAULT_ZIP_CODE end def organization_name parsed_form.dig('burialInformation', 'recipientOrganization', 'name') || parsed_form.dig('burialInformation', 'nameOfStateCemeteryOrTribalOrganization') end def veteran_name first = parsed_form.dig('veteranInformation', 'fullName', 'first') last = parsed_form.dig('veteranInformation', 'fullName', 'last') "#{first} #{last}".strip.presence end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/saved_claim/pension.rb
# frozen_string_literal: true ## # Pension 21P-527EZ Active::Record # proxy for backwards compatibility # # @see modules/pensions/app/models/pensions/saved_claim.rb # class SavedClaim::Pension < SavedClaim # form_id, form_type FORM = '21P-527EZ' end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/saved_claim/education_benefits.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits < SavedClaim has_one(:education_benefits_claim, foreign_key: 'saved_claim_id', inverse_of: :saved_claim) validates(:education_benefits_claim, presence: true) before_validation(:add_education_benefits_claim) def self.form_class(form_type) raise 'Invalid form type' unless EducationBenefitsClaim::FORM_TYPES.include?(form_type) "SavedClaim::EducationBenefits::VA#{form_type}".constantize end def in_progress_form_id form_id end def after_submit(user); end private def regional_office_address (_title, *address) = education_benefits_claim.regional_office.split("\n") address.join("\n") end def add_education_benefits_claim build_education_benefits_claim if education_benefits_claim.nil? end # most forms use regional_office_address so default to true. For forms that don't, set regional_office: false # rubocop:disable Metrics/MethodLength def send_education_benefits_confirmation_email(email, parsed_form_data, template_params = {}, regional_office: true) form_number = self.class.name.split('::').last.downcase.gsub('va', '') # Base parameters that all forms have base_params = { 'date_submitted' => Time.zone.today.strftime('%B %d, %Y'), 'confirmation_number' => education_benefits_claim.confirmation_number } # Add regional office address if the form supports it base_params['regional_office_address'] = regional_office_address if regional_office # Add first name - most forms use this pattern first_name_key = determine_first_name_key base_params['first_name'] = parsed_form_data.dig(first_name_key, 'first')&.upcase.presence # Merge with form-specific parameters all_params = base_params.merge(template_params) # Build callback options callback_options = build_callback_options(form_number) begin VANotify::EmailJob.perform_async( email, template_id, all_params, Settings.vanotify.services.va_gov.api_key, callback_options ) rescue => e method_name = 'send_confirmation_email' Rails.logger.error "#{self.class.name}##{method_name}: Failed to queue confirmation email: #{e.message}" end end # rubocop:enable Metrics/MethodLength def determine_first_name_key case self.class.name.split('::').last when 'VA0994', 'VA5490', 'VA5495' 'relativeFullName' when 'VA10297' 'applicantFullName' else 'veteranFullName' end end def build_callback_options(form_number) # based on my understanding of modules/va_notify/lib/default_callback.rb & # lib/veteran_facing_services/adr/vanotify_default_callback_concerns.md, # we should be using someting other than error for the notification_type { callback_metadata: { notification_type: 'confirmation', form_number: "22-#{form_number}", statsd_tags: { service: "submit-#{form_number}-form", function: "form_#{form_number}_failure_confirmation_email_sending" } } } end def template_id raise NotImplementedError, "#{self.class.name} must implement template_id method" end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/saved_claim/burial.rb
# frozen_string_literal: true ## # Burial 21P-530EZ Active::Record # proxy for backwards compatibility # # @see modules/burials/app/models/burials/saved_claim.rb # class SavedClaim::Burial < SavedClaim # form_id, form_type FORM = Burials::FORM_ID end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/saved_claim/form212680.rb
# frozen_string_literal: true class SavedClaim::Form212680 < SavedClaim FORM = '21-2680' # Regional office information for Pension Management Center def regional_office [ 'Department of Veterans Affairs', 'Pension Management Center', 'P.O. Box 5365', 'Janesville, WI 53547-5365' ] end # Business line for VA processing def business_line 'PMC' # Pension Management Center end # VBMS document type for Aid and Attendance/Housebound # Note: This form can be used as either: # - Supporting documentation for an existing pension claim (most common) # - A primary claim form for A&A/Housebound benefits (some cases) def document_type 540 # Aid and Attendance/Housebound end # Generate pre-filled PDF with veteran sections def generate_prefilled_pdf pdf_path = to_pdf # Update metadata to track PDF generation update_metadata_with_pdf_generation pdf_path end # Get PDF download instructions def download_instructions { title: 'Next Steps: Get Physician to Complete Form', steps: [ 'Download the pre-filled PDF below', 'Print the PDF or save it to your device', 'Take the form to your physician', 'Have your physician complete Sections VI-VIII', 'Have your physician sign Section VIII', 'Scan or photograph the completed form', 'Upload the completed form at: va.gov/upload-supporting-documents' ], upload_url: "#{Settings.hostname}/upload-supporting-documents", form_number: '21-2680', regional_office: regional_office.join(', ') } end # Attachment keys (not used in this workflow, but required by SavedClaim) def attachment_keys [].freeze end # Override to_pdf to add veteran signature stamp def to_pdf(file_name = nil, fill_options = {}) pdf_path = PdfFill::Filler.fill_form(self, file_name, fill_options) PdfFill::Forms::Va212680.stamp_signature(pdf_path, parsed_form) end def veteran_first_last_name full_name = parsed_form.dig('veteranInformation', 'fullName') return 'Veteran' unless full_name.is_a?(Hash) "#{full_name['first']} #{full_name['last']}" end private def update_metadata_with_pdf_generation current_metadata = metadata.present? ? JSON.parse(metadata) : {} current_metadata['pdf_generated_at'] = Time.current.iso8601 current_metadata['submission_method'] = 'print_and_upload' self.metadata = current_metadata.to_json save!(validate: false) end end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/disability_compensation/form526_increase_only.rb
# frozen_string_literal: true # This model is no longer actvely used, new forms use Form526AllClaim, but it's useful for retreiving old data. class SavedClaim::DisabilityCompensation::Form526IncreaseOnly < SavedClaim::DisabilityCompensation end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/disability_compensation/form526_all_claim.rb
# frozen_string_literal: true class SavedClaim::DisabilityCompensation::Form526AllClaim < SavedClaim::DisabilityCompensation add_form_and_validation('21-526EZ-ALLCLAIMS') end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_0839.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA0839 < SavedClaim::EducationBenefits add_form_and_validation('22-0839') end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_5490.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA5490 < SavedClaim::EducationBenefits add_form_and_validation('22-5490') def after_submit(_user) parsed_form_data ||= JSON.parse(form) email = parsed_form_data['email'] return if email.blank? return unless Flipper.enabled?(:form5490_confirmation_email) send_confirmation_email(parsed_form_data, email) end private def send_confirmation_email(parsed_form_data, email) benefit = case parsed_form_data['benefit'] when 'chapter35' 'Survivors’ and Dependents’ Educational Assistance (DEA, Chapter 35)' when 'chapter33' 'The Fry Scholarship (Chapter 33)' end VANotify::EmailJob.perform_async( email, Settings.vanotify.services.va_gov.template_id.form5490_confirmation_email, { 'first_name' => parsed_form.dig('relativeFullName', 'first')&.upcase.presence, 'benefit' => benefit, 'date_submitted' => Time.zone.today.strftime('%B %d, %Y'), 'confirmation_number' => education_benefits_claim.confirmation_number, 'regional_office_address' => regional_office_address } ) end end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_1990.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA1990 < SavedClaim::EducationBenefits add_form_and_validation('22-1990') # pulled from https://github.com/department-of-veterans-affairs/vets-website/blob/f27b8a5ffe4e2f9357d6c501c9a6a73dacdad0e1/src/applications/edu-benefits/utils/helpers.jsx#L100 BENEFIT_TITLE_FOR_1990 = { 'chapter30' => 'Montgomery GI Bill (MGIB or Chapter 30) Education Assistance Program', 'chapter33' => 'Post-9/11 GI Bill (Chapter 33)', 'chapter1606' => 'Montgomery GI Bill Selected Reserve (MGIB-SR or Chapter 1606) Educational Assistance Program', 'chapter32' => 'Post-Vietnam Era Veterans’ Educational Assistance Program (VEAP or chapter 32)' }.freeze # pulled from https://github.com/department-of-veterans-affairs/vets-website/blob/f27b8a5ffe4e2f9357d6c501c9a6a73dacdad0e1/src/applications/edu-benefits/1990/helpers.jsx#L88 BENEFIT_RELINQUISHED_TITLE_FOR_1990 = { 'unknown' => 'I’m only eligible for the Post-9/11 GI Bill', 'chapter30' => 'Montgomery GI Bill (MGIB-AD, Chapter 30)', 'chapter1606' => 'Montgomery GI Bill Selected Reserve (MGIB-SR, Chapter 1606)', 'chapter1607' => 'Reserve Educational Assistance Program (REAP, Chapter 1607)' }.freeze def after_submit(_user) return unless Flipper.enabled?(:form1990_confirmation_email) parsed_form_data ||= JSON.parse(form) email = parsed_form_data['email'] return if email.blank? send_confirmation_email(parsed_form_data, email) end private def send_confirmation_email(parsed_form_data, email) benefit_relinquished = if parsed_form_data['benefitsRelinquished'].present? "__Benefits Relinquished:__\n^" \ "#{BENEFIT_RELINQUISHED_TITLE_FOR_1990[parsed_form_data['benefitsRelinquished']]}" else '' end VANotify::EmailJob.perform_async( email, Settings.vanotify.services.va_gov.template_id.form1990_confirmation_email, { 'first_name' => parsed_form.dig('veteranFullName', 'first')&.upcase.presence, 'benefits' => benefits_claimed(parsed_form_data), 'benefit_relinquished' => benefit_relinquished, 'date_submitted' => Time.zone.today.strftime('%B %d, %Y'), 'confirmation_number' => education_benefits_claim.confirmation_number, 'regional_office_address' => regional_office_address } ) end def benefits_claimed(parsed_form_data) %w[chapter30 chapter33 chapter1606 chapter32] .map { |benefit| parsed_form_data[benefit] ? BENEFIT_TITLE_FOR_1990[benefit] : nil } .compact .join("\n\n^") end end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_5495.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA5495 < SavedClaim::EducationBenefits add_form_and_validation('22-5495') def after_submit(_user) return unless Flipper.enabled?(:form5495_confirmation_email) parsed_form_data = JSON.parse(form) email = parsed_form_data['email'] return if email.blank? send_confirmation_email(email) end private def send_confirmation_email(email) VANotify::EmailJob.perform_async( email, Settings.vanotify.services.va_gov.template_id.form5495_confirmation_email, { 'first_name' => parsed_form.dig('relativeFullName', 'first')&.upcase.presence, 'date_submitted' => Time.zone.today.strftime('%B %d, %Y'), 'confirmation_number' => education_benefits_claim.confirmation_number, 'regional_office_address' => regional_office_address } ) end end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_1995.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA1995 < SavedClaim::EducationBenefits add_form_and_validation('22-1995') # Pulled from https://github.com/department-of-veterans-affairs/vets-website/src/applications/edu-benefits/utils/helpers.jsx#L100 # & https://github.com/department-of-veterans-affairs/vets-website/blob/main/src/applications/edu-benefits/utils/labels.jsx BENEFIT_TITLE_FOR_1995 = { 'chapter30' => 'Montgomery GI Bill (MGIB, Chapter 30)', 'chapter33Post911' => 'Post-9/11 GI Bill (Chapter 33)', 'chapter33FryScholarship' => 'Fry Scholarship (Chapter 33)', 'chapter1606' => 'Montgomery GI Bill Selected Reserve (MGIB-SR, Chapter 1606)', 'chapter32' => 'Post-Vietnam Era Veterans’ Educational Assistance Program (VEAP, chapter 32)', 'transferOfEntitlement' => 'Transfer of Entitlement Program (TOE)' }.freeze def after_submit(_user) return unless Flipper.enabled?(:form1995_confirmation_email) parsed_form_data = JSON.parse(form) email = parsed_form_data['email'] return if email.blank? send_confirmation_email(parsed_form_data, email) end private def send_confirmation_email(parsed_form_data, email) benefit_claimed = BENEFIT_TITLE_FOR_1995[parsed_form_data['benefit']] || '' VANotify::EmailJob.perform_async( email, Settings.vanotify.services.va_gov.template_id.form1995_confirmation_email, { 'first_name' => parsed_form.dig('veteranFullName', 'first')&.upcase.presence, 'benefit' => benefit_claimed, 'date_submitted' => Time.zone.today.strftime('%B %d, %Y'), 'confirmation_number' => education_benefits_claim.confirmation_number, 'regional_office_address' => regional_office_address } ) end end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_8794.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA8794 < SavedClaim::EducationBenefits add_form_and_validation('22-8794') end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_10216.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA10216 < SavedClaim::EducationBenefits add_form_and_validation('22-10216') end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_0803.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA0803 < SavedClaim::EducationBenefits add_form_and_validation('22-0803') end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_0994.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA0994 < SavedClaim::EducationBenefits add_form_and_validation('22-0994') def after_submit(_user) return unless Flipper.enabled?(:form0994_confirmation_email) parsed_form_data ||= JSON.parse(form) email = parsed_form_data['emailAddress'] return if email.blank? send_confirmation_email(parsed_form_data, email) end private def send_confirmation_email(parsed_form_data, email) email_template = if parsed_form_data['appliedForVaEducationBenefits'] Settings.vanotify.services.va_gov.template_id.form0994_confirmation_email else Settings.vanotify.services.va_gov.template_id.form0994_extra_action_confirmation_email end VANotify::EmailJob.perform_async( email, email_template, { 'first_name' => parsed_form_data.dig('applicantFullName', 'first')&.upcase.presence, 'date_submitted' => Time.zone.today.strftime('%B %d, %Y'), 'confirmation_number' => education_benefits_claim.confirmation_number, 'regional_office_address' => regional_office_address } ) end end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_0976.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA0976 < SavedClaim::EducationBenefits add_form_and_validation('22-0976') end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_1919.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA1919 < SavedClaim::EducationBenefits add_form_and_validation('22-1919') end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_10203.rb
# frozen_string_literal: true require 'lighthouse/benefits_education/service' require 'feature_flipper' class SavedClaim::EducationBenefits::VA10203 < SavedClaim::EducationBenefits add_form_and_validation('22-10203') class Submit10203Error < StandardError end def after_submit(user) @user = user if @user.present? @gi_bill_status = get_gi_bill_status create_stem_automated_decision end email_sent(false) send_confirmation_email if Flipper.enabled?(:form21_10203_confirmation_email) if @user.present? && FeatureFlipper.send_email? education_benefits_claim.education_stem_automated_decision.update(confirmation_email_sent_at: Time.zone.now) authorized = @user.authorize(:evss, :access?) if authorized EducationForm::SendSchoolCertifyingOfficialsEmail.perform_async(id, less_than_six_months?, get_facility_code) end end end def create_stem_automated_decision logger.info "EDIPI available for submit STEM claim id=#{education_benefits_claim.id}: #{@user.edipi.present?}" education_benefits_claim.build_education_stem_automated_decision( user_uuid: @user.uuid, user_account: @user.user_account, auth_headers_json: EVSS::AuthHeaders.new(@user).to_h.to_json, remaining_entitlement: ).save end def email_sent(sco_email_sent) update_form('scoEmailSent', sco_email_sent) save end private def get_gi_bill_status service = BenefitsEducation::Service.new(@user.icn) service.get_gi_bill_status rescue => e Rails.logger.error "Failed to retrieve GiBillStatus data: #{e.message}" {} end def get_facility_code return {} if @gi_bill_status.blank? || @gi_bill_status.enrollments.blank? most_recent = @gi_bill_status.enrollments.max_by(&:begin_date) return {} if most_recent.blank? most_recent.facility_code end def remaining_entitlement return nil if @gi_bill_status.blank? || @gi_bill_status.remaining_entitlement.blank? months = @gi_bill_status.remaining_entitlement.months days = @gi_bill_status.remaining_entitlement.days ((months * 30) + days) end def less_than_six_months? return false if remaining_entitlement.blank? remaining_entitlement <= 180 end def send_confirmation_email parsed_form = JSON.parse(form) email = parsed_form['email'] return if email.blank? if Flipper.enabled?(:form1995_confirmation_email_with_silent_failure_processing) # this method is in the parent class send_education_benefits_confirmation_email(email, parsed_form, {}) else VANotify::EmailJob.perform_async( email, Settings.vanotify.services.va_gov.template_id.form21_10203_confirmation_email, { 'first_name' => parsed_form.dig('veteranFullName', 'first')&.upcase.presence, 'date_submitted' => Time.zone.today.strftime('%B %d, %Y'), 'confirmation_number' => education_benefits_claim.confirmation_number, 'regional_office_address' => regional_office_address } ) end end def template_id Settings.vanotify.services.va_gov.template_id.form21_10203_confirmation_email end end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_10282.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA10282 < SavedClaim::EducationBenefits add_form_and_validation('22-10282') def after_submit(_user) return unless Flipper.enabled?(:form22_10282_confirmation_email) parsed_form_data = JSON.parse(form) email = parsed_form_data.dig('contactInfo', 'email') return if email.blank? send_confirmation_email(parsed_form_data, email) end private def send_confirmation_email(parsed_form_data, email) VANotify::EmailJob.perform_async( email, Settings.vanotify.services.va_gov.template_id.form22_10282_confirmation_email, { 'first_name' => parsed_form_data.dig('veteranFullName', 'first')&.upcase.presence, 'date_submitted' => Time.zone.today.strftime('%B %d, %Y'), 'confirmation_number' => education_benefits_claim.confirmation_number } ) end end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_10275.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA10275 < SavedClaim::EducationBenefits add_form_and_validation('22-10275') def after_submit(_user) return unless Flipper.enabled?(:form22_10275_submission_email) email_template = Settings.vanotify.services.va_gov.template_id.form10275_submission_email email_params = { agreement_type: construct_agreement_type, institution_details: construct_institution_details, additional_locations: construct_additional_locations, points_of_contact: construct_points_of_contact, principles_of_excellence: construct_principles_of_excellence, submission_information: construct_submission_information, submission_id: id } VANotify::EmailJob.perform_async( Settings.form_10275.submission_email, email_template, email_params, callback_metadata ) end private def callback_metadata { callback_metadata: { notification_type: 'error', form_number: '22-10275', statsd_tags: { service: 'submit-10275-form', function: 'form_10275_failure_confirmation_email_sending' } } } end def construct_agreement_type case parsed_form['agreementType'] when 'newCommitment' then 'New commitment' when 'withdrawal' then 'Withdrawal' else 'Unknown' end end def construct_institution_details institution = parsed_form['mainInstitution'] <<~DETAILS **Institution name:** #{institution['institutionName']} **Facility code:** #{institution['facilityCode']} **Institution address:** #{format_address(institution['institutionAddress'])} DETAILS end def construct_additional_locations (parsed_form['additionalInstitutions'] || []).map do |location| format_location(location) end.join("\n\n") end def construct_points_of_contact str = format_official(parsed_form['authorizedOfficial'], 'Authorizing official') if parsed_form['agreementType'] == 'newCommitment' poc = parsed_form['newCommitment']['principlesOfExcellencePointOfContact'] sco = parsed_form['newCommitment']['schoolCertifyingOfficial'] str += <<~OFF #{format_official(poc, 'Principles of Excellence point of contact', include_title: false)} #{format_official(sco, 'School certifying official', include_title: false)} OFF end str end def construct_principles_of_excellence return '' unless parsed_form['agreementType'] == 'newCommitment' <<~POE ### Principles of Excellence agreement **Principle 1:** Institution agrees **Principle 2:** Institution agrees **Principle 3:** Institution agrees **Principle 4:** Institution agrees **Principle 5:** Institution agrees **Principle 6:** Institution agrees **Principle 7:** Institution agrees **Principle 8:** Institution agrees POE end def construct_submission_information <<~SUBMISSION **Date submitted:** #{parsed_form['dateSigned']} **Digitally signed by:** #{parsed_form['statementOfTruthSignature']} **Submission ID:** #{id} SUBMISSION end def format_location(location_hash) <<~LOCATION **#{location_hash['institutionName']}** **Facility code:** #{location_hash['facilityCode']} **Address:** #{format_address(location_hash['institutionAddress']).chomp} **Point of contact:** #{format_name(location_hash['pointOfContact']['fullName'])} **Email:** #{location_hash['pointOfContact']['email']} LOCATION end def format_official(official_hash, header, include_title: true) str = "**#{header}:** #{format_name(official_hash['fullName'])}" str += "\n**Title:** #{official_hash['title']}" if include_title str += "\n**Phone number:** #{official_hash['usPhone'] || official_hash['internationalPhone']}" str += "\n**Email address:** #{official_hash['email']}" str end def format_address(address_hash) str = <<~ADDRESS #{address_hash['street']} #{address_hash['street2']} #{address_hash['street3']} #{address_hash['city']}, #{address_hash['state']}, #{address_hash['postalCode']} ADDRESS str += address_hash['country'] unless %w[US USA].include?(address_hash['country']) str end def format_name(name_hash) "#{name_hash['first']} #{name_hash['middle']} #{name_hash['last']}" end end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_0993.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA0993 < SavedClaim::EducationBenefits add_form_and_validation('22-0993') end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_10297.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA10297 < SavedClaim::EducationBenefits add_form_and_validation('22-10297') def after_submit(_user) return unless Flipper.enabled?(:form22_10297_confirmation_email) parsed_form_data = JSON.parse(form) email = parsed_form_data.dig('contactInfo', 'emailAddress') return if email.blank? send_confirmation_email(parsed_form_data, email) end private def send_confirmation_email(parsed_form_data, email) if Flipper.enabled?(:form10297_confirmation_email_with_silent_failure_processing) # this method is in the parent class send_education_benefits_confirmation_email(email, parsed_form, {}) else VANotify::EmailJob.perform_async( email, template_id, { 'first_name' => parsed_form_data.dig('applicantFullName', 'first')&.upcase.presence, 'date_submitted' => Time.zone.today.strftime('%B %d, %Y'), 'confirmation_number' => education_benefits_claim.confirmation_number, 'regional_office_address' => regional_office_address } ) end end def template_id Settings.vanotify.services.va_gov.template_id.form10297_confirmation_email end end
0
code_files/vets-api-private/app/models/saved_claim
code_files/vets-api-private/app/models/saved_claim/education_benefits/va_10215.rb
# frozen_string_literal: true class SavedClaim::EducationBenefits::VA10215 < SavedClaim::EducationBenefits add_form_and_validation('22-10215') end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/claims_api/claim_submission.rb
# frozen_string_literal: true module ClaimsApi class ClaimSubmission < ApplicationRecord validates :claim_type, presence: true validates :consumer_label, presence: true belongs_to :claim, class_name: 'AutoEstablishedClaim' end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/va_profile_redis/veteran_status.rb
# frozen_string_literal: true require 'va_profile/models/veteran_status' require 'common/models/redis_store' require 'common/models/concerns/cache_aside' require 'va_profile/configuration' module VAProfileRedis class VeteranStatus < Common::RedisStore include Common::CacheAside redis_config_key :va_profile_veteran_status attr_accessor :user def self.for_user(user) veteran_status = new veteran_status.user = user veteran_status.populate_from_redis veteran_status end def veteran? title38_status == 'V1' end def title38_status return unless @user.loa3? value_for('title38_status_code') end # Returns boolean for user being/not being considered a military person, by VA Profile, # based on their Title 38 Status Code. # # @return [Boolean] # def military_person? %w[V3 V6].include?(title38_status) end def status return VAProfile::Response::RESPONSE_STATUS[:not_authorized] unless @user.loa3? response.status end def response @response ||= response_from_redis_or_service end def populate_from_redis response_from_redis_or_service end private def value_for(key) value = response&.title38_status_code&.send(key) value.presence end def response_from_redis_or_service unless VAProfile::Configuration::SETTINGS.veteran_status.cache_enabled return veteran_status_service.get_veteran_status end do_cached_with(key: @user.uuid) do veteran_status_service.get_veteran_status end end def veteran_status_service @service ||= VAProfile::VeteranStatus::Service.new(@user) end end end
0
code_files/vets-api-private/app/models/va_profile_redis
code_files/vets-api-private/app/models/va_profile_redis/v2/cache.rb
# frozen_string_literal: true require 'vets/shared_logging' module VAProfileRedis module V2 class Cache include Vets::SharedLogging # Invalidates the cache set in VAProfileRedis::V2::ContactInformation through # our Common::RedisStore#destroy method. # # @param user [User] The current user # def self.invalidate(user) return if user&.icn.blank? contact_info = VAProfileRedis::V2::ContactInformation.find(user.icn) contact_info.destroy if contact_info.present? end end end end
0
code_files/vets-api-private/app/models/va_profile_redis
code_files/vets-api-private/app/models/va_profile_redis/v2/contact_information.rb
# frozen_string_literal: true require 'va_profile/contact_information/v2/person_response' require 'va_profile/contact_information/v2/service' require 'va_profile/models/address' require 'va_profile/models/telephone' require 'common/models/redis_store' require 'common/models/concerns/cache_aside' require 'va_profile/configuration' module VAProfileRedis # Facade for VAProfile::ContactInformation::V2::Service. The user_serializer delegates # to this class through the User model. # # When a person is requested from the serializer, it returns either a cached # response in Redis or from the VAProfile::ContactInformation::V2::Service. # module V2 class ContactInformation < Common::RedisStore include Common::CacheAside # Redis settings for ttl and namespacing reside in config/redis.yml # redis_config_key :va_profile_v2_contact_info_response # @return [User] the user being queried in VA Profile # attr_accessor :user def self.for_user(user) contact_info = new contact_info.user = user contact_info.populate_from_redis contact_info end # Returns the user's email model. In VA Profile, a user can only have one # email address. # # @return [VAProfile::Models::Email] The user's one email address model # def email return unless verified_user? value_for('emails')&.first end # Returns the user's residence. In VA Profile, a user can only have one # residence address. # # @return [VAProfile::Models::Address] The user's one residential address model # def residential_address return unless verified_user? dig_out('addresses', 'address_pou', VAProfile::Models::Address::RESIDENCE) end # Returns the user's mailing address. In VA Profile, a user can only have one # mailing address. # # @return [VAProfile::Models::Address] The user's one mailing address model # def mailing_address return unless verified_user? dig_out('addresses', 'address_pou', VAProfile::Models::Address::CORRESPONDENCE) end # Returns the user's home phone. In VA Profile, a user can only have one # home phone. # # @return [VAProfile::Models::Telephone] The user's one home phone model # def home_phone return unless verified_user? dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::HOME) end # Returns the user's mobile phone. In VA Profile, a user can only have one # mobile phone. # # @return [VAProfile::Models::Telephone] The user's one mobile phone model # def mobile_phone return unless verified_user? dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::MOBILE) end # Returns the user's work phone. In VA Profile, a user can only have one # work phone. # # @return [VAProfile::Models::Telephone] The user's one work phone model # def work_phone return unless verified_user? dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::WORK) end # Returns the user's temporary phone. In VA Profile, a user can only have one # temporary phone. # # @return [VAProfile::Models::Telephone] The user's one temporary phone model # def temporary_phone return unless verified_user? dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::TEMPORARY) end # Returns the user's fax number. In VA Profile, a user can only have one # fax number. # # @return [VAProfile::Models::Telephone] The user's one fax number model # def fax_number return unless verified_user? dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::FAX) end # The status of the last VAProfile::ContactInformation::V2::Service response, # or not authorized for for users < LOA 3 # # @return [Integer <> String] the status of the last VAProfile::ContactInformation::V2::Service response # def status return VAProfile::ContactInformation::V2::PersonResponse::RESPONSE_STATUS[:not_authorized] unless verified_user? response.status end # @return [VAProfile::ContactInformation::PersonResponse] the response returned from # the redis cache. If that is unavailable, it calls the # VAProfile::ContactInformation::V2::Service#get_person endpoint. # def response @response ||= response_from_redis_or_service end # This method allows us to populate the local instance of a # VAProfileRedis::V2::ContactInformation object with the icn necessary # to perform subsequent actions on the key such as deletion. def populate_from_redis response_from_redis_or_service end private def verified_user? @user&.icn.present? end def value_for(key) value = response&.person&.send(key) value.presence end def dig_out(key, type, matcher) response_value = value_for(key) if key == 'addresses' && Settings.vsp_environment == 'staging' Rails.logger.info("ContactInformationV2 Redis Address POU: #{response_value}") end return if response_value.blank? response_value.find do |contact_info| contact_info.send(type) == matcher end end def response_from_redis_or_service do_cached_with(key: @user.icn) do contact_info_service.get_person end end def contact_info_service @service ||= VAProfile::ContactInformation::V2::Service.new @user end end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/adapters/payment_history_adapter.rb
# frozen_string_literal: true module Adapters class PaymentHistoryAdapter attr_accessor :payments, :return_payments def initialize(input) @input_payment = input&.dig(:payments, :payment) if @input_payment.nil? || !Flipper.enabled?(:payment_history) @payments = [] @return_payments = [] else @input_payments = [@input_payment].flatten payments, return_payments = @input_payments.partition do |payment| payment&.dig(:return_payment, :check_trace_number).blank? end @payments = process_payments(payments) @return_payments = process_return_payments(return_payments) end end private def process_payments(payments) payments.map do |payment| { pay_check_dt: payment[:payment_date], pay_check_amount: ActiveSupport::NumberHelper.number_to_currency(payment[:payment_amount]), pay_check_type: payment[:payment_type], payment_method: get_payment_method(payment), bank_name: payment&.dig(:address_eft, :bank_name), account_number: mask_account_number(payment[:address_eft]) } end end def process_return_payments(returned_payments) returned_payments.map do |payment| { returned_check_issue_dt: payment[:payment_date], returned_check_cancel_dt: payment[:return_payment][:return_date], returned_check_amount: ActiveSupport::NumberHelper.number_to_currency(payment[:payment_amount]), returned_check_number: payment[:return_payment][:check_trace_number], returned_check_type: payment[:payment_type], return_reason: payment[:return_payment][:return_reason] } end end def get_payment_method(payment) return 'Direct Deposit' if payment&.dig(:address_eft, :account_number).present? return 'Paper Check' if payment&.dig(:check_address, :address_line1).present? nil end def mask_account_number(address_eft, all_but = 4, char = '*') return if address_eft.blank? account_number = address_eft[:account_number] return if account_number.blank? account_number.gsub(/.(?=.{#{all_but}})/, char) end end end
0
code_files/vets-api-private/app/models/mhv
code_files/vets-api-private/app/models/mhv/mr/vaccine.rb
# frozen_string_literal: true module MHV module MR class Vaccine < MHV::MR::FHIRRecord include RedisCaching redis_config REDIS_CONFIG[:medical_records_cache] attribute :id, String attribute :name, String attribute :date_received, String # Pass on as-is to the frontend attribute :location, String attribute :manufacturer, String attribute :reactions, String attribute :notes, String, array: true default_sort_by date_received: :desc ## # Map from a FHIR::Immunization resource # def self.map_fhir(fhir) # extract location.name loc_res = find_contained(fhir, fhir.location&.reference, type: 'Location') # extract reaction Observation.code.text obs_res = find_contained(fhir, fhir.reaction&.first&.detail&.reference, type: 'Observation') { id: fhir.id, name: fhir.vaccineCode&.text, date_received: fhir.occurrenceDateTime, location: loc_res&.name, manufacturer: fhir.manufacturer&.display, reactions: obs_res&.code&.text, notes: (fhir.note || []).map(&:text) } end end end end
0
code_files/vets-api-private/app/models/mhv
code_files/vets-api-private/app/models/mhv/mr/health_condition.rb
# frozen_string_literal: true require 'common/models/base' module MHV module MR class HealthCondition < MHV::MR::FHIRRecord include RedisCaching redis_config REDIS_CONFIG[:medical_records_cache] attribute :id, String attribute :name, String attribute :date, String # Pass on as-is to the frontend attribute :provider, String attribute :facility, String attribute :comments, String, array: true default_sort_by date: :desc def self.map_fhir(fhir) facility_ref = fhir.recorder&.extension&.first&.valueReference&.reference provider_ref = fhir.recorder&.reference { id: fhir.id, name: fhir.code&.text, date: fhir.recordedDate, facility: find_contained(fhir, facility_ref, type: 'Location')&.name, provider: find_contained(fhir, provider_ref, type: 'Practitioner')&.name&.first&.text, comments: (fhir.note || []).map(&:text) } end end end end
0
code_files/vets-api-private/app/models/mhv
code_files/vets-api-private/app/models/mhv/mr/fhir_record.rb
# frozen_string_literal: true require 'vets/model' module MHV module MR # Abstract superclass for models built from FHIR resources # template class that handles common lookup and construction logic class FHIRRecord include Vets::Model # Build a new instance from a FHIR resource, or return nil if none def self.from_fhir(fhir) return nil if fhir.nil? new(map_fhir(fhir)) end # Subclasses must implement this to return a hash of attributes def self.map_fhir(fhir) raise NotImplementedError, "#{name}.map_fhir must be implemented by subclass" end # Locate a contained resource by its reference string ("#id"), optionally filtering by type def self.find_contained(fhir, reference, type: nil) return nil unless reference && fhir.contained target_id = reference.delete_prefix('#') resource = fhir.contained.detect { |res| res.id == target_id } return nil unless resource return resource if type.nil? || resource.resourceType == type nil end end end end
0
code_files/vets-api-private/app/models/mhv
code_files/vets-api-private/app/models/mhv/mr/allergy.rb
# frozen_string_literal: true require 'common/models/base' module MHV module MR class Allergy < MHV::MR::FHIRRecord include RedisCaching redis_config REDIS_CONFIG[:medical_records_cache] attribute :id, String attribute :name, String attribute :date, String # Pass on as-is to the frontend attribute :categories, String, array: true attribute :reactions, String, array: true attribute :location, String attribute :observedHistoric, String # 'o' or 'h' attribute :notes, String attribute :provider, String default_sort_by date: :desc def self.map_fhir(fhir) { id: fhir.id, name: fhir.code&.text, date: fhir.recordedDate, categories: categories(fhir), reactions: reactions(fhir), location: location_name(fhir), observedHistoric: observed_historic(fhir), notes: note_text(fhir), provider: provider(fhir) } end def self.categories(fhir) fhir.category || [] end def self.reactions(fhir) Array(fhir.reaction).flat_map do |r| Array(r.manifestation).map { |m| m&.text }.compact end end def self.location_name(fhir) ref = fhir.recorder&.extension&.first&.valueReference&.reference find_contained(fhir, ref, type: 'Location')&.name end def self.observed_historic(fhir) ext = Array(fhir.extension).find { |e| e.url&.include?('allergyObservedHistoric') } ext&.valueCode end def self.note_text(fhir) fhir.note&.first&.text end def self.provider(fhir) fhir.recorder&.display end end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/audit/log.rb
# frozen_string_literal: true module Audit class Log < ApplicationRecord IDENTIFIER_TYPES = { icn: 'icn', logingov_uuid: 'logingov_uuid', idme_uuid: 'idme_uuid', mhv_id: 'mhv_id', dslogon_id: 'dslogon_id', system_hostname: 'system_hostname' }.freeze validates :subject_user_identifier, presence: true validates :acting_user_identifier, presence: true validates :event_id, presence: true validates :event_description, presence: true validates :event_status, presence: true validates :event_occurred_at, presence: true validates :message, presence: true enum :subject_user_identifier_type, IDENTIFIER_TYPES, prefix: true, validate: true enum :acting_user_identifier_type, IDENTIFIER_TYPES, prefix: true, validate: true end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/audit/application_record.rb
# frozen_string_literal: true module Audit class ApplicationRecord < ActiveRecord::Base self.abstract_class = true connects_to database: { writing: :audit, reading: :audit } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/base.rb
# frozen_string_literal: true require 'vets/model' module BGSDependents class Base include Vets::Model MILITARY_POST_OFFICE_TYPE_CODES = %w[APO DPO FPO].freeze # Gets the person's address based on the lives with veteran flag # # @param dependents_application [Hash] the submitted form information # @param lives_with_vet [Boolean] does live with veteran indicator # @param alt_address [Hash] alternate address # @return [Hash] address information # def dependent_address(dependents_application:, lives_with_vet:, alt_address:) return dependents_application.dig('veteran_contact_information', 'veteran_address') if lives_with_vet alt_address end def relationship_type(info) if info['dependent_type'] return { participant: 'Guardian', family: 'Other' } if info['dependent_type'] == 'DEPENDENT_PARENT' { participant: info['dependent_type'].capitalize.gsub('_', ' '), family: info['dependent_type'].capitalize.gsub('_', ' ') } end end def serialize_dependent_result( participant, participant_relationship_type, family_relationship_type, optional_fields = {} ) { vnp_participant_id: participant[:vnp_ptcpnt_id], participant_relationship_type_name: participant_relationship_type, family_relationship_type_name: family_relationship_type, begin_date: optional_fields[:begin_date], end_date: optional_fields[:end_date], event_date: optional_fields[:event_date], marriage_state: optional_fields[:marriage_state], marriage_city: optional_fields[:marriage_city], marriage_country: optional_fields[:marriage_country], divorce_state: optional_fields[:divorce_state], divorce_city: optional_fields[:divorce_city], divorce_country: optional_fields[:divorce_country], marriage_termination_type_code: optional_fields[:marriage_termination_type_code], living_expenses_paid_amount: optional_fields[:living_expenses_paid], child_prevly_married_ind: optional_fields[:child_prevly_married_ind], guardian_particpant_id: optional_fields[:guardian_particpant_id], type: optional_fields[:type], dep_has_income_ind: optional_fields[:dep_has_income_ind] } end def create_person_params(proc_id, participant_id, payload) { vnp_proc_id: proc_id, vnp_ptcpnt_id: participant_id, first_nm: payload['first'], middle_nm: payload['middle'], last_nm: payload['last'], suffix_nm: payload['suffix'], brthdy_dt: format_date(payload['birth_date']), birth_cntry_nm: payload['place_of_birth_country'], birth_state_cd: payload['place_of_birth_state'], birth_city_nm: payload['place_of_birth_city'], file_nbr: payload['va_file_number'], ssn_nbr: payload['ssn'], death_dt: format_date(payload['death_date']), ever_maried_ind: payload['ever_married_ind'], vet_ind: payload['vet_ind'], martl_status_type_cd: payload['martl_status_type_cd'], vnp_srusly_dsabld_ind: payload['not_self_sufficient'] } end # Converts a string "00/00/0000" to standard iso8601 format # # @return [String] formatted date # def format_date(date) return nil if date.nil? DateTime.parse("#{date} 12:00:00").to_time.iso8601 end def generate_address(address) # BGS will throw an error if we pass in a military postal code in for state if MILITARY_POST_OFFICE_TYPE_CODES.include?(address['city']) address['military_postal_code'] = v2? ? address.delete('state') : address.delete('state_code') address['military_post_office_type_code'] = address.delete('city') end adjust_address_lines_for!(address: address['veteran_address']) if address['veteran_address'] adjust_address_lines_for!(address:) adjust_country_name_for!(address:) address end # BGS will not accept address lines longer than 20 characters def adjust_address_lines_for!(address:) all_lines = if v2? "#{address['street']} #{address['street2']} #{address['street3']}" else "#{address['address_line1']} #{address['address_line2']} #{address['address_line3']}" end new_lines = all_lines.gsub(/\s+/, ' ').scan(/.{1,19}(?: |$)/).map(&:strip) address['address_line1'] = new_lines[0] address['address_line2'] = new_lines[1] address['address_line3'] = new_lines[2] end # rubocop:disable Metrics/MethodLength # This method converts ISO 3166-1 Alpha-3 country codes to ISO 3166-1 country names. def adjust_country_name_for!(address:) # international postal code is only in v1, return if country is usa in v2 return if address['international_postal_code'].blank? || address['country'] == 'USA' # handle v1 and v2 country naming country_name = address['country_name'] || address['country'] return if country_name.blank? || country_name.size != 3 # The ISO 3166-1 country name for GBR exceeds BIS's (formerly, BGS) 50 char limit. No other country name exceeds # this limit. For GBR, BIS expects "United Kingdom" instead. BIS has suggested using one of their web services # to get the correct country names, rather than relying on the IsoCountryCodes gem below. It may be worth # pursuing that some day. Until then, the following short-term improvement suffices. # we are now using a short term fix for special country names that are different from IsoCountryCodes in BIS. special_country_names = { 'USA' => 'USA', 'BOL' => 'Bolivia', 'BIH' => 'Bosnia-Herzegovina', 'BRN' => 'Brunei', 'CPV' => 'Cape Verde', 'COG' => "Congo, People's Republic of", 'COD' => 'Congo, Democratic Republic of', 'CIV' => "Cote d'Ivoire", 'CZE' => 'Czech Republic', 'PRK' => 'North Korea', 'KOR' => 'South Korea', 'LAO' => 'Laos', 'MKD' => 'Macedonia', 'MDA' => 'Moldavia', 'RUS' => 'Russia', 'KNA' => 'St. Kitts', 'LCA' => 'St. Lucia', 'STP' => 'Sao-Tome/Principe', 'SCG' => 'Serbia', 'SYR' => 'Syria', 'TZA' => 'Tanzania', 'GBR' => 'United Kingdom', 'VEN' => 'Venezuela', 'VNM' => 'Vietnam', 'YEM' => 'Yemen Arab Republic' } address['country_name'] = if country_name.to_s == 'TUR' address['city'].to_s.downcase == 'adana' ? 'Turkey (Adana only)' : 'Turkey (except Adana)' elsif special_country_names[country_name.to_s].present? special_country_names[country_name.to_s] else IsoCountryCodes.find(country_name).name end address['country'] = address['country_name'] if v2? address end # rubocop:enable Metrics/MethodLength # rubocop:disable Metrics/MethodLength def create_address_params(proc_id, participant_id, payload) is_v2 = v2? address = generate_address(payload) frgn_postal_code = if is_v2 if address['military_postal_code'].present? || address['country'] == 'USA' nil else address['postal_code'] end else address['international_postal_code'] end { efctv_dt: Time.current.iso8601, vnp_ptcpnt_id: participant_id, vnp_proc_id: proc_id, ptcpnt_addrs_type_nm: 'Mailing', shared_addrs_ind: 'N', addrs_one_txt: address['address_line1'], addrs_two_txt: address['address_line2'], addrs_three_txt: address['address_line3'], city_nm: address['city'], cntry_nm: is_v2 ? address['country'] : address['country_name'], postal_cd: is_v2 ? address['state'] : address['state_code'], frgn_postal_cd: frgn_postal_code, mlty_postal_type_cd: address['military_postal_code'], mlty_post_office_type_cd: address['military_post_office_type_code'], zip_prefix_nbr: is_v2 ? address['postal_code'] : address['zip_code'], prvnc_nm: is_v2 ? address['state'] : address['state_code'], email_addrs_txt: payload['email_address'] } end # rubocop:enable Metrics/MethodLength def formatted_boolean(bool_attribute) return nil if bool_attribute.nil? bool_attribute ? 'Y' : 'N' end private def v2? false end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/veteran.rb
# frozen_string_literal: true module BGSDependents class Veteran < Base attribute :participant_id, String attribute :ssn, String attribute :first_name, String attribute :middle_name, String attribute :last_name, String def initialize(proc_id, user) @proc_id = proc_id @user = user assign_attributes end def formatted_params(payload) dependents_application = payload['dependents_application'] vet_info = [ *payload['veteran_information'], ['first', first_name], ['middle', middle_name], ['last', last_name], *dependents_application['veteran_contact_information'], *dependents_application.dig('veteran_contact_information', 'veteran_address'), %w[vet_ind Y] ] if dependents_application['current_marriage_information'] vet_info << ['martl_status_type_cd', marital_status(dependents_application)] end vet_info.to_h end # rubocop:disable Metrics/MethodLength def veteran_response(participant, address, claim_info) { vnp_participant_id: participant[:vnp_ptcpnt_id], first_name:, last_name:, vnp_participant_address_id: address[:vnp_ptcpnt_addrs_id], file_number: claim_info[:va_file_number], address_line_one: address[:addrs_one_txt], address_line_two: address[:addrs_two_txt], address_line_three: address[:addrs_three_txt], address_country: address[:cntry_nm], address_state_code: address[:postal_cd], address_city: address[:city_nm], address_zip_code: address[:zip_prefix_nbr], address_type: address[:address_type], mlty_postal_type_cd: address[:mlty_postal_type_cd], mlty_post_office_type_cd: address[:mlty_post_office_type_cd], foreign_mail_code: address[:frgn_postal_cd], type: 'veteran', benefit_claim_type_end_product: claim_info[:claim_type_end_product], regional_office_number: claim_info[:regional_office_number], location_id: claim_info[:location_id], net_worth_over_limit_ind: claim_info[:net_worth_over_limit_ind] } end # rubocop:enable Metrics/MethodLength private def assign_attributes @participant_id = @user.participant_id @ssn = @user.ssn @first_name = @user.first_name @middle_name = @user.middle_name @last_name = @user.last_name end def marital_status(dependents_application) spouse_lives_with_vet = dependents_application.dig('does_live_with_spouse', 'spouse_does_live_with_veteran') return nil if spouse_lives_with_vet.nil? spouse_lives_with_vet ? 'Married' : 'Separated' end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/adult_child_attending_school.rb
# frozen_string_literal: true module BGSDependents class AdultChildAttendingSchool < Base # The AdultChildAttendingSchool class represents a person including name and address info # # @!attribute first # @return [String] the person's first name # @!attribute middle # @return [String] the person's middle name # @!attribute last # @return [String] the person's last name # @!attribute suffix # @return [String] the person's name suffix # @!attribute ssn # @return [String] the person's social security number # @!attribute birth_date # @return [String] the person's birth date # @!attribute ever_married_ind # @return [String] Y/N indicates whether the person has ever been married # attribute :first, String attribute :middle, String attribute :last, String attribute :suffix, String attribute :ssn, String attribute :birth_date, String attribute :ever_married_ind, String attribute :dependent_income, String validates :first, presence: true validates :last, presence: true def initialize(dependents_application) @dependents_application = dependents_application @is_v2 = v2? # with v2 handling, dependents_application is one to many hashes within the student_information array @source = @is_v2 ? @dependents_application : @dependents_application['student_name_and_ssn'] @ssn = @source['ssn'] @full_name = @source['full_name'] @birth_date = @source['birth_date'] @was_married = @is_v2 ? @source['was_married'] : @dependents_application['student_address_marriage_tuition']['was_married'] # rubocop:disable Layout/LineLength @dependent_income = @is_v2 ? @source['student_income'] : @source['dependent_income'] @ever_married_ind = formatted_boolean(@was_married) @dependent_income = formatted_boolean(@dependent_income) @first = @full_name['first'] @middle = @full_name['middle'] @last = @full_name['last'] @suffix = @full_name['suffix'] end # Sets a hash with AdultChildAttendingSchool attributes # # @return [Hash] AdultChildAttendingSchool attributes including name and address info # def format_info attributes.with_indifferent_access end # Sets a hash with the student's address based on the submitted form information # # @return [Hash] the student's address # def address @is_v2 ? @source['address'] : @dependents_application['student_address_marriage_tuition']['address'] end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/divorce.rb
# frozen_string_literal: true module BGSDependents class Divorce < Base def initialize(divorce_info) @divorce_info = divorce_info @is_v2 = v2? end def format_info { divorce_state: @is_v2 ? @divorce_info.dig('divorce_location', 'location', 'state') : @divorce_info.dig('location', 'state'), # rubocop:disable Layout/LineLength divorce_city: @is_v2 ? @divorce_info.dig('divorce_location', 'location', 'city') : @divorce_info.dig('location', 'city'), # rubocop:disable Layout/LineLength divorce_country: @is_v2 ? @divorce_info.dig('divorce_location', 'location', 'country') : @divorce_info.dig('location', 'country'), # rubocop:disable Layout/LineLength marriage_termination_type_code: @divorce_info['reason_marriage_ended'], end_date: format_date(@divorce_info['date']), vet_ind: 'N', ssn: @divorce_info['ssn'], birth_date: @divorce_info['birth_date'], type: 'divorce', spouse_income: formatted_boolean(@divorce_info['spouse_income']) }.merge(@divorce_info['full_name']).with_indifferent_access end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/child.rb
# frozen_string_literal: true module BGSDependents class Child < Base # The Child class represents a veteran's dependent/child including name, address, and birth info # # @!attribute ssn # @return [String] the person's social security number # @!attribute first # @return [String] the person's first name # @!attribute middle # @return [String] the person's middle name # @!attribute last # @return [String] the person's last name # @!attribute suffix # @return [String] the person's name suffix # @!attribute ever_married_ind # @return [String] Y/N indicates whether the person has ever been married # @!attribute place_of_birth_city # @return [String] city where child was born # @!attribute place_of_birth_state # @return [String] state where child was born # @!attribute reason_marriage_ended # @return [String] reason child marriage ended # @!attribute family_relationship_type # @return [String] family relationship type: Biological/Stepchild/Adopted Child/Other # @!attribute child_income # @return [String] did this child have income in the last 365 days # attribute :ssn, String attribute :first, String attribute :middle, String attribute :last, String attribute :suffix, String attribute :birth_date, String attribute :ever_married_ind, String attribute :place_of_birth_city, String attribute :place_of_birth_state, String attribute :place_of_birth_country, String attribute :reason_marriage_ended, String attribute :family_relationship_type, String attribute :child_income, String attribute :not_self_sufficient, String CHILD_STATUS = { 'stepchild' => 'Stepchild', 'biological' => 'Biological', 'adopted' => 'Adopted Child', 'disabled' => 'Other', 'child_under18' => 'Other', 'child_over18_in_school' => 'Other' }.freeze # These are required fields in BGS validates :first, presence: true validates :last, presence: true def initialize(child_info) @child_info = child_info @is_v2 = v2? assign_attributes end # Sets a hash with child attributes # # @return [Hash] child attributes including name, address and birth info # def format_info attributes.with_indifferent_access end # Sets a hash with address information based on the submitted form information # # @param dependents_application [Hash] the submitted form information # @return [Hash] child address # def address(dependents_application) dependent_address( dependents_application:, lives_with_vet: @child_info['does_child_live_with_you'], alt_address: @is_v2 ? @child_info['address'] : @child_info.dig('child_address_info', 'address') ) end private def assign_attributes @ssn = @child_info['ssn'] @birth_date = @child_info['birth_date'] @family_relationship_type = child_status @place_of_birth_country = place_of_birth['country'] @place_of_birth_state = place_of_birth['state'] @place_of_birth_city = place_of_birth['city'] @reason_marriage_ended = reason_marriage_ended @ever_married_ind = marriage_indicator @child_income = formatted_boolean(@is_v2 ? @child_info['income_in_last_year'] : @child_info['child_income']) @not_self_sufficient = formatted_boolean(@child_info['not_self_sufficient']) @first = @child_info['full_name']['first'] @middle = @child_info['full_name']['middle'] @last = @child_info['full_name']['last'] @suffix = @child_info['full_name']['suffix'] end def place_of_birth @is_v2 ? @child_info.dig('birth_location', 'location') : @child_info['place_of_birth'] end def child_status if @is_v2 CHILD_STATUS[@child_info['relationship_to_child']&.key(true)] else CHILD_STATUS[@child_info['child_status']&.key(true)] end end def marriage_indicator if @is_v2 @child_info['has_child_ever_been_married'] ? 'Y' : 'N' else @child_info['previously_married'] == 'Yes' ? 'Y' : 'N' end end def reason_marriage_ended if @is_v2 @child_info['marriage_end_reason'] else @child_info.dig('previous_marriage_details', 'reason_marriage_ended') end end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/vnp_benefit_claim.rb
# frozen_string_literal: true module BGSDependents class VnpBenefitClaim VNP_BENEFIT_CREATE_PARAMS = { status_type_cd: 'CURR', svc_type_cd: 'CP', pgm_type_cd: 'COMP', bnft_claim_type_cd: '130DPNEBNADJ', atchms_ind: 'N' }.freeze def initialize(proc_id, veteran) @veteran = veteran @proc_id = proc_id end def create_params_for_686c { vnp_proc_id: @proc_id, claim_rcvd_dt: Time.current.iso8601, ptcpnt_clmant_id: @veteran[:vnp_participant_id], ptcpnt_mail_addrs_id: @veteran[:vnp_participant_address_id], vnp_ptcpnt_vet_id: @veteran[:vnp_participant_id], claim_jrsdtn_lctn_id: @veteran[:location_id], intake_jrsdtn_lctn_id: @veteran[:location_id], net_worth_over_limit_ind: @veteran[:net_worth_over_limit_ind] }.merge(VNP_BENEFIT_CREATE_PARAMS) end def update_params_for_686c(vnp_benefit_claim_record, benefit_claim_record) { vnp_proc_id: vnp_benefit_claim_record[:vnp_proc_id], vnp_bnft_claim_id: vnp_benefit_claim_record[:vnp_benefit_claim_id], vnp_ptcpnt_vet_id: @veteran[:vnp_participant_id], end_prdct_type_cd: @veteran[:benefit_claim_type_end_product], bnft_claim_type_cd: benefit_claim_record[:claim_type_code], claim_rcvd_dt: Time.current.iso8601, bnft_claim_id: benefit_claim_record[:benefit_claim_id], intake_jrsdtn_lctn_id: vnp_benefit_claim_record[:intake_jrsdtn_lctn_id], claim_jrsdtn_lctn_id: vnp_benefit_claim_record[:claim_jrsdtn_lctn_id], pgm_type_cd: benefit_claim_record[:program_type_code], ptcpnt_clmant_id: vnp_benefit_claim_record[:participant_claimant_id], status_type_cd: benefit_claim_record[:status_type_code], svc_type_cd: 'CP', net_worth_over_limit_ind: @veteran[:net_worth_over_limit_ind] }.merge end def vnp_benefit_claim_response(vnp_benefit_claim) { vnp_proc_id: vnp_benefit_claim[:vnp_proc_id], vnp_benefit_claim_id: vnp_benefit_claim[:vnp_bnft_claim_id], vnp_benefit_claim_type_code: vnp_benefit_claim[:bnft_claim_type_cd], claim_jrsdtn_lctn_id: vnp_benefit_claim[:claim_jrsdtn_lctn_id], intake_jrsdtn_lctn_id: vnp_benefit_claim[:intake_jrsdtn_lctn_id], participant_claimant_id: vnp_benefit_claim[:ptcpnt_clmant_id] } end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/child_marriage.rb
# frozen_string_literal: true module BGSDependents class ChildMarriage < Base def initialize(child_marriage) @child_marriage = child_marriage end def format_info { event_date: @child_marriage['date_married'], ssn: @child_marriage['ssn'], birth_date: @child_marriage['birth_date'], ever_married_ind: 'Y', dependent_income: formatted_boolean(@child_marriage['dependent_income']) }.merge(@child_marriage['full_name']).with_indifferent_access end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/step_child.rb
# frozen_string_literal: true module BGSDependents class StepChild < Base EXPENSE_PAID_CONVERTER = { 'Half' => '.5', 'More than half' => '.75', 'Less than half' => '.25' }.freeze def initialize(stepchild_info) @stepchild_info = stepchild_info end def format_info { living_expenses_paid: EXPENSE_PAID_CONVERTER[@stepchild_info['living_expenses_paid']], lives_with_relatd_person_ind: 'N', ssn: @stepchild_info['ssn'], birth_date: @stepchild_info['birth_date'] }.merge(@stepchild_info['full_name']).with_indifferent_access end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/child_school.rb
# frozen_string_literal: true module BGSDependents class ChildSchool < Base attribute :last_term_school_information, Hash attribute :school_information, Hash attribute :program_information, Hash attribute :current_term_dates, Hash def initialize(dependents_application, proc_id, vnp_participant_id, student = nil) @proc_id = proc_id @vnp_participant_id = vnp_participant_id @student = student @is_v2 = v2? assign_attributes(@is_v2 ? student : dependents_application) end # rubocop:disable Metrics/MethodLength def params_for_686c { vnp_proc_id: @proc_id, vnp_ptcpnt_id: @vnp_participant_id, last_term_start_dt: format_date(last_term_school_information&.dig('term_begin')), last_term_end_dt: format_date(last_term_school_information&.dig('date_term_ended')), prev_hours_per_wk_num: last_term_school_information&.dig('hours_per_week'), prev_sessns_per_wk_num: last_term_school_information&.dig('classes_per_week'), prev_school_nm: last_term_school_information&.dig('name'), prev_school_cntry_nm: last_term_school_information&.dig('address', 'country_name'), prev_school_addrs_one_txt: last_term_school_information&.dig('address', 'address_line1'), prev_school_addrs_two_txt: last_term_school_information&.dig('address', 'address_line2'), prev_school_addrs_three_txt: last_term_school_information&.dig('address', 'address_line3'), prev_school_city_nm: last_term_school_information&.dig('address', 'city'), prev_school_postal_cd: last_term_school_information&.dig('address', 'state_code'), prev_school_addrs_zip_nbr: last_term_school_information&.dig('address', 'zip_code'), curnt_school_nm: school_information&.dig('name'), curnt_school_addrs_one_txt: school_information&.dig('address', 'address_line1'), curnt_school_addrs_two_txt: school_information&.dig('address', 'address_line2'), curnt_school_addrs_three_txt: school_information&.dig('address', 'address_line3'), curnt_school_postal_cd: school_information&.dig('address', 'state_code'), curnt_school_city_nm: school_information&.dig('address', 'city'), curnt_school_addrs_zip_nbr: school_information&.dig('address', 'zip_code'), curnt_school_cntry_nm: school_information&.dig('address', 'country_name'), course_name_txt: school_information&.dig('training_program'), curnt_sessns_per_wk_num: program_information&.dig('classes_per_week'), curnt_hours_per_wk_num: program_information&.dig('hours_per_week'), school_actual_expctd_start_dt: current_term_dates&.dig('official_school_start_date'), school_term_start_dt: format_date(current_term_dates&.dig('expected_student_start_date')), gradtn_dt: format_date(current_term_dates&.dig('expected_graduation_date')), full_time_studnt_type_cd: school_information&.dig('school_type'), part_time_school_subjct_txt: program_information&.dig('course_of_study') } end # rubocop:enable Metrics/MethodLength # this method is duplicated from the above because each line will be parsed # differently from v1. # rubocop:disable Metrics/MethodLength def params_for_686c_v2 { vnp_proc_id: @proc_id, vnp_ptcpnt_id: @vnp_participant_id, last_term_start_dt: format_date(school_information&.dig('last_term_school_information', 'term_begin')), last_term_end_dt: format_date(school_information&.dig('last_term_school_information', 'date_term_ended')), prev_hours_per_wk_num: nil, prev_sessns_per_wk_num: nil, prev_school_nm: nil, prev_school_cntry_nm: nil, prev_school_addrs_one_txt: nil, prev_school_addrs_two_txt: nil, prev_school_addrs_three_txt: nil, prev_school_city_nm: nil, prev_school_postal_cd: nil, prev_school_addrs_zip_nbr: nil, curnt_school_nm: school_information&.dig('name'), curnt_school_addrs_one_txt: nil, curnt_school_addrs_two_txt: nil, curnt_school_addrs_three_txt: nil, curnt_school_postal_cd: nil, curnt_school_city_nm: nil, curnt_school_addrs_zip_nbr: nil, curnt_school_cntry_nm: nil, course_name_txt: nil, curnt_sessns_per_wk_num: nil, curnt_hours_per_wk_num: nil, school_actual_expctd_start_dt: school_information&.dig('current_term_dates', 'expected_student_start_date'), school_term_start_dt: format_date(school_information&.dig('current_term_dates', 'official_school_start_date')), gradtn_dt: format_date(school_information&.dig('current_term_dates', 'expected_graduation_date')), full_time_studnt_type_cd: nil, part_time_school_subjct_txt: nil } end # rubocop:enable Metrics/MethodLength private def assign_attributes(data) @last_term_school_information = data['last_term_school_information'] @school_information = data['school_information'] @program_information = data['program_information'] @current_term_dates = data['current_term_dates'] end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/marriage_history.rb
# frozen_string_literal: true module BGSDependents class MarriageHistory < Base def initialize(former_spouse) @former_spouse = former_spouse @is_v2 = v2? @start_source = @is_v2 ? @former_spouse.dig('start_location', 'location') : @former_spouse['start_location'] @end_source = @is_v2 ? @former_spouse.dig('end_location', 'location') : @former_spouse['end_location'] end def format_info { start_date: @former_spouse['start_date'], end_date: @former_spouse['end_date'], marriage_country: @start_source['country'], marriage_state: @start_source['state'], marriage_city: @start_source['city'], divorce_country: @end_source['country'], divorce_state: @end_source['state'], divorce_city: @end_source['city'], marriage_termination_type_code: @former_spouse['reason_marriage_ended'] }.merge(@former_spouse['full_name']).with_indifferent_access end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/death.rb
# frozen_string_literal: true module BGSDependents class Death < Base def initialize(death_info) @death_info = death_info @is_v2 = v2? end def format_info dependent_type = relationship_type(@death_info) info = { death_date: @is_v2 ? format_date(@death_info['dependent_death_date']) : format_date(@death_info['date']), ssn: @death_info['ssn'], birth_date: @death_info['birth_date'], vet_ind: 'N', dependent_income: formatted_boolean(@is_v2 ? @death_info['deceased_dependent_income'] : @death_info['dependent_income']) # rubocop:disable Layout/LineLength } info['marriage_termination_type_code'] = 'Death' if dependent_type[:family] == 'Spouse' info.merge(@death_info['full_name']).with_indifferent_access end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/relationship.rb
# frozen_string_literal: true module BGSDependents class Relationship < Base def initialize(proc_id) @proc_id = proc_id end def params_for_686c(participant_a_id, dependent) { vnp_proc_id: @proc_id, vnp_ptcpnt_id_a: participant_a_id, vnp_ptcpnt_id_b: dependent[:vnp_participant_id], ptcpnt_rlnshp_type_nm: dependent[:participant_relationship_type_name], family_rlnshp_type_nm: dependent[:family_relationship_type_name], event_dt: format_date(dependent[:event_date]), begin_dt: format_date(dependent[:begin_date]), end_dt: format_date(dependent[:end_date]), marage_cntry_nm: dependent[:marriage_country], marage_state_cd: dependent[:marriage_state], marage_city_nm: dependent[:marriage_city], marage_trmntn_cntry_nm: dependent[:divorce_country], marage_trmntn_state_cd: dependent[:divorce_state], marage_trmntn_city_nm: dependent[:divorce_city], marage_trmntn_type_cd: dependent[:marriage_termination_type_code], mthly_support_from_vet_amt: dependent[:living_expenses_paid_amount], child_prevly_married_ind: dependent[:child_prevly_married_ind], dep_has_income_ind: dependent[:dep_has_income_ind] } end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/spouse.rb
# frozen_string_literal: true module BGSDependents class Spouse < Base # The Spouse class represents a person including name, address, and marital status info # # @!attribute ssn # @return [String] the person's social security number # @!attribute first # @return [String] the person's first name # @!attribute middle # @return [String] the person's middle name # @!attribute last # @return [String] the person's last name # @!attribute suffix # @return [String] the person's name suffix # @!attribute vet_ind # @return [String] Y/N indicates whether the person is a veteran # @!attribute birth_date # @return [String] the person's birth date # @!attribute address # @return [Hash] the person's address # @!attribute va_file_number # @return [String] the person's va file number # @!attribute ever_married_ind # @return [String] Y/N indicates whether the person has ever been married # @!attribute martl_status_type_cd # @return [String] marital status type: Married, Divorced, Widowed, Separated, Never Married # @!attribute spouse_income # @return [String] did this spouse have income in the last 365 days # attribute :ssn, String attribute :first, String attribute :middle, String attribute :last, String attribute :suffix, String attribute :vet_ind, String attribute :birth_date, String attribute :address, Hash attribute :va_file_number, String attribute :ever_married_ind, String attribute :martl_status_type_cd, String attribute :spouse_income, String def initialize(dependents_application) @dependents_application = dependents_application @spouse_information = @dependents_application['spouse_information'] @is_v2 = v2? assign_attributes end # Sets a hash with spouse attributes # # @return [Hash] spouse attributes including name, address and marital info # def format_info attributes.with_indifferent_access end private def assign_attributes @ssn = @spouse_information['ssn'] @birth_date = @spouse_information['birth_date'] @ever_married_ind = 'Y' @martl_status_type_cd = marital_status @vet_ind = spouse_is_veteran @address = spouse_address @spouse_income = formatted_boolean(@dependents_application['does_live_with_spouse']['spouse_income']) @first = @spouse_information['full_name']['first'] @middle = @spouse_information['full_name']['middle'] @last = @spouse_information['full_name']['last'] @suffix = @spouse_information['full_name']['suffix'] @va_file_number = @spouse_information['va_file_number'] if spouse_is_veteran == 'Y' end def lives_with_vet @dependents_application['does_live_with_spouse']['spouse_does_live_with_veteran'] end def spouse_is_veteran @spouse_information['is_veteran'] ? 'Y' : 'N' end def marital_status lives_with_vet ? 'Married' : 'Separated' end def spouse_address dependent_address( dependents_application: @dependents_application, lives_with_vet: @dependents_application['does_live_with_spouse']['spouse_does_live_with_veteran'], alt_address: @dependents_application.dig('does_live_with_spouse', 'address') ) end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/child_stopped_attending_school.rb
# frozen_string_literal: true module BGSDependents class ChildStoppedAttendingSchool < Base def initialize(child_info) @child_info = child_info end def format_info { event_date: @child_info['date_child_left_school'], ssn: @child_info['ssn'], birth_date: @child_info['birth_date'], dependent_income: formatted_boolean(@child_info['dependent_income']) }.merge(@child_info['full_name']).with_indifferent_access end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/bgs_dependents/child_student.rb
# frozen_string_literal: true module BGSDependents class ChildStudent < Base attribute :student_address_marriage_tuition, Hash attribute :student_earnings_from_school_year, Hash attribute :student_networth_information, Hash attribute :student_expected_earnings_next_year, Hash attribute :student_information, Hash def initialize(dependents_application, proc_id, vnp_participant_id, student = nil) @proc_id = proc_id @vnp_participant_id = vnp_participant_id @dependents_application = dependents_application @is_v2 = v2? @student = student assign_attributes(@is_v2 ? student : dependents_application) end # rubocop:disable Metrics/MethodLength def params_for_686c { vnp_proc_id: @proc_id, vnp_ptcpnt_id: @vnp_participant_id, saving_amt: student_networth_information&.dig('savings'), real_estate_amt: student_networth_information&.dig('real_estate'), other_asset_amt: student_networth_information&.dig('other_assets'), rmks: @is_v2 ? student_information&.dig('remarks') : student_networth_information&.dig('remarks'), marage_dt: format_date(@is_v2 ? student_information&.dig('marriage_date') : student_address_marriage_tuition&.dig('marriage_date')), # rubocop:disable Layout/LineLength agency_paying_tuitn_nm: student_address_marriage_tuition&.dig('agency_name'), stock_bond_amt: student_networth_information&.dig('securities'), govt_paid_tuitn_ind: convert_boolean(@is_v2 ? student_information&.dig('tuition_is_paid_by_gov_agency') : student_address_marriage_tuition&.dig('tuition_is_paid_by_gov_agency')), # rubocop:disable Layout/LineLength govt_paid_tuitn_start_dt: format_date(student_address_marriage_tuition&.dig('date_payments_began')), term_year_emplmt_income_amt: student_earnings_from_school_year&.dig('earnings_from_all_employment'), term_year_other_income_amt: student_earnings_from_school_year&.dig('all_other_income'), term_year_ssa_income_amt: student_earnings_from_school_year&.dig('annual_social_security_payments'), term_year_annty_income_amt: student_earnings_from_school_year&.dig('other_annuities_income'), next_year_annty_income_amt: student_expected_earnings_next_year&.dig('other_annuities_income'), next_year_emplmt_income_amt: student_expected_earnings_next_year&.dig('earnings_from_all_employment'), next_year_other_income_amt: student_expected_earnings_next_year&.dig('all_other_income'), next_year_ssa_income_amt: student_expected_earnings_next_year&.dig('annual_social_security_payments'), acrdtdSchoolInd: convert_boolean(@dependents_application&.dig('current_term_dates', 'is_school_accredited')), atndedSchoolCntnusInd: convert_boolean(@dependents_application&.dig('program_information', 'student_is_enrolled_full_time')), # rubocop:disable Layout/LineLength stopedAtndngSchoolDt: format_date(@dependents_application&.dig('child_stopped_attending_school', 'date_stopped_attending')) # rubocop:disable Layout/LineLength } end # rubocop:enable Metrics/MethodLength # rubocop:disable Metrics/MethodLength def params_for_686c_v2 { vnp_proc_id: @proc_id, vnp_ptcpnt_id: @vnp_participant_id, saving_amt: student_networth_information&.dig('savings'), real_estate_amt: student_networth_information&.dig('real_estate'), other_asset_amt: student_networth_information&.dig('other_assets'), rmks: @student&.dig('remarks'), marage_dt: format_date(@student&.dig('marriage_date')), agency_paying_tuitn_nm: nil, stock_bond_amt: student_networth_information&.dig('securities'), govt_paid_tuitn_ind: convert_boolean(@student&.dig('tuition_is_paid_by_gov_agency')), govt_paid_tuitn_start_dt: format_date(@student&.dig('benefit_payment_date')), term_year_emplmt_income_amt: student_earnings_from_school_year&.dig('earnings_from_all_employment'), term_year_other_income_amt: student_earnings_from_school_year&.dig('all_other_income'), term_year_ssa_income_amt: student_earnings_from_school_year&.dig('annual_social_security_payments'), term_year_annty_income_amt: student_earnings_from_school_year&.dig('other_annuities_income'), next_year_annty_income_amt: student_expected_earnings_next_year&.dig('other_annuities_income'), next_year_emplmt_income_amt: student_expected_earnings_next_year&.dig('earnings_from_all_employment'), next_year_other_income_amt: student_expected_earnings_next_year&.dig('all_other_income'), next_year_ssa_income_amt: student_expected_earnings_next_year&.dig('annual_social_security_payments'), acrdtdSchoolInd: convert_boolean(@student&.dig('school_information', 'is_school_accredited')), atndedSchoolCntnusInd: convert_boolean(@student&.dig('school_information', 'student_is_enrolled_full_time')), stopedAtndngSchoolDt: nil } end # rubocop:enable Metrics/MethodLength private def convert_boolean(bool) bool == true ? 'Y' : 'N' end def assign_attributes(data) @student_address_marriage_tuition = data['student_address_marriage_tuition'] @student_earnings_from_school_year = data['student_earnings_from_school_year'] @student_networth_information = data['student_networth_information'] @student_expected_earnings_next_year = data['student_expected_earnings_next_year'] @student_information = data['student_information'] end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/schema_contract/validation.rb
# frozen_string_literal: true module SchemaContract class Validation < ApplicationRecord self.table_name = 'schema_contract_validations' attribute :contract_name, :string attribute :user_account_id, :string attribute :user_uuid, :string attribute :response, :jsonb attribute :error_details, :string validates :contract_name, presence: true validates :user_account_id, presence: true validates :user_uuid, presence: true validates :response, presence: true validates :status, presence: true enum :status, { initialized: 0, success: 1, schema_errors_found: 2, schema_not_found: 3, error: 4 }, default: :initialized end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/schema_contract/validation_initiator.rb
# frozen_string_literal: true module SchemaContract class ValidationInitiator def self.call(user:, response:, contract_name:) if response.success? body = response.body initiate_validation(user:, body:, contract_name:) end rescue => e # blanket rescue to avoid blocking main thread execution message = { response:, contract_name:, error_details: e.message } Rails.logger.error('Error creating schema contract job', message) end def self.call_with_body(user:, body:, contract_name:) initiate_validation(user:, body:, contract_name:) rescue => e # blanket rescue to avoid blocking main thread execution message = { body:, contract_name:, error_details: e.message } Rails.logger.error('Error creating schema contract job with body', message) end def self.initiate_validation(user:, body:, contract_name:) if Flipper.enabled?("schema_contract_#{contract_name}") return if SchemaContract::Validation.where(contract_name:, created_at: Time.zone.today.all_day).any? record = SchemaContract::Validation.create( contract_name:, user_account_id: user.user_account_uuid, user_uuid: user.uuid, response: body, status: 'initialized' ) Rails.logger.info('Initiating schema contract validation', { contract_name:, record_id: record.id }) SchemaContract::ValidationJob.perform_async(record.id) end end private_class_method :initiate_validation end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/schema_contract/validator.rb
# frozen_string_literal: true module SchemaContract class Validator class SchemaContractValidationError < StandardError; end def initialize(record_id) @record_id = record_id end def validate errors = JSON::Validator.fully_validate(parsed_schema, record.response) if errors.any? @result = 'schema_errors_found' record.update(error_details: errors) detailed_message = { error_type: 'Schema discrepancy found', record_id: @record_id, response: record.response, details: errors, contract_name: record.contract_name } raise SchemaContractValidationError, detailed_message else @result = 'success' end rescue SchemaContractValidationError => e raise e rescue => e @result = 'error' detailed_message = { error_type: 'Unknown', record_id: @record_id, details: e.message } raise SchemaContractValidationError, detailed_message ensure record&.update(status: @result) if defined?(@record) end private def record @record ||= Validation.find(@record_id) end def schema_file @schema_file ||= begin path = Settings.schema_contract[record.contract_name] if path.nil? @result = 'schema_not_found' raise SchemaContractValidationError, "No schema file #{record.contract_name} found." end Rails.root.join(path) end end def parsed_schema file_contents = File.read(schema_file) JSON.parse(file_contents) end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/external_services_redis/status.rb
# frozen_string_literal: true require 'common/models/concerns/cache_aside' require 'pagerduty/external_services/service' module ExternalServicesRedis # Facade for the PagerDuty::ExternalServices::Service class. # class Status < Common::RedisStore include Common::CacheAside KEY = 'pager_duty_services' # Redis settings for ttl and namespacing reside in config/redis.yml # redis_config_key :external_service_statuses_response # The time from the call to PagerDuty's API # # @return [Time] For example, 2019-03-14 20:19:43 UTC # delegate :reported_at, to: :fetch_or_cache # Returns either the cached response from the # PagerDuty::ExternalServices::Service.new.get_services call, or makes # a fresh call to that endpoint, then caches and returns the response. # # @return [PagerDuty::ExternalServices::Response] An instance of the # PagerDuty::ExternalServices::Response class # @example ExternalServicesRedis.new.fetch_or_cache.as_json # { # "status" => 200, # "reported_at" => "2019-03-14T19:47:47.000Z", # "statuses" => [ # { # "service" => "Appeals", # "service_id" => "appeals" # "status" => "active", # "last_incident_timestamp" => "2019-03-01T02:55:55.000-05:00" # }, # ... # ] # } # def fetch_or_cache @response ||= response_from_redis_or_service end # The HTTP status code from call to PagerDuty's API # # @return [Integer] For example, 200 # def response_status fetch_or_cache.status end private def response_from_redis_or_service do_cached_with(key: KEY) do PagerDuty::ExternalServices::Service.new.get_services end end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form1010cg/attachment.rb
# frozen_string_literal: true module Form1010cg class Attachment < FormAttachment ATTACHMENT_UPLOADER_CLASS = ::Form1010cg::PoaUploader def to_local_file remote_file = get_file local_path = "tmp/#{remote_file.path.gsub('/', '_')}" File.write(local_path, remote_file.read) local_path end end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form1010cg/submission.rb
# frozen_string_literal: true module Form1010cg # A Form1010CG::Submission is the submission of a CaregiversAssistanceClaim (form 10-10CG) # Used to store data of the relating record created in CARMA. # # More information about CARMA can be found in lib/carma/README.md # class Submission < ApplicationRecord self.table_name = 'form1010cg_submissions' belongs_to :claim, class_name: 'SavedClaim::CaregiversAssistanceClaim', foreign_key: 'claim_guid', primary_key: 'guid', inverse_of: :submission, dependent: :destroy # Allows us to call #save with a nested (and unsaved) claim attached, so both are save simultaneously. accepts_nested_attributes_for :claim attr_accessor :attachments_job_id end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_0839.rb
# frozen_string_literal: true class FormProfiles::VA0839 < 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_1990ez.rb
# frozen_string_literal: true class FormProfiles::VA1990ez < FormProfile def return_url if Flipper.enabled?(:meb_1606_30_automation) '/benefit-selection' else '/applicant-information/personal-information' end end def metadata { version: 0, prefill: true, returnUrl: return_url } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_5490.rb
# frozen_string_literal: true class FormProfiles::VA5490 < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/5490/applicant/information' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_5655.rb
# frozen_string_literal: true require 'debt_management_center/models/payment' require 'debt_management_center/payments_service' ## # Form Profile for VA Form 5655, the Financial Status Report Form # class FormProfiles::VA5655 < FormProfile attribute :payments, DebtManagementCenter::Payment ## # Overrides the FormProfile metadata method, to provide frontend with usable metadata # # @return [Hash] # def metadata { version: 0, prefill: true, returnUrl: '/veteran-information' } end ## # Overrides the FormProfile prefill method to initialize @va_awards_composite # # @return [Hash] # def prefill @payments = init_payments super 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 def init_payments return {} unless user.authorize :debt, :access? payments = DebtManagementCenter::PaymentsService.new(user) DebtManagementCenter::Payment.new( education_amount: payment_amount(payments.education), compensation_amount: payment_amount(payments.compensation_and_pension), veteran_or_spouse: 'VETERAN' ) end def payment_amount(payments) return payments&.last&.[](:payment_amount) if Settings.dmc.fsr_payment_window.blank? # Window of time to consider included payments (in days) window = Time.zone.today - Settings.dmc.fsr_payment_window.days # Filter to only use recent payments from window of time payments&.select { |payment| Date.parse(payment[:payment_date].to_s) > window }&.last&.[](:payment_amount) end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_212680.rb
# frozen_string_literal: true # FormProfile for VA Form 21-2680 # Examination for Housebound Status or Permanent Need for Regular Aid and Attendance class FormProfiles::VA212680 < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/veteran-information' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_1990.rb
# frozen_string_literal: true class FormProfiles::VA1990 < 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_281900v2.rb
# frozen_string_literal: true class FormProfiles::VA281900v2 < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/veteran-information-review' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_5495.rb
# frozen_string_literal: true class FormProfiles::VA5495 < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/5495/applicant/information' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_1995.rb
# frozen_string_literal: true class FormProfiles::VA1995 < 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_1010ez.rb
# frozen_string_literal: true class FormProfiles::VA1010ez < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/veteran-information/personal-information' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_526ez.rb
# frozen_string_literal: true require 'evss/disability_compensation_form/service' require 'disability_compensation/factories/api_provider_factory' require 'vets/model' module VA526ez class FormSpecialIssue include Vets::Model attribute :code, String attribute :name, String end class FormRatedDisability include Vets::Model attribute :name, String attribute :rated_disability_id, String attribute :rating_decision_id, String attribute :diagnostic_code, Integer attribute :decision_code, String attribute :decision_text, String attribute :rating_percentage, Integer attribute :maximum_rating_percentage, Integer end class FormRatedDisabilities include Vets::Model attribute :rated_disabilities, FormRatedDisability, array: true end class FormPaymentAccountInformation include Vets::Model attribute :account_type, String attribute :account_number, String attribute :routing_number, String attribute :bank_name, String end class FormAddress include Vets::Model attribute :country, String attribute :city, String attribute :state, String attribute :zip_code, String attribute :address_line_1, String attribute :address_line_2, String attribute :address_line_3, String end class FormContactInformation include Vets::Model attribute :mailing_address, FormAddress attribute :primary_phone, String attribute :email_address, String end class FormVeteranContactInformation include Vets::Model attribute :veteran, FormContactInformation end # internal form prefill # does not reach out to external services class Form526Prefill include Vets::Model attribute :started_form_version, String attribute :sync_modern_0781_flow, Bool end end class FormProfiles::VA526ez < FormProfile FORM_ID = '21-526EZ' attribute :rated_disabilities_information, VA526ez::FormRatedDisabilities attribute :veteran_contact_information, VA526ez::FormContactInformation attribute :payment_information, VA526ez::FormPaymentAccountInformation attribute :prefill_526, VA526ez::Form526Prefill def prefill @prefill_526 = initialize_form526_prefill begin @rated_disabilities_information = initialize_rated_disabilities_information rescue => e Rails.logger.error("Form526 Prefill for rated disabilities failed. #{e.message}") end begin @veteran_contact_information = initialize_veteran_contact_information rescue => e Rails.logger.error("Form526 Prefill for veteran contact information failed. #{e.message}") end begin @payment_information = initialize_payment_information rescue => e Rails.logger.error("Form526 Prefill for payment information failed. #{e.message}") end prefill_base_class_methods mappings = self.class.mappings_for_form(form_id) form_data = generate_prefill(mappings) { form_data:, metadata: } end def metadata { version: 0, prefill: true, returnUrl: '/veteran-information' } end def initialize_rated_disabilities_information return {} unless user.authorize :evss, :access? api_provider = ApiProviderFactory.call( type: ApiProviderFactory::FACTORIES[:rated_disabilities], provider: :lighthouse, options: { icn: user.icn.to_s, auth_headers: EVSS::DisabilityCompensationAuthHeaders.new(user).add_headers(EVSS::AuthHeaders.new(user).to_h) }, current_user: user, feature_toggle: nil ) invoker = 'FormProfiles::VA526ez#initialize_rated_disabilities_information' response = api_provider.get_rated_disabilities(nil, nil, { invoker: }) ClaimFastTracking::MaxRatingAnnotator.annotate_disabilities(response) # Remap response object to schema fields VA526ez::FormRatedDisabilities.new( rated_disabilities: response.rated_disabilities.map(&:attribute_values) ) end private def prefill_base_class_methods begin @identity_information = initialize_identity_information rescue => e Rails.logger.error("Form526 Prefill for identity information failed. #{e.message}") end begin @contact_information = initialize_contact_information rescue => e Rails.logger.error("Form526 Prefill for contact information failed. #{e.message}") end begin @military_information = initialize_military_information rescue => e Rails.logger.error("Form526 Prefill for military information failed. #{e.message}") end end def initialize_form526_prefill VA526ez::Form526Prefill.new( started_form_version: '2022', sync_modern_0781_flow: Flipper.enabled?(:disability_compensation_sync_modern_0781_flow, user) ) end def initialize_vets360_contact_info return {} unless vet360_contact_info { mailing_address: convert_vets360_address(vet360_mailing_address), email_address: vet360_contact_info&.email&.email_address, primary_phone: [ vet360_contact_info&.home_phone&.area_code, vet360_contact_info&.home_phone&.phone_number ].join }.compact end def initialize_veteran_contact_information return {} unless user.authorize :va_profile, :access_to_v2? contact_info = initialize_vets360_contact_info contact_info = VA526ez::FormContactInformation.new(contact_info) VA526ez::FormVeteranContactInformation.new( veteran: contact_info ) end def convert_vets360_address(address) return if address.blank? { address_line_1: address.address_line1, address_line_2: address.address_line2, address_line_3: address.address_line3, city: address.city, country: address.country_code_iso3, state: address.state_code || address.province, zip_code: address.zip_plus_four || address.international_postal_code }.compact end def prefill_domestic_address(address) { country: address&.country_name, city: address&.city, state: address&.state_code, zip_code: address&.zip_code, address_line_1: address&.address_one, address_line_2: address&.address_two, address_line_3: address&.address_three }.compact end def prefill_international_address(address) { country: address&.country_name, city: address&.city, address_line_1: address&.address_one, address_line_2: address&.address_two, address_line_3: address&.address_three }.compact end def prefill_military_address(address) { country: 'USA', city: address&.military_post_office_type_code, state: address&.military_state_code, zip_code: address&.zip_code, address_line_1: address&.address_one, address_line_2: address&.address_two, address_line_3: address&.address_three }.compact end def initialize_payment_information return {} unless user.authorize(:lighthouse, :direct_deposit_access?) && user.authorize(:evss, :access?) provider = ApiProviderFactory.call(type: ApiProviderFactory::FACTORIES[:ppiu], provider: ApiProviderFactory::API_PROVIDER[:lighthouse], current_user: user, feature_toggle: nil) response = provider.get_payment_information raw_account = response.responses.first&.payment_account if raw_account VA526ez::FormPaymentAccountInformation.new( account_type: raw_account&.account_type&.capitalize, account_number: mask(raw_account&.account_number), routing_number: mask(raw_account&.financial_institution_routing_number), bank_name: raw_account&.financial_institution_name ) else {} end rescue => e lighthouse_direct_deposit_error(e, provider) {} end def lighthouse_direct_deposit_error(e, provider) method_name = '#initialize_payment_information' error_message = "#{method_name} Failed to retrieve DirectDeposit data from #{provider.class}: #{e.message}" Rails.logger.error(error_message) end def mask(number) number.gsub(/.(?=.{4})/, '*') end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_8794.rb
# frozen_string_literal: true class FormProfiles::VA8794 < 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_261880.rb
# frozen_string_literal: true class FormProfiles::VA261880 < 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_10216.rb
# frozen_string_literal: true class FormProfiles::VA10216 < 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_0803.rb
# frozen_string_literal: true class FormProfiles::VA0803 < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/applicant/information' } end def va_file_number response = BGS::People::Request.new.find_person_by_participant_id(user:) response.file_number.presence end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/feedback_tool.rb
# frozen_string_literal: true class FormProfiles::FeedbackTool < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/applicant-relationship' } end def convert_country!(form_data) country = form_data.try(:[], 'address').try(:[], 'country') form_data['address']['country'] = IsoCountryCodes.find(country).alpha2 if country.present? && country.size == 3 end def prefill(*args) return_val = super convert_country!(return_val[:form_data]) return_val end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_686c674v2.rb
# frozen_string_literal: true require 'vets/model' require 'bid/awards/service' class FormProfiles::VA686c674v2 < FormProfile class DependentInformation include Vets::Model attribute :full_name, FormFullName attribute :date_of_birth, Date attribute :ssn, String attribute :relationship_to_veteran, String attribute :award_indicator, String end 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 attribute :dependents_information, DependentInformation, array: true def prefill prefill_form_address prefill_dependents_information super end def metadata { version: 0, prefill: true, returnUrl: '/686-options-selection' } end private def prefill_form_address begin mailing_address = VAProfileRedis::V2::ContactInformation.for_user(user).mailing_address rescue nil end return if mailing_address.blank? zip_code = mailing_address.zip_code.presence || mailing_address.international_postal_code.presence @form_address = FormAddress.new( mailing_address.to_h.slice( :address_line1, :address_line2, :address_line3, :city, :state_code, :province ).merge(country_name: mailing_address.country_code_iso3, zip_code:) ) 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 # @return [Integer] 1 if user is in receipt of pension, 0 if not, -1 if request fails # Needed for FE to differentiate between 200 response and error def is_in_receipt_of_pension # rubocop:disable Naming/PredicatePrefix case awards_pension[:is_in_receipt_of_pension] when true 1 when false 0 else -1 end end # @return [Integer] the net worth limit for pension, default is 163,699 as of 2026 # Default will be cached in future enhancement def net_worth_limit awards_pension[:net_worth_limit] || 163_699 end # @return [Hash] the awards pension data from BID service or an empty hash if the request fails def awards_pension @awards_pension ||= begin response = pension_award_service.get_awards_pension response.try(:body)&.dig('awards_pension')&.transform_keys(&:to_sym) rescue => e payload = { user_account_uuid: user&.user_account_uuid, error: e.message, form_id: } Rails.logger.warn('Failed to retrieve awards pension data', payload) {} end end ## # This method retrieves the dependents from the BGS service and maps them to the DependentInformation model. # If no dependents are found or if they are not active for benefits, it returns an empty array. def prefill_dependents_information dependents = dependent_service.get_dependents persons = if dependents.blank? || dependents[:persons].blank? [] else dependents[:persons] end @dependents_information = persons.filter_map do |person| person_to_dependent_information(person) end if Flipper.enabled?(:va_dependents_v3, user) @dependents_information = { success: 'true', dependents: @dependents_information } else @dependents_information end rescue => e monitor.track_event('warn', 'Failure initializing dependents_information', 'dependents.prefill.error', { error: e&.message }) @dependents_information = Flipper.enabled?(:va_dependents_v3, user) ? { success: 'false', dependents: [] } : [] end ## # Assigns a dependent's information to the DependentInformation model. # # @param person [Hash] The dependent's information as a hash # @return [DependentInformation] The dependent's information mapped to the model def person_to_dependent_information(person) first_name = person[:first_name] last_name = person[:last_name] middle_name = person[:middle_name] ssn = person[:ssn] date_of_birth = person[:date_of_birth] relationship = person[:relationship] award_indicator = person[:award_indicator] parsed_date = parse_date_safely(date_of_birth) DependentInformation.new( full_name: FormFullName.new({ first: first_name, middle: middle_name, last: last_name }), date_of_birth: parsed_date, ssn:, relationship_to_veteran: relationship, award_indicator: ) end def dependent_service @dependent_service ||= BGS::DependentService.new(user) end def pension_award_service @pension_award_service ||= BID::Awards::Service.new(user) end def monitor @monitor ||= Dependents::Monitor.new(nil) end ## # Safely parses a date string, handling various formats # # @param date_string [String, Date, nil] The date to parse # @return [Date, nil] The parsed date or nil if parsing fails def parse_date_safely(date_string) return nil if date_string.blank? return date_string if date_string.is_a?(Date) Date.strptime(date_string.to_s, '%m/%d/%Y') rescue ArgumentError, TypeError nil end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_0994.rb
# frozen_string_literal: true require 'vets/model' module VA0994 FORM_ID = '22-0994' class FormPaymentAccountInformation include Vets::Model attribute :account_type, String attribute :account_number, String attribute :routing_number, String attribute :bank_name, String end end class FormProfiles::VA0994 < FormProfile attribute :payment_information, VA0994::FormPaymentAccountInformation def prefill @payment_information = initialize_payment_information super end def metadata { version: 0, prefill: true, returnUrl: '/applicant/information' } end private def initialize_payment_information return {} unless user.authorize(:ppiu, :access?) && user.authorize(:evss, :access?) # Return empty hash since EVSS PPIU is deprecated # Payment information is now handled by Lighthouse # VA0994::FormPaymentAccountInformation.new( # account_type: raw_account&.account_type&.capitalize, # account_number: mask(raw_account&.account_number), # routing_number: mask(raw_account&.financial_institution_routing_number), # bank_name: raw_account&.financial_institution_name # ) {} rescue => e Rails.logger.error "Failed to retrieve PPIU data: #{e.message}" {} end def mask(number) number.gsub(/.(?=.{4})/, '*') end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/mdot.rb
# frozen_string_literal: true require 'mdot/address' require 'mdot/client' require 'mdot/eligibility' require 'mdot/supply' require 'vets/model' module MDOT class FormContactInformation include Vets::Model attribute :permanent_address, MDOT::Address attribute :temporary_address, MDOT::Address attribute :vet_email, String end class FormSupplyInformation include Vets::Model attribute :available, MDOT::Supply, array: true attribute :eligibility, MDOT::Eligibility end end class FormProfiles::MDOT < FormProfile attribute :mdot_contact_information, MDOT::FormContactInformation attribute :mdot_supplies, MDOT::FormSupplyInformation def metadata { version: 0, prefill: true, returnUrl: '/veteran-information' } end def prefill @response = MDOT::Client.new(user).get_supplies @mdot_contact_information = initialize_mdot_contact_information(@response) @mdot_supplies = initialize_mdot_supplies(@response) super end private def initialize_mdot_contact_information(response) MDOT::FormContactInformation.new( permanent_address: response&.permanent_address, temporary_address: response&.temporary_address, vet_email: response&.vet_email ) end def initialize_mdot_supplies(response) MDOT::FormSupplyInformation.new( available: response&.supplies, eligibility: response&.eligibility ) end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_0976.rb
# frozen_string_literal: true class FormProfiles::VA0976 < 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_5490e.rb
# frozen_string_literal: true class FormProfiles::VA5490e < 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_0995.rb
# frozen_string_literal: true class FormProfiles::VA0995 < FormProfiles::DecisionReview def metadata { version: 0, prefill: true, returnUrl: '/veteran-information' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_1010ezr.rb
# frozen_string_literal: true require 'hca/enrollment_eligibility/service' class FormProfiles::VA1010ezr < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/veteran-information/personal-information' } end def ezr_data @ezr_data ||= begin HCA::EnrollmentEligibility::Service.new.get_ezr_data(user) rescue => e log_exception_to_sentry(e) OpenStruct.new end end def clean!(hash) hash.deep_transform_keys! { |k| k.camelize(:lower) } Common::HashHelpers.deep_compact(hash) end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_10182.rb
# frozen_string_literal: true class FormProfiles::VA10182 < FormProfiles::DecisionReview 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/form_profiles/va_1919.rb
# frozen_string_literal: true class FormProfiles::VA1919 < 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/decision_review.rb
# frozen_string_literal: true class FormProfiles::DecisionReview < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/veteran-information' } end private def street3 vet360_mailing_address&.address_line3 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_1990emeb.rb
# frozen_string_literal: true class FormProfiles::VA1990emeb < 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/vha_10_7959c.rb
# frozen_string_literal: true class FormProfiles::VHA107959c < FormProfile FORM_ID = '10-7959C' def metadata { version: 0, prefill: true, returnUrl: '/applicant-info' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_10203.rb
# frozen_string_literal: true require 'lighthouse/benefits_education/service' require 'vets/model' module VA10203 FORM_ID = '22-10203' class FormInstitutionInfo include Vets::Model attribute :name, String attribute :city, String attribute :state, String attribute :country, String end class FormEntitlementInformation include Vets::Model attribute :months, Integer attribute :days, Integer end end class FormProfiles::VA10203 < FormProfile attribute :remaining_entitlement, VA10203::FormEntitlementInformation attribute :school_information, VA10203::FormInstitutionInfo def prefill authorized = user.authorize :evss, :access? if authorized gi_bill_status = get_gi_bill_status @remaining_entitlement = initialize_entitlement_information(gi_bill_status) @school_information = initialize_school_information(gi_bill_status) else @remaining_entitlement = {} @school_information = {} end super end def metadata { version: 0, prefill: true, returnUrl: '/applicant/information' } end private def get_gi_bill_status service = BenefitsEducation::Service.new(user.icn) service.get_gi_bill_status rescue => e Rails.logger.error "Failed to retrieve GiBillStatus data: #{e.message}" {} end def initialize_entitlement_information(gi_bill_status) return {} if gi_bill_status.blank? || gi_bill_status.remaining_entitlement.blank? VA10203::FormEntitlementInformation.new( months: gi_bill_status.remaining_entitlement.months, days: gi_bill_status.remaining_entitlement.days ) end def initialize_school_information(gi_bill_status) return {} if gi_bill_status.blank? most_recent = gi_bill_status.enrollments.max_by(&:begin_date) return {} if most_recent.blank? service = GIDSRedis.new profile_response = service.get_institution_details_v0({ id: most_recent.facility_code }) VA10203::FormInstitutionInfo.new( name: profile_response[:data][:attributes][:name], city: profile_response[:data][:attributes][:city], state: profile_response[:data][:attributes][:state], country: profile_response[:data][:attributes][:country] ) rescue => e Rails.logger.error "Failed to retrieve GIDS data: #{e.message}" {} end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_0873.rb
# frozen_string_literal: true require 'va_profile/demographics/service' require 'vets/model' module VA0873 FORM_ID = '0873' class FormPersonalInformation include Vets::Model attribute :first, String attribute :middle, String attribute :last, String attribute :suffix, String attribute :preferred_name, String attribute :service_number, String attribute :work_phone, String end class FormAvaProfile include Vets::Model attribute :school_facility_code, String attribute :school_name, String attribute :business_phone, String attribute :business_email, String end end class FormProfiles::VA0873 < FormProfile attribute :personal_information, VA0873::FormPersonalInformation attribute :ava_profile, VA0873::FormAvaProfile def prefill @personal_information = initialize_personal_information @ava_profile = initialize_ava_profile super end private # Initializes the personal information for the form with proper error handling def initialize_personal_information service_number = extract_service_number work_phone = format_work_phone payload = user.full_name_normalized.merge( preferred_name:, service_number:, work_phone: ) VA0873::FormPersonalInformation.new(payload) rescue => e handle_exception(e, :personal_information) end # Initializes the AVA profile for the form, retrieving school details if available def initialize_ava_profile school_name = fetch_school_name(profile.school_facility_code) payload = { school_facility_code: profile.school_facility_code, school_name:, business_phone: profile.business_phone, business_email: profile.business_email } VA0873::FormAvaProfile.new(payload) rescue => e handle_exception(e, :ava_profile) end # Retrieves the preferred name for the user def preferred_name VAProfile::Demographics::Service.new(user).get_demographics.demographics&.preferred_name&.text rescue => e handle_exception(e, :preferred_name) end # Retrieves the profile from the AskVAApi service def profile @profile ||= AskVAApi::Profile::Retriever.new(icn: user.icn).call rescue => e handle_exception(e, :profile) end # Retrieves the school name based on the facility code if available def fetch_school_name(facility_code) return nil if facility_code.nil? school = GIDSRedis.new.get_institution_details_v0(id: facility_code) school.dig(:data, :attributes, :name) rescue => e handle_exception(e, :school_name) end # Logs the exception to Sentry and returns an empty object as a fallback def handle_exception(exception, context) log_exception_to_sentry(exception, {}, prefill: context) {} end def extract_service_number profile.is_a?(Hash) ? profile[:service_number] : profile&.service_number end def format_work_phone phone = user&.vet360_contact_info&.work_phone return nil unless phone [ phone.country_code, phone.area_code, phone.phone_number, phone.extension ].compact.join end # Metadata for the form def metadata { version: 0, prefill: true, returnUrl: '/your-personal-information' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_10282.rb
# frozen_string_literal: true class FormProfiles::VA10282 < 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_281900.rb
# frozen_string_literal: true class FormProfiles::VA281900 < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/veteran-information-review' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_0996.rb
# frozen_string_literal: true class FormProfiles::VA0996 < FormProfiles::DecisionReview end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_10275.rb
# frozen_string_literal: true class FormProfiles::VA10275 < 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_upload.rb
# frozen_string_literal: true class FormProfiles::FormUpload < FormProfile def self.load_form_mapping(_form_id) file = Rails.root.join('config', 'form_profile_mappings', 'FORM-UPLOAD.yml') YAML.load_file(file) end def metadata { version: 0, prefill: true } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_1330m.rb
# frozen_string_literal: true class FormProfiles::VA1330m < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/applicant-name' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_214140.rb
# frozen_string_literal: true # FormProfile for VA Form 21-4140 # Employment Questionnaire class FormProfiles::VA214140 < FormProfile def metadata { version: 0, prefill: true, returnUrl: '/name-and-date-of-birth' } end end
0
code_files/vets-api-private/app/models
code_files/vets-api-private/app/models/form_profiles/va_0993.rb
# frozen_string_literal: true class FormProfiles::VA0993 < 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/va_10297.rb
# frozen_string_literal: true require 'vets/model' module VA10297 FORM_ID = '22-10297' class FormPaymentAccountInformation include Vets::Model attribute :account_type, String attribute :account_number, String attribute :routing_number, String attribute :bank_name, String end end class FormProfiles::VA10297 < FormProfile attribute :payment_information, VA10297::FormPaymentAccountInformation def prefill @payment_information = initialize_payment_information result = super result[:form_data]['applicantFullName'].delete('suffix') # no name suffix needed in this schema result end def metadata { version: 0, prefill: true, returnUrl: '/applicant/information' } end private def initialize_payment_information return {} unless user.authorize(:lighthouse, :direct_deposit_access?) && user.authorize(:evss, :access?) provider = ApiProviderFactory.call(type: ApiProviderFactory::FACTORIES[:ppiu], provider: ApiProviderFactory::API_PROVIDER[:lighthouse], current_user: user, feature_toggle: nil) response = provider.get_payment_information raw_account = response.responses.first&.payment_account if raw_account VA10297::FormPaymentAccountInformation.new( account_type: raw_account&.account_type&.capitalize, account_number: raw_account&.account_number, routing_number: raw_account&.financial_institution_routing_number, bank_name: raw_account&.financial_institution_name ) else {} end rescue => e Rails.logger.error "FormProfiles::VA10297 Failed to retrieve Payment Information data: #{e.message}" {} end end