Skip to content

Commit 634dc3d

Browse files
author
popey2700
committed
Merge branch 'HIA-750-create-notification-for-certificates-expiry-both-internal-external' of github.com:ministryofjustice/hmpps-integration-api into HIA-750-create-notification-for-certificates-expiry-both-internal-external
2 parents 36ea75f + 0789d7f commit 634dc3d

33 files changed

+657
-69
lines changed

openapi.yml

+42-42
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ paths:
1212
get:
1313
tags:
1414
- persons
15-
summary: Returns person(s) by search criteria, sorted by date of birth. At least one query parameter must be specified.
15+
summary: Returns person(s) by search criteria, sorted by date of birth (newest first). At least one query parameter must be specified.
1616
parameters:
1717
- in: query
1818
name: first_name
@@ -44,7 +44,7 @@ paths:
4444
type: boolean
4545
default: false
4646
required: false
47-
description: Whether to return results that match the search criteria within the aliases of a person, sorted by date of birth.
47+
description: Whether to return results that match the search criteria within the aliases of a person.
4848
- $ref: "#/components/parameters/page"
4949
- $ref: "#/components/parameters/perPage"
5050
responses:
@@ -126,7 +126,7 @@ paths:
126126
get:
127127
tags:
128128
- persons
129-
summary: Returns metadata of images associated with a person sorted by captureDateTime.
129+
summary: Returns metadata of images associated with a person sorted by captureDateTime (newest first).
130130
parameters:
131131
- $ref: "#/components/parameters/hmppsId"
132132
- $ref: "#/components/parameters/page"
@@ -254,11 +254,11 @@ paths:
254254
tags:
255255
- persons
256256
summary: >
257-
Returns offences associated with a person, ordered by startDate.
258-
259-
Note: This API does not contain the complete list of offences for a person.
260-
Offences are retrieved from Prison and Probation systems exclusively.
261-
Prison systems record only custodial sentences, while Probation systems record only the main offence and some additional offences for case management purposes. Other offences recorded by HMCTS and police may not be included.
257+
Returns offences associated with a person, ordered by startDate (newest first).
258+
>
259+
Note: This API does not contain the complete list of offences for a person.
260+
Offences are retrieved from Prison and Probation systems exclusively.
261+
Prison systems record only custodial sentences, while Probation systems record only the main offence and some additional offences for case management purposes. Other offences recorded by HMCTS and police may not be included.
262262
parameters:
263263
- $ref: "#/components/parameters/hmppsId"
264264
- $ref: "#/components/parameters/page"
@@ -331,7 +331,7 @@ paths:
331331
tags:
332332
- persons
333333
- alerts
334-
summary: Returns alerts associated with a person, sorted by dateCreated.
334+
summary: Returns alerts associated with a person, sorted by dateCreated (newest first).
335335
parameters:
336336
- $ref: "#/components/parameters/hmppsId"
337337
- $ref: "#/components/parameters/page"
@@ -375,7 +375,7 @@ paths:
375375
tags:
376376
- persons
377377
- alerts
378-
summary: Returns alerts associated with a person, sorted by dateCreated.
378+
summary: Returns alerts associated with a person, sorted by dateCreated (newest first).
379379
parameters:
380380
- $ref: "#/components/parameters/hmppsId"
381381
- $ref: "#/components/parameters/page"
@@ -418,7 +418,7 @@ paths:
418418
get:
419419
tags:
420420
- persons
421-
summary: Returns sentences associated with a person, sorted by dateOfSentencing.
421+
summary: Returns sentences associated with a person, sorted by dateOfSentencing (newest first).
422422
parameters:
423423
- $ref: "#/components/parameters/hmppsId"
424424
- $ref: "#/components/parameters/page"
@@ -497,7 +497,7 @@ paths:
497497
get:
498498
tags:
499499
- risks
500-
summary: Returns risk scores from the last year associated with a person, sorted by completedDate.
500+
summary: Returns risk scores from the last year associated with a person, sorted by completedDate (newest first). This endpoint does not serve LAO (Limited Access Offender) data.
501501
parameters:
502502
- $ref: "#/components/parameters/hmppsId"
503503
- $ref: "#/components/parameters/page"
@@ -649,7 +649,7 @@ paths:
649649
tags:
650650
- needs
651651
summary: >
652-
Returns criminogenic needs associated with a person.
652+
Returns criminogenic needs associated with a person. This endpoint does not serve LAO (Limited Access Offender) data.
653653
654654
Note: Criminogenic needs are dynamic factors that are directly linked to criminal behaviour. Eight criminogenic needs are measured in OASys: Accommodation, Employability, Relationships, Lifestyle and Associates, Drug Misuse, Alcohol Misuse, Thinking & Behaviour and Attitudes. These are scored according to whether there is “no need”, “some need” or “severe need”, and a need is identified in a specific section based on calculations around these scores.
655655
However, the process by which needs are assessed is changing as early as next year (2024), specifically moving to a strength-based model that seeks to identify and develop the strengths of people with convictions. As a consequence of this, the information provided by this endpoint will also change.
@@ -688,7 +688,7 @@ paths:
688688
get:
689689
tags:
690690
- risks
691-
summary: Returns Risk of Serious Harm (ROSH) risks associated with a person. Returns only assessments completed in the last year.
691+
summary: Returns Risk of Serious Harm (ROSH) risks associated with a person. Returns only assessments completed in the last year. This endpoint does not serve LAO (Limited Access Offender) data.
692692
parameters:
693693
- $ref: "#/components/parameters/hmppsId"
694694
responses:
@@ -802,7 +802,7 @@ paths:
802802

