Skip to content
Simon Nebesnuick edited this page May 29, 2024 · 15 revisions

There are several checks that the service performs on each claim. They can be found here

Associated tests can be found here.

They are controlled by this process file.

Checks performed

  • are-children-under-18

This code checks whether any claimed children are over 18 years old and returns a result accordingly

  • claimant-has-not-been-overpaid

This code checks whether the claimant has been flagged as being overpaid on any previous claim and returns a result accordingly. If any previous claim is flagged as overpaid, the check fails and returns a failure message; otherwise, it passes with no message.

  • cost-and-variance-equal-or-less-than-first-time-claim

This code checks whether the total costs of various expense types in the current claim fall within an accepted variance from the last manually approved claim, and it returns a result accordingly. If any expense type exceeds the defined variance, the check fails and returns a failure message with additional information. It first checks if there's data available for the latest manually approved claim and its associated claim expenses. It groups expenses by type for both the latest manually approved claim and the current claim. It iterates through each expense type in the current claim's expenses. For each expense type, it calculates the total cost for both the current claim and the corresponding expense type in the latest manually approved claim. It then calculates a variance based on the costVariancePercentage provided in autoApprovalData. If the current expense type's total cost falls outside the accepted variance from the previous claim's total cost, it constructs an additional info string including relevant information about the claim and the thresholds. If the current expense type's total cost exceeds the upper or lower threshold, it returns a new AutoApprovalCheckResult object indicating failure, with the failure message concatenated with the additional info.

  • do-expenses-match-first-time-claim

This code checks whether the number and type of expenses in the current claim match those in the last manually approved claim, and it returns a result accordingly. If there's any discrepancy, the check fails and returns a failure message with additional information about the mismatch. It first checks if there's data available for the latest manually approved claim and its associated claim expenses. It groups expenses by type for both the latest manually approved claim and the current claim. It then iterates through each expense type in the current claim's expenses. For each expense type, it checks if the corresponding expense type exists in the last manually approved claim's expenses. If the expense type doesn't exist in the last manually approved claim's expenses, it constructs an additional info string indicating the absence of the expense type and returns a failure result. If the expense type exists but the number of expenses in the current claim exceeds the number in the last manually approved claim, it constructs an additional info string indicating the mismatch in numbers and returns a failure result.

  • has-claimed-less-than-max-times-this-month

This code checks whether the claimant has claimed more than the maximum number of times allowed for the current month and returns a result accordingly, providing additional information about the claim count if the check fails.

  • has-claimed-less-than-max-times-this-year

This code checks whether the claimant has claimed more than the maximum number of times allowed for the current year and returns a result accordingly, providing additional information about the claim count if the check fails.

  • has-uploaded-prison-visit-confirmation-and-receipts

This code checks whether a prison visit confirmation and all required documents have been uploaded for the claim, returning a result accordingly, and providing additional information about the document upload status if the check fails.

  • is-benefit-expiry-date-in-future

This code snippet checks whether the benefit expiry date is on or after the date of journey for the visitor, returning a result accordingly, and providing additional information about the dates if the check fails. It initializes variables for the benefit expiry date (benefitExpiryDate) and the date of journey (dateOfJourney). It checks if the benefit expiry date exists. If not, it returns an auto-approval result indicating failure with a message stating that the benefit expiry date has not been set. It compares the benefit expiry date with the date of journey to determine if the benefit expiry date is on or after the date of journey. It constructs an additional info string providing details about the claim reference, benefit expiry date, and date of journey. It returns a new AutoApprovalCheckResult object indicating whether the check passed or failed, along with the additional info or failure message.

  • is-claim-total-under-limit

This code checks whether the total claim value is within the maximum permitted amount, returning a result accordingly, and providing additional information about the claim total if the check fails. It initializes variables to track whether the check passed (checkPassed) and the total claim value (claimTotal). It iterates through the claim expenses (autoApprovalData.ClaimExpenses array) and accumulates their costs to calculate the total claim value. It compares the total claim value against the maximum permitted amount (autoApprovalData.maxClaimTotal) to determine whether the check passed.

  • is-claimant-trusted

This code checks whether the claimant has been marked as trusted by a case worker, returning a result indicating whether the check passed or failed, and providing a failure message if applicable. It checks if the claimant is marked as trusted (autoApprovalData.Eligibility.IsTrusted === true).

  • is-latest-manual-claim-approved

This code snippet checks whether the last manually evaluated claim was approved, returning a result indicating whether the check passed or failed, and providing a failure message if applicable. It checks if there's data available for the latest manually evaluated claim (autoApprovalData.latestManualClaim). If data is available, it checks the approval status of the latest manual claim. If the status is 'APPROVED', it returns a new AutoApprovalCheckResult object indicating that the check passed. If the status is not 'APPROVED' or if there's no data available for the latest manual claim, it returns a new AutoApprovalCheckResult object indicating that the check failed with the predefined failure message.

  • is-no-previous-pending-claim

