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

PI-1508 Migrate to the new Delius integration API #1515

Merged
merged 2 commits into from
Nov 24, 2023
Merged
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
ENABLE_TEST_UTILS: true
NOMIS_API_URL: http://localhost:8080/prisonApi
NOMIS_AUTH_URL: http://hmpps-auth:9090/auth
DELIUS_API_URL: http://localhost:8080/communityapi
DELIUS_API_URL: http://localhost:8080/delius
PROBATION_TEAMS_API_URL: http://localhost:8080/probationteams
TOKENVERIFICATION_API_ENABLED: false
GOTENBERG_API_URL: http://localhost:3001
Expand Down
2 changes: 1 addition & 1 deletion Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ For,

```
CA and DM: prisonApi, /offender-sentences/home-detention-curfew-candidates -> OffenderSentenceCalc
RO: deliusApi, /staff/staffCode/${deliusStaffCode}/managedOffenders -> OffenderSummary
RO: deliusApi, /staff/${deliusStaffCode}/managedPrisonerIds -> OffenderSummary
```

Every row links to a taskList: hdc/taskList/:bookingId
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ To run locally you need:
- redis
- auth server
- nomis
- community api
- delius api
- probation teams
- gotenberg
- nomis-user-roles-api
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
NOMIS_AUTH_EXTERNAL_URL: "http://localhost:9090/auth"
TOKENVERIFICATION_API_URL: "http://token-verification-api:8080"
NOMIS_API_URL: "http://stubs:3000/prisonApi"
DELIUS_API_URL: "http://stubs:3000/communityapi"
DELIUS_API_URL: "http://stubs:3000/delius"
PROBATION_TEAMS_API_URL: "http://stubs:3000/probationteams"
HDC_URL: "http://licences:3000"
GOTENBERG_API_URL: "http://gotenberg:3000"
Expand Down
3 changes: 1 addition & 2 deletions feature.env
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ ADMIN_API_CLIENT_ID=licencesadmin
ADMIN_API_CLIENT_SECRET=clientsecret

# DELIUS API
DELIUS_API_URL=http://localhost:8080/communityapi
DELIUS_API_URL=http://localhost:8080/delius
DELIUS_AUTH_URL=http://localhost:9090/auth
DELIUS_API_CLIENT_ID=licencesadmin
DELIUS_API_CLIENT_SECRET=clientsecret
DELIUS_API_PREFIX=/api
DELIUS_RO_ROLE_ID=LHDCBT002
DELIUS_RO_VARY_ROLE_ID=LHDCBT003

Expand Down
3 changes: 0 additions & 3 deletions helm_deploy/licences/templates/_envs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ env:
- name: DELIUS_API_URL
value: {{ .Values.env.DELIUS_API_URL | quote }}

- name: DELIUS_API_PREFIX
value: {{ .Values.env.DELIUS_API_PREFIX | quote }}

- name: PROBATION_TEAMS_API_URL
value: {{ .Values.env.PROBATION_TEAMS_API_URL | quote }}

