Skip to content

Commit

Permalink
map-581 get body-camera details from 'evidence' and use in 'details' …
Browse files Browse the repository at this point in the history
…section
  • Loading branch information
GurnankCheema committed Jan 23, 2024
1 parent 4dda810 commit ca059c6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
6 changes: 4 additions & 2 deletions server/data/UseOfForceReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export type IncidentDetails = {

export type UseOfForceDetails = {
positiveCommunication: boolean
bodyWornCamera: string
bodyWornCameraNumbers: { cameraNum: string }[]
bodyWornCamera?: string
bodyWornCameraNumbers?: { cameraNum: string }[]
personalProtectionTechniques: boolean
batonDrawn: boolean
batonUsed: boolean
Expand Down Expand Up @@ -48,6 +48,8 @@ export type Evidence = {
baggedEvidence: boolean
photographsTaken: boolean
cctvRecording: string
bodyWornCamera?: string
bodyWornCameraNumbers?: { cameraNum: string }[]
}

export type InvolvedStaff = {
Expand Down
33 changes: 32 additions & 1 deletion server/services/reportSummary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { Prison } from '../data/prisonClientTypes'
import { UseOfForceDraftReport } from '../data/UseOfForceReport'
import reportSummary from './reportSummary'

const form: UseOfForceDraftReport = { useOfForceDetails: {}, relocationAndInjuries: {}, reasonsForUseOfForce: {} }
const form: UseOfForceDraftReport = {
useOfForceDetails: {},
relocationAndInjuries: {},
reasonsForUseOfForce: {},
evidence: {},
}
const offenderDetail = {}
const prison: Prison = { agencyId: 'MDI', description: 'Moorland HMP', active: true, agencyType: 'INST' }
const locationDescription = ''
Expand Down Expand Up @@ -46,7 +51,33 @@ describe('reportSummary', () => {
expect(result.useOfForceDetails.painInducingTechniques).toEqual('No')
})
})
describe('Use of force details', () => {
it("should return body-camera details in 'details' even if in 'evidence' data ", () => {
form.useOfForceDetails = {}
form.evidence.bodyWornCamera = 'NO'
const result = reportSummary(form, offenderDetail, prison, locationDescription, involvedStaff, incidentDate)
expect(result.useOfForceDetails.bodyCameras).toEqual('No')
})

it("should return body-camera reference numbers within 'details' section even if they are part of 'evidence' data", () => {
form.useOfForceDetails = {}
form.evidence = {
bodyWornCamera: 'YES',
bodyWornCameraNumbers: [{ cameraNum: '1' }, { cameraNum: '2' }],
}
const result = reportSummary(form, offenderDetail, prison, locationDescription, involvedStaff, incidentDate)
expect(result.useOfForceDetails.bodyCameras).toEqual('Yes - 1, 2')
})

it("should return body-camera details saved in 'details' data", () => {
form.useOfForceDetails = {
bodyWornCamera: 'YES',
bodyWornCameraNumbers: [{ cameraNum: '1' }, { cameraNum: '2' }],
}
const result = reportSummary(form, offenderDetail, prison, locationDescription, involvedStaff, incidentDate)
expect(result.useOfForceDetails.bodyCameras).toEqual('Yes - 1, 2')
})
})
describe('Use of force reasons', () => {
it('should return undefined', () => {
form.reasonsForUseOfForce.reasons = undefined
Expand Down
14 changes: 10 additions & 4 deletions server/services/reportSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ const createIncidentDetails = (

const createUseOfForceDetails = (
details: Partial<UseOfForceDetails> = {},
reasonsForUseOfForce: Partial<ReasonsForUseOfForce> = {}
reasonsForUseOfForce: Partial<ReasonsForUseOfForce> = {},
evidence: Partial<Evidence> = {}
) => {
const bodyWornCamera = details.bodyWornCamera ? details.bodyWornCamera : evidence.bodyWornCamera
const bodyWornCameraNumbers = details.bodyWornCameraNumbers
? details.bodyWornCameraNumbers
: evidence.bodyWornCameraNumbers

return {
reasonsForUseOfForce: whenPresent(reasonsForUseOfForce.reasons, reasons =>
reasons.map(value => toLabel(UofReasons, value)).join(', ')
Expand All @@ -68,9 +74,9 @@ const createUseOfForceDetails = (

painInducingTechniques: getPainInducingTechniques(details),
handcuffsApplied: details.handcuffsApplied,
bodyCameras: whenPresent(details.bodyWornCamera, value =>
bodyCameras: whenPresent(bodyWornCamera, value =>
value === BodyWornCameras.YES.value
? `${YES} - ${extractCommaSeparatedList('cameraNum', details.bodyWornCameraNumbers)}` || YES
? `${YES} - ${extractCommaSeparatedList('cameraNum', bodyWornCameraNumbers)}` || YES
: toLabel(BodyWornCameras, value)
),
}
Expand Down Expand Up @@ -193,7 +199,7 @@ export = (
incidentDate
),
offenderDetail,
useOfForceDetails: createUseOfForceDetails(useOfForceDetails, reasonsForUseOfForce),
useOfForceDetails: createUseOfForceDetails(useOfForceDetails, reasonsForUseOfForce, evidence),
relocationAndInjuries: createRelocation(relocationAndInjuries),
evidence: createEvidence(evidence),
}
Expand Down

0 comments on commit ca059c6

Please sign in to comment.