This code checks whether there are any previous pending claims for the claimant, returning a result indicating whether the check passed or failed, and providing a failure message if applicable. It checks if there are previous claims data available (autoApprovalData.previousClaims). If data is available, it iterates through the previous claims. For each claim, it checks if the status is 'PENDING' using the statusEnum. If it finds any pending claim, it returns a new AutoApprovalCheckResult object indicating that the check failed with the predefined failure message. If there are no pending claims or if there's no previous claims data available, it returns a new AutoApprovalCheckResult object indicating that the check passed.

  • is-prison-not-in-guernsey-jersey

This code checks whether the prison being visited by the claimant is located in either Guernsey or Jersey, returning a result indicating whether the check passed or failed, and providing a failure message if applicable. It checks if there's prisoner data available (autoApprovalData.Prisoner). If prisoner data is available, it extracts the name of the prison being visited (prisonName). It uses the enumHelper to check if the prisonName exists in the guernseyJerseyPrisonsEnum. If the prison name matches any value in the Guernsey or Jersey prisons enum, it returns a new AutoApprovalCheckResult object indicating that the check failed with the predefined failure message.

  • is-release-date-set

This code checks whether a release date is set for the prisoner, returning a result indicating whether the check passed or failed, and providing a failure message if applicable.

  • is-visit-in-past

This code snippet checks whether the date of visit for the claim is in the past at the time of processing, returning a result indicating whether the check passed or failed, and providing a failure message if applicable.

  • prisoner-not-visited-on-this-date

this code checks whether a claim has already been made for the prisoner on a specific date, returning a result indicating whether the check passed or failed, and providing a failure message if applicable. It initializes a variable matchedCount to count the number of times the prisoner's prison number matches those in autoApprovalData.prisonNumbers. It iterates through autoApprovalData.prisonNumbers array, incrementing matchedCount each time it matches the prisoner's prison number (autoApprovalData.Prisoner.PrisonNumber). If matchedCount is greater than 1, indicating that the prisoner has been visited more than once on this date, it returns a new AutoApprovalCheckResult object indicating that the check failed with the predefined failure message. If matchedCount is 1 or less, indicating that the prisoner has not been visited on this date or has been visited only once, it returns a new AutoApprovalCheckResult object indicating that the check passed.

  • visit-date-different-to-previous-claims

This code checks whether the date of visit for the current claim is different from the date of visit for any previous claims, returning a result indicating whether the check passed or failed, and providing a failure message with additional information if applicable. It checks if there are previous claims data available (autoApprovalData.previousClaims && autoApprovalData.previousClaims.length > 0). If previous claims data is available, it iterates through the previous claims. For each previous claim, it compares the date of visit (DateOfJourney) with the date of visit for the current claim (autoApprovalData.Claim.DateOfJourney). If the date of visit for the current claim is the same as the date of visit for any previous claim, it constructs a new AutoApprovalCheckResult object indicating that the check failed with the predefined failure message, including additional information about the claims. If the date of visit for the current claim is different from all previous claims or if there are no previous claims data available, it constructs a new AutoApprovalCheckResult object indicating that the check passed.


Former checks

  • is-claim-submitted-within-time-limit
const moment = require('moment')

const AutoApprovalCheckResult = require('../../domain/auto-approval-check-result')

const CHECK_NAME = 'is-claim-submitted-within-time-limit'
const FAILURE_MESSAGE = 'Claim was not submitted within the time limit'

module.exports = function (autoApprovalData) {
  const claimSubmissionDateMoment = moment(autoApprovalData.Claim.DateSubmitted)
  let claimSubmissionCutOffDate
  if (autoApprovalData.latestManuallyApprovedClaim) {
    claimSubmissionCutOffDate = moment(autoApprovalData.latestManuallyApprovedClaim.DateReviewed).add(
      autoApprovalData.maxDaysAfterAPVUVisit,
      'days',
    )
  } else {
    return new AutoApprovalCheckResult(CHECK_NAME, false, 'There is no manually approved claim for this eligibility')
  }

  const checkPassed = claimSubmissionDateMoment.isSameOrBefore(claimSubmissionCutOffDate)

  const ADDITIONAL_INFO = `. Claim ref: ${autoApprovalData.Claim.Reference}, Claim submission date: ${claimSubmissionDateMoment.format('DD/MM/YYYY')}, Claim submission cut off date: ${claimSubmissionCutOffDate.format('DD/MM/YYYY')}`
  return new AutoApprovalCheckResult(CHECK_NAME, checkPassed, checkPassed ? '' : FAILURE_MESSAGE + ADDITIONAL_INFO)
}
Clone this wiki locally