Expand Down
3 changes: 1 addition & 2 deletions helm_deploy/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ env:
SCHEDULED_JOBS_OVERLAP: "5000"
NOTIFY_ACTIVE_TEMPLATES: "CA_RETURN,CA_DECISION,RO_NEW,RO_TWO_DAYS,RO_DUE,RO_OVERDUE,DM_NEW,DM_TO_CA_RETURN"
RO_SERVICE_TYPE: "DELIUS"
DELIUS_API_URL: "https://community-api-secure.test.delius.probation.hmpps.dsd.io"
DELIUS_API_PREFIX: "/secure"
DELIUS_API_URL: "https://hdc-licences-and-delius-dev.hmpps.service.justice.gov.uk"
PROBATION_TEAMS_API_URL: "https://probation-teams-dev.prison.service.justice.gov.uk"
PRISONER_SEARCH_API_URL: "https://prisoner-search-dev.prison.service.justice.gov.uk"
EXIT_LOCATION_URL: "https://digital-dev.prison.service.justice.gov.uk/"
Expand Down
3 changes: 1 addition & 2 deletions helm_deploy/values-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ env:
SCHEDULED_JOBS_AUTOSTART: "yes"
SCHEDULED_JOBS_OVERLAP: "5000"
NOTIFY_ACTIVE_TEMPLATES: "CA_RETURN,CA_DECISION,RO_NEW,DM_NEW,DM_TO_CA_RETURN"
DELIUS_API_URL: "https://community-api-secure.pre-prod.delius.probation.hmpps.dsd.io"
DELIUS_API_PREFIX: "/secure"
DELIUS_API_URL: "https://hdc-licences-and-delius-preprod.hmpps.service.justice.gov.uk"
PROBATION_TEAMS_API_URL: "https://probation-teams-preprod.prison.service.justice.gov.uk"
PRISONER_SEARCH_API_URL: "https://prisoner-search-preprod.prison.service.justice.gov.uk"
EXIT_LOCATION_URL: "https://digital-preprod.prison.service.justice.gov.uk/"
Expand Down
3 changes: 1 addition & 2 deletions helm_deploy/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ env:
SCHEDULED_JOBS_AUTOSTART: "yes"
SCHEDULED_JOBS_OVERLAP: "5000"
NOTIFY_ACTIVE_TEMPLATES: "CA_RETURN,CA_DECISION,RO_NEW,DM_NEW,DM_TO_CA_RETURN"
DELIUS_API_URL: "https://community-api-secure.probation.service.justice.gov.uk"
DELIUS_API_PREFIX: "/secure"
DELIUS_API_URL: "https://hdc-licences-and-delius.hmpps.service.justice.gov.uk"
PROBATION_TEAMS_API_URL: "https://probation-teams.prison.service.justice.gov.uk"
PRISONER_SEARCH_API_URL: "https://prisoner-search.prison.service.justice.gov.uk"
EXIT_LOCATION_URL: "https://digital.prison.service.justice.gov.uk/"
Expand Down
4 changes: 2 additions & 2 deletions mock-server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ app.use('/prisonApi/api/agencies', agenciesRouter)
app.use('/prisonApi/api/movements', movementsRouter)
app.use('/prisonApi/api/prisoners', prisonersRouter)

app.use('/communityapi/api', deliusRouter)
app.use('/delius', deliusRouter)
app.use('/probationteams', probationteamsRouter)

