Repository: DEFRA/ffc-ahwr-application
Pull request #304: feat(AHWR-547): send claim status updates to message generator
Author: login: rossjarvisesynergy
Created: 2025-03-13T16:31:52Z | Merged: 2025-03-17T15:17:56Z



Diff:
diff --git a/app/config/index.js b/app/config/index.js
index 67ce065d..aa551a5e 100644
--- a/app/config/index.js
+++ b/app/config/index.js
@@ -30,7 +30,8 @@ const buildConfig = () => {
     sfdRequestMsgType: Joi.string(),
     sfdMessage: {
       enabled: Joi.bool()
-    }
+    },
+    messageGeneratorMsgType: Joi.string()
   })
 
   const config = {
@@ -56,7 +57,8 @@ const buildConfig = () => {
     sfdRequestMsgType: `${msgTypePrefix}.sfd.request`,
     sfdMessage: {
       enabled: process.env.SFD_MESSAGE_ENABLED === 'true'
-    }
+    },
+    messageGeneratorMsgType: `${msgTypePrefix}.claim.status.update`
   }
 
   const { error } = schema.validate(config, { abortEarly: false })
diff --git a/app/config/message-queue.js b/app/config/message-queue.js
index ccf81992..4e4e97f2 100644
--- a/app/config/message-queue.js
+++ b/app/config/message-queue.js
@@ -44,6 +44,11 @@ export const getMessageQueueConfig = () => {
       address: Joi.string(),
       type: Joi.string(),
       ...sharedConfigSchema
+    },
+    messageGeneratorQueue: {
+      address: Joi.string(),
+      type: Joi.string(),
+      ...sharedConfigSchema
     }
   })
 
@@ -87,6 +92,11 @@ export const getMessageQueueConfig = () => {
       address: process.env.SFD_MESSAGE_QUEUE_ADDRESS,
       type: 'queue',
       ...sharedConfig
+    },
+    messageGeneratorQueue: {
+      address: process.env.MESSAGE_GENERATOR_QUEUE_ADDRESS,
+      type: 'queue',
+      ...sharedConfig
     }
   }
 
diff --git a/app/routes/api/claim.js b/app/routes/api/claim.js
index 65d66cd0..25d3ec52 100644
--- a/app/routes/api/claim.js
+++ b/app/routes/api/claim.js
@@ -12,7 +12,7 @@ import { requiresComplianceCheck } from '../../lib/requires-compliance-check.js'
 import { searchPayloadSchema } from './schema/search-payload.schema.js'
 import { createClaimReference } from '../../lib/create-reference.js'
 
-const { submitPaymentRequestMsgType, submitRequestQueue, optionalPIHunt: { enabled: optionalPiHuntEnabled }, notify: { templateIdFarmerEndemicsReviewComplete, templateIdFarmerEndemicsFollowupComplete } } = config
+const { submitPaymentRequestMsgType, submitRequestQueue, optionalPIHunt: { enabled: optionalPiHuntEnabled }, notify: { templateIdFarmerEndemicsReviewComplete, templateIdFarmerEndemicsFollowupComplete }, messageGeneratorMsgType, messageGeneratorQueue } = config
 
 const isReview = (payload) => payload.type === claimType.review
 const isFollowUp = (payload) => payload.type === claimType.endemics
@@ -304,6 +304,20 @@ export const claimHandlers = [
           })
         }
 
+        await sendMessage(
+          {
+            crn: application?.dataValues?.data?.organisation?.crn,
+            sbi,
+            agreementReference: applicationReference,
+            claimReference,
+            claimStatus: statusId,
+            dateTime: new Date()
+          },
+          messageGeneratorMsgType,
+          messageGeneratorQueue,
+          { sessionId: uuid() }
+        )
+
         return h.response(claim).code(200)
       }
     }
