diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/Cas3ApiClient.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/Cas3ApiClient.kt index 756df7281a..61e83c6a5f 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/Cas3ApiClient.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremesis/Cas3ApiClient.kt @@ -18,8 +18,8 @@ interface Cas3ApiClient { fun getBookingCancelledDetails(uri: URI): EventDetails @GetMapping - fun getBookingConfirmedDetails(uri: URI): EventDetails + fun getBookingConfirmedDetails(uri: URI): EventDetails @GetMapping - fun getBookingProvisionallyMade(uri: URI): EventDetails + fun getBookingProvisionallyMade(uri: URI): EventDetails } 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 838406fafb..542b0588cb 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 @@ -11,7 +11,9 @@ data class EventDetails( data class ApplicationSubmitted( val applicationId: String -) +){ + val urn = "urn:hmpps:cas3:application-submitted:$applicationId" +} data class BookingCancelled( val applicationId: String?, @@ -21,8 +23,23 @@ data class BookingCancelled( val cancellationReason: String, val cancellationContext: String? ) +{ + val urn = "urn:hmpps:cas3:booking-cancelled:$bookingId" +} + +data class BookingProvisional( + val applicationId: String?, + val applicationUrl: String?, + val bookingId: String, + val bookingUrl: String, + val expectedArrivedAt: ZonedDateTime, + val notes: String +) +{ + val urn = "urn:hmpps:cas3:booking-provisional:$bookingId" +} -data class BookingProvisionalOrConfirmed( +data class BookingConfirmed( val applicationId: String?, val applicationUrl: String?, val bookingId: String, @@ -30,3 +47,7 @@ data class BookingProvisionalOrConfirmed( val expectedArrivedAt: ZonedDateTime, val notes: String ) +{ + val urn = "urn:hmpps:cas3:booking-confirmed:$bookingId" +} + diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/ContactService.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/ContactService.kt index f4a5d2e893..aa299f11cc 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/ContactService.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/ContactService.kt @@ -36,7 +36,7 @@ class ContactService( fun createReferralSubmitted(event: HmppsDomainEvent) { val details = cas3ApiClient.getApplicationSubmittedDetails(event.url()).eventDetails val crn = event.crn() - val externalReference = details.applicationId + val externalReference = details.urn if (contactRepository.getByExternalReference(externalReference) != null) { telemetryService.trackEvent("Duplicate ApplicationSubmitted event received for crn $crn") @@ -54,39 +54,36 @@ class ContactService( fun createBookingCancelled(event: HmppsDomainEvent) { val details = cas3ApiClient.getBookingCancelledDetails(event.url()).eventDetails val crn = event.crn() - val externalReference = details.bookingId createContact( event.occurredAt, crn, "${details.cancellationReason} ${details.cancellationContext} ${details.bookingUrl}", BOOKING_CANCELLED, - externalReference + details.urn ) } fun createBookingConfirmed(event: HmppsDomainEvent) { val details = cas3ApiClient.getBookingConfirmedDetails(event.url()).eventDetails val crn = event.crn() - val externalReference = details.bookingId createContact( event.occurredAt, crn, "${details.expectedArrivedAt} ${details.notes} ${details.bookingUrl}", BOOKING_CONFIRMED, - externalReference + details.urn ) } fun createBookingProvisionallyMade(event: HmppsDomainEvent) { val crn = event.crn() val details = cas3ApiClient.getBookingProvisionallyMade(event.url()).eventDetails - val externalReference = details.bookingId createContact( event.occurredAt, crn, "${details.expectedArrivedAt} ${details.notes} ${details.bookingUrl}", BOOKING_PROVISIONAL, - externalReference + details.urn ) }