Skip to content

Commit

Permalink
Merge pull request #712 from ministryofjustice/APG-317-section-11-upd…
Browse files Browse the repository at this point in the history
…ates

(APG-317) Update Risks and Needs Section 11 - Thinking and behaving
  • Loading branch information
jsrobertson authored Aug 19, 2024
2 parents 1915e91 + 92b02d8 commit 520f763
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 33 deletions.
3 changes: 1 addition & 2 deletions integration_tests/mockApis/oasys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { stubFor } from '../../wiremock'
import type {
AssessmentDateInfo,
Attitude,
Behaviour,
DrugAlcoholDetail,
Health,
LearningNeeds,
Expand All @@ -14,7 +13,7 @@ import type {
RisksAndAlerts,
RoshAnalysis,
} from '@accredited-programmes/models'
import type { Lifestyle, Psychiatric, Relationships } from '@accredited-programmes-api'
import type { Behaviour, Lifestyle, Psychiatric, Relationships } from '@accredited-programmes-api'

export default {
stubAssessmentDateInfo: (args: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CourseUtils, ThinkingAndBehavingUtils } from '../../../../../server/utils'
import Page from '../../../page'
import type { Behaviour, Course } from '@accredited-programmes/models'
import type { Course } from '@accredited-programmes/models'
import type { Behaviour } from '@accredited-programmes-api'

export default class ThinkingAndBehavingPage extends Page {
behaviour: Behaviour
Expand Down
8 changes: 0 additions & 8 deletions server/@types/models/Behaviour.ts

This file was deleted.

2 changes: 0 additions & 2 deletions server/@types/models/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { AssessmentDateInfo } from './AssessmentDateInfo'
import type { Attitude } from './Attitude'
import type { Behaviour } from './Behaviour'
import type { Course } from './Course'
import type { Audience, CourseAudience } from './CourseAudience'
import type { CourseCreateRequest } from './CourseCreateRequest'
Expand Down Expand Up @@ -43,7 +42,6 @@ export type {
AssessmentDateInfo,
Attitude,
Audience,
Behaviour,
ConfirmationFields,
Course,
CourseAudience,
Expand Down
3 changes: 1 addition & 2 deletions server/data/accreditedProgrammesApi/oasysClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import RestClient from '../restClient'
import type {
AssessmentDateInfo,
Attitude,
Behaviour,
DrugAlcoholDetail,
Health,
LearningNeeds,
Expand All @@ -14,7 +13,7 @@ import type {
RisksAndAlerts,
RoshAnalysis,
} from '@accredited-programmes/models'
import type { Lifestyle, Psychiatric, Relationships } from '@accredited-programmes-api'
import type { Behaviour, Lifestyle, Psychiatric, Relationships } from '@accredited-programmes-api'
import type { SystemToken } from '@hmpps-auth'

export default class OasysClient {
Expand Down
3 changes: 1 addition & 2 deletions server/services/oasysService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { HmppsAuthClient, OasysClient, RestClientBuilder, RestClientBuilder
import type {
AssessmentDateInfo,
Attitude,
Behaviour,
DrugAlcoholDetail,
Health,
LearningNeeds,
Expand All @@ -14,7 +13,7 @@ import type {
RisksAndAlerts,
RoshAnalysis,
} from '@accredited-programmes/models'
import type { Lifestyle, Psychiatric, Relationships } from '@accredited-programmes-api'
import type { Behaviour, Lifestyle, Psychiatric, Relationships } from '@accredited-programmes-api'

export default class OasysService {
constructor(
Expand Down
6 changes: 5 additions & 1 deletion server/testutils/factories/behaviour.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import { faker } from '@faker-js/faker'
import { Factory } from 'fishery'

import FactoryHelpers from './factoryHelpers'
import type { Behaviour } from '@accredited-programmes/models'
import type { Behaviour } from '@accredited-programmes-api'

export default Factory.define<Behaviour>(() => {
return {
achieveGoals: FactoryHelpers.optionalArrayElement(faker.lorem.sentence()),
aggressiveControllingBehaviour: FactoryHelpers.optionalArrayElement(faker.lorem.sentence()),
awarenessOfConsequences: FactoryHelpers.optionalArrayElement(faker.lorem.sentence()),
concreteAbstractThinking: FactoryHelpers.optionalArrayElement(faker.lorem.sentence()),
impulsivity: FactoryHelpers.optionalArrayElement(faker.lorem.sentence()),
offenceRelatedSexualInterests: FactoryHelpers.optionalArrayElement(faker.lorem.sentence()),
problemSolvingSkills: FactoryHelpers.optionalArrayElement(faker.lorem.sentence()),
sexualPreOccupation: FactoryHelpers.optionalArrayElement(faker.lorem.sentence()),
temperControl: FactoryHelpers.optionalArrayElement(faker.lorem.sentence()),
understandsViewsOfOthers: FactoryHelpers.optionalArrayElement(faker.lorem.sentence()),
}
Expand Down
46 changes: 33 additions & 13 deletions server/utils/risksAndNeeds/thinkingAndBehavingUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,61 @@ import ThinkingAndBehavingUtils from './thinkingAndBehavingUtils'
import { behaviourFactory } from '../../testutils/factories'

describe('ThinkingAndBehavingUtils', () => {
const roshAnalysis = behaviourFactory.build({
const behaviour = behaviourFactory.build({
achieveGoals: '1 - Some problems',
awarenessOfConsequences: '2 - Some problems',
concreteAbstractThinking: '3 - Some problems',
problemSolvingSkills: '4 - Some problems',
temperControl: '5 - Some problems',
understandsViewsOfOthers: '6 - Some problems',
aggressiveControllingBehaviour: '2 - Some problems',
awarenessOfConsequences: '3 - Some problems',
concreteAbstractThinking: '4 - Some problems',
impulsivity: '5 - Some problems',
offenceRelatedSexualInterests: '6 - Some problems',
problemSolvingSkills: '7 - Some problems',
sexualPreOccupation: '8 - Some problems',
temperControl: '9 - Some problems',
understandsViewsOfOthers: '10 - Some problems',
})

describe('previousBehaviourSummaryListRows', () => {
it('formats the behaviour data in the appropriate format for passing to a GOV.UK summary list Nunjucks macro', () => {
expect(ThinkingAndBehavingUtils.thinkingAndBehavingSummaryListRows(roshAnalysis)).toEqual([
expect(ThinkingAndBehavingUtils.thinkingAndBehavingSummaryListRows(behaviour)).toEqual([
{
key: { text: '11.4 - Temper control' },
key: { text: '11.2 - Impulsivity' },
value: { text: '5 - Some problems' },
},
{
key: { text: '11.3 - Aggressive or controlling behaviour' },
value: { text: '2 - Some problems' },
},
{
key: { text: '11.4 - Temper control' },
value: { text: '9 - Some problems' },
},
{
key: { text: '11.6 - Problem solving skills' },
value: { text: '4 - Some problems' },
value: { text: '7 - Some problems' },
},
{
key: { text: '11.7 - Awareness of consequences' },
value: { text: '2 - Some problems' },
value: { text: '3 - Some problems' },
},
{
key: { text: '11.8 - Achieves goals (optional)' },
value: { text: '1 - Some problems' },
},
{
key: { text: "11.9 - Understands other people's views" },
value: { text: '6 - Some problems' },
value: { text: '10 - Some problems' },
},
{
key: { text: '11.10 - Concrete / abstract thinking (optional)' },
value: { text: '3 - Some problems' },
key: { text: '11.10 - Concrete or abstract thinking (optional)' },
value: { text: '4 - Some problems' },
},
{
key: { text: '11.11 - Sexual preoccupation' },
value: { text: '8 - Some problems' },
},
{
key: { text: '11.12 - Offence-related sexual interests' },
value: { text: '6 - Some problems' },
},
])
})
Expand Down
20 changes: 18 additions & 2 deletions server/utils/risksAndNeeds/thinkingAndBehavingUtils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import ShowRisksAndNeedsUtils from '../referrals/showRisksAndNeedsUtils'
import type { Behaviour } from '@accredited-programmes/models'
import type { GovukFrontendSummaryListRowWithKeyAndValue } from '@accredited-programmes/ui'
import type { Behaviour } from '@accredited-programmes-api'

export default class ThinkingAndBehavingUtils {
static thinkingAndBehavingSummaryListRows(behaviour: Behaviour): Array<GovukFrontendSummaryListRowWithKeyAndValue> {
return [
{
key: { text: '11.2 - Impulsivity' },
value: { text: ShowRisksAndNeedsUtils.textValue(behaviour.impulsivity) },
},
{
key: { text: '11.3 - Aggressive or controlling behaviour' },
value: { text: ShowRisksAndNeedsUtils.textValue(behaviour.aggressiveControllingBehaviour) },
},
{
key: { text: '11.4 - Temper control' },
value: { text: ShowRisksAndNeedsUtils.textValue(behaviour.temperControl) },
Expand All @@ -26,9 +34,17 @@ export default class ThinkingAndBehavingUtils {
value: { text: ShowRisksAndNeedsUtils.textValue(behaviour.understandsViewsOfOthers) },
},
{
key: { text: '11.10 - Concrete / abstract thinking (optional)' },
key: { text: '11.10 - Concrete or abstract thinking (optional)' },
value: { text: ShowRisksAndNeedsUtils.textValue(behaviour.concreteAbstractThinking) },
},
{
key: { text: '11.11 - Sexual preoccupation' },
value: { text: ShowRisksAndNeedsUtils.textValue(behaviour.sexualPreOccupation) },
},
{
key: { text: '11.12 - Offence-related sexual interests' },
value: { text: ShowRisksAndNeedsUtils.textValue(behaviour.offenceRelatedSexualInterests) },
},
]
}
}

0 comments on commit 520f763

Please sign in to comment.