Skip to content

95912 Check most recent status prior to sending ZSF email + update test coverage - IVC CHAMPVA forms #20044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

michaelclement
Copy link
Contributor

@michaelclement michaelclement commented Dec 27, 2024

Summary

This PR adds functionality to allow the MissingFormStatusJob to verify form submissions with missing PEGA status against the PEGA reporting API. This provides one extra layer of confidence when determining whether or not to send the user a Zero Silent Failure email.

Additionally, this PR adds some new unit tests, updates some test data, and does some minor refactoring of the code that makes up the MissingFormStatusJob workflow.

Related issue(s)

Testing done

  • New code is covered by unit tests
  • Previously, if a form did not receive a PEGA status update in 7 days, the affected user would be sent a ZSF email. Now, prior to sending that ZSF email, a final check is made against the PEGA reporting API to verify the status is in fact missing.
  • To demonstrate this new functionality locally, start vets-api and then enter the following into the rails console:
require 'pega_api/client'
Settings.ivc_champva.pega_api.base_path = "<INSERT BASE PATH HERE>"
Settings.ivc_champva.pega_api.api_key = "<INSERT API KEY HERE>"

def demo(form_uuid)
  return unless Settings.vsp_environment == "localhost"
  ActiveRecord::Base.logger.level = 1 # quiet down the output
  client = IvcChampva::PegaApi::Client.new

  IvcChampvaForm.delete_all

  # There exists a submission with three docs in staging,
  # so set up local instance to correspond to that
  3.times do |i|
    f = IvcChampvaForm.create!(
      form_uuid:,
      email: '[email protected]',
      first_name: 'Veteran',
      last_name: 'Surname',
      form_number: '10-10D',
      file_name: "#{form_uuid}_vha_10_10d#{i}.pdf",
      s3_status: 'Submitted',
      pega_status: nil,
      case_id: nil,
      email_sent: false
    )

    f.update(created_at: Time.utc(2025, 3, 12))
    f.save
  end

  job = IvcChampva::MissingFormStatusJob.new
  batches = job.missing_status_cleanup.get_missing_statuses(silent: true)

  job.num_docs_match_reports?(batches[form_uuid])

end

# This demonstrates checking if forms with nil statuses are actually
# present in PEGA's system. If they are, then the statuses will be set
# on the newly created forms:
demo('e41076cf-90c3-43ef-83b1-a69ec7b02ef5')
# OUTPUT:
# Rails -- IVC ChampVA Forms - Setting e41076cf-90c3-43ef-83b1-a69ec7b02ef5_vha_10_10d0.pdf to 'Manually Processed'
# Rails -- IVC ChampVA Forms - Setting e41076cf-90c3-43ef-83b1-a69ec7b02ef5_vha_10_10d1.pdf to 'Manually Processed'
# Rails -- IVC ChampVA Forms - Setting e41076cf-90c3-43ef-83b1-a69ec7b02ef5_vha_10_10d2.pdf to 'Manually Processed'

# This demonstrates what happens when there isn't a match in PEGA's system:
demo('11111111-2222-3333-4444-555555555555')
# OUTPUT:
# false

Screenshots

NA

What areas of the site does it impact?

IVC CHAMPVA forms

Acceptance criteria

  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • No error nor warning in the console.
  • Events are being sent to the appropriate logging solution
  • Documentation has been updated (link to documentation)
  • No sensitive information (i.e. PII/credentials/internal URLs/etc.) is captured in logging, hardcoded, or specs
  • Feature/bug has a monitor built into Datadog (if applicable)
  • If app impacted requires authentication, did you login to a local build and verify all authenticated routes work as expected
  • I added a screenshot of the developed feature

Requested Feedback

NA

@va-vfs-bot va-vfs-bot temporarily deployed to 95912-check-most-recent-status-prior-to-sending-zsf-email/main/main December 27, 2024 20:21 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to 95912-check-most-recent-status-prior-to-sending-zsf-email/main/main December 27, 2024 21:26 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to 95912-check-most-recent-status-prior-to-sending-zsf-email/main/main December 31, 2024 18:49 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to 95912-check-most-recent-status-prior-to-sending-zsf-email/main/main December 31, 2024 19:02 Inactive
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jan 30, 2025
@michaelclement
Copy link
Contributor Author

Keep

@github-actions github-actions bot removed the Stale label Feb 3, 2025
Copy link

github-actions bot commented Mar 5, 2025

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Mar 5, 2025
@michaelclement
Copy link
Contributor Author

Keep

@github-actions github-actions bot removed the Stale label Mar 5, 2025
…ts-api into 95912-check-most-recent-status-prior-to-sending-zsf-email
@va-vfs-bot va-vfs-bot temporarily deployed to 95912-check-most-recent-status-prior-to-sending-zsf-email/main/main March 12, 2025 20:47 Inactive
batches = get_nil_batches
batches = missing_status_cleanup.get_missing_statuses(silent: true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The batch fetching functionality was added as part of the new MissingStatusCleanup class, so replacing this get_nil_batches usage with that shared class.

Comment on lines +8 to +17
# @param [boolean] silent whether or not to `puts` the batch information
#
# @returns [Hash] a hash where keys are form UUIDs and values are arrays of
# IvcChampvaForm records matching that UUID
def get_missing_statuses
def get_missing_statuses(silent: false)
all_nil_statuses = IvcChampvaForm.where(pega_status: nil)
batches = batch_records(all_nil_statuses)

return batches if silent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated get_missing_statuses and get_batches_for_email methods so that printing to console can be silenced (improves unit test output readability, etc)

Comment on lines -86 to +96
puts "Setting #{form.file_name} to 'Manually Processed'"
# In this context, `form.file_name` has this structure: "#{uuid}_#{form_id}_supporting_doc-#{index}.pdf"
Rails.logger.info("IVC ChampVA Forms - Setting #{form.file_name} to 'Manually Processed'")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this puts to an actual logger call in case we want to track this in Data Dog later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to reflect that the API now includes "UUID" as a field in responses.

@va-vfs-bot va-vfs-bot temporarily deployed to 95912-check-most-recent-status-prior-to-sending-zsf-email/main/main March 13, 2025 19:06 Inactive
@va-vfs-bot va-vfs-bot temporarily deployed to 95912-check-most-recent-status-prior-to-sending-zsf-email/main/main March 14, 2025 01:17 Inactive
Copy link
Contributor

@stevelong00 stevelong00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@michaelclement michaelclement marked this pull request as ready for review March 18, 2025 18:47
@michaelclement michaelclement requested review from a team as code owners March 18, 2025 18:47
@michaelclement michaelclement merged commit 8b90114 into master Mar 24, 2025
39 of 41 checks passed
@michaelclement michaelclement deleted the 95912-check-most-recent-status-prior-to-sending-zsf-email branch March 24, 2025 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants