Skip to content

Commit

Permalink
Change Approved Premises Residency NSI Staff
Browse files Browse the repository at this point in the history
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
  • Loading branch information
davidatkinsuk committed Dec 23, 2024
1 parent a357d88 commit 4ae4301
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"apCode": "NEHOPE1",
"legacyApCode": "Q001"
},
"keyWorker": {
"recordedBy": {
"staffCode": "N54A001",
"forenames": "John",
"surname": "Smith",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"apCode": "NEHOPE1",
"legacyApCode": "Q001"
},
"keyWorker": {
"recordedBy": {
"staffCode": "N54A001",
"forenames": "John",
"surname": "Smith",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"code": "XYZ456"
}
},
"keyWorker": {
"recordedBy": {
"staffCode": "N54A001",
"staffIdentifier": 1501234567,
"forenames": "John",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"code": "XYZ456"
}
},
"keyWorker": {
"recordedBy": {
"staffCode": "N54A001",
"staffIdentifier": 1501234567,
"forenames": "John",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NsiService(
): Pair<PersonAddress?, PersonAddress>? {
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,
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down

0 comments on commit 4ae4301

Please sign in to comment.