diff --git a/integration_tests/pages/page.ts b/integration_tests/pages/page.ts
index 4a31919e8..139bf5d29 100644
--- a/integration_tests/pages/page.ts
+++ b/integration_tests/pages/page.ts
@@ -410,10 +410,16 @@ export default abstract class Page {
referralSubmissionDate: Referral['submittedOn'],
referrerName: User['name'],
referrerEmail: CourseOffering['contactEmail'],
+ prisonOffenderManager: Referral['primaryPrisonOffenderManager'],
): void {
cy.get('[data-testid="submission-summary-list"]').then(summaryListElement => {
this.shouldContainSummaryListRows(
- ShowReferralUtils.submissionSummaryListRows(referralSubmissionDate, referrerName, referrerEmail),
+ ShowReferralUtils.submissionSummaryListRows(
+ referralSubmissionDate,
+ referrerName,
+ referrerEmail,
+ prisonOffenderManager,
+ ),
summaryListElement,
)
})
diff --git a/integration_tests/pages/refer/new/duplicate.ts b/integration_tests/pages/refer/new/duplicate.ts
index e35d0b3cf..279d6dec5 100644
--- a/integration_tests/pages/refer/new/duplicate.ts
+++ b/integration_tests/pages/refer/new/duplicate.ts
@@ -57,7 +57,12 @@ export default class NewReferralDuplicatePage extends Page {
shouldContainSubmissionSummaryList(referrerName: User['name'], referrerEmail: CourseOffering['contactEmail']): void {
cy.get('[data-testid="submission-summary-list"]').then(summaryListElement => {
this.shouldContainSummaryListRows(
- ShowReferralUtils.submissionSummaryListRows(this.referral.submittedOn, referrerName, referrerEmail),
+ ShowReferralUtils.submissionSummaryListRows(
+ this.referral.submittedOn,
+ referrerName,
+ referrerEmail,
+ this.referral.primaryPrisonOffenderManager,
+ ),
summaryListElement,
)
})
diff --git a/integration_tests/support/sharedTests.ts b/integration_tests/support/sharedTests.ts
index 61f23fbed..decf84a0a 100644
--- a/integration_tests/support/sharedTests.ts
+++ b/integration_tests/support/sharedTests.ts
@@ -195,6 +195,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
+ referral.primaryPrisonOffenderManager,
)
additionalInformationPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
additionalInformationPage.shouldContainAdditionalInformationSummaryCard()
@@ -232,6 +233,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
+ referral.primaryPrisonOffenderManager,
)
offenceHistoryPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
offenceHistoryPage.shouldContainImportedFromText('NOMIS')
@@ -267,6 +269,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
+ referral.primaryPrisonOffenderManager,
)
programmeHistoryPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
programmeHistoryPage.shouldContainNoHistorySummaryCard()
@@ -334,6 +337,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
+ referral.primaryPrisonOffenderManager,
)
offenceHistoryPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
offenceHistoryPage.shouldContainImportedFromText('NOMIS')
@@ -365,6 +369,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
+ referral.primaryPrisonOffenderManager,
)
personalDetailsPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
personalDetailsPage.shouldContainImportedFromText('NOMIS')
@@ -406,6 +411,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
+ referral.primaryPrisonOffenderManager,
)
programmeHistoryPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
programmeHistoryPage.shouldContainHistorySummaryCards(courseParticipationsPresenter, referral.id, {
@@ -441,6 +447,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
+ referral.primaryPrisonOffenderManager,
)
releaseDatesPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
releaseDatesPage.shouldContainImportedFromText('NOMIS')
@@ -482,6 +489,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
+ referral.primaryPrisonOffenderManager,
)
releaseDatesPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
releaseDatesPage.shouldContainImportedFromText('NOMIS')
@@ -515,6 +523,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
+ referral.primaryPrisonOffenderManager,
)
sentenceInformationPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
sentenceInformationPage.shouldContainImportedFromText('NOMIS')
@@ -556,6 +565,7 @@ const sharedTests = {
referral.submittedOn,
referringUser.name,
addedByUser1Email.email,
+ referral.primaryPrisonOffenderManager,
)
sentenceInformationPage.shouldContainSubmittedReferralSideNavigation(path, referral.id)
sentenceInformationPage.shouldContainImportedFromText('NOMIS')
diff --git a/server/controllers/shared/referralsController.ts b/server/controllers/shared/referralsController.ts
index f06f2c8f6..ec7d8b318 100644
--- a/server/controllers/shared/referralsController.ts
+++ b/server/controllers/shared/referralsController.ts
@@ -229,6 +229,7 @@ export default class ReferralsController {
referral.submittedOn,
referrerUserFullName,
referrerEmailAddress,
+ referral.primaryPrisonOffenderManager,
),
}
}
diff --git a/server/utils/referrals/showReferralUtils.test.ts b/server/utils/referrals/showReferralUtils.test.ts
index 611250361..1b84600fc 100644
--- a/server/utils/referrals/showReferralUtils.test.ts
+++ b/server/utils/referrals/showReferralUtils.test.ts
@@ -7,6 +7,7 @@ import {
referralFactory,
referralStatusHistoryFactory,
referralStatusRefDataFactory,
+ staffDetailFactory,
} from '../../testutils/factories'
import CourseUtils from '../courseUtils'
import type { ReferralStatusHistoryPresenter } from '@accredited-programmes/ui'
@@ -348,6 +349,22 @@ describe('ShowReferralUtils', () => {
key: { text: 'Referrer email address' },
value: { html: `${referrerEmail}` },
},
+ {
+ key: {
+ text: 'Prison Offender Manager',
+ },
+ value: {
+ text: 'Not assigned',
+ },
+ },
+ {
+ key: {
+ text: 'Prison Offender Manager email address',
+ },
+ value: {
+ text: 'Not assigned',
+ },
+ },
])
})
@@ -365,6 +382,40 @@ describe('ShowReferralUtils', () => {
)
})
})
+
+ describe('when the referral has a prison offender manager assigned', () => {
+ const referral = referralFactory.submitted().build({
+ primaryPrisonOffenderManager: staffDetailFactory.build({
+ firstName: 'Bob',
+ lastName: 'Smith',
+ primaryEmail: 'bob.smith@email.com',
+ }),
+ })
+
+ it('returns the prison offender manager details', () => {
+ expect(
+ ShowReferralUtils.submissionSummaryListRows(
+ referral.submittedOn,
+ 'Test User',
+ 'test@test.com',
+ referral.primaryPrisonOffenderManager,
+ ),
+ ).toEqual(
+ expect.arrayContaining([
+ {
+ key: { text: 'Prison Offender Manager' },
+ value: { text: 'Bob Smith' },
+ },
+ {
+ key: { text: 'Prison Offender Manager email address' },
+ value: {
+ html: 'bob.smith@email.com',
+ },
+ },
+ ]),
+ )
+ })
+ })
})
describe('subNavigationItems', () => {
diff --git a/server/utils/referrals/showReferralUtils.ts b/server/utils/referrals/showReferralUtils.ts
index 80b290079..d3a52cabd 100644
--- a/server/utils/referrals/showReferralUtils.ts
+++ b/server/utils/referrals/showReferralUtils.ts
@@ -3,6 +3,7 @@ import type { Request } from 'express'
import CaseListUtils from './caseListUtils'
import { assessPathBase, assessPaths, referPaths } from '../../paths'
import DateUtils from '../dateUtils'
+import StringUtils from '../stringUtils'
import type { CourseOffering, Organisation, ReferralStatusRefData } from '@accredited-programmes/models'
import type {
CoursePresenter,
@@ -150,7 +151,10 @@ export default class ShowReferralUtils {
referralSubmissionDate: Referral['submittedOn'],
referrerName: User['name'],
referrerEmail: UserEmail['email'],
+ prisonOffenderManager?: Referral['primaryPrisonOffenderManager'],
): Array {
+ const pomNotAssignedString = 'Not assigned'
+
return [
{
key: { text: 'Date referred' },
@@ -166,6 +170,26 @@ export default class ShowReferralUtils {
key: { text: 'Referrer email address' },
value: { html: `${referrerEmail}` },
},
+
+ {
+ key: { text: 'Prison Offender Manager' },
+ value: {
+ text:
+ prisonOffenderManager?.firstName || prisonOffenderManager?.lastName
+ ? StringUtils.convertToTitleCase(`${prisonOffenderManager?.firstName} ${prisonOffenderManager?.lastName}`)
+ : pomNotAssignedString,
+ },
+ },
+ {
+ key: { text: 'Prison Offender Manager email address' },
+ value: {
+ ...(prisonOffenderManager?.primaryEmail
+ ? {
+ html: `${prisonOffenderManager.primaryEmail}`,
+ }
+ : { text: pomNotAssignedString }),
+ },
+ },
]
}