@@ -360,27 +374,55 @@ export const claimHandlers = [
         if (!claim.dataValues) {
           return h.response('Not Found').code(404).takeover()
         }
-        const application = await getApplication(claim.dataValues.applicationReference)
-        const sbi = application?.dataValues?.data?.organisation?.sbi
+        const { typeOfLivestock, claimType, reviewTestResults } = claim.dataValues.data || {}
+        const applicationReference = claim.dataValues.applicationReference
+
+        const application = await getApplication(applicationReference)
+        const { sbi, frn, crn } = application?.dataValues?.data?.organisation || {}
 
         request.logger.setBindings({ sbi })
 
-        let optionalPiHuntValue
+        await updateClaimByReference(
+          {
+            reference,
+            statusId: status,
+            updatedBy: request.payload.user,
+            sbi
+          },
+          note,
+          request.logger
+        )
 
-        if (optionalPiHuntEnabled) {
-          optionalPiHuntValue = claim.dataValues.data.piHunt === piHunt.yes && claim.dataValues.data.piHuntAllAnimals === piHuntAllAnimals.yes ? 'yesPiHunt' : 'noPiHunt'
-        }
+        await sendMessage(
+          {
+            crn,
+            sbi,
+            agreementReference: applicationReference,
+            claimReference: reference,
+            claimStatus: status,
+            dateTime: new Date()
+          },
+          messageGeneratorMsgType,
+          messageGeneratorQueue,
+          { sessionId: uuid() }
+        )
 
         if (status === applicationStatus.readyToPay) {
+          let optionalPiHuntValue
+
+          if (config.optionalPIHunt.enabled) {
+            optionalPiHuntValue = claim.dataValues.data.piHunt === piHunt.yes && claim.dataValues.data.piHuntAllAnimals === piHuntAllAnimals.yes ? 'yesPiHunt' : 'noPiHunt'
+          }
+
           await sendMessage(
             {
               reference,
-              sbi: application.dataValues.data.organisation.sbi,
-              whichReview: claim.dataValues.data.typeOfLivestock,
+              sbi,
+              whichReview: typeOfLivestock,
               isEndemics: true,
-              claimType: claim.dataValues.data?.claimType,
-              reviewTestResults: claim.dataValues.data.reviewTestResults,
-              frn: application.dataValues.data.organisation.frn,
+              claimType,
+              reviewTestResults,
+              frn,
               optionalPiHuntValue
             },
             submitPaymentRequestMsgType,
@@ -389,17 +431,6 @@ export const claimHandlers = [
           )
         }
 
-        await updateClaimByReference(
-          {
-            reference,
-            statusId: status,
-            updatedBy: request.payload.user,
-            sbi
-          },
-          note,
-          request.logger
-        )
-
         return h.response().code(200)
       }
     }
diff --git a/appconfig/common.yaml b/appconfig/common.yaml
index 85dd1b31..29e6e299 100644
--- a/appconfig/common.yaml
+++ b/appconfig/common.yaml
@@ -3,4 +3,5 @@ container.applicationResponseQueueAddress: queue:ffc-ahwr-application-response
 container.paymentRequestQueueAddress: queue:ffc-ahwr-payment-request
 container.eventQueueAddress: queue:ffc-ahwr-event
 container.applicationDocCreationRequestQueueAddress: queue:ffc-ahwr-document-request
-container.sfdMessageQueueAddress: queue:ffc-ahwr-sfd-message
\ No newline at end of file
+container.sfdMessageQueueAddress: queue:ffc-ahwr-sfd-message
+container.messageGeneratorQueueAddress: queue:ffc-ahwr-message-generator
\ No newline at end of file
diff --git a/docker-compose.yaml b/docker-compose.yaml
index ff899699..bf630529 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -36,6 +36,7 @@ services:
       CLAIM_COMPLIANCE_CHECK_RATIO: ${CLAIM_COMPLIANCE_CHECK_RATIO:-1}
       OPTIONAL_PIHUNT_ENABLED: ${OPTIONAL_PIHUNT_ENABLED:-false}
       SFD_MESSAGE_QUEUE_ADDRESS: ${SFD_MESSAGE_QUEUE_ADDRESS:-ffc-ahwr-sfd-message}${MESSAGE_QUEUE_SUFFIX}
+      MESSAGE_GENERATOR_QUEUE_ADDRESS: ${MESSAGE_GENERATOR_QUEUE_ADDRESS:-ffc-ahwr-message-generator}${MESSAGE_QUEUE_SUFFIX}
 
   ffc-ahwr-application-postgres:
     image: postgres:11.4-alpine
