Skip to content

Commit

Permalink
PI-1991: Surfaced offender id for deep links to delius (#3494)
Browse files Browse the repository at this point in the history
* PI-1991: Surfaced offender id for deep links to delius
* PI-1991: Make address type optional
  • Loading branch information
pmcphee77 authored Mar 18, 2024
1 parent 04d005f commit 917cd96
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.time.LocalDate
data class PersonSummary(
val name: Name,
val crn: String,
val offenderId: Long,
val pnc: String?,
val dateOfBirth: LocalDate
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PersonAddress(

@ManyToOne
@JoinColumn(name = "address_type_id")
val type: ReferenceData,
val type: ReferenceData?,

@Column(name = "building_name")
val buildingName: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ fun PersonalContactEntity.toContact() = PersonalContact(
)

fun Person.toSummary() =
PersonSummary(name = Name(forename, secondName, surname), pnc = pnc, dateOfBirth = dateOfBirth, crn = crn)
PersonSummary(
name = Name(forename, secondName, surname),
pnc = pnc,
dateOfBirth = dateOfBirth,
crn = crn,
offenderId = id
)

fun Person.name() = Name(forename, listOfNotNull(secondName, thirdName).joinToString(" "), surname)
fun PersonAddress.toAddress() = Address.from(
Expand All @@ -201,7 +207,7 @@ fun PersonAddress.toAddress() = Address.from(
verified = typeVerified,
lastUpdated = lastUpdated,
status = status.description,
type = type.description,
type = type?.description,
telephoneNumber = telephoneNumber,
lastUpdatedBy = Name(forename = lastUpdatedUser.forename, surname = lastUpdatedUser.surname)

Expand All @@ -220,4 +226,5 @@ fun ContactAddress.toAddress() = uk.gov.justice.digital.hmpps.api.model.personal
)

fun PersonDocument.toDocument() = Document(id = alfrescoId, name = name, lastUpdated = lastUpdated)
fun PersonSummaryEntity.toPersonSummary() = PersonSummary(Name(forename, secondName, surname), crn, pnc, dateOfBirth)
fun PersonSummaryEntity.toPersonSummary() =
PersonSummary(Name(forename, secondName, surname), crn, id, pnc, dateOfBirth)
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal class PersonalDetailsControllerTest {
personSummary = PersonSummary(
Name(forename = "TestName", middleName = null, surname = "TestSurname"), pnc = "Test PNC",
crn = "CRN",
dateOfBirth = LocalDate.now(),
dateOfBirth = LocalDate.now(), offenderId = 1L
)
}

Expand Down

0 comments on commit 917cd96

Please sign in to comment.