app.get('/prisonApi/health/ping', (req, res) => {
Expand All @@ -53,7 +53,7 @@ app.get('/probationteams/health/ping', (req, res) => {
res.send({ status: 'UP' })
})

app.get('/communityapi/health/ping', (req, res) => {
app.get('/delius/health/ping', (req, res) => {
res.send('pong')
})

Expand Down
110 changes: 44 additions & 66 deletions mock-server/routes/delius.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ const teamC01T04 = {
code: 'C01T04',
description: 'OMU A',
telephone: '01234567890',
localDeliveryUnit: { code: 'ABC124', description: 'ABC124 delivery unit' },
district: { code: 'D', description: 'E' },
borough: { code: 'F', description: 'G' },
localAdminUnit: { code: 'ABC124', description: 'ABC124 delivery unit' },
}

const deliusTeams = [teamC01T04]

const AUTH_RO_USER_TEST = {
username: 'AUTH_RO_USER_TEST',
staffCode: 'DELIUS_ID_TEST',
staffIdentifier: 1,
code: 'DELIUS_ID_TEST',
staffId: 1,
email: '[email protected]',
staff: {
name: {
forenames: 'FIRSTA',
surname: 'LASTA',
},
Expand All @@ -26,10 +24,10 @@ const AUTH_RO_USER_TEST = {

const RO_USER_TEST = {
username: 'RO_USER_TEST',
staffCode: 'AUTH_DELIUS_ID_TEST',
staffIdentifier: 2,
code: 'AUTH_DELIUS_ID_TEST',
staffId: 2,
email: '[email protected]',
staff: {
name: {
forenames: 'FIRSTA',
surname: 'LASTA',
},
Expand All @@ -38,10 +36,10 @@ const RO_USER_TEST = {

const RO_USER = {
username: 'RO_USER',
staffCode: 'DELIUS_ID',
staffIdentifier: 3,
code: 'DELIUS_ID',
staffId: 3,
email: '[email protected]',
staff: {
name: {
forenames: 'JESSY',
surname: 'SMITH',
},
Expand Down Expand Up @@ -69,14 +67,22 @@ const staffDetailsByStaffIdentifier = {

const router = express.Router()

router.get('/staff/username/:username', (req, res) => {
const { username } = req.params
const staffDetails = staffDetailsByUsername[username]
if (staffDetails) {
res.send(staffDetails)
} else {
res.sendStatus(404)
router.get('/staff', (req, res) => {
const { username, id } = req.query
if (username) {
const staffDetails = staffDetailsByUsername[username]
if (staffDetails) {
res.send(staffDetails)
return
}
} else if (id) {
const staffDetails = staffDetailsByStaffIdentifier[id]
if (staffDetails) {
res.send(staffDetails)
return
}
}
res.sendStatus(404)
})

/*
Expand Down Expand Up @@ -112,55 +118,23 @@ router.get('/staff/staffCode/:staffCode/managedOffenders', (req, res) => {
})
*/

router.get('/staff/staffIdentifier/:staffIdentifier', (req, res) => {
const { staffIdentifier } = req.params
const staffDetails = staffDetailsByStaffIdentifier[staffIdentifier]
if (staffDetails) {
res.send(staffDetails)
} else {
res.sendStatus(404)
}
})

router.get('/staff/staffIdentifier/:staffIdentifier/managedOffenders', (req, res) => {
const { staffIdentifier } = req.params

const offenders = [
{
staffIdentifier,
offenderId: 1234567,
nomsNumber: 'A5001DY',
crnNumber: 1234567,
offenderSurname: 'Andrews',
isCurrentRo: true,
isCurrentOm: true,
isCurrentPom: true,
omStartDate: '01/01/2001',
omEndDate: '01/01/2001',
},
]

res.send(offenders)
router.get('/managedPrisonerIds', (req, res) => {
res.send(['A5001DY'])
})

router.get('/offenders/nomsNumber/:nomsNumber/allOffenderManagers', (req, res) => {
const ros = [
{
isPrisonOffenderManager: false,
isUnallocated: false,
isResponsibleOfficer: true,
staff: { forenames: 'Ryan', surname: 'Orton' },
staffCode: 'DELIUS_ID',
staffId: 2,
team: teamC01T04,
probationArea: { code: 'ABC', description: 'ABC probation area' },
},
]

res.send(ros)
router.get('/case/:nomsNumber/communityManager', (req, res) => {
res.send({
code: 'DELIUS_ID',
staffId: 2,
name: { forenames: 'Ryan', surname: 'Orton' },
team: teamC01T04,
provider: { code: 'ABC', description: 'ABC probation area' },
localAdminUnit: { code: 'ABC124', description: 'ABC124 delivery unit' },
isUnallocated: false,
})
})

router.get('/probationAreas', (req, res) => {
router.get('/providers', (req, res) => {
// return all probation areas
const allProbationAreas = probationAreas.map((probArea) => ({
code: probArea.code,
Expand All @@ -170,11 +144,15 @@ router.get('/probationAreas', (req, res) => {
res.send(response)
})

router.get('/probationAreas/code/:code/localDeliveryUnits', (req, res) => {
router.get('/providers/:code', (req, res) => {
// return the LDUs for a specific probation area
const { code: probationAreaCode } = req.params
const probationArea = probationAreas.filter((probArea) => probArea.code === probationAreaCode)
const response = { content: probationArea[0].ldus }
const response = {
code: probationArea[0].code,
description: probationArea[0].description,
localAdminUnits: probationArea[0].ldus,
}
res.send(response)
})

Expand Down
3 changes: 1 addition & 2 deletions server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = {
},

delius: {
apiUrl: get('DELIUS_API_URL', 'http://localhost:8080/communityapi'),
apiUrl: get('DELIUS_API_URL', 'http://localhost:8080/delius'),
authUrl: get('DELIUS_AUTH_URL', get('NOMIS_AUTH_URL', 'http://localhost:9090/auth')),
admin: {
apiClientId: get('DELIUS_API_CLIENT_ID', get('ADMIN_API_CLIENT_ID', 'licencesadmin')),
Expand All @@ -73,7 +73,6 @@ module.exports = {
maxFreeSockets: 10,
freeSocketTimeout: 30000,
},
apiPrefix: get('DELIUS_API_PREFIX', '/api'),
// this refers to the 'HDC Digital Update' RBAC which is mapped to LICENCE_RO and GLOBAL_SEARCH in the auth server
responsibleOfficerRoleId: get('DELIUS_RO_ROLE_ID', 'LHDCBT002'),
// this refers to the 'HDC Digital Update' RBAC which is mapped to LICENCE_RO, GLOBAL_SEARCH and LICENCE_VARY in the auth server
Expand Down
Loading
Loading