Skip to content
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

APS-1298 update space search page for user research #2139

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ workflows:
branches:
only:
- main
- feature/APS-1298-update-space-search-for-user-research
- hmpps/deploy_env:
name: deploy_dev
env: 'dev'
Expand Down Expand Up @@ -258,8 +259,13 @@ workflows:
- request-preprod-approval
- request-test-approval:
type: approval
filters:
branches:
only:
- feature/APS-1298-update-space-search-for-user-research
requires:
- deploy_dev
- helm_lint
- build_docker
- hmpps/deploy_env:
name: deploy_test
env: 'test'
Expand All @@ -269,10 +275,6 @@ workflows:
context:
- hmpps-common-vars
- hmpps-approved-premises-ui-stage
filters:
branches:
only:
- main
requires:
- helm_lint
- build_docker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ describe('MatchingInformation', () => {
const page = new MatchingInformation({}, assessment)

expect(page.errors()).toEqual({
isStepFreeDesignated: 'You must specify a preference for step-free access',
hasEnSuite: 'You must specify a preference for en-suite bathroom',
isStepFreeDesignated: 'You must specify a preference for limited mobility',
hasEnSuite: 'You must specify a preference for en-suite (room)',
lengthOfStayAgreed: 'You must state if you agree with the length of the stay',
})
})
Expand All @@ -104,17 +104,17 @@ describe('MatchingInformation', () => {
'What type of AP is required?': 'Enhanced Security AP (ESAP)',
'Designated arson room': 'Essential',
'Room suitable for a person with sexual offences': 'Not relevant',
'Wheelchair accessible': 'Essential',
'Single room': 'Desirable',
'Step-free access': 'Desirable',
'Catering required': 'Not relevant',
'En-suite bathroom': 'Not relevant',
'Vulnerable to exploitation': 'Relevant',
'Sexual offences against an adult': 'Relevant',
'Sexual offences against children': 'Relevant',
'Wheelchair needs': 'Essential',
'Single (room)': 'Desirable',
'Limited mobility': 'Desirable',
'Catered (property)': 'Not relevant',
'En-suite (room)': 'Not relevant',
'At risk of criminal exploitation': 'Relevant',
'Poses sexual risk to adults': 'Relevant',
'Poses risk to children': 'Relevant',
'Non sexual offences against children': 'Relevant',
'Hate based offences': 'Relevant',
'Arson offences': 'Relevant',
'Has committed hate-based offences': 'Relevant',
'Poses arson risk': 'Relevant',
'Do you agree with the suggested length of stay?': 'Yes',
'Information for Central Referral Unit (CRU) manager': 'Some info',
})
Expand Down
2 changes: 1 addition & 1 deletion server/testutils/factories/spaceBookingRequirements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Factory } from 'fishery'
import { faker } from '@faker-js/faker/locale/en_GB'

import type { Cas1SpaceBookingRequirements } from '@approved-premises/api'
import { filterOutAPTypes } from '../../utils/match'
import { filterOutAPTypes } from '../../utils/match/util'
import { placementCriteria } from './placementRequest'

