Skip to content

Commit

Permalink
PI-1915: Added probation-case/crn endpoint (#3740)
Browse files Browse the repository at this point in the history
* PI-1915: Added probation-case/crn endpoint
  • Loading branch information
pmcphee77 authored May 14, 2024
1 parent 502977e commit e45f1e8
Show file tree
Hide file tree
Showing 13 changed files with 827 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,7 @@ import org.springframework.context.ApplicationListener
import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Transactional
import uk.gov.justice.digital.hmpps.api.model.DocumentType
import uk.gov.justice.digital.hmpps.data.generator.BoroughGenerator
import uk.gov.justice.digital.hmpps.data.generator.BusinessInteractionGenerator
import uk.gov.justice.digital.hmpps.data.generator.ContactTypeGenerator
import uk.gov.justice.digital.hmpps.data.generator.CourtCaseNoteGenerator
import uk.gov.justice.digital.hmpps.data.generator.DistrictGenerator
import uk.gov.justice.digital.hmpps.data.generator.DocumentEntityGenerator
import uk.gov.justice.digital.hmpps.data.generator.IdGenerator
import uk.gov.justice.digital.hmpps.data.generator.LDUGenerator
import uk.gov.justice.digital.hmpps.data.generator.PersonGenerator
import uk.gov.justice.digital.hmpps.data.generator.ProviderGenerator
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator
import uk.gov.justice.digital.hmpps.data.generator.SentenceGenerator
import uk.gov.justice.digital.hmpps.data.generator.StaffGenerator
import uk.gov.justice.digital.hmpps.data.generator.TeamGenerator
import uk.gov.justice.digital.hmpps.data.generator.UserGenerator
import uk.gov.justice.digital.hmpps.data.generator.*
import uk.gov.justice.digital.hmpps.integrations.delius.event.courtappearance.entity.Outcome
import uk.gov.justice.digital.hmpps.user.AuditUserRepository
import java.time.LocalDate
Expand Down Expand Up @@ -58,10 +44,7 @@ class DataLoader(
SentenceGenerator.ADDITIONAL_OFFENCE,
BusinessInteractionGenerator.UPDATE_CONTACT,
ContactTypeGenerator.CONTACT_TYPE,
PersonGenerator.NEW_TO_PROBATION,
PersonGenerator.CURRENTLY_MANAGED,
PersonGenerator.PREVIOUSLY_MANAGED,
PersonGenerator.NO_SENTENCE,

ReferenceDataGenerator.DISPOSAL_TYPE,
ReferenceDataGenerator.LENGTH_UNITS,
ReferenceDataGenerator.TERMINATION_REASON,
Expand All @@ -76,7 +59,29 @@ class DataLoader(
ReferenceDataGenerator.NSI_BREACH_OUTCOME,
ReferenceDataGenerator.PSS_MAIN_CAT,
ReferenceDataGenerator.PSS_SUB_CAT,
ReferenceDataGenerator.COURT_REPORT_TYPE
ReferenceDataGenerator.COURT_REPORT_TYPE,
ReferenceDataGenerator.GENDER_MALE,
ReferenceDataGenerator.PROVISION_TYPE_1,
ReferenceDataGenerator.PROVISION_CATEGORY_1,
ReferenceDataGenerator.DISABILITY_TYPE_1,
ReferenceDataGenerator.DISABILITY_CONDITION_1,
ReferenceDataGenerator.GENDER_IDENTITY,
ReferenceDataGenerator.ETHNICITY,
ReferenceDataGenerator.IMMIGRATION_STATUS,
ReferenceDataGenerator.NATIONALITY,
ReferenceDataGenerator.LANGUAGE_ENG,
ReferenceDataGenerator.RELIGION,
ReferenceDataGenerator.SECOND_NATIONALITY,
ReferenceDataGenerator.SEXUAL_ORIENTATION,
ReferenceDataGenerator.TITLE,
PersonGenerator.PARTITION_AREA,
PersonGenerator.NEW_TO_PROBATION,
PersonGenerator.CURRENTLY_MANAGED,
PersonGenerator.PREVIOUSLY_MANAGED,
PersonGenerator.NO_SENTENCE,
PersonGenerator.PROVISION_1,
PersonGenerator.DISABILITY_1,
PersonGenerator.PREVIOUS_CONVICTION_DOC
)

em.saveAll(StaffGenerator.ALLOCATED, StaffGenerator.UNALLOCATED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object DocumentEntityGenerator {

val R_INSTITUTION = Institution(IdGenerator.getAndIncrement(), "test", false)

fun generateDocument(personId: Long, primaryKeyId: Long, type: String, tableName: String) =
fun generateDocument(personId: Long, primaryKeyId: Long?, type: String, tableName: String?) =
DocumentEntity(
IdGenerator.getAndIncrement(),
personId,
Expand All @@ -31,6 +31,7 @@ object DocumentEntityGenerator {
"filename.txt",
type,
tableName,
ZonedDateTime.now()
ZonedDateTime.now(),
lastUpdated = ZonedDateTime.now()
)
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,88 @@
package uk.gov.justice.digital.hmpps.data.generator

import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.Person
import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.PersonManager
import uk.gov.justice.digital.hmpps.api.model.DocumentType
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.DISABILITY_CONDITION_1
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.DISABILITY_TYPE_1
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.ETHNICITY
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.GENDER_IDENTITY
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.GENDER_MALE
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.IMMIGRATION_STATUS
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.LANGUAGE_ENG
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.NATIONALITY
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.PROVISION_CATEGORY_1
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.PROVISION_TYPE_1
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.RELIGION
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.SECOND_NATIONALITY
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.SEXUAL_ORIENTATION
import uk.gov.justice.digital.hmpps.data.generator.ReferenceDataGenerator.TITLE
import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.*
import java.time.LocalDate
import java.time.ZonedDateTime

object PersonGenerator {
val PARTITION_AREA = PartitionArea(IdGenerator.getAndIncrement(), "Partition Area")
val NEW_TO_PROBATION = generate("N123456")
val CURRENTLY_MANAGED = generate("C123456")
val CURRENTLY_MANAGED = generate("C123456", currentDisposal = true)
val PREVIOUSLY_MANAGED = generate("P123456")
val NO_SENTENCE = generate("U123456")
val PROVISION_1 = generateProvision(CURRENTLY_MANAGED.id, null)
val DISABILITY_1 = generateDisability(CURRENTLY_MANAGED.id, null)

fun generate(crn: String, softDeleted: Boolean = false, id: Long = IdGenerator.getAndIncrement()) =
Person(crn, softDeleted, id)
val PREVIOUS_CONVICTION_DOC = DocumentEntityGenerator.generateDocument(
personId = CURRENTLY_MANAGED.id,
primaryKeyId = null,
DocumentType.PREVIOUS_CONVICTION.name,
null
)

fun generate(
crn: String,
softDeleted: Boolean = false,
id: Long = IdGenerator.getAndIncrement(),
currentDisposal: Boolean = false
) =
Person(
id = id,
crn = crn,
softDeleted = softDeleted,
emailAddress = "[email protected]",
currentDisposal = currentDisposal,
currentExclusion = false,
currentRestriction = false,
currentHighestRiskColour = "RED",
dateOfBirth = LocalDate.of(1977, 8, 12),
partitionArea = PARTITION_AREA,
allowSms = true,
mobileNumber = "07876545678",
telephoneNumber = "0161786567",
forename = "TestForename",
secondName = "MiddleName",
thirdName = "OtherMiddleName",
gender = GENDER_MALE,
surname = "TestSurname",
preferredName = "Other name",
offenderDetails = "Some details",
genderIdentity = GENDER_IDENTITY,
genderIdentityDescription = "Some self described gender identity",
ethnicity = ETHNICITY,
immigrationStatus = IMMIGRATION_STATUS,
nationality = NATIONALITY,
language = LANGUAGE_ENG,
languageConcerns = "A concern",
requiresInterpreter = false,
currentRemandStatus = "Remand Status",
secondNationality = SECOND_NATIONALITY,
sexualOrientation = SEXUAL_ORIENTATION,
religion = RELIGION,
niNumber = "JK002213K",
pnc = "1234567890123",
nomsNumber = "NOMS123",
croNumber = "CRO123",
immigrationNumber = "IMA123",
mostRecentPrisonerNumber = "PRS123",
previousSurname = "Previous",
title = TITLE
)

fun generatePersonManager(person: Person) =
PersonManager(
Expand All @@ -22,4 +93,26 @@ object PersonGenerator {
ProviderGenerator.DEFAULT,
ZonedDateTime.now()
)

fun generateProvision(personId: Long, end: LocalDate?) = Provision(
id = IdGenerator.getAndIncrement(),
personId = personId,
type = PROVISION_TYPE_1,
startDate = LocalDate.now().minusDays(1),
lastUpdated = LocalDate.now().minusDays(1),
category = PROVISION_CATEGORY_1,
notes = null,
finishDate = end,
)

fun generateDisability(personId: Long, end: LocalDate?) = Disability(
id = IdGenerator.getAndIncrement(),
personId = personId,
type = DISABILITY_TYPE_1,
startDate = LocalDate.now().minusDays(1),
lastUpdated = ZonedDateTime.now().minusDays(1),
condition = DISABILITY_CONDITION_1,
notes = null,
finishDate = end,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,88 @@ object ReferenceDataGenerator {
"court report",
IdGenerator.getAndIncrement()
)

val GENDER_MALE = ReferenceData(
"MALE",
"Male",
IdGenerator.getAndIncrement()
)

val PROVISION_TYPE_1 = ReferenceData(
"PROV1",
"Provision type 1",
IdGenerator.getAndIncrement()
)

val PROVISION_CATEGORY_1 = ReferenceData(
"PROV1",
"Provision type 1",
IdGenerator.getAndIncrement()
)

val DISABILITY_TYPE_1 = ReferenceData(
"DIS1",
"Disability type 1",
IdGenerator.getAndIncrement()
)

val DISABILITY_CONDITION_1 = ReferenceData(
"DISCON1",
"Disability Condition 1",
IdGenerator.getAndIncrement()
)

val GENDER_IDENTITY = ReferenceData(
"GEN",
"Some gender identity",
IdGenerator.getAndIncrement()
)

val ETHNICITY = ReferenceData(
"ETH",
"Some ethnicity",
IdGenerator.getAndIncrement()
)

val IMMIGRATION_STATUS = ReferenceData(
"ETH",
"Some immigration status",
IdGenerator.getAndIncrement()
)

val NATIONALITY = ReferenceData(
"BRIT",
"British",
IdGenerator.getAndIncrement()
)

val LANGUAGE_ENG = ReferenceData(
"ENG",
"English",
IdGenerator.getAndIncrement()
)

val RELIGION = ReferenceData(
"REL",
"A Relgion",
IdGenerator.getAndIncrement()
)

val SECOND_NATIONALITY = ReferenceData(
"FRE",
"French",
IdGenerator.getAndIncrement()
)

val SEXUAL_ORIENTATION = ReferenceData(
"SO",
"A sexual orientation",
IdGenerator.getAndIncrement()
)

val TITLE = ReferenceData(
"MR",
"Mr",
IdGenerator.getAndIncrement()
)
}
Loading

0 comments on commit e45f1e8

Please sign in to comment.