Skip to content

Commit

Permalink
PI-1679 changes to contact notes (#2751)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevomcallister authored Nov 28, 2023
1 parent a99fd7e commit 44e870a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand All @@ -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?,
Expand All @@ -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(
Expand All @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
}

0 comments on commit 44e870a

Please sign in to comment.