Skip to content

Commit

Permalink
PI-1991: Added further gender info and surface contact id (#3476)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcphee77 authored Mar 15, 2024
1 parent ee95234 commit a2af4cb
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class DataLoader(
PersonDetailsGenerator.RELIGION_DEFAULT,
PersonDetailsGenerator.SEXUAL_ORIENTATION,
PersonDetailsGenerator.LANGUAGE_RD,
PersonDetailsGenerator.GENDER_IDENTITY_RD,
PersonDetailsGenerator.PERSONAL_DETAILS,
PersonDetailsGenerator.DISABILITY_1_RD,
PersonDetailsGenerator.DISABILITY_2_RD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ object PersonGenerator {
preferredName = preferredName,
pnc = "pnc",
religion = null,
sexualOrientation = null
sexualOrientation = null,
genderIdentity = null,
genderIdentityDescription = null
)

fun generateRequirement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ object PersonDetailsGenerator {
val RELIGION_DEFAULT = ReferenceData(IdGenerator.getAndIncrement(), "C", "Christian")
val SEXUAL_ORIENTATION = ReferenceData(IdGenerator.getAndIncrement(), "H", "Heterosexual")
val LANGUAGE_RD = ReferenceData(IdGenerator.getAndIncrement(), "E", "Arabic")
val GENDER_IDENTITY_RD = ReferenceData(IdGenerator.getAndIncrement(), "GI", "Test Gender Identity")

val PERSONAL_DETAILS = generatePersonDetails(
"X000005", "Caroline",
"Louise", "Bloggs", "Caz", GENDER_FEMALE, RELIGION_DEFAULT,
SEXUAL_ORIENTATION, LANGUAGE_RD, "Smith"
SEXUAL_ORIENTATION, LANGUAGE_RD, "Smith", GENDER_IDENTITY_RD, "Some gender description"
)

val ALIAS_1 = generateAlias("Sam", "Edward", "Smith", PERSONAL_DETAILS.id)
Expand Down Expand Up @@ -211,7 +212,7 @@ object PersonDetailsGenerator {
fun generatePersonDetails(
crn: String, forename: String, secondName: String, surname: String, preferredName: String,
gender: ReferenceData, religion: ReferenceData, sexualOrientation: ReferenceData, language: ReferenceData,
previousSurname: String
previousSurname: String, genderIdentity: ReferenceData, genderIdentityDescription: String
) = Person(
id = IdGenerator.getAndIncrement(),
crn = crn,
Expand All @@ -228,7 +229,9 @@ object PersonDetailsGenerator {
religion = religion,
sexualOrientation = sexualOrientation,
language = language,
previousSurname = previousSurname
previousSurname = previousSurname,
genderIdentity = genderIdentity,
genderIdentityDescription = genderIdentityDescription
)

fun generateDocument(personId: Long, alfrescoId: String, name: String, documentType: String) = PersonDocument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ internal class PersonalDetailsIntegrationTest {
assertThat(res.otherAddressCount, equalTo(1))
assertThat(res.previousAddressCount, equalTo(1))
assertThat(res.contacts.size, equalTo(1))
assertThat(res.contacts[0].contactId, equalTo(PERSONAL_CONTACT_1.id))
assertThat(res.contacts[0].name, equalTo(Name("Sam", "Steven", "Smith")))
assertThat(res.contacts[0].address?.postcode, equalTo("NE1 56A"))
assertThat(res.contacts[0].relationship, equalTo("Brother"))
Expand All @@ -79,6 +80,8 @@ internal class PersonalDetailsIntegrationTest {
assertThat(res.documents[0].id, equalTo("A001"))
assertThat(res.documents[1].id, equalTo("A002"))
assertThat(res.aliases[0].forename, equalTo(ALIAS_1.forename))
assertThat(res.genderIdentity, equalTo("Test Gender Identity"))
assertThat(res.selfDescribedGender, equalTo("Some gender description"))
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import uk.gov.justice.digital.hmpps.api.model.PersonSummary

data class PersonalContact(
val personSummary: PersonSummary,
val contactId: Long,
val name: Name,
val relationship: String?,
val relationshipType: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ data class PersonalDetails(
val preferredName: String?,
val previousSurname: String?,
val preferredLanguage: String?,
val genderIdentity: String?,
val selfDescribedGender: String?,
val aliases: List<Name>,
val telephoneNumber: String?,
val mobileNumber: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class Person(
@JoinColumn(name = "sexual_orientation_id")
val sexualOrientation: ReferenceData?,

@ManyToOne
@JoinColumn(name = "gender_identity_id")
val genderIdentity: ReferenceData?,

val genderIdentityDescription: String?,

@Column(columnDefinition = "number")
val softDeleted: Boolean = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ class PersonalDetailsService(
email = person.emailAddress,
preferredLanguage = person.language?.description,
previousSurname = person.previousSurname,
aliases = aliases.map { Name(forename = it.forename, middleName = it.secondName, it.surname) }
aliases = aliases.map { Name(forename = it.forename, middleName = it.secondName, it.surname) },
genderIdentity = person.genderIdentity?.description,
selfDescribedGender = person.genderIdentityDescription
)
}

Expand Down Expand Up @@ -114,7 +116,8 @@ fun PersonalContactEntity.toContact() = PersonalContact(
relationship = relationship,
address = address.toAddress(),
notes = notes,
relationshipType = relationshipType.description
relationshipType = relationshipType.description,
contactId = id
)

fun Person.toSummary() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ internal class PersonalDetailsControllerTest {
sexualOrientation = "Heterosexual",
previousSurname = "Smith",
preferredLanguage = "English",
aliases = emptyList()
aliases = emptyList(),
genderIdentity = null,
selfDescribedGender = null
)
whenever(personalDetailsService.getPersonalDetails(crn)).thenReturn(personalDetails)
val res = controller.getPersonalDetails("X000005")
Expand Down

0 comments on commit a2af4cb

Please sign in to comment.