diff --git a/helm/ffc-ahwr-application/templates/config-map.yaml b/helm/ffc-ahwr-application/templates/config-map.yaml
index 315c2997..607733b9 100644
--- a/helm/ffc-ahwr-application/templates/config-map.yaml
+++ b/helm/ffc-ahwr-application/templates/config-map.yaml
@@ -25,4 +25,5 @@ data:
   OPTIONAL_PIHUNT_ENABLED: {{ quote .Values.container.optionalPIHuntEnabled }}
   AZURE_STORAGE_ENDEMICS_SETTINGS_CONTAINER: {{ quote .Values.container.azureStorageEndemicsSettingsContainerName }}
   SFD_MESSAGE_QUEUE_ADDRESS: {{ quote .Values.container.sfdMessageQueueAddress }}
+  MESSAGE_GENERATOR_QUEUE_ADDRESS: {{ quote .Values.container.messageGeneratorQueueAddress }}
 {{- end -}}
diff --git a/helm/ffc-ahwr-application/values.yaml b/helm/ffc-ahwr-application/values.yaml
index 010ffe66..dcfed699 100644
--- a/helm/ffc-ahwr-application/values.yaml
+++ b/helm/ffc-ahwr-application/values.yaml
@@ -57,6 +57,7 @@ container:
   endemicsClaimComplianceCheckRatio:
   azureStorageEndemicsSettingsContainerName: 
   sfdMessageQueueAddress: ffc-ahwr-sfd-message
+  messageGeneratorQueueAddress: ffc-ahwr-message-generator
 
 postgresService:
   postgresDb: ffc_ahwr_application
