From 44e870a474e1781989376e72a8e5835cf08104ec Mon Sep 17 00:00:00 2001 From: stevomcallister <78762879+stevomcallister@users.noreply.github.com> Date: Tue, 28 Nov 2023 09:51:48 +0000 Subject: [PATCH] PI-1679 changes to contact notes (#2751) --- .../approvedpremesis/EventDetails.kt | 72 ++++++++++--------- .../approvedpremesis/EventDetailsTest.kt | 2 +- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/EventDetails.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/EventDetails.kt index 1b0927812f..60259ef1a2 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/EventDetails.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/EventDetails.kt @@ -32,11 +32,12 @@ data class BookingCancelled( val bookingId: String, val bookingUrl: String, val cancellationReason: String, - val cancellationContext: String? + val cancellationContext: String?, + val notes: String? ) : Cas3Event { override val urn = "urn:hmpps:cas3:booking-cancelled:$bookingId" override val noteText = - listOfNotNull(cancellationReason, cancellationContext).joinToString(" ") + System.lineSeparator() + bookingUrl + listOfNotNull(cancellationReason, cancellationContext, notes).joinToString(System.lineSeparator()) override val contactTypeCode = ContactType.BOOKING_CANCELLED } @@ -51,10 +52,9 @@ data class BookingProvisional( override val urn = "urn:hmpps:cas3:booking-provisionally-made:$bookingId" override val noteText = listOfNotNull( - "Expected arrival date:", - DeliusDateFormatter.format(expectedArrivedAt), + "Expected arrival date: ${DeliusDateFormatter.format(expectedArrivedAt)}", notes - ).joinToString(" ") + System.lineSeparator() + bookingUrl + ).joinToString(System.lineSeparator()) override val contactTypeCode = ContactType.BOOKING_PROVISIONAL } @@ -69,10 +69,9 @@ data class BookingConfirmed( override val urn = "urn:hmpps:cas3:booking-confirmed:$bookingId" override val noteText = listOfNotNull( - "Expected arrival date:", - DeliusDateFormatter.format(expectedArrivedAt), + "Expected arrival date: ${DeliusDateFormatter.format(expectedArrivedAt)}", notes - ).joinToString(" ") + System.lineSeparator() + bookingUrl + ).joinToString(System.lineSeparator()) override val contactTypeCode = ContactType.BOOKING_CONFIRMED } @@ -88,13 +87,36 @@ data class PersonArrived( override val urn = "urn:hmpps:cas3:person-arrived:$bookingId" override val noteText = listOfNotNull( - "Arrival date:", - DeliusDateFormatter.format(arrivedAt), - notes - ).joinToString(" ") + System.lineSeparator() + bookingUrl + "Arrival date: ${DeliusDateFormatter.format(arrivedAt)}", + notes, + "Arrival address: ${premises.inNotes()}" + ).joinToString(System.lineSeparator()) override val contactTypeCode = ContactType.PERSON_ARRIVED } +data class PersonDeparted( + val applicationId: String?, + val applicationUrl: String?, + val bookingId: String, + val bookingUrl: String, + val departedAt: ZonedDateTime, + val notes: String, + val reason: String, + val reasonDetail: String?, + val moveOnCategory: Category + +) : Cas3Event { + override val urn = "urn:hmpps:cas3:person-departed:$bookingId" + override val noteText = listOfNotNull( + "Departure date: ${DeliusDateFormatter.format(departedAt)}", + notes, + reason, + reasonDetail, + moveOnCategory.description + ).joinToString(System.lineSeparator()) + override val contactTypeCode = ContactType.PERSON_DEPARTED +} + data class Address( val addressLine1: String, val addressLine2: String?, @@ -111,6 +133,9 @@ data class Address( AddressLines(lines.pop(), lines.pop(), lines.pop()) } } + fun inNotes(): String { + return listOfNotNull(addressLine1, addressLine2, postcode, town, region).joinToString(" ") + } } data class AddressLines( @@ -119,29 +144,6 @@ data class AddressLines( val district: String? ) -data class PersonDeparted( - val applicationId: String?, - val applicationUrl: String?, - val bookingId: String, - val bookingUrl: String, - val departedAt: ZonedDateTime, - val notes: String, - val reason: String, - val reasonDetail: String?, - val moveOnCategory: Category - -) : Cas3Event { - override val urn = "urn:hmpps:cas3:person-departed:$bookingId" - override val noteText = listOfNotNull( - DeliusDateFormatter.format(departedAt), - notes, - reason, - reasonDetail, - moveOnCategory.description - ).joinToString(" ") - override val contactTypeCode = ContactType.PERSON_DEPARTED -} - data class Category( val description: String ) diff --git a/projects/cas3-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/EventDetailsTest.kt b/projects/cas3-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/EventDetailsTest.kt index 9ddbb19b3e..a7c6bcad61 100644 --- a/projects/cas3-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/EventDetailsTest.kt +++ b/projects/cas3-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/EventDetailsTest.kt @@ -20,6 +20,6 @@ class EventDetailsTest { reasonDetail = null, moveOnCategory = Category(description = "E") ) - assertThat(event.noteText, equalTo("01/01/2020 C D E")) + assertThat(event.noteText, equalTo("Departure date: 01/01/2020${System.lineSeparator()}C${System.lineSeparator()}D${System.lineSeparator()}E")) } }