Skip to content

Commit 6bbb2e3

Browse files
Merge pull request #352 from ministryofjustice/HIA-643
Golden record for adjudications endpoint
2 parents f155e4d + 8638afe commit 6bbb2e3

35 files changed

+684
-314
lines changed

openapi.yml

+175-6
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ paths:
195195
- persons
196196
summary: >
197197
Returns offences associated with a person.
198-
198+
199199
Note: This API does not contain the complete list of offences for a person.
200200
Offences are retrieved from Prison and Probation systems exclusively.
201201
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.
@@ -364,7 +364,7 @@ paths:
364364
- needs
365365
summary: >
366366
Returns criminogenic needs associated with a person.
367-
367+
368368
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.
369369
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.
370370
parameters:
@@ -463,14 +463,31 @@ paths:
463463
"200":
464464
description: Success.
465465

466-
/{TBC}/v1/persons/{Id}/adjudications:
466+
/v1/persons/{Id}/adjudications:
467467
get:
468-
summary: FUTURE ENDPOINT - Returns adjudications associated with a person.
468+
summary: Returns adjudications associated with a person.
469469
parameters:
470-
- $ref: "#/components/parameters/Id"
470+
- name: hmppsId
471+
in: path
472+
required: true
473+
schema:
474+
type: string
471475
responses:
472476
"200":
473-
description: Success.
477+
description: OK
478+
content:
479+
application/json:
480+
schema:
481+
$ref: '#/components/schemas/Adjudication'
482+
"404":
483+
description: "Adjudications for the person with the provided HmppsId does not exist."
484+
content:
485+
application/json:
486+
schema:
487+
$ref: "#/components/schemas/Error"
488+
examples:
489+
PersonNotFoundError:
490+
$ref: "#/components/examples/PersonNotFoundError"
474491

