diff --git a/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt b/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt index 03bc58fe1a..d8dcaa5196 100644 --- a/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt +++ b/projects/cas3-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/CASIntegrationTest.kt @@ -48,7 +48,7 @@ internal class CASIntegrationTest { Mockito.verify(telemetryService).notificationReceived(event) val contact = - contactRepository.getByExternalReference(event.message.additionalInformation["applicationId"] as String) + contactRepository.getByExternalReference("urn:hmpps:cas3:application-submitted:${event.message.additionalInformation["applicationId"] as String}") MatcherAssert.assertThat(contact!!.type.code, Matchers.equalTo("EARS")) } @@ -64,7 +64,7 @@ internal class CASIntegrationTest { Mockito.verify(telemetryService).notificationReceived(event) val contact = - contactRepository.getByExternalReference("14c80733-4b6d-4f35-b724-66955aac320c") + contactRepository.getByExternalReference("urn:hmpps:cas3:booking-cancelled:14c80733-4b6d-4f35-b724-66955aac320c") MatcherAssert.assertThat(contact!!.type.code, Matchers.equalTo("EACA")) } @@ -80,7 +80,7 @@ internal class CASIntegrationTest { Mockito.verify(telemetryService).notificationReceived(event) val contact = - contactRepository.getByExternalReference("14c80733-4b6d-4f35-b724-66955aac320d") + contactRepository.getByExternalReference("urn:hmpps:cas3:booking-confirmed:14c80733-4b6d-4f35-b724-66955aac320d") MatcherAssert.assertThat(contact!!.type.code, Matchers.equalTo("EACO")) } @@ -96,7 +96,7 @@ internal class CASIntegrationTest { Mockito.verify(telemetryService).notificationReceived(event) val contact = - contactRepository.getByExternalReference("14c80733-4b6d-4f35-b724-66955aac320e") + contactRepository.getByExternalReference("urn:hmpps:cas3:booking-provisionally-made:14c80733-4b6d-4f35-b724-66955aac320e") MatcherAssert.assertThat(contact!!.type.code, Matchers.equalTo("EABP")) } 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..69bf6e2c2a 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?, @@ -20,13 +22,28 @@ data class BookingCancelled( val bookingUrl: String, val cancellationReason: String, val cancellationContext: String? -) +) { + val urn = "urn:hmpps:cas3:booking-cancelled:$bookingId" +} -data class BookingProvisionalOrConfirmed( +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-provisionally-made:$bookingId" +} + +data class BookingConfirmed( + val applicationId: String?, + val applicationUrl: String?, + val bookingId: String, + val bookingUrl: String, + 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 ) }