export default Factory.define<Cas1SpaceBookingRequirements>(() => {
Expand Down
2 changes: 1 addition & 1 deletion server/testutils/factories/spaceSearchParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { faker } from '@faker-js/faker/locale/en_GB'

import type { Cas1SpaceSearchParameters, Cas1SpaceSearchRequirements } from '@approved-premises/api'
import { DateFormats } from '../../utils/dateUtils'
import { filterOutAPTypes } from '../../utils/match'
import { filterOutAPTypes } from '../../utils/match/util'
import { placementCriteria } from './placementRequest'
import postcodeAreas from '../../etc/postcodeAreas.json'
import { SpaceSearchParametersUi } from '../../@types/ui'
Expand Down
4 changes: 2 additions & 2 deletions server/utils/apTypeLabels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export const apTypeLabels: Record<ApType, string> = {
normal: 'Standard AP',
pipe: 'Psychologically Informed Planned Environment (PIPE)',
esap: 'Enhanced Security AP (ESAP)',
mhapElliottHouse: 'Specialist mental health AP (Elliot House, East Midlands)',
mhapStJosephs: 'Specialist mental health AP (St Joseph’s, Greater Manchester)',
rfap: 'Recovery Focused AP (RFAP)',
mhapElliottHouse: 'Specialist Mental Health AP (Elliott House - Midlands)',
mhapStJosephs: 'Specialist Mental Health AP (St Josephs - Greater Manchester)',
} as const

export type ApTypeLabel = (typeof apTypeLabels)[ApType]
35 changes: 17 additions & 18 deletions server/utils/match/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Gender,
PlacementCriteria,
PlacementRequestDetail,
Cas1SpaceCharacteristic as SpaceCharacteristic,
Cas1SpaceSearchParameters as SpaceSearchParameters,
Cas1SpaceSearchResult as SpaceSearchResult,
} from '../../@types/shared'
Expand All @@ -25,6 +24,7 @@ import { preferredApsRow } from '../placementRequests/preferredApsRow'
import { placementRequirementsRow } from '../placementRequests/placementRequirementsRow'

export { placementDates } from './placementDates'
export { filterOutAPTypes } from './util'

type PlacementDates = {
placementLength: number
Expand Down Expand Up @@ -129,20 +129,6 @@ export const spaceBookingPersonNeedsSummaryCardRows = (
]
}

export const filterOutAPTypes = (requirements: Array<PlacementCriteria>): Array<SpaceCharacteristic> => {
return requirements.filter(
requirement =>
![
'isPIPE',
'isESAP',
'isRecoveryFocussed',
'isMHAPElliottHouse',
'isMHAPStJosephs',
'isSemiSpecialistMentalHealth',
].includes(requirement),
) as Array<SpaceCharacteristic>
}

export const requirementsHtmlString = (requirements: Array<PlacementCriteria>): string => {
let htmlString = ''
requirements.forEach(requirement => {
Expand Down Expand Up @@ -219,7 +205,7 @@ export const addressRow = (spaceSearchResult: SpaceSearchResult) => ({

export const characteristicsRow = (spaceSearchResult: SpaceSearchResult) => {
return {
key: { text: 'Characteristics' },
key: { text: 'Suitable for' },
value: {
html: `<ul class="govuk-list govuk-list--bullet">${spaceSearchResult.premises.premisesCharacteristics.map(characteristic => `<li>${characteristic.name}</li>`).join(' ')}</ul>`,
},
Expand Down Expand Up @@ -275,15 +261,28 @@ export const startDateObjFromParams = (params: { startDate: string } | ObjectWit
return { startDate: params.startDate, ...DateFormats.isoDateToDateInputs(params.startDate, 'startDate') }
}

export const offenceAndRiskCriteriaLabelsFiltered = () => {
const result = offenceAndRiskCriteriaLabels
delete result.acceptsNonSexualChildOffenders
return result
}

export const placementRequirementCriteriaLabelsFiltered = () => {
const result = placementRequirementCriteriaLabels
delete result.isSuitedForSexOffenders
delete result.isArsonDesignated
return result
}

export const groupedCriteria = {
offenceAndRisk: {
title: 'Risks and offences',
items: offenceAndRiskCriteriaLabels,
items: offenceAndRiskCriteriaLabelsFiltered(),
inputName: 'spaceCharacteristics',
},
accessNeeds: {
title: 'Access needs and additional features',
items: placementRequirementCriteriaLabels,
items: placementRequirementCriteriaLabelsFiltered(),
inputName: 'spaceCharacteristics',
},
}
Expand Down
15 changes: 15 additions & 0 deletions server/utils/match/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PlacementCriteria, Cas1SpaceCharacteristic as SpaceCharacteristic } from '@approved-premises/api'

export const filterOutAPTypes = (requirements: Array<PlacementCriteria>): Array<SpaceCharacteristic> => {
return requirements.filter(
requirement =>
![
'isPIPE',
'isESAP',
'isRecoveryFocussed',
'isMHAPElliottHouse',
'isMHAPStJosephs',
'isSemiSpecialistMentalHealth',
].includes(requirement),
) as Array<SpaceCharacteristic>
}
20 changes: 10 additions & 10 deletions server/utils/placementCriteriaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ export const placementCriteriaLabels: Record<UiPlacementCriteria, string> = {
isMHAPElliottHouse: 'Specialist Mental Health AP (Elliott House - Midlands)',
isMHAPStJosephs: 'Specialist Mental Health AP (St Josephs - Greater Manchester)',
isSemiSpecialistMentalHealth: 'Semi-specialist mental health',
isSuitableForVulnerable: 'Vulnerable to exploitation',
acceptsSexOffenders: 'Sexual offences against an adult',
acceptsChildSexOffenders: 'Sexual offences against children',
isSuitableForVulnerable: 'At risk of criminal exploitation',
acceptsChildSexOffenders: 'Poses risk to children',
acceptsHateCrimeOffenders: 'Has committed hate-based offences',
isArsonSuitable: 'Poses arson risk',
acceptsSexOffenders: 'Poses sexual risk to adults',
acceptsNonSexualChildOffenders: 'Non sexual offences against children',
acceptsHateCrimeOffenders: 'Hate based offences',
isWheelchairDesignated: 'Wheelchair accessible',
isSingle: 'Single room',
isStepFreeDesignated: 'Step-free access',
isCatered: 'Catering required',
hasEnSuite: 'En-suite bathroom',
isWheelchairDesignated: 'Wheelchair needs',
isStepFreeDesignated: 'Limited mobility',
hasEnSuite: 'En-suite (room)',
isSingle: 'Single (room)',
isCatered: 'Catered (property)',
isSuitedForSexOffenders: 'Room suitable for a person with sexual offences',
isArsonSuitable: 'Arson offences',
hasBrailleSignage: 'Braille signage',
hasTactileFlooring: 'Tactile flooring',
hasHearingLoop: 'Hearing loop',
Expand Down
2 changes: 1 addition & 1 deletion server/views/match/search.njk
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
value: requirements.gender,
fieldset: {
legend: {
text: 'Gender',
text: 'Person on probation',
classes: 'govuk-fieldset__legend--s',
isPageHeading: false
}
Expand Down