From aa59403e8f4ed40c373ab6ba7d502493301753d0 Mon Sep 17 00:00:00 2001 From: Chiara Date: Fri, 7 Jun 2024 15:26:11 +0100 Subject: [PATCH 01/12] Combing thru open api --- openapi.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openapi.yml b/openapi.yml index d2f4e5e55..d7568bcec 100644 --- a/openapi.yml +++ b/openapi.yml @@ -752,7 +752,7 @@ paths: schema: $ref: '#/components/schemas/CaseDetails' "404": - description: "A person detail with the provided hmppsId and event number does not exist in Delius." + description: "Failed to find a person detail with the provided hmppsId and event number in Delius." content: application/json: schema: @@ -787,7 +787,7 @@ paths: schema: $ref: '#/components/schemas/Adjudication' "404": - description: "Adjudications for the person with the provided hmppsId does not exist." + description: "Failed to find adjudications for the person with the provided hmppsId." content: application/json: schema: From f392fe824c28e741519167aed090513bb3cd01f0 Mon Sep 17 00:00:00 2001 From: Chiara Date: Fri, 7 Jun 2024 15:52:59 +0100 Subject: [PATCH 02/12] Sorting --- openapi.yml | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/openapi.yml b/openapi.yml index d7568bcec..0266dc5e3 100644 --- a/openapi.yml +++ b/openapi.yml @@ -45,6 +45,13 @@ paths: default: false required: false description: Whether to return results that match the search criteria within the aliases of a person + - name: sortBy + in: query + description: | + Specifies the field to sort the persons by. + schema: + type: string + default: dateOfBirth - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" responses: @@ -80,6 +87,7 @@ paths: examples: NoQueryParametersBadRequestError: $ref: "#/components/examples/InternalServerError" + /v1/persons/{hmppsId}: get: tags: @@ -130,6 +138,13 @@ paths: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" + - name: sortBy + in: query + description: | + Specifies the field to sort the persons by. + schema: + type: string + default: captureDateTime responses: "200": description: > @@ -306,6 +321,13 @@ paths: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" + - name: sortBy + in: query + description: | + Specifies the field to sort the alerts by. + schema: + type: string + default: dateCreated responses: "200": description: Successfully found alerts for a person with the provided HMPPS ID. @@ -350,6 +372,13 @@ paths: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" + - name: sortBy + in: query + description: | + Specifies the field to sort the PND alerts by. + schema: + type: string + default: dateCreated responses: "200": description: Successfully found alerts for a person with the provided HMPPS ID. @@ -393,6 +422,13 @@ paths: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" + - name: sortBy + in: query + description: | + Specifies the field to sort the alerts by. + schema: + type: string + default: dateOfSentencing responses: "200": description: Successfully found sentences for a person with the provided HMPPS ID. @@ -472,6 +508,13 @@ paths: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" + - name: sortBy + in: query + description: | + Specifies the field to sort the alerts by. + schema: + type: string + default: completedDate responses: "200": description: Successfully found risk scores for a person with the provided HMPPS ID. @@ -513,6 +556,13 @@ paths: summary: Returns the categories related to an offender. parameters: - $ref: "#/components/parameters/hmppsId" + - name: sortBy + in: query + description: | + Specifies the field to sort the alerts by. + schema: + type: string + default: assessmentDate responses: "200": description: Successfully found risk categories for a person with the provided HMPPS ID. @@ -625,6 +675,13 @@ paths: 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. parameters: - $ref: "#/components/parameters/hmppsId" + - name: sortBy + in: query + description: | + Specifies the field to sort the alerts by. + schema: + type: string + default: assessedOn responses: "200": description: Successfully found criminogenic needs for a person with the provided HMPPS ID. From cc9787c5e17f44b292352e0369d49ef0751e1346 Mon Sep 17 00:00:00 2001 From: Chiara Date: Fri, 7 Jun 2024 15:54:38 +0100 Subject: [PATCH 03/12] Ordering --- openapi.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openapi.yml b/openapi.yml index 0266dc5e3..401a3b5ea 100644 --- a/openapi.yml +++ b/openapi.yml @@ -950,6 +950,13 @@ paths: required: false description: Filter by the location. example MDI - $ref: "#/components/parameters/hmppsId" + - name: sortBy + in: query + description: | + Specifies the field to sort the alerts by. + schema: + type: string + default: CreatDateTime responses: "200": description: Successfully found case notes for a person with the provided HMPPS ID. From 193efa49215f2a437c1c5e343548066bb6765bdd Mon Sep 17 00:00:00 2001 From: Chiara Date: Mon, 10 Jun 2024 11:26:45 +0100 Subject: [PATCH 04/12] Reformat enums for best practice, added examples in endpoints and list of ENUM choices in schema --- openapi.yml | 488 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 432 insertions(+), 56 deletions(-) diff --git a/openapi.yml b/openapi.yml index 401a3b5ea..4e19d4917 100644 --- a/openapi.yml +++ b/openapi.yml @@ -290,7 +290,36 @@ paths: minItems: 0 items: $ref: "#/components/schemas/Offence" - pagination: + examples: + successfulResponse: + summary: Example response with all properties and possible enum values + value: + data: + - serviceSource: NOMIS + systemSource: PRISON_SYSTEMS + cjsCode: RR84170 + courtDates: + - "2018-02-10" + - "2019-02-10" + courtName: "London Magistrates Court" + description: "Commit an act / series of acts with intent to pervert the course of public justice" + endDate: "2018-03-10" + hoCode: 06601 + startDate: "1965-12-01" + statuteCode: RR84 + - serviceSource: NDELIUS + systemSource: PROBATION_SYSTEMS + cjsCode: RR12345 + courtDates: + - "2020-05-15" + - "2021-05-15" + courtName: "Manchester Crown Court" + description: "Assault causing grievous bodily harm" + endDate: "2020-06-20" + hoCode: 06602 + startDate: "2020-05-10" + statuteCode: RR85 + pagination: $ref: "#/components/schemas/Pagination" "404": description: Failed to find offences a person with the provided HMPPS ID. @@ -908,6 +937,98 @@ paths: application/json: schema: $ref: "#/components/schemas/PersonLicencesData" + examples: + successfulResponse: + summary: Example response with all properties and possible enum values + value: + data: + hmppsId: "2008/0545166T" + offenderNumber: "Z1234ZZ" + licences: + - status: "IN_PROGRESS" + typeCode: "AP" + createdDate: "2015-09-23" + approvedDate: "2015-09-24" + updatedDate: "2015-10-23" + conditions: + - type: "Standard" + code: "5a105297-dce1-4d18-b9ea-4195b46b7594" + category: "Residence at a specific place" + condition: "You must reside at an approved address" + - type: "Custom" + code: "b457e9c3-68c6-4f5e-9bd8-c36c5b7e70fb" + category: "Contact Restrictions" + condition: "You must not contact the victim" + - status: "SUBMITTED" + typeCode: "PSS" + createdDate: "2016-01-15" + approvedDate: "2016-01-16" + updatedDate: "2016-02-15" + conditions: + - type: "Standard" + code: "5a105297-dce1-4d18-b9ea-4195b46b7594" + category: "Residence at a specific place" + condition: "You must reside at an approved address" + - status: "APPROVED" + typeCode: "AP_PSS" + createdDate: "2017-03-10" + approvedDate: "2017-03-11" + updatedDate: "2017-04-10" + conditions: + - type: "Standard" + code: "5a105297-dce1-4d18-b9ea-4195b46b7594" + category: "Residence at a specific place" + condition: "You must reside at an approved address" + - status: "ACTIVE" + typeCode: "AP" + createdDate: "2018-05-20" + approvedDate: "2018-05-21" + updatedDate: "2018-06-20" + conditions: + - type: "Custom" + code: "c97f33e3-1e50-4b28-8f71-5de3e2fbbf79" + category: "Travel Restrictions" + condition: "You must not leave the country without permission" + - status: "VARIATION_IN_PROGRESS" + typeCode: "PSS" + createdDate: "2019-07-01" + approvedDate: "2019-07-02" + updatedDate: "2019-08-01" + conditions: + - type: "Rehabilitation" + code: "a5371dd7-7f54-42b9-9c3b-35f9e8f6f1e9" + category: "Rehabilitation Program" + condition: "You must participate in a rehabilitation program" + - status: "VARIATION_SUBMITTED" + typeCode: "AP_PSS" + createdDate: "2020-09-12" + approvedDate: "2020-09-13" + updatedDate: "2020-10-12" + conditions: + - type: "Monitoring" + code: "e4a8b9cf-4a50-44a2-8a0c-5f38d2fae6f9" + category: "Electronic Monitoring" + condition: "You must comply with electronic monitoring" + - status: "VARIATION_APPROVED" + typeCode: "AP" + createdDate: "2021-11-23" + approvedDate: "2021-11-24" + updatedDate: "2021-12-23" + conditions: + - type: "Substance Abuse" + code: "d4b8b1e8-9e4e-4f6a-a2df-b41e8f8e8e8e" + category: "Alcohol Restrictions" + condition: "You must not consume alcohol" + - status: "VARIATION_REJECTED" + typeCode: "PSS" + createdDate: "2022-01-01" + approvedDate: "2022-01-02" + updatedDate: "2022-02-01" + conditions: + - type: "Association" + code: "f9e8f1c8-2f4a-4a6a-a1de-5e7e9f7d9e8f" + category: "Contact Restrictions" + condition: "You must not associate with known criminals" "404": description: Failed to find licenses for a person with the provided HMPPS ID. content: @@ -1393,7 +1514,10 @@ components: properties: status: type: integer - enum: [ 400, 404, 500 ] + enum: + - 400 + - 404 + - 500 errorCode: type: integer nullable: true @@ -1473,7 +1597,13 @@ components: view: type: string example: FACE - enum: [FACE, TAT, OTH, SCAR, MARK, OIC] + enum: + - FACE + - TAT + - OTH + - SCAR + - MARK + - OIC description: > 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. Options include: @@ -1486,7 +1616,30 @@ components: orientation: type: string example: FRONT - enum: [ANKLE, ARM, DAMAGE, EAR, ELBOW, FACE, FIGHT, FINGER, FOOT, FRONT, HAND, HEAD, INCIDENT, INJURY, KNEE, LEG, LIP, NECK, NOSE, SHOULDER, THIGH, TOE, TORSO] + enum: + - ANKLE + - ARM + - DAMAGE + - EAR + - ELBOW + - FACE + - FIGHT + - FINGER + - FOOT + - FRONT + - HAND + - HEAD + - INCIDENT + - INJURY + - KNEE + - LEG + - LIP + - NECK + - NOSE + - SHOULDER + - THIGH + - TOE + - TORSO description: > 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`). Options include: @@ -1516,7 +1669,11 @@ components: type: type: string example: OFF_BKG - enum: [OFF_BKG, OFF_IDM, OIC, PPTY] + enum: + - OFF_BKG + - OFF_IDM + - OIC + - PPTY description: > 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. Options include: @@ -1615,14 +1772,38 @@ components: properties: status: type: string + enum: + - IN_PROGRESS + - SUBMITTED + - APPROVED + - ACTIVE + - VARIATION_IN_PROGRESS + - VARIATION_SUBMITTED + - VARIATION_APPROVED + - VARIATION_REJECTED example: IN_PROGRESS - "enum": [ "IN_PROGRESS","SUBMITTED","APPROVED","ACTIVE","VARIATION_IN_PROGRESS","VARIATION_SUBMITTED","VARIATION_APPROVED","VARIATION_REJECTED" ] - description: Licence status + description: > + Licence status. Options include: + `IN_PROGRESS`, + `SUBMITTED`, + `APPROVED`, + `ACTIVE`, + `VARIATION_IN_PROGRESS`, + `VARIATION_SUBMITTED`, + `VARIATION_APPROVED`, + `VARIATION_REJECTED` typeCode: type: string example: AP - enum: [ "AP","PSS","AP_PSS" ] - description: The type of licence + enum: + - AP + - PSS + - AP_PSS + description: > + The type of licence. Options include: + `AP`, + `PSS`, + `AP_PSS` createdDate: type: string format: date @@ -1684,14 +1865,24 @@ components: properties: serviceSource: type: string - enum: [ NOMIS, NDELIUS ] + enum: + - NOMIS + - NDELIUS example: NOMIS - description: Which upstream API service the sentence originates from + description: > + Which upstream API service the sentence originates from. Options include: + `NOMIS`, + `NDELIUS` systemSource: type: string - enum: [ PRISON_SYSTEMS, PROBATION_SYSTEMS ] + enum: + - PRISON_SYSTEMS + - PROBATION_SYSTEMS example: PROBATION_SYSTEMS - description: Which upstream API system the sentence originates from + description: > + Which upstream API system the sentence originates from. Options include: + `PRISON_SYSTEMS`, + `PROBATION_SYSTEMS` cjsCode: type: string example: RR84170 @@ -2038,14 +2229,24 @@ components: properties: serviceSource: type: string - enum: [NOMIS, NDELIUS] + enum: + - NOMIS + - NDELIUS example: NOMIS - description: Which upstream API service the sentence originates from + description: > + Which upstream API service the sentence originates from. Options include: + `NOMIS`, + `NDELIUS` systemSource: type: string - enum: [ PRISON_SYSTEMS, PROBATION_SYSTEMS ] + enum: + - PRISON_SYSTEMS + - PROBATION_SYSTEMS example: PROBATION_SYSTEMS - description: Which upstream API system the sentence originates from + description: > + Which upstream API system the sentence originates from. Options include: + `PRISON_SYSTEMS`, + `PROBATION_SYSTEMS` dateOfSentencing: type: string format: date @@ -2168,9 +2369,18 @@ components: description: Release date for non-DTO sentence (if applicable). This will be based on one of ARD, CRD, NPD or PRRD. releaseDateType: type: string - enum: [ ARD, CRD, NPD, PRRD ] + enum: + - ARD + - CRD + - NPD + - PRRD example: ARD - description: Indicates which type of non-DTO release date is the effective release date. One of 'ARD', 'CRD', 'NPD' or 'PRRD'. + description: > + Indicates which type of non-DTO release date is the effective release date. One of 'ARD', 'CRD', 'NPD' or 'PRRD'. Options include: + `ARD`, + `CRD`, + `NPD`, + `PRRD` ReasonableAdjustment: type: object properties: @@ -2278,9 +2488,20 @@ components: description: Duration of the sentence units: type: string - enum: [Hours, Days, Weeks, Months, Years] + enum: + - Hours + - Days + - Weeks + - Months + - Years example: Hours - description: Time unit that is used in combination with the duration field + description: > + Time unit that is used in combination with the duration field. Options include: + `Hours`, + `Days`, + `Weeks`, + `Months`, + `Years` terms: type: array minItems: 0 @@ -2307,7 +2528,20 @@ components: description: Number of days in the term prisonTermCode: type: string - enum: [CUR, DEF, DET, HOURS, IMP, LIC, PSYCH, SCUS, SEC104, SEC105, SEC86, SUP, SUSP] + enum: + - CUR + - DEF + - DET + - HOURS + - IMP + - LIC + - PSYCH + - SCUS + - SEC104 + - SEC105 + - SEC86 + - SUP + - SUSP example: IMP description: > The sentence term code @@ -2374,9 +2608,14 @@ components: description: Risk scores calculation completion date assessmentStatus: type: string - enum: [ COMPLETE, LOCKED_INCOMPLETE ] + enum: + - COMPLETE + - LOCKED_INCOMPLETE example: COMPLETE - description: Whether the risk score calculation is complete + description: > + Whether the risk score calculation is complete. Options include: + `COMPLETE`, + `LOCKED_INCOMPLETE` groupReconviction: $ref: "#/components/schemas/GroupReconviction" violencePredictor: @@ -2392,7 +2631,12 @@ components: properties: scoreLevel: type: string - enum: [ LOW, MEDIUM, HIGH, VERY_HIGH, NOT_APPLICABLE ] + enum: + - LOW + - MEDIUM + - HIGH + - VERY_HIGH + - NOT_APPLICABLE example: LOW description: > Indicator for risk of group reconviction. Options include: @@ -2407,7 +2651,12 @@ components: properties: scoreLevel: type: string - enum: [ LOW, MEDIUM, HIGH, VERY_HIGH, NOT_APPLICABLE ] + enum: + - LOW + - MEDIUM + - HIGH + - VERY_HIGH + - NOT_APPLICABLE example: MEDIUM description: > Indicator for risk of violence. Options include: @@ -2422,7 +2671,12 @@ components: properties: scoreLevel: type: string - enum: [ LOW, MEDIUM, HIGH, VERY_HIGH, NOT_APPLICABLE ] + enum: + - LOW + - MEDIUM + - HIGH + - VERY_HIGH + - NOT_APPLICABLE example: VERY_HIGH description: > Indicator for general prediction. Options include: @@ -2437,7 +2691,12 @@ components: properties: scoreLevel: type: string - enum: [ LOW, MEDIUM, HIGH, VERY_HIGH, NOT_APPLICABLE ] + enum: + - LOW + - MEDIUM + - HIGH + - VERY_HIGH + - NOT_APPLICABLE example: MEDIUM description: > Indicator for risk of serious recidivism. Options include: @@ -2452,7 +2711,12 @@ components: properties: indecentScoreLevel: type: string - enum: [ LOW, MEDIUM, HIGH, VERY_HIGH, NOT_APPLICABLE ] + enum: + - LOW + - MEDIUM + - HIGH + - VERY_HIGH + - NOT_APPLICABLE example: HIGH description: > Indicator for risk of sexual indecency. Options include: @@ -2463,7 +2727,12 @@ components: `NOT_APPLICABLE`, contactScoreLevel: type: string - enum: [ LOW, MEDIUM, HIGH, VERY_HIGH, NOT_APPLICABLE ] + enum: + - LOW + - MEDIUM + - HIGH + - VERY_HIGH + - NOT_APPLICABLE example: MEDIUM description: > Indicator for risk of sexual contact. Options include: @@ -2506,22 +2775,49 @@ components: risk: type: string example: "YES" - enum: [ YES, NO, DK, NA ] - description: Presence of risk + enum: + - YES + - NO + - DK + - NA + description: > + Presence of risk. Options include: + `YES`, + `NO`, + `DK`, + `NA` previous: type: string example: "NO" - enum: [ YES, NO, DK, NA ] - description: Previous concerns + enum: + - YES + - NO + - DK + - NA + description: > + Previous concerns. Options include: + `YES`, + `NO`, + `DK`, + `NA` previousConcernsText: type: string example: "Risk of self harm concerns due to ..." - description: Supporting comments for any previous concerns + description: Supporting comments for any previous concerns. current: type: string example: "YES" - enum: [ YES, NO, DK, NA ] - description: Current concerns + enum: + - YES + - NO + - DK + - NA + description: > + Current concerns. Options include: + `YES`, + `NO`, + `DK`, + `NA` currentConcernsText: type: string example: "Risk of self harm concerns due to ..." @@ -2591,23 +2887,59 @@ components: escapeOrAbscond: type: string example: "YES" - enum: [ YES, NO, DK, NA ] - description: Risk of escape/abscond + enum: + - YES + - NO + - DK + - NA + description: > + Risk of escape/abscond. Options include: + `YES`, + `NO`, + `DK`, + `NA` controlIssuesDisruptiveBehaviour: type: string example: "DK" - enum: [ YES, NO, DK, NA ] - description: Risk control issues/disruptive behaviour + enum: + - YES + - NO + - DK + - NA + description: > + Risk control issues/disruptive behaviour. Options include: + `YES`, + `NO`, + `DK`, + `NA` breachOfTrust: type: string example: "NO" - enum: [ YES, NO, DK, NA ] - description: Risk of breach of trust + enum: + - YES + - NO + - DK + - NA + description: > + Risk of breach of trust. Options include: + `YES`, + `NO`, + `DK`, + `NA` riskToOtherPrisoners: type: string example: "YES" - enum: [ YES, NO, DK, NA ] - description: Risk to other prisoners + enum: + - YES + - NO + - DK + - NA + description: > + Risk to other prisoners. Options include: + `YES`, + `NO`, + `DK`, + `NA` Summary: type: object properties: @@ -2634,7 +2966,11 @@ components: overallRiskLevel: type: string example: HIGH - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW description: The overall risk level riskInCommunity: type: object @@ -2644,23 +2980,43 @@ components: children: type: string example: HIGH - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW public: type: string example: Medium - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW knownAdult: type: string example: VERY_HIGH - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW staff: type: string example: HIGH - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW prisoners: type: string example: LOW - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW riskInCustody: type: object description: > @@ -2669,23 +3025,43 @@ components: children: type: string example: HIGH - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW public: type: string example: Medium - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW knownAdult: type: string example: VERY_HIGH - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW staff: type: string example: HIGH - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW prisoners: type: string example: LOW - enum: [ VERY_HIGH, HIGH, MEDIUM, LOW ] + enum: + - VERY_HIGH + - HIGH + - MEDIUM + - LOW Needs: type: object properties: From 2b56e70a60d51e5abe6e2554525fc7683efd5b07 Mon Sep 17 00:00:00 2001 From: Chiara Date: Mon, 10 Jun 2024 14:41:09 +0100 Subject: [PATCH 05/12] Examples --- openapi.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openapi.yml b/openapi.yml index 4e19d4917..c714d0d3c 100644 --- a/openapi.yml +++ b/openapi.yml @@ -1236,11 +1236,13 @@ components: code: type: string example: BUS - description: Address type code + description: > + Address type code, for example: `BUS`. description: type: string example: Business Address - description: Description of address type + description: > + Description of address type, for example `Business Address`. Adjudication: type: object properties: From 421dc6ca4030fd4491e082fe0a3d41cdec094c88 Mon Sep 17 00:00:00 2001 From: Chiara Date: Mon, 10 Jun 2024 15:09:46 +0100 Subject: [PATCH 06/12] Examples --- openapi.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openapi.yml b/openapi.yml index c714d0d3c..2366d6146 100644 --- a/openapi.yml +++ b/openapi.yml @@ -1226,7 +1226,8 @@ components: minItems: 0 items: $ref: "#/components/schemas/AddressType" - description: Type or usage of address + description: < + Type or usage of address, for example `Business Address`, `Home Address`, `Work Address`. notes: type: string example: This is their partner's address. @@ -1237,7 +1238,7 @@ components: type: string example: BUS description: > - Address type code, for example: `BUS`. + Address type code, for example: `BUS`, `HOME`, `WORK`. description: type: string example: Business Address From 1ff2199b139746d8876ac7e3e53451c598bb2b25 Mon Sep 17 00:00:00 2001 From: Chiara Date: Mon, 10 Jun 2024 15:19:45 +0100 Subject: [PATCH 07/12] More examples --- openapi.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openapi.yml b/openapi.yml index 2366d6146..d5adde308 100644 --- a/openapi.yml +++ b/openapi.yml @@ -2049,6 +2049,8 @@ components: properties: name: type: string + example: "Manchester Crown Court" + description: The name of the court. PersonResponsibleOfficerTeam: type: object properties: @@ -2161,6 +2163,7 @@ components: code: type: string nullable: true + description: The prison code, which is usually short for the prison name. PrisonOffenderManager: type: object properties: From cd65092e5e1b6f2af2b3a27e28de74701e13283c Mon Sep 17 00:00:00 2001 From: Chiara Date: Tue, 11 Jun 2024 09:19:36 +0100 Subject: [PATCH 08/12] Examples --- openapi.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openapi.yml b/openapi.yml index d5adde308..f573d0172 100644 --- a/openapi.yml +++ b/openapi.yml @@ -2372,7 +2372,9 @@ components: type: string format: date example: 2023-03-01 - description: Release date for non-DTO sentence (if applicable). This will be based on one of ARD, CRD, NPD or PRRD. + description: > + Release date for non-DTO sentence (if applicable). This will be based on one of ARD, CRD, NPD or PRRD. + NonDto stands for Non-Detention training order. releaseDateType: type: string enum: From cf4959100df48aabc3da15695381e963d918a611 Mon Sep 17 00:00:00 2001 From: Chiara Date: Wed, 12 Jun 2024 10:33:11 +0100 Subject: [PATCH 09/12] Removed sorted query --- openapi.yml | 65 +---------------------------------------------------- 1 file changed, 1 insertion(+), 64 deletions(-) diff --git a/openapi.yml b/openapi.yml index f573d0172..13bfe9af7 100644 --- a/openapi.yml +++ b/openapi.yml @@ -44,14 +44,7 @@ paths: type: boolean default: false required: false - description: Whether to return results that match the search criteria within the aliases of a person - - name: sortBy - in: query - description: | - Specifies the field to sort the persons by. - schema: - type: string - default: dateOfBirth + description: Whether to return results that match the search criteria within the aliases of a person, sorted by date of birth. - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" responses: @@ -138,13 +131,6 @@ paths: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" - - name: sortBy - in: query - description: | - Specifies the field to sort the persons by. - schema: - type: string - default: captureDateTime responses: "200": description: > @@ -350,13 +336,6 @@ paths: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" - - name: sortBy - in: query - description: | - Specifies the field to sort the alerts by. - schema: - type: string - default: dateCreated responses: "200": description: Successfully found alerts for a person with the provided HMPPS ID. @@ -401,13 +380,6 @@ paths: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" - - name: sortBy - in: query - description: | - Specifies the field to sort the PND alerts by. - schema: - type: string - default: dateCreated responses: "200": description: Successfully found alerts for a person with the provided HMPPS ID. @@ -451,13 +423,6 @@ paths: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" - - name: sortBy - in: query - description: | - Specifies the field to sort the alerts by. - schema: - type: string - default: dateOfSentencing responses: "200": description: Successfully found sentences for a person with the provided HMPPS ID. @@ -537,13 +502,6 @@ paths: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" - $ref: "#/components/parameters/perPage" - - name: sortBy - in: query - description: | - Specifies the field to sort the alerts by. - schema: - type: string - default: completedDate responses: "200": description: Successfully found risk scores for a person with the provided HMPPS ID. @@ -585,13 +543,6 @@ paths: summary: Returns the categories related to an offender. parameters: - $ref: "#/components/parameters/hmppsId" - - name: sortBy - in: query - description: | - Specifies the field to sort the alerts by. - schema: - type: string - default: assessmentDate responses: "200": description: Successfully found risk categories for a person with the provided HMPPS ID. @@ -704,13 +655,6 @@ paths: 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. parameters: - $ref: "#/components/parameters/hmppsId" - - name: sortBy - in: query - description: | - Specifies the field to sort the alerts by. - schema: - type: string - default: assessedOn responses: "200": description: Successfully found criminogenic needs for a person with the provided HMPPS ID. @@ -1071,13 +1015,6 @@ paths: required: false description: Filter by the location. example MDI - $ref: "#/components/parameters/hmppsId" - - name: sortBy - in: query - description: | - Specifies the field to sort the alerts by. - schema: - type: string - default: CreatDateTime responses: "200": description: Successfully found case notes for a person with the provided HMPPS ID. From 1715d0fa47cb1a496b0cfbee5930b608a864e75b Mon Sep 17 00:00:00 2001 From: Chiara Date: Wed, 12 Jun 2024 11:23:42 +0100 Subject: [PATCH 10/12] Sorting --- .../hmppsintegrationapi/gateways/AdjudicationsGateway.kt | 6 +++++- .../gateways/AssessRisksAndNeedsGateway.kt | 2 +- .../hmpps/hmppsintegrationapi/gateways/NomisGateway.kt | 8 ++++---- .../gateways/PrisonerOffenderSearchGateway.kt | 2 +- .../gateways/ProbationOffenderSearchGateway.kt | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AdjudicationsGateway.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AdjudicationsGateway.kt index 70e018dc0..adfa92354 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AdjudicationsGateway.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AdjudicationsGateway.kt @@ -30,7 +30,11 @@ class AdjudicationsGateway( return when (result) { is WebClientWrapper.WebClientWrapperResponse.Success -> { - Response(data = result.data.map { it.toAdjudication() }) + Response( + data = result.data + .map { it.toAdjudication() } + .sortedBy { it.incidentDetails?.dateTimeOfIncident } + ) } is WebClientWrapper.WebClientWrapperResponse.Error -> { diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AssessRisksAndNeedsGateway.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AssessRisksAndNeedsGateway.kt index feff5a6cd..49c1e39c0 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AssessRisksAndNeedsGateway.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AssessRisksAndNeedsGateway.kt @@ -35,7 +35,7 @@ class AssessRisksAndNeedsGateway( return when (result) { is WebClientWrapperResponse.Success -> { - Response(data = result.data.map { it.toRiskPredictorScore() }) + Response(data = result.data.map { it.toRiskPredictorScore() }.sortedBy { it.completedDate }) } is WebClientWrapperResponse.Error -> { diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/NomisGateway.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/NomisGateway.kt index d1cfbc0c4..01345918d 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/NomisGateway.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/NomisGateway.kt @@ -89,7 +89,7 @@ class NomisGateway( return when (result) { is WebClientWrapperResponse.Success -> { - Response(data = result.data.map { it.toAddress() }) + Response(data = result.data.map { it.toAddress() }.sortedBy { it.startDate }) } is WebClientWrapperResponse.Error -> { @@ -111,7 +111,7 @@ class NomisGateway( ) return when (result) { is WebClientWrapperResponse.Success -> { - Response(data = result.data.map { it.toOffence() }) + Response(data = result.data.map { it.toOffence() }.sortedBy { it.startDate }) } is WebClientWrapperResponse.Error -> { @@ -133,7 +133,7 @@ class NomisGateway( ) return when (result) { is WebClientWrapperResponse.Success -> { - Response(data = result.data.map { it.toAlert() }) + Response(data = result.data.map { it.toAlert() }.sortedBy { it.dateCreated }) } is WebClientWrapperResponse.Error -> { @@ -155,7 +155,7 @@ class NomisGateway( ) return when (result) { is WebClientWrapperResponse.Success -> { - Response(data = result.data.map { it.toSentence() }) + Response(data = result.data.map { it.toSentence() }.sortedBy { it.dateOfSentencing }) } is WebClientWrapperResponse.Error -> { diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/PrisonerOffenderSearchGateway.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/PrisonerOffenderSearchGateway.kt index 2f997f4cc..d58594db1 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/PrisonerOffenderSearchGateway.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/PrisonerOffenderSearchGateway.kt @@ -43,7 +43,7 @@ class PrisonerOffenderSearchGateway( return when (result) { is WebClientWrapperResponse.Success -> { - Response(data = result.data.content.map { it.toPerson() }) + Response(data = result.data.content.map { it.toPerson() }.sortedBy { it.dateOfBirth }) } is WebClientWrapperResponse.Error -> { diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/ProbationOffenderSearchGateway.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/ProbationOffenderSearchGateway.kt index 4f82d4e24..01d750c17 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/ProbationOffenderSearchGateway.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/ProbationOffenderSearchGateway.kt @@ -104,7 +104,7 @@ class ProbationOffenderSearchGateway( return when (result) { is WebClientWrapperResponse.Success -> { Response( - data = result.data.map { it.toPerson() }, + result.data.map { it.toPerson() }.sortedBy { it.dateOfBirth }, ) } is WebClientWrapperResponse.Error -> { From e8f7c4ed292dafeb1b7c69744b90b0bd6435b6d7 Mon Sep 17 00:00:00 2001 From: Chiara Date: Wed, 12 Jun 2024 11:25:43 +0100 Subject: [PATCH 11/12] Lint --- .../hmppsintegrationapi/gateways/AdjudicationsGateway.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AdjudicationsGateway.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AdjudicationsGateway.kt index adfa92354..0524d4717 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AdjudicationsGateway.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/AdjudicationsGateway.kt @@ -31,9 +31,10 @@ class AdjudicationsGateway( return when (result) { is WebClientWrapper.WebClientWrapperResponse.Success -> { Response( - data = result.data - .map { it.toAdjudication() } - .sortedBy { it.incidentDetails?.dateTimeOfIncident } + data = + result.data + .map { it.toAdjudication() } + .sortedBy { it.incidentDetails?.dateTimeOfIncident }, ) } From ebf5d843d5cac0ac6f36ca99875ae8260eb4eae6 Mon Sep 17 00:00:00 2001 From: Chiara Date: Wed, 12 Jun 2024 11:37:37 +0100 Subject: [PATCH 12/12] Sorting --- openapi.yml | 20 +++++++++---------- .../gateways/CreateAndVaryLicenceGateway.kt | 3 ++- .../caseNotes/CaseNotesGatewayTest.kt | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/openapi.yml b/openapi.yml index 13bfe9af7..7aaa6b560 100644 --- a/openapi.yml +++ b/openapi.yml @@ -12,7 +12,7 @@ paths: get: tags: - persons - summary: Returns person(s) by search criteria. At least one query parameter must be specified. + summary: Returns person(s) by search criteria, sorted by date of birth. At least one query parameter must be specified. parameters: - in: query name: first_name @@ -126,7 +126,7 @@ paths: get: tags: - persons - summary: Returns metadata of images associated with a person ordered by newest to oldest date. + summary: Returns metadata of images associated with a person sorted by captureDateTime. parameters: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" @@ -210,7 +210,7 @@ paths: get: tags: - persons - summary: Returns addresses associated with a person. + summary: Returns addresses associated with a person, ordered by startDate. parameters: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" @@ -254,7 +254,7 @@ paths: tags: - persons summary: > - Returns offences associated with a person. + Returns offences associated with a person, ordered by startDate. Note: This API does not contain the complete list of offences for a person. Offences are retrieved from Prison and Probation systems exclusively. @@ -331,7 +331,7 @@ paths: tags: - persons - alerts - summary: Returns alerts associated with a person. + summary: Returns alerts associated with a person, sorted by dateCreated. parameters: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" @@ -375,7 +375,7 @@ paths: tags: - persons - alerts - summary: Returns alerts associated with a person. + summary: Returns alerts associated with a person, sorted by dateCreated. parameters: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" @@ -418,7 +418,7 @@ paths: get: tags: - persons - summary: Returns sentences associated with a person. + summary: Returns sentences associated with a person, sorted by dateOfSentencing. parameters: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" @@ -497,7 +497,7 @@ paths: get: tags: - risks - summary: Returns risk scores from the last year associated with a person. + summary: Returns risk scores from the last year associated with a person, sorted by completedDate. parameters: - $ref: "#/components/parameters/hmppsId" - $ref: "#/components/parameters/page" @@ -802,7 +802,7 @@ paths: /v1/persons/{hmppsId}/adjudications: get: - summary: Returns adjudications associated with a person. + summary: Returns adjudications associated with a person, sorted by dateTimeOfIncident. parameters: - name: hmppsId in: path @@ -871,7 +871,7 @@ paths: /v1/persons/{hmppsId}/licences/conditions: get: - summary: Returns license conditions associated with a person. + summary: Returns license conditions associated with a person, sorted by createdDateTime. parameters: - $ref: "#/components/parameters/hmppsId" responses: diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/CreateAndVaryLicenceGateway.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/CreateAndVaryLicenceGateway.kt index 834425dbc..d137c2c77 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/CreateAndVaryLicenceGateway.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/CreateAndVaryLicenceGateway.kt @@ -33,7 +33,8 @@ class CreateAndVaryLicenceGateway( return when (result) { is WebClientWrapperResponse.Success -> { - Response(data = result.data.map { it.toLicence() }) + val sortedLicences = result.data.sortedBy { it.createdDateTime } + Response(data = sortedLicences.map { it.toLicence() }) } is WebClientWrapperResponse.Error -> { diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/caseNotes/CaseNotesGatewayTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/caseNotes/CaseNotesGatewayTest.kt index e414241e0..87f04cb60 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/caseNotes/CaseNotesGatewayTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/caseNotes/CaseNotesGatewayTest.kt @@ -28,7 +28,7 @@ import java.time.LocalDateTime ) class CaseNotesGatewayTest( @MockBean val hmppsAuthGateway: HmppsAuthGateway, - val caseNotesGateway: CaseNotesGateway, + private val caseNotesGateway: CaseNotesGateway, ) : DescribeSpec( {