From 4dd14ae5e782e302caa105898a5e2a7940e012f8 Mon Sep 17 00:00:00 2001 From: David Atkins Date: Mon, 23 Dec 2024 13:27:55 +0000 Subject: [PATCH] Change Approved Premises Residency NSI Staff (#4512) This commit modifies the automatic opening and closure of the residency NSI to use the staff member who recorded the arrival/departure, instead of the associated keyworker --- .../digital/hmpps/data/generator/EventDetailsGenerator.kt | 2 +- .../__files/approved-premises-person-arrived-inactive.json | 2 +- .../simulations/__files/approved-premises-person-arrived.json | 2 +- .../__files/approved-premises-person-departed-inactive.json | 2 +- .../__files/approved-premises-person-departed.json | 2 +- .../hmpps/integrations/approvedpremises/EventDetails.kt | 4 ++-- .../kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt | 4 ++-- .../uk/gov/justice/digital/hmpps/service/ReferralService.kt | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventDetailsGenerator.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventDetailsGenerator.kt index eb5b90b22a..8b9e0efd14 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventDetailsGenerator.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventDetailsGenerator.kt @@ -88,7 +88,7 @@ object EventDetailsGenerator { premises = premises(), arrivedAt = ZonedDateTime.now(), expectedDepartureOn = LocalDate.now().plusMonths(6), - keyWorker = staffMember(keyWorker), + recordedBy = staffMember(keyWorker), notes = "Arrived on time", applicationSubmittedOn = LocalDate.now().minusDays(1), eventNumber = "11" diff --git a/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-arrived-inactive.json b/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-arrived-inactive.json index aeeb8dbe45..81202ae6e8 100644 --- a/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-arrived-inactive.json +++ b/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-arrived-inactive.json @@ -17,7 +17,7 @@ "apCode": "NEHOPE1", "legacyApCode": "Q001" }, - "keyWorker": { + "recordedBy": { "staffCode": "N54A001", "forenames": "John", "surname": "Smith", diff --git a/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-arrived.json b/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-arrived.json index 554e70244a..91ab4c2e85 100644 --- a/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-arrived.json +++ b/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-arrived.json @@ -17,7 +17,7 @@ "apCode": "NEHOPE1", "legacyApCode": "Q001" }, - "keyWorker": { + "recordedBy": { "staffCode": "N54A001", "forenames": "John", "surname": "Smith", diff --git a/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-departed-inactive.json b/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-departed-inactive.json index 6788790fa5..6ad186adae 100644 --- a/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-departed-inactive.json +++ b/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-departed-inactive.json @@ -37,7 +37,7 @@ "code": "XYZ456" } }, - "keyWorker": { + "recordedBy": { "staffCode": "N54A001", "staffIdentifier": 1501234567, "forenames": "John", diff --git a/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-departed.json b/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-departed.json index d1c79748c1..4b898aeb97 100644 --- a/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-departed.json +++ b/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-person-departed.json @@ -37,7 +37,7 @@ "code": "XYZ456" } }, - "keyWorker": { + "recordedBy": { "staffCode": "N54A001", "staffIdentifier": 1501234567, "forenames": "John", diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremises/EventDetails.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremises/EventDetails.kt index 2a0c495e7f..615d4b41d2 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremises/EventDetails.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremises/EventDetails.kt @@ -167,7 +167,7 @@ data class PersonArrived( val applicationId: String, val applicationUrl: String, val premises: Premises, - val keyWorker: StaffMember, + val recordedBy: StaffMember, val applicationSubmittedOn: LocalDate, val arrivedAt: ZonedDateTime, val expectedDepartureOn: LocalDate?, @@ -180,7 +180,7 @@ data class PersonDeparted( val applicationId: String, val applicationUrl: String, val bookingId: String, - val keyWorker: StaffMember, + val recordedBy: StaffMember, val departedAt: ZonedDateTime, val premises: Premises, val legacyReasonCode: String, diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt index 56f5a89d7f..20e51bdbf9 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt @@ -42,7 +42,7 @@ class NsiService( ): Pair? { val externalReference = EXT_REF_BOOKING_PREFIX + details.bookingId nsiRepository.findByPersonIdAndExternalReference(person.id, externalReference) ?: run { - val staff = staffRepository.getByCode(details.keyWorker.staffCode) + val staff = staffRepository.getByCode(details.recordedBy.staffCode) val nsi = nsiRepository.save( Nsi( person = person, @@ -111,7 +111,7 @@ class NsiService( person = person, eventId = eventRepository.getEvent(person.id, details.eventNumber).id, team = teamRepository.getApprovedPremisesTeam(details.premises.legacyApCode), - staff = staffRepository.getByCode(details.keyWorker.staffCode), + staff = staffRepository.getByCode(details.recordedBy.staffCode), probationAreaCode = ap.probationArea.code ) referralService.personDeparted(person, details) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ReferralService.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ReferralService.kt index 1926dbf3bb..caf609f9a4 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ReferralService.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ReferralService.kt @@ -186,7 +186,7 @@ class ReferralService( fun personArrived(person: Person, ap: ApprovedPremises, details: PersonArrived) { val referral = getReferral(person, EXT_REF_BOOKING_PREFIX + details.bookingId) referral.admissionDate = details.arrivedAt.toLocalDate() - val kw = staffRepository.getByCode(details.keyWorker.staffCode) + val kw = staffRepository.getByCode(details.recordedBy.staffCode) residenceRepository.save(details.residence(person, ap, referral, kw)) }