Skip to content

Commit

Permalink
Merge pull request #159 from ministryofjustice/pnc-number
Browse files Browse the repository at this point in the history
[P4-507] Capture PNC number instead of Athena reference
  • Loading branch information
teneightfive committed Jul 24, 2019
2 parents 47fff37 + 1e091a1 commit 96e1280
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 39 deletions.
13 changes: 5 additions & 8 deletions app/move/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,16 @@ function toLocationType (type) {

module.exports = {
// personal details
athena_reference: {
police_national_computer: {
validate: 'required',
component: 'govukInput',
label: {
text: 'fields:athena_reference.label',
text: 'fields:police_national_computer.label',
classes: 'govuk-label--s',
},
hint: {
text: 'fields:athena_reference.hint',
},
id: 'athena_reference',
name: 'athena_reference',
classes: 'govuk-input--width-20',
id: 'police_national_computer',
name: 'police_national_computer',
classes: 'govuk-input--width-10',
autocomplete: 'off',
},
first_names: {
Expand Down
2 changes: 1 addition & 1 deletion app/move/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
heading: 'moves:steps.personal_details.heading',
next: 'move-details',
fields: [
'athena_reference',
'police_national_computer',
'last_name',
'first_names',
'date_of_birth',
Expand Down
4 changes: 2 additions & 2 deletions common/presenters/moves-to-csv.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ const move = [
]
const person = [
{
label: 'Athena custody number',
value: _getIdentifier('athena_reference'),
label: 'PNC number',
value: _getIdentifier('police_national_computer'),
},
{
label: 'Last name',
Expand Down
27 changes: 25 additions & 2 deletions common/presenters/moves-to-csv.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ const {
const {
data: mockQuestions,
} = require('../../test/fixtures/api-client/reference.assessment.deserialized.json')
const filename = path.resolve(__dirname, '../../test/fixtures/moves.csv')
const csv = fs.readFileSync(filename, 'utf8')
const csv = fs.readFileSync(
path.resolve(__dirname, '../../test/fixtures/moves.csv'),
'utf8'
)
const emptyCsv = fs.readFileSync(
path.resolve(__dirname, '../../test/fixtures/moves-empty.csv'),
'utf8'
)

describe('Presenters', function () {
describe('movesToCSV', function () {
Expand Down Expand Up @@ -40,6 +46,23 @@ describe('Presenters', function () {
})
})

context('with no moves', function () {
beforeEach(async function () {
referenceDataServce.getAssessmentQuestions.resolves(mockQuestions)

transformedResponse = await movesToCSV([])
})

it('should format correctly', function () {
expect(transformedResponse).to.equal(emptyCsv.trim())
})

it('should call CSV parse', function () {
expect(json2csv.parse).to.be.calledOnce
expect(json2csv.parse.args[0][0]).to.deep.equal([])
})
})

context('when reference data returns an error', function () {
const errorStub = new Error('Error stub')

Expand Down
27 changes: 24 additions & 3 deletions common/presenters/person-to-summary-list-component.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
/* eslint-disable camelcase */
const { find } = require('lodash')

const filters = require('../../config/nunjucks/filters')

module.exports = function personToSummaryListComponent ({ date_of_birth, gender, ethnicity }) {
module.exports = function personToSummaryListComponent ({
date_of_birth: dateOfBirth,
gender,
ethnicity,
identifiers,
}) {
const pncNumber = find(identifiers, {
identifier_type: 'police_national_computer',
})
const rows = [
{
key: {
text: 'PNC Number',
},
value: {
text: pncNumber ? pncNumber.value : '',
},
},
{
key: {
text: 'Date of birth',
},
value: {
text: date_of_birth ? `${filters.formatDate(date_of_birth)} (Age ${filters.calculateAge(date_of_birth)})` : '',
text: dateOfBirth
? `${filters.formatDate(dateOfBirth)} (Age ${filters.calculateAge(
dateOfBirth
)})`
: '',
},
},
{
Expand Down
40 changes: 30 additions & 10 deletions common/presenters/person-to-summary-list-component.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const personToSummaryListComponent = require('./person-to-summary-list-component')
const filters = require('../../config/nunjucks/filters')

const { data: mockMove } = require('../../test/fixtures/api-client/move.get.deserialized.json')
const {
data: mockMove,
} = require('../../test/fixtures/api-client/move.get.deserialized.json')

describe('Presenters', function () {
describe('#personToSummaryListComponent()', function () {
Expand All @@ -20,29 +22,38 @@ describe('Presenters', function () {
describe('response', function () {
it('should contain rows property', function () {
expect(transformedResponse).to.have.property('rows')
expect(transformedResponse.rows.length).to.equal(3)
expect(transformedResponse.rows.length).to.equal(4)
})

it('should contain date of birth as first row', function () {
it('should contain PNC as first row', function () {
const row = transformedResponse.rows[0]

expect(row).to.deep.equal({
key: { text: 'PNC Number' },
value: { text: mockMove.person.identifiers[0].value },
})
})

it('should contain date of birth as second row', function () {
const row = transformedResponse.rows[1]

expect(row).to.deep.equal({
key: { text: 'Date of birth' },
value: { text: '18 Jun 1960 (Age 50)' },
})
})

it('should contain gender as second row', function () {
const row = transformedResponse.rows[1]
it('should contain gender as third row', function () {
const row = transformedResponse.rows[2]

expect(row).to.deep.equal({
key: { text: 'Gender' },
value: { text: mockMove.person.gender.title },
})
})

it('should contain ethnicity as second row', function () {
const row = transformedResponse.rows[2]
it('should contain ethnicity as fourth row', function () {
const row = transformedResponse.rows[3]

expect(row).to.deep.equal({
key: { text: 'Ethnicity' },
Expand All @@ -60,17 +71,26 @@ describe('Presenters', function () {
})

describe('response', function () {
it('should return an empty string for gender', function () {
it('should return an empty string for police national computer', function () {
const row = transformedResponse.rows[0]

expect(row).to.deep.equal({
key: { text: 'PNC Number' },
value: { text: '' },
})
})

it('should return an empty string for date of birth', function () {
const row = transformedResponse.rows[1]

expect(row).to.deep.equal({
key: { text: 'Date of birth' },
value: { text: '' },
})
})

it('should return an empty string for gender', function () {
const row = transformedResponse.rows[1]
const row = transformedResponse.rows[2]

expect(row).to.deep.equal({
key: { text: 'Gender' },
Expand All @@ -79,7 +99,7 @@ describe('Presenters', function () {
})

it('should return an empty string for ethnicity', function () {
const row = transformedResponse.rows[2]
const row = transformedResponse.rows[3]

expect(row).to.deep.equal({
key: { text: 'Ethnicity' },
Expand Down
5 changes: 2 additions & 3 deletions locales/en/fields.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"athena_reference": {
"label": "Reference number",
"hint": "Your reference for the person"
"police_national_computer": {
"label": "PNC number"
},
"first_names": {
"label": "First name(s)"
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/api-client/move.get.deserialized.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"category": "court"
}],
"identifiers": [{
"identifier_type": "police_national_computer",
"value": "11009922"
}, {
"identifier_type": "cro_number",
"value": "538154"
}, {
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/api-client/move.get.serialized.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
}
],
"identifiers": [
{
"identifier_type": "police_national_computer",
"value": "11009922"
},
{
"identifier_type": "cro_number",
"value": "538154"
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/api-client/moves.get.deserialized.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
"key": "health_issue"
}],
"identifiers": [{
"identifier_type": "police_national_computer",
"value": "11223344"
}, {
"identifier_type": "prison_number",
"value": "796507"
}, {
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/api-client/moves.get.serialized.json
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@
}
],
"identifiers": [{
"identifier_type": "police_national_computer",
"value": "11223344"
}, {
"identifier_type": "prison_number",
"value": "796507"
},
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/moves-empty.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"Request reference","From location name","From location code","To location name","To location code","Move date","PNC number","Last name","First name(s)","Date of birth","Gender","Ethnicity","Ethnicity code","Violent","Violent details","Escape","Escape details","Self harm","Self harm details","Sign or other language interpreter","Sign or other language interpreter details","Medication","Medication details","Health issue","Health issue details"
20 changes: 10 additions & 10 deletions test/fixtures/moves.csv
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"Request reference","From location name","From location code","To location name","To location code","Move date","Athena custody number","Last name","First name(s)","Date of birth","Gender","Ethnicity","Ethnicity code","Violent","Violent details","Escape","Escape details","Self harm","Self harm details","Sign or other language interpreter","Sign or other language interpreter details","Medication","Medication details","Health issue","Health issue details"
"XRW6A5HP","HMP Dartmoor",,"Axminster Crown Court",,"2019-07-13","763307","Ondricka","Raymond","1959-08-13","Transexual","Mixed (White and Asian)","M3",false,,false,,false,,false,,true,"Anti-biotics taken three-times daily",true,"Broken arm"
"Request reference","From location name","From location code","To location name","To location code","Move date","PNC number","Last name","First name(s)","Date of birth","Gender","Ethnicity","Ethnicity code","Violent","Violent details","Escape","Escape details","Self harm","Self harm details","Sign or other language interpreter","Sign or other language interpreter details","Medication","Medication details","Health issue","Health issue details"
"XRW6A5HP","HMP Dartmoor",,"Axminster Crown Court",,"2019-07-13","11223344","Ondricka","Raymond","1959-08-13","Transexual","Mixed (White and Asian)","M3",false,,false,,false,,false,,true,"Anti-biotics taken three-times daily",true,"Broken arm"
"F5XUHAE2","HMP/YOI Bronzefield",,"Axminster Crown Court",,"2019-07-04",,"O'Connell","Virgina","1967-02-25","Male","Mixed (White and Black Caribbean)","M1",false,,true,"Climber",false,,false,,false,,false,
"FA3RC7JT","HMP/YOI Hewell",,"Axminster Crown Court",,"2019-07-04",,"Schowalter","Enedina","1993-10-13","Transexual","Mixed (White and Black Caribbean)","M1",false,,false,,false,,false,,false,,true,"Keeps complaining of headaches"
"CE68R53U","HMP/YOI Portland",,"Axminster Crown Court",,"2019-07-22",,"Kilback","Antonia","1964-04-27","Transexual","Any other ethnic group","O9",false,,false,,false,,false,,true,"Anti-biotics taken three-times daily",false,
"8JH1NP2K","HMIRC The Verne",,"Axminster Crown Court",,"2019-06-29",,"Runolfsdottir","Eliseo","1992-11-01","Transexual","Mixed (White and Asian)","M3",false,,false,,false,,false,,false,,false,
"JTAE83RM","HMP Lindholme",,"Axminster Crown Court",,"2019-07-16",,"Bartell","Hilda","1939-07-26","Transexual","Mixed (White and Asian)","M3",false,,true,"Climber",false,,false,,false,,true,"Broken arm"
"M6XPC51T","HMP/YOI Warren Hill",,"Axminster Crown Court",,"2019-07-20","392460","Sipes","Aubrey","1970-05-26","Female","Any other ethnic group","O9",false,,false,,true,"Attempted suicide",false,,false,,false,
"M6XPC51T","HMP/YOI Warren Hill",,"Axminster Crown Court",,"2019-07-20",,"Sipes","Aubrey","1970-05-26","Female","Any other ethnic group","O9",false,,false,,true,"Attempted suicide",false,,false,,false,
"KN1CHMX7","HMP/YOI Sudbury",,"Axminster Crown Court",,"2019-07-10",,"Kozey","Carson","1957-03-05","Female","Mixed (White and Black Caribbean)","M1",false,,false,,false,,true,"Only speaks Welsh",false,,false,
"XJCAR28E","HMP/YOI Altcourse",,"Axminster Crown Court",,"2019-07-12","215805","Ratke","Dane","1939-08-25","Male","Asian or Asian British (Other)","A9",false,,false,,false,,false,,false,,false,
"XJCAR28E","HMP/YOI Altcourse",,"Axminster Crown Court",,"2019-07-12",,"Ratke","Dane","1939-08-25","Male","Asian or Asian British (Other)","A9",false,,false,,false,,false,,false,,false,
"58MF76N2","HMP Long Lartin",,"Axminster Crown Court",,"2019-07-07",,"Schultz","Kati","1944-12-31","Female","Black (Other)","B9",false,,false,,false,,false,,false,,false,
"M48TYU2R","HMP Coldingley",,"Barnstaple Magistrates Court",,"2019-07-17",,"Bergnaum","Alex","1962-08-15","Transexual","White (Irish)","W2",false,,true,"Former miner",false,,false,,false,,true,"Heart condition"
"4CAFTK2R","HMP/YOI Belmarsh",,"Barnstaple Magistrates Court",,"2019-07-17","181027","Mante","Fernando","1989-11-28","Transexual","Asian or Asian British (Bangladeshi)","A3",false,,false,,false,,true,"Only speaks Welsh",false,,true,"Heart condition"
"KYRFHN8C","HMP/YOI Eastwood Park",,"Barnstaple Magistrates Court",,"2019-07-12","392460","Sipes","Aubrey","1970-05-26","Female","Any other ethnic group","O9",false,,false,,true,"Attempted suicide",false,,false,,false,
"P74X6VMW","HMP/YOI Glen Parva",,"Barnstaple Magistrates Court",,"2019-07-02","170491","Auer","Simone","1952-10-07","Transexual","Asian or Asian British (Indian)","A1",true,"Karate black belt",false,,false,,false,,false,,true,"Broken arm"
"RCH6AJ4F","HMP Camp Hill",,"Barnstaple Magistrates Court",,"2019-07-18","170491","Auer","Simone","1952-10-07","Transexual","Asian or Asian British (Indian)","A1",true,"Karate black belt",false,,false,,false,,false,,true,"Broken arm"
"4CAFTK2R","HMP/YOI Belmarsh",,"Barnstaple Magistrates Court",,"2019-07-17",,"Mante","Fernando","1989-11-28","Transexual","Asian or Asian British (Bangladeshi)","A3",false,,false,,false,,true,"Only speaks Welsh",false,,true,"Heart condition"
"KYRFHN8C","HMP/YOI Eastwood Park",,"Barnstaple Magistrates Court",,"2019-07-12",,"Sipes","Aubrey","1970-05-26","Female","Any other ethnic group","O9",false,,false,,true,"Attempted suicide",false,,false,,false,
"P74X6VMW","HMP/YOI Glen Parva",,"Barnstaple Magistrates Court",,"2019-07-02",,"Auer","Simone","1952-10-07","Transexual","Asian or Asian British (Indian)","A1",true,"Karate black belt",false,,false,,false,,false,,true,"Broken arm"
"RCH6AJ4F","HMP Camp Hill",,"Barnstaple Magistrates Court",,"2019-07-18",,"Auer","Simone","1952-10-07","Transexual","Asian or Asian British (Indian)","A1",true,"Karate black belt",false,,false,,false,,false,,true,"Broken arm"
"3FPT1K8V","HMP The Mount",,"Barrow in Furness County Court",,"2019-06-30",,"Runolfsdottir","Eliseo","1992-11-01","Transexual","Mixed (White and Asian)","M3",false,,false,,false,,false,,false,,false,
"69H1JA5X","HMP Kirkham",,"Barrow in Furness County Court",,"2019-07-04","557017","Smitham","Trent","1962-05-24","Male","White (Irish)","W2",false,,false,,false,,false,,true,"Heart medication needed twice daily",false,
"69H1JA5X","HMP Kirkham",,"Barrow in Furness County Court",,"2019-07-04",,"Smitham","Trent","1962-05-24","Male","White (Irish)","W2",false,,false,,false,,false,,true,"Heart medication needed twice daily",false,
"3P5EAXMN","HMP Reading",,"Barrow in Furness County Court",,"2019-07-20",,"Runolfsdottir","Eliseo","1992-11-01","Transexual","Mixed (White and Asian)","M3",false,,false,,false,,false,,false,,false,
"TE1JHC7Y","HMP Long Lartin",,"Barrow in Furness County Court",,"2019-07-01",,"Kiehn","Russel","1960-06-09","Transexual","Black (African)","B2",false,,false,,false,,true,"Only speaks Welsh",false,,false,
"MFVX4RAK","HMP Brockhill",,"Barrow in Furness County Court",,"2019-07-13","656684","Price","Jerrell","1979-04-24","Female","Black (African)","B2",false,,false,,false,,false,,false,,false,
"MFVX4RAK","HMP Brockhill",,"Barrow in Furness County Court",,"2019-07-13",,"Price","Jerrell","1979-04-24","Female","Black (African)","B2",false,,false,,false,,false,,false,,false,

0 comments on commit 96e1280

Please sign in to comment.