475492
/{TBC}/v1/persons/{Id}/interventions:
476493
get:
@@ -631,6 +648,33 @@ components:
631648
type: string
632649
example: Business Address
633650
description: Description of address type
651+
Adjudication:
652+
type: object
653+
properties:
654+
incidentDetails:
655+
$ref: '#/components/schemas/IncidentDetails'
656+
isYouthOffender:
657+
type: boolean
658+
incidentRole:
659+
$ref: '#/components/schemas/IncidentRole'
660+
offenceDetails:
661+
$ref: '#/components/schemas/OffenceDetail'
662+
hearings:
663+
type: array
664+
items:
665+
$ref: '#/components/schemas/Hearing'
666+
outcomes:
667+
type: array
668+
items:
669+
$ref: '#/components/schemas/Outcome'
670+
punishments:
671+
type: array
672+
items:
673+
$ref: '#/components/schemas/Punishment'
674+
punishmentComments:
675+
type: array
676+
items:
677+
$ref: '#/components/schemas/PunishmentComment'
634678
Alert:
635679
type: object
636680
properties:
@@ -774,6 +818,36 @@ components:
774818
type: string
775819
nullable: true
776820
example: null
821+
Hearing:
822+
type: object
823+
properties:
824+
dateTimeOfHearing:
825+
type: string
826+
format: date-time
827+
nullable: true
828+
oicHearingType:
829+
type: string
830+
nullable: true
831+
outcome:
832+
nullable: true
833+
HearingOutcome:
834+
type: object
835+
properties:
836+
code:
837+
type: string
838+
nullable: true
839+
details:
840+
type: string
841+
nullable: true
842+
reason:
843+
type: string
844+
nullable: true
845+
quashedReason:
846+
type: string
847+
nullable: true
848+
canRemove:
849+
type: boolean
850+
nullable: true
777851
Identifiers:
778852
type: object
779853
description: Other unique identifiers for a person.
@@ -862,6 +936,21 @@ components:
862936
`OFF_IDM` - Offender Identification Marks,
863937
`OIC` - Offence In Custody,
864938
`PPTY` - Property Image
939+
IncidentDetails:
940+
type: object
941+
properties:
942+
dateTimeOfIncident:
943+
type: string
944+
format: date-time
945+
nullable: true
946+
IncidentRole:
947+
type: object
948+
properties:
949+
roleCode:
950+
type: string
951+
nullable: true
952+
offenceRule:
953+
nullable: true
865954
LatestSentenceKeyDatesAndAdjustments:
866955
type: object
867956
properties:
@@ -925,6 +1014,41 @@ components:
9251014
type: string
9261015
example: RR84
9271016
description: Statute code
1017+
OffenceDetail:
1018+
type: object
1019+
properties:
1020+
offenceCode:
1021+
type: number
1022+
nullable: true
1023+
offenceRule:
1024+
nullable: true
1025+
OffenceRuleDetails:
1026+
type: object
1027+
properties:
1028+
paragraphNumber:
1029+
type: string
1030+
nullable: true
1031+
paragraphDescription:
1032+
type: string
1033+
nullable: true
1034+
Outcome:
1035+
type: object
1036+
properties:
1037+
code:
1038+
type: string
1039+
nullable: true
1040+
details:
1041+
type: string
1042+
nullable: true
1043+
reason:
1044+
type: string
1045+
nullable: true
1046+
quashedReason:
1047+
type: string
1048+
nullable: true
1049+
canRemove:
1050+
type: boolean
1051+
nullable: true
9281052
Pagination:
9291053
type: object
9301054
properties:
@@ -997,6 +1121,51 @@ components:
9971121
type: string
9981122
example: 2008/0545166T
9991123
description: Currently a hmppsId is a PNC identifier however this will change in the near future to be a CRN identifier
1124+
Punishment:
1125+
type: object
1126+
properties:
1127+
type:
1128+
type: string
1129+
nullable: true
1130+
privilegeType:
1131+
type: string
1132+
nullable: true
1133+
otherPrivilege:
1134+
type: string
1135+
nullable: true
1136+
schedule:
1137+
nullable: true
1138+
PunishmentComment:
1139+
type: object
1140+
properties:
1141+
comment:
1142+
type: string
1143+
nullable: true
1144+
reasonForChange:
1145+
type: string
1146+
nullable: true
1147+
dateTime:
1148+
type: string
1149+
format: date-time
1150+
nullable: true
1151+
PunishmentSchedule:
1152+
type: object
1153+
properties:
1154+
days:
1155+
type: number
1156+
nullable: true
1157+
startDate:
1158+
type: string
1159+
format: date
1160+
nullable: true
1161+
endDate:
1162+
type: string
1163+
format: date
1164+
nullable: true
1165+
suspendedUntil:
1166+
type: string
1167+
format: date
1168+
nullable: true
10001169
ResponsibleProvider:
10011170
required:
10021171
- code

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AdjudicationsGateway.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Value
55
import org.springframework.http.HttpMethod
66
import org.springframework.stereotype.Component
77
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.WebClientWrapper
8-
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications.ReportedAdjudicationDto
8+
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications.ReportedAdjudication
99
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Adjudication
1010
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
1111
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
@@ -18,7 +18,7 @@ class AdjudicationsGateway(@Value("\${services.adjudications.base-url}") baseUrl
1818
lateinit var hmppsAuthGateway: HmppsAuthGateway
1919

2020
fun getReportedAdjudicationsForPerson(id: String): Response<List<Adjudication>> {
21-
val result = webClient.requestList<ReportedAdjudicationDto>(
21+
val result = webClient.requestList<ReportedAdjudication>(
2222
HttpMethod.GET,
2323
"/reported-adjudications/prisoner/$id",
2424
authenticationHeader(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
class AdjudicationHearingOutcome(
4+
val id: Number? = null,
5+
val adjudicator: String? = null,
6+
val code: String? = null,
7+
val reason: String? = null,
8+
val details: String? = null,
9+
val plea: String? = null,
10+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
class AdjudicationsCombinedOutcome(
4+
val outcome: AdjudicationsOutcome? = null,
5+
val referralOutcome: AdjudicationsOutcome? = null,
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
data class AdjudicationsHearing(
4+
val id: Number? = null,
5+
val locationId: Number? = null,
6+
val dateTimeOfHearing: String? = null,
7+
val oicHearingType: String? = null,
8+
val outcome: AdjudicationHearingOutcome? = null,
9+
val agencyId: String? = null,
10+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
data class AdjudicationsIncidentDetails(
3+
val locationId: Number? = null,
4+
val dateTimeOfIncident: String? = null,
5+
val dateTimeOfDiscovery: String? = null,
6+
val handoverDeadline: String? = null,
7+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
data class AdjudicationsIncidentRole(
4+
val roleCode: String? = null,
5+
val offenceRule: AdjudicationsOffenceRuleDetails? = null,
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
class AdjudicationsOffenceDetails(
4+
val offenceCode: Number? = null,
5+
val offenceRule: AdjudicationsOffenceRule? = null,
6+
val victimPrisonersNumber: String? = null,
7+
val victimStaffUsername: String? = null,
8+
val victimOtherPersonsName: String? = null,
9+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
class AdjudicationsOffenceRule(
4+
val paragraphNumber: String? = null,
5+
val paragraphDescription: String? = null,
6+
val nomisCode: String? = null,
7+
val withOthersNomisCode: String? = null,
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
data class AdjudicationsOffenceRuleDetails(
4+
val paragraphNumber: String? = null,
5+
val paragraphDescription: String? = null,
6+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
class AdjudicationsOutcome(
4+
val id: Number? = null,
5+
val code: String? = null,
6+
val details: String? = null,
7+
val reason: String? = null,
8+
val quashedReason: String? = null,
9+
val canRemove: Boolean? = null,
10+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
class AdjudicationsOutcomeHistory(
3+
val hearing: AdjudicationsHearing? = null,
4+
val outcome: AdjudicationsCombinedOutcome? = null,
5+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
class AdjudicationsPunishment(
4+
val id: Number? = null,
5+
val type: String? = null,
6+
val privilegeType: String? = null,
7+
val otherPrivilege: String? = null,
8+
val stoppagePercentage: Number? = null,
9+
val activatedBy: String? = null,
10+
val activatedFrom: String? = null,
11+
val schedule: AdjudicationsPunishmentSchedule? = null,
12+
val consecutiveChargeNumber: String? = null,
13+
val consecutiveReportAvailable: Boolean? = null,
14+
val damagesOwedAmount: Number? = null,
15+
val canRemove: Boolean? = null,
16+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
class AdjudicationsPunishmentComment(
4+
val id: Number? = null,
5+
val comment: String? = null,
6+
val reasonForChange: String? = null,
7+
val dateTime: String? = null,
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.adjudications
2+
3+
class AdjudicationsPunishmentSchedule(
4+
val days: Number? = null,
5+
val startDate: String? = null,
6+
val endDate: String? = null,
7+
val suspendedUntil: String? = null,
8+
)

0 commit comments

Comments
 (0)