803803
/v1/persons/{hmppsId}/adjudications:
804804
get:
805-
summary: Returns adjudications associated with a person, sorted by dateTimeOfIncident.
805+
summary: Returns adjudications associated with a person, sorted by dateTimeOfIncident (newest first).
806806
parameters:
807807
- name: hmppsId
808808
in: path
@@ -871,7 +871,7 @@ paths:
871871

872872
/v1/persons/{hmppsId}/licences/conditions:
873873
get:
874-
summary: Returns license conditions associated with a person, sorted by createdDateTime.
874+
summary: Returns license conditions associated with a person, sorted by createdDateTime (newest first).
875875
parameters:
876876
- $ref: "#/components/parameters/hmppsId"
877877
responses:
@@ -1546,7 +1546,7 @@ components:
15461546
- OIC
15471547
description: >
15481548
View is the subject focus; describing the inner focus or subject of the image, normally referring to a marking, tattoo or deeper level focus of the orientation. In practise this is the interior foci of what is captured in the 'orientation' field.
1549-
Options include:
1549+
Possible values are:
15501550
`FACE` - Facing,
15511551
`TAT` - Tattoo,
15521552
`OTH` - Other,
@@ -1582,7 +1582,7 @@ components:
15821582
- TORSO
15831583
description: >
15841584
Orientation is the scope focus; describing the scope or outer focus of the image, normally referring to the highest level object of interest within the bounds of the photo itself. This is normally a body part or an angle of photography, such as a photo of someone’s facial view (`FRONT`) or arm (`ARM`).
1585-
Options include:
1585+
Possible values are:
15861586
`ANKLE` - Ankle,
15871587
`ARM` - Arm,
15881588
`DAMAGE` - Damage,
@@ -1616,7 +1616,7 @@ components:
16161616
- PPTY
16171617
description: >
16181618
Type is the contextual focus; describing the context or scenario the image was taken within. It could be for a particular purpose or capturing the results of a particular type of incident.
1619-
Options include:
1619+
Possible values are:
16201620
`OFF_BKG` - Offender Booking,
16211621
`OFF_IDM` - Offender Identification Marks,
16221622
`OIC` - Offence In Custody,
@@ -1723,7 +1723,7 @@ components:
17231723
- VARIATION_REJECTED
17241724
example: IN_PROGRESS
17251725
description: >
1726-
Licence status. Options include:
1726+
Licence status. Possible values are:
17271727
`IN_PROGRESS`,
17281728
`SUBMITTED`,
17291729
`APPROVED`,
@@ -1740,7 +1740,7 @@ components:
17401740
- PSS
17411741
- AP_PSS
17421742
description: >
1743-
The type of licence. Options include:
1743+
The type of licence. Possible values are:
17441744
`AP`,
17451745
`PSS`,
17461746
`AP_PSS`
@@ -1810,7 +1810,7 @@ components:
18101810
- NDELIUS
18111811
example: NOMIS
18121812
description: >
1813-
Which upstream API service the sentence originates from. Options include:
1813+
Which upstream API service the sentence originates from. Possible values are:
18141814
`NOMIS`,
18151815
`NDELIUS`
18161816
systemSource:
@@ -1820,7 +1820,7 @@ components:
18201820
- PROBATION_SYSTEMS
18211821
example: PROBATION_SYSTEMS
18221822
description: >
1823-
Which upstream API system the sentence originates from. Options include:
1823+
Which upstream API system the sentence originates from. Possible values are:
18241824
`PRISON_SYSTEMS`,
18251825
`PROBATION_SYSTEMS`
18261826
cjsCode:
@@ -2177,7 +2177,7 @@ components:
21772177
- NDELIUS
21782178
example: NOMIS
21792179
description: >
2180-
Which upstream API service the sentence originates from. Options include:
2180+
Which upstream API service the sentence originates from. Possible values are:
21812181
`NOMIS`,
21822182
`NDELIUS`
21832183
systemSource:
@@ -2187,7 +2187,7 @@ components:
21872187
- PROBATION_SYSTEMS
21882188
example: PROBATION_SYSTEMS
21892189
description: >
2190-
Which upstream API system the sentence originates from. Options include:
2190+
Which upstream API system the sentence originates from. Possible values are:
21912191
`PRISON_SYSTEMS`,
21922192
`PROBATION_SYSTEMS`
21932193
dateOfSentencing:
@@ -2321,7 +2321,7 @@ components:
23212321
- PRRD
23222322
example: ARD
23232323
description: >
2324-
Indicates which type of non-DTO release date is the effective release date. One of 'ARD', 'CRD', 'NPD' or 'PRRD'. Options include:
2324+
Indicates which type of non-DTO release date is the effective release date. One of 'ARD', 'CRD', 'NPD' or 'PRRD'. Possible values are:
23252325
`ARD`,
23262326
`CRD`,
23272327
`NPD`,
@@ -2441,7 +2441,7 @@ components:
24412441
- Years
24422442
example: Hours
24432443
description: >
2444-
Time unit that is used in combination with the duration field. Options include:
2444+
Time unit that is used in combination with the duration field. Possible values are:
24452445
`Hours`,
24462446
`Days`,
24472447
`Weeks`,
@@ -2490,7 +2490,7 @@ components:
24902490
example: IMP
24912491
description: >
24922492
The sentence term code
2493-
Options include:
2493+
Possible values are:
24942494
`CUR` - Curfew Period,
24952495
`DEF` - Deferment Period,
24962496
`DET` - Detention,
@@ -2558,7 +2558,7 @@ components:
25582558
- LOCKED_INCOMPLETE
25592559
example: COMPLETE
25602560
description: >
2561-
Whether the risk score calculation is complete. Options include:
2561+
Whether the risk score calculation is complete. Possible values are:
25622562
`COMPLETE`,
25632563
`LOCKED_INCOMPLETE`
25642564
groupReconviction:
@@ -2584,7 +2584,7 @@ components:
25842584
- NOT_APPLICABLE
25852585
example: LOW
25862586
description: >
2587-
Indicator for risk of group reconviction. Options include:
2587+
Indicator for risk of group reconviction. Possible values are:
25882588
`LOW`,
25892589
`MEDIUM`,
25902590
`HIGH`,
@@ -2604,7 +2604,7 @@ components:
26042604
- NOT_APPLICABLE
26052605
example: MEDIUM
26062606
description: >
2607-
Indicator for risk of violence. Options include:
2607+
Indicator for risk of violence. Possible values are:
26082608
`LOW`,
26092609
`MEDIUM`,
26102610
`HIGH`,
@@ -2624,7 +2624,7 @@ components:
26242624
- NOT_APPLICABLE
26252625
example: VERY_HIGH
26262626
description: >
2627-
Indicator for general prediction. Options include:
2627+
Indicator for general prediction. Possible values are:
26282628
`LOW`,
26292629
`MEDIUM`,
26302630
`HIGH`,
@@ -2644,7 +2644,7 @@ components:
26442644
- NOT_APPLICABLE
26452645
example: MEDIUM
26462646
description: >
2647-
Indicator for risk of serious recidivism. Options include:
2647+
Indicator for risk of serious recidivism. Possible values are:
26482648
`LOW`,
26492649
`MEDIUM`,
26502650
`HIGH`,
@@ -2664,7 +2664,7 @@ components:
26642664
- NOT_APPLICABLE
26652665
example: HIGH
26662666
description: >
2667-
Indicator for risk of sexual indecency. Options include:
2667+
Indicator for risk of sexual indecency. Possible values are:
26682668
`LOW`,
26692669
`MEDIUM`,
26702670
`HIGH`,
@@ -2680,7 +2680,7 @@ components:
26802680
- NOT_APPLICABLE
26812681
example: MEDIUM
26822682
description: >
2683-
Indicator for risk of sexual contact. Options include:
2683+
Indicator for risk of sexual contact. Possible values are:
26842684
`LOW`,
26852685
`MEDIUM`,
26862686
`HIGH`,
@@ -2726,7 +2726,7 @@ components:
27262726
- DK
27272727
- NA
27282728
description: >
2729-
Presence of risk. Options include:
2729+
Presence of risk. Possible values are:
27302730
`YES`,
27312731
`NO`,
27322732
`DK`,
@@ -2740,7 +2740,7 @@ components:
27402740
- DK
27412741
- NA
27422742
description: >
2743-
Previous concerns. Options include:
2743+
Previous concerns. Possible values are:
27442744
`YES`,
27452745
`NO`,
27462746
`DK`,
@@ -2758,7 +2758,7 @@ components:
27582758
- DK
27592759
- NA
27602760
description: >
2761-
Current concerns. Options include:
2761+
Current concerns. Possible values are:
27622762
`YES`,
27632763
`NO`,
27642764
`DK`,
@@ -2838,7 +2838,7 @@ components:
28382838
- DK
28392839
- NA
28402840
description: >
2841-
Risk of escape/abscond. Options include:
2841+
Risk of escape/abscond. Possible values are:
28422842
`YES`,
28432843
`NO`,
28442844
`DK`,
@@ -2852,7 +2852,7 @@ components:
28522852
- DK
28532853
- NA
28542854
description: >
2855-
Risk control issues/disruptive behaviour. Options include:
2855+
Risk control issues/disruptive behaviour. Possible values are:
28562856
`YES`,
28572857
`NO`,
28582858
`DK`,
@@ -2866,7 +2866,7 @@ components:
28662866
- DK
28672867
- NA
28682868
description: >
2869-
Risk of breach of trust. Options include:
2869+
Risk of breach of trust. Possible values are:
28702870
`YES`,
28712871
`NO`,
28722872
`DK`,
@@ -2880,7 +2880,7 @@ components:
28802880
- DK
28812881
- NA
28822882
description: >
2883-
Risk to other prisoners. Options include:
2883+
Risk to other prisoners. Possible values are:
28842884
`YES`,
28852885
`NO`,
28862886
`DK`,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.controllers.v1.person
2+
3+
import org.springframework.beans.factory.annotation.Autowired
4+
import org.springframework.web.bind.annotation.GetMapping
5+
import org.springframework.web.bind.annotation.PathVariable
6+
import org.springframework.web.bind.annotation.RequestMapping
7+
import org.springframework.web.bind.annotation.RequestParam
8+
import org.springframework.web.bind.annotation.RestController
9+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.exception.EntityNotFoundException
10+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.decodeUrlCharacters
11+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.DynamicRisk
12+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError
13+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.GetDynamicRisksForPersonService
14+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.services.internal.AuditService
15+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.util.PaginatedResponse
16+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.util.paginateWith
17+
18+
@RestController
19+
@RequestMapping("/v1/persons")
20+
class DynamicRisksController(
21+
@Autowired val getDynamicRisksForPersonService: GetDynamicRisksForPersonService,
22+
@Autowired val auditService: AuditService,
23+
) {
24+
@GetMapping("{encodedHmppsId}/risks/dynamic")
25+
fun getDynamicRisks(
26+
@PathVariable encodedHmppsId: String,
27+
@RequestParam(required = false, defaultValue = "1", name = "page") page: Int,
28+
@RequestParam(required = false, defaultValue = "10", name = "perPage") perPage: Int,
29+
): PaginatedResponse<DynamicRisk> {
30+
val hmppsId = encodedHmppsId.decodeUrlCharacters()
31+
val response = getDynamicRisksForPersonService.execute(hmppsId)
32+
33+
if (response.hasError(UpstreamApiError.Type.ENTITY_NOT_FOUND)) {
34+
throw EntityNotFoundException("Could not find person with id: $hmppsId")
35+
}
36+
auditService.createEvent("GET_DYNAMIC_RISKS", mapOf("hmppsId" to hmppsId))
37+
return response.data.paginateWith(page, perPage)
38+
}
39+
}

0 commit comments

Comments
 (0)