Skip to content

Commit

Permalink
PI-2300: Changed Registration types to cater for different examples (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcphee77 authored Jul 1, 2024
1 parent 69de270 commit 31ded69
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@ 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")
val description: String,
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?
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ data class SupervisionResponse(
val communityManager: Manager,
val mappaDetail: MappaDetail?,
val supervisions: List<Supervision>,
val dynamicRisks: List<Registration>,
val personStatus: List<Registration>
val dynamicRisks: List<DynamicRiskRegistration>,
val personStatus: List<PersonStatusRegistration>
)

data class Manager(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
}

Expand Down Expand Up @@ -66,8 +68,18 @@ class CaseDetailsService(
)
}

private fun List<RegistrationEntity>.toRegistrationResponse() = this.map {
Registration(
private fun List<RegistrationEntity>.toDynamicRiskRegistrationResponse() = this.map {
DynamicRiskRegistration(
code = it.type.code,
description = it.type.description,
startDate = it.date,
reviewDate = it.reviewDate,
notes = it.notes
)
}

private fun List<RegistrationEntity>.toPersonStatusRegistrationResponse() = this.map {
PersonStatusRegistration(
code = it.type.code,
description = it.type.description,
startDate = it.date,
Expand Down

0 comments on commit 31ded69

Please sign in to comment.