diff --git a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt index 5c6b386a6b..58b635a65b 100644 --- a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt +++ b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/DataLoader.kt @@ -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, diff --git a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.kt b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.kt index cff3a660cf..95b2dbdf2d 100644 --- a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.kt +++ b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/PersonGenerator.kt @@ -206,7 +206,9 @@ object PersonGenerator { preferredName = preferredName, pnc = "pnc", religion = null, - sexualOrientation = null + sexualOrientation = null, + genderIdentity = null, + genderIdentityDescription = null ) fun generateRequirement( diff --git a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/personalDetails/PersonDetailsGenerator.kt b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/personalDetails/PersonDetailsGenerator.kt index dbf8b41908..981b4ad482 100644 --- a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/personalDetails/PersonDetailsGenerator.kt +++ b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/personalDetails/PersonDetailsGenerator.kt @@ -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) @@ -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, @@ -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( diff --git a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PersonalDetailsIntegrationTest.kt b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PersonalDetailsIntegrationTest.kt index 7d6b4eaf48..4b889c1700 100644 --- a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PersonalDetailsIntegrationTest.kt +++ b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/PersonalDetailsIntegrationTest.kt @@ -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")) @@ -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 diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalContact.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalContact.kt index a60a497c20..ad4e4bd322 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalContact.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalContact.kt @@ -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, diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalDetails.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalDetails.kt index f893c2f711..0a538ecbc9 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalDetails.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/personalDetails/PersonalDetails.kt @@ -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, val telephoneNumber: String?, val mobileNumber: String?, diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt index 7da394d042..836fdfb66a 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Person.kt @@ -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 diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsService.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsService.kt index ddd8640bab..a090304752 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsService.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/PersonalDetailsService.kt @@ -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 ) } @@ -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() = diff --git a/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsControllerTest.kt b/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsControllerTest.kt index 1725a8b6e4..05b535258b 100644 --- a/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsControllerTest.kt +++ b/projects/manage-supervision-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/api/controller/PersonalDetailsControllerTest.kt @@ -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")