diff --git a/package-lock.json b/package-lock.json
index 9add67c4..26f63344 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "ffc-ahwr-application",
-  "version": "2.1.1",
+  "version": "2.1.2",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "ffc-ahwr-application",
-      "version": "2.1.1",
+      "version": "2.1.2",
       "license": "OGL-UK-3.0",
       "dependencies": {
         "@azure/data-tables": "^13.2.1",
diff --git a/package.json b/package.json
index 033613f5..73d2e6cd 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "ffc-ahwr-application",
-  "version": "2.1.1",
+  "version": "2.1.2",
   "description": "Application manager for AHWR",
   "homepage": "https://github.com/DEFRA/ffc-ahwr-application",
   "main": "app/index.js",
diff --git a/provision.azure.yaml b/provision.azure.yaml
index 06d4e2f0..3f02824a 100644
--- a/provision.azure.yaml
+++ b/provision.azure.yaml
@@ -23,3 +23,6 @@ resources:
     - name: ffc-ahwr-sfd-message
       role: sender
       session: false
+    - name: ffc-ahwr-message-generator
+      role: sender
+      session: false
\ No newline at end of file
diff --git a/test/integration/narrow/routes/api/claim.test.js b/test/integration/narrow/routes/api/claim.test.js
index bcced9ea..3cf5df61 100644
--- a/test/integration/narrow/routes/api/claim.test.js
+++ b/test/integration/narrow/routes/api/claim.test.js
@@ -7,6 +7,7 @@ import { claimPricesConfig } from '../../../../data/claim-prices-config'
 import { getBlob } from '../../../../../app/storage/getBlob'
 import { getAmount } from '../../../../../app/lib/getAmount'
 import appInsights from 'applicationinsights'
+import { config } from '../../../../../app/config'
 
 jest.mock('../../../../../app/insights')
 jest.mock('applicationinsights', () => ({ defaultClient: { trackException: jest.fn(), trackEvent: jest.fn() }, dispose: jest.fn() }))
@@ -295,7 +296,11 @@ describe('Post claim test', () => {
           vetRCVSNumber: 'AK-2024',
           speciesNumbers: 'yes',
           typeOfLivestock: 'pigs',
-          numberAnimalsTested: 30
+          numberAnimalsTested: 30,
+          organisation: {
+            crn: '1100014934',
+            sbi: '106705779'
+          }
         },
         statusId: 1,
         type: 'R',
@@ -316,6 +321,17 @@ describe('Post claim test', () => {
 
     expect(setClaim).toHaveBeenCalledTimes(1)
     expect(sendFarmerEndemicsClaimConfirmationEmail).toHaveBeenCalledTimes(1)
+    expect(sendMessage).toHaveBeenCalledWith(
+      {
+        crn: '1100014934',
+        sbi: '106705779',
+        agreementReference: 'AHWR-0AD3-3322',
+        claimReference: 'TEMP-O9UD-22F6',
+        claimStatus: 11,
+        dateTime: expect.any(Date)
+      },
+      'uk.gov.ffc.ahwr.claim.status.update', expect.any(Object), { sessionId: expect.any(String) }
+    )
   })
 
   test.each([
@@ -1024,12 +1040,16 @@ describe('Post claim test', () => {
 })
 
 describe('PUT claim test', () => {
-  beforeEach(async () => {
+  beforeAll(async () => {
     jest.clearAllMocks()
     await server.start()
   })
 
-  afterEach(async () => {
+  beforeEach(() => {
+    config.optionalPIHunt.enabled = false
+  })
+
+  afterAll(async () => {
     await server.stop()
   })
 
@@ -1042,25 +1062,33 @@ describe('PUT claim test', () => {
       method: 'PUT',
       url: '/api/claim/update-by-reference',
       payload: {
-        reference: 'AHWR-0F5D-4A26',
+        reference: 'REBC-J9AR-KILQ',
         status: statusId,
         user: 'admin'
       }
     }
 
     getClaimByReference.mockResolvedValue({
-      dataValues: { reference: 'AHWR-0F5D-4A26', data: { typeOfLivestock: 'sheep' } }
+      dataValues: {
+        reference: 'REBC-J9AR-KILQ',
+        applicationReference: 'AHWR-KJLI-2678',
+        data: {
+          typeOfLivestock: 'sheep',
+          claimType: 'R',
+          reviewTestResults: 'positive'
+        }
+      }
     })
-
     updateClaimByReference.mockResolvedValue({
-      dataValues: { reference: 'AHWR-0F5D-4A26', statusId }
+      dataValues: { reference: 'REBC-J9AR-KILQ', statusId }
     })
-
     getApplication.mockResolvedValue({
       dataValues: {
         data: {
           organisation: {
-            sbi: 'sbi'
+            sbi: '106705779',
+            crn: '1100014934',
+            frn: '1102569649'
           }
         }
       }
@@ -1069,8 +1097,86 @@ describe('PUT claim test', () => {
     const res = await server.inject(options)
 
     expect(res.statusCode).toBe(200)
-    expect(sendMessage).toHaveBeenCalledTimes(statusId === 9 ? 1 : 0)
+    if (statusId === 9) {
+      expect(sendMessage).toHaveBeenCalledWith(
+        {
+          reference: 'REBC-J9AR-KILQ',
+          sbi: '106705779',
+          whichReview: 'sheep',
+          isEndemics: true,
+          claimType: 'R',
+          reviewTestResults: 'positive',
+          frn: '1102569649'
+        },
+        'uk.gov.ffc.ahwr.submit.payment.request', expect.any(Object), { sessionId: expect.any(String) })
+    }
+    expect(sendMessage).toHaveBeenCalledWith(
+      {
+        crn: '1100014934',
+        sbi: '106705779',
+        agreementReference: 'AHWR-KJLI-2678',
+        claimReference: 'REBC-J9AR-KILQ',
+        claimStatus: statusId,
+        dateTime: expect.any(Date)
+      },
+      'uk.gov.ffc.ahwr.claim.status.update', expect.any(Object), { sessionId: expect.any(String) }
+    )
+  })
+
+  test('should update claim when application does not exist', async () => {
+    const options = {
+      method: 'PUT',
+      url: '/api/claim/update-by-reference',
+      payload: {
+        reference: 'REBC-J9AR-KILQ',
+        status: 9,
+        user: 'admin',
+        note: 'updating status'
+      }
+    }
+
+    getClaimByReference.mockResolvedValue({
+      dataValues: {
+        reference: 'REBC-J9AR-KILQ',
+        applicationReference: 'AHWR-KJLI-2678',
+        data: {
+          typeOfLivestock: 'sheep',
+          claimType: 'R',
+          reviewTestResults: 'positive'
+        }
+      }
+    })
+    getApplication.mockResolvedValue({})
+
+    const res = await server.inject(options)
+
+    expect(res.statusCode).toBe(200)
+    expect(updateClaimByReference).toHaveBeenCalledWith({
+      reference: 'REBC-J9AR-KILQ',
+      sbi: undefined,
+      statusId: 9,
+      updatedBy: 'admin'
+    }, 'updating status', expect.any(Object))
+    expect(sendMessage).toHaveBeenCalledWith(
+      {
+        reference: 'REBC-J9AR-KILQ',
+        whichReview: 'sheep',
+        isEndemics: true,
+        claimType: 'R',
+        reviewTestResults: 'positive'
+      },
+      'uk.gov.ffc.ahwr.submit.payment.request', expect.any(Object), { sessionId: expect.any(String) })
+    expect(sendMessage).toHaveBeenCalledWith(
+      {
+        agreementReference: 'AHWR-KJLI-2678',
+        claimReference: 'REBC-J9AR-KILQ',
+        claimStatus: 9,
+        dateTime: expect.any(Date)
+      },
+      'uk.gov.ffc.ahwr.claim.status.update', expect.any(Object), { sessionId: expect.any(String) }
+    )
   })
+
   test('Update claim should failed when claim is not exist', async () => {
     const options = {
       method: 'PUT',
@@ -1088,6 +1194,216 @@ describe('PUT claim test', () => {
 
     expect(res.statusCode).toBe(404)
   })
+
+  test('should update claim and submit payment request when optionalPiHunt is enabled and piHunt is yes', async () => {
+    config.optionalPIHunt.enabled = true
+    const options = {
+      method: 'PUT',
+      url: '/api/claim/update-by-reference',
+      payload: {
+        reference: 'REBC-J9AR-KILQ',
+        status: 9,
+        user: 'admin',
+        note: 'updating status'
+      }
+    }
+    getClaimByReference.mockResolvedValue({
+      dataValues: {
+        reference: 'REBC-J9AR-KILQ',
+        applicationReference: 'AHWR-KJLI-2678',
+        data: {
+          typeOfLivestock: 'sheep',
+          claimType: 'R',
+          reviewTestResults: 'positive',
+          piHunt: 'yes',
+          piHuntAllAnimals: 'yes'
+        }
+      }
+    })
+    getApplication.mockResolvedValue({
+      dataValues: {
+        data: {
+          organisation: {
+            sbi: '106705779',
+            crn: '1100014934',
+            frn: '1102569649'
+          }
+        }
+      }
+    })
+    const res = await server.inject(options)
+
+    expect(res.statusCode).toBe(200)
+    expect(updateClaimByReference).toHaveBeenCalledWith({
+      reference: 'REBC-J9AR-KILQ',
+      sbi: '106705779',
+      statusId: 9,
+      updatedBy: 'admin'
+    }, 'updating status', expect.any(Object))
+    expect(sendMessage).toHaveBeenCalledWith(
+      {
+        agreementReference: 'AHWR-KJLI-2678',
+        claimReference: 'REBC-J9AR-KILQ',
+        claimStatus: 9,
+        dateTime: expect.any(Date),
+        sbi: '106705779',
+        crn: '1100014934'
+      },
+      'uk.gov.ffc.ahwr.claim.status.update', expect.any(Object), { sessionId: expect.any(String) }
+    )
+    expect(sendMessage).toHaveBeenCalledWith(
+      {
+        reference: 'REBC-J9AR-KILQ',
+        whichReview: 'sheep',
+        isEndemics: true,
+        claimType: 'R',
+        reviewTestResults: 'positive',
+        optionalPiHuntValue: 'yesPiHunt',
+        frn: '1102569649',
+        sbi: '106705779'
+      },
+      'uk.gov.ffc.ahwr.submit.payment.request', expect.any(Object), { sessionId: expect.any(String) })
+  })
+
+  test('should update claim and submit payment request when optionalPiHunt is enabled and piHunt is no', async () => {
+    config.optionalPIHunt.enabled = true
+    const options = {
+      method: 'PUT',
+      url: '/api/claim/update-by-reference',
+      payload: {
+        reference: 'REBC-J9AR-KILQ',
+        status: 9,
+        user: 'admin',
+        note: 'updating status'
+      }
+    }
+    getClaimByReference.mockResolvedValue({
+      dataValues: {
+        reference: 'REBC-J9AR-KILQ',
+        applicationReference: 'AHWR-KJLI-2678',
+        data: {
+          typeOfLivestock: 'sheep',
+          claimType: 'R',
+          reviewTestResults: 'positive',
+          piHunt: 'no',
+          piHuntAllAnimals: 'no'
+        }
+      }
+    })
+    getApplication.mockResolvedValue({
+      dataValues: {
+        data: {
+          organisation: {
+            sbi: '106705779',
+            crn: '1100014934',
+            frn: '1102569649'
+          }
+        }
+      }
+    })
+    const res = await server.inject(options)
+
+    expect(res.statusCode).toBe(200)
+    expect(updateClaimByReference).toHaveBeenCalledWith({
+      reference: 'REBC-J9AR-KILQ',
+      sbi: '106705779',
+      statusId: 9,
+      updatedBy: 'admin'
+    }, 'updating status', expect.any(Object))
+    expect(sendMessage).toHaveBeenCalledWith(
+      {
+        agreementReference: 'AHWR-KJLI-2678',
+        claimReference: 'REBC-J9AR-KILQ',
+        claimStatus: 9,
+        dateTime: expect.any(Date),
+        sbi: '106705779',
+        crn: '1100014934'
+      },
+      'uk.gov.ffc.ahwr.claim.status.update', expect.any(Object), { sessionId: expect.any(String) }
+    )
+    expect(sendMessage).toHaveBeenCalledWith(
+      {
+        reference: 'REBC-J9AR-KILQ',
+        whichReview: 'sheep',
+        isEndemics: true,
+        claimType: 'R',
+        reviewTestResults: 'positive',
+        optionalPiHuntValue: 'noPiHunt',
+        frn: '1102569649',
+        sbi: '106705779'
+      },
+      'uk.gov.ffc.ahwr.submit.payment.request', expect.any(Object), { sessionId: expect.any(String) })
+  })
+
+  test('should update claim and submit payment request when optionalPiHunt is not enabled', async () => {
+    config.optionalPIHunt.enabled = false
+    const options = {
+      method: 'PUT',
+      url: '/api/claim/update-by-reference',
+      payload: {
+        reference: 'REBC-J9AR-KILQ',
+        status: 9,
+        user: 'admin',
+        note: 'updating status'
+      }
+    }
+    getClaimByReference.mockResolvedValue({
+      dataValues: {
+        reference: 'REBC-J9AR-KILQ',
+        applicationReference: 'AHWR-KJLI-2678',
+        data: {
+          typeOfLivestock: 'sheep',
+          claimType: 'R',
+          reviewTestResults: 'positive',
+          piHunt: 'yes',
+          piHuntAllAnimals: 'yes'
+        }
+      }
+    })
+    getApplication.mockResolvedValue({
+      dataValues: {
+        data: {
+          organisation: {
+            sbi: '106705779',
+            crn: '1100014934',
+            frn: '1102569649'
+          }
+        }
+      }
+    })
+    const res = await server.inject(options)
+
+    expect(res.statusCode).toBe(200)
+    expect(updateClaimByReference).toHaveBeenCalledWith({
+      reference: 'REBC-J9AR-KILQ',
+      sbi: '106705779',
+      statusId: 9,
+      updatedBy: 'admin'
+    }, 'updating status', expect.any(Object))
+    expect(sendMessage).toHaveBeenCalledWith(
+      {
+        agreementReference: 'AHWR-KJLI-2678',
+        claimReference: 'REBC-J9AR-KILQ',
+        claimStatus: 9,
+        dateTime: expect.any(Date),
+        sbi: '106705779',
+        crn: '1100014934'
+      },
+      'uk.gov.ffc.ahwr.claim.status.update', expect.any(Object), { sessionId: expect.any(String) }
+    )
+    expect(sendMessage).toHaveBeenCalledWith(
+      {
+        reference: 'REBC-J9AR-KILQ',
+        whichReview: 'sheep',
+        isEndemics: true,
+        claimType: 'R',
+        reviewTestResults: 'positive',
+        frn: '1102569649',
+        sbi: '106705779'
+      },
+      'uk.gov.ffc.ahwr.submit.payment.request', expect.any(Object), { sessionId: expect.any(String) })
+  })
+
   test('Update claim should failed when reference is not provieded', async () => {
     const options = {
       method: 'PUT',


Reviews:
user: login: aaroncarroll82
body: Couple of other bits missing:

* provision.azure.yaml needs updating with an entry for a sender role to message-generator queue
* appconfig/common.yaml needs new outbound queue details
* helm/ffc-ahwr-application/values.yaml needs new queue details
* helm/ffc-ahwr-application/templates/config-map.yaml needs queue details ENV var
state: CHANGES_REQUESTED
author_association: COLLABORATOR
submitted_at: 2025-03-14T08:28:52Z
user: login: rossjarvisesynergy
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-14T09:05:35Z
user: login: rossjarvisesynergy
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-03-14T09:40:06Z
user: login: aaroncarroll82
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-03-17T14:51:05Z

Review comments:
diff_hunk: @@ -56,7 +57,8 @@ const buildConfig = () => {
     sfdRequestMsgType: `${msgTypePrefix}.sfd.request`,
     sfdMessage: {
       enabled: process.env.SFD_MESSAGE_ENABLED === 'true'
-    }
+    },
+    messageGeneratorMsgType: `${msgTypePrefix}.message.generator`
path: app/config/index.js
user: login: aaroncarroll82
body: I'd prefer the type to be indicative of what it is, rather than where it is going. Perhaps `${msgTypePrefix}.claim.status.update`
created_at: 2025-03-14T08:17:54Z
author_association: COLLABORATOR
path: app/routes/api/claim.js
user: login: aaroncarroll82
body: I know the previous code was already like this - but I don't think it's right that the we were updating the database with the claim status after the message was sent out to notify downstream services that we have changed status, the DB update should be first.

With this update, the DB update is now in the middle, so it goes send message, update DB, send another message. Which I think makes it even more wonky. I'd like the DB update to be the first port of call - if that fails, then the claim has not changed status and we should not be notify outwards that is has.
created_at: 2025-03-14T08:25:11Z
author_association: COLLABORATOR
path: app/routes/api/claim.js
user: login: rossjarvisesynergy
body: yeah agreed, I also thought of changing it but didn't want to break it, will move it around
created_at: 2025-03-14T09:05:35Z
author_association: COLLABORATOR
diff_hunk: @@ -56,7 +57,8 @@ const buildConfig = () => {
     sfdRequestMsgType: `${msgTypePrefix}.sfd.request`,
     sfdMessage: {
       enabled: process.env.SFD_MESSAGE_ENABLED === 'true'
-    }
+    },
+    messageGeneratorMsgType: `${msgTypePrefix}.message.generator`
path: app/config/index.js
user: login: rossjarvisesynergy
body: Yeah that sounds better. I had this originally but changed it as in the past i've usually named the message type after the queue, where a queue only handles one type of message rather than a single queue with many message types and you'd just create a new queue for each message type
created_at: 2025-03-14T09:40:05Z
author_association: COLLABORATOR

PR comments:
user: login: aaroncarroll82
created_at: 2025-03-14T08:33:21Z
body: We'll also need something adding to catch the case of the status changing when the claim is first created. On creation, the status will be set to either on-hold or in-check, and we need to make sure we also emit this status change outwards, as the in-check one will be important for the message generator, as it will use that as basis for sending email that requests evidence.
author_association: COLLABORATOR
user: login: sonarqubecloud[bot]
created_at: 2025-03-17T14:34:29Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=ffc-ahwr-application&pullRequest=304) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=ffc-ahwr-application&pullRequest=304&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=ffc-ahwr-application&pullRequest=304&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=ffc-ahwr-application&pullRequest=304&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [95.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=ffc-ahwr-application&pullRequest=304&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=ffc-ahwr-application&pullRequest=304&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=ffc-ahwr-application&pullRequest=304)


author_association: NONE