From 31ded69a01498401c5c17fdef6e0f3f8f9bb835d Mon Sep 17 00:00:00 2001 From: pmcphee77 <150798161+pmcphee77@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:43:02 +0100 Subject: [PATCH] PI-2300: Changed Registration types to cater for different examples (#3958) --- .../digital/hmpps/model/Registration.kt | 12 ++++++++++- .../hmpps/model/SupervisionResponse.kt | 4 ++-- .../hmpps/service/CaseDetailsService.kt | 20 +++++++++++++++---- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/Registration.kt b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/Registration.kt index 9f3cc15061..fcc20570a9 100644 --- a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/Registration.kt +++ b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/Registration.kt @@ -3,7 +3,7 @@ package uk.gov.justice.digital.hmpps.model import io.swagger.v3.oas.annotations.media.Schema import java.time.LocalDate -data class Registration( +data class DynamicRiskRegistration( @Schema(example = "RCCO") val code: String, @Schema(example = "Child Concerns") @@ -11,4 +11,14 @@ data class Registration( val startDate: LocalDate, val reviewDate: LocalDate?, val notes: String? +) + +data class PersonStatusRegistration( + @Schema(example = "ASFO") + val code: String, + @Schema(example = "Serious Further Offence - Subject to SFO review/investigation") + val description: String, + val startDate: LocalDate, + val reviewDate: LocalDate?, + val notes: String? ) \ No newline at end of file diff --git a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/SupervisionResponse.kt b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/SupervisionResponse.kt index c6798af99f..31a0bbdb9a 100644 --- a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/SupervisionResponse.kt +++ b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/SupervisionResponse.kt @@ -4,8 +4,8 @@ data class SupervisionResponse( val communityManager: Manager, val mappaDetail: MappaDetail?, val supervisions: List, - val dynamicRisks: List, - val personStatus: List + val dynamicRisks: List, + val personStatus: List ) data class Manager( diff --git a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CaseDetailsService.kt b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CaseDetailsService.kt index ed89352e49..95e4689607 100644 --- a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CaseDetailsService.kt +++ b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CaseDetailsService.kt @@ -24,8 +24,10 @@ class CaseDetailsService( communityManager = toCommunityManagerResponse(), mappaDetail = registrationRepository.findMappa(person.id).toMappaResponse(), supervisions = eventRepository.findByPersonIdOrderByConvictionDateDesc(person.id).toSupervisionResponse(), - dynamicRisks = registrationRepository.findDynamicRiskRegistrations(person.id).toRegistrationResponse(), - personStatus = registrationRepository.findPersonStatusRegistrations(person.id).toRegistrationResponse(), + dynamicRisks = registrationRepository.findDynamicRiskRegistrations(person.id) + .toDynamicRiskRegistrationResponse(), + personStatus = registrationRepository.findPersonStatusRegistrations(person.id) + .toPersonStatusRegistrationResponse(), ) } @@ -66,8 +68,18 @@ class CaseDetailsService( ) } - private fun List.toRegistrationResponse() = this.map { - Registration( + private fun List.toDynamicRiskRegistrationResponse() = this.map { + DynamicRiskRegistration( + code = it.type.code, + description = it.type.description, + startDate = it.date, + reviewDate = it.reviewDate, + notes = it.notes + ) + } + + private fun List.toPersonStatusRegistrationResponse() = this.map { + PersonStatusRegistration( code = it.type.code, description = it.type.description, startDate = it.date,