diff --git a/projects/cas2-and-delius/README.md b/projects/cas2-and-delius/README.md index f5fc098a1d..9694c18027 100644 --- a/projects/cas2-and-delius/README.md +++ b/projects/cas2-and-delius/README.md @@ -1,3 +1,47 @@ -# cas2-and-delius +# CAS2 and Delius -// TODO Describe the service \ No newline at end of file +Service that responds to Community Accommodation Services Tier 2 (CAS2) domain events. The service is responsible for updating Delius with progress of referrals to short-term accommodation for people released from custody on Home Detention Curfew or bail. + +## Business Need + +Ensuring the Probation Practitioner has an up-to-date view of activity in the CAS2 service when interacting with the probation case via Delius. + +## Context Map + +![Context Map](./tech-docs/source/img/cas2-and-delius-context-map.svg) + +## Workflows + +CAS2 domain events are raised in real time as referral applications are processed. There is a single update domain event to inform of progress or changes to the referral application. + +### Create a CAS2 Referral Application + +A referral application is created in the CAS2 service which is reflected in a Delius contact. An `EXTERNAL_REFERENCE` URN is added to the contact in the form `urn:hmpps:cas2:application-submitted:{referralId}` using the CAS2 referral ID as a unique reference. + +| Business Event | Message Event Type / Filter | +|---------------------------------------------------------------|----------------------------------------------| +| Submission of a accommodation referral application | applications.cas2.application.submitted | + +![Context Map](./tech-docs/source/img/cas2-and-delius-workflow-application.svg) + +### Update the Status of a CAS2 Referral Application + +A referral application is updated in the CAS2 service which is reflected in a Delius contact. Only a single update contact exists in Delius for any single CAS2 referral and the contact is updated with the latest status. An `EXTERNAL_REFERENCE` URN is added to the contact in the form `urn:hmpps:cas2:application-status-updated:{referralId}` using the CAS2 referral ID as a unique reference. + +| Business Event | Message Event Type / Filter | +|---------------------------------------------------------------|----------------------------------------------| +| Update to the status of an accommodation referral application | applications.cas2.application.status-updated | + +![Context Map](./tech-docs/source/img/cas2-and-delius-workflow-application-update.svg) + +## Interfaces + +### Message Interface + +The service responds to HMPPS Domain Event messages via the +[Queue](https://github.com/ministryofjustice/cloud-platform-environments/blob/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-probation-integration-services-prod/resources/cas2-and-delius-queue.tf). +The events are raised by the [HMPPS Approved Premises API](https://github.com/ministryofjustice/hmpps-approved-premises-api/) which handles backend integration for the [CAS2 UI](https://github.com/ministryofjustice/hmpps-community-accommodation-tier-2-ui) + +Example [messages](./src/dev/resources/messages/) are in the development source tree. + +Incoming messages are filtered on `eventType` by the [SQS queue policy](https://github.com/ministryofjustice/cloud-platform-environments/blob/2aeb8aeb7b7798cbe12bc81b14d01aaa707041f1/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-probation-integration-services-prod/resources/cas2-and-delius-queue.tf#L5-L10) diff --git a/projects/cas2-and-delius/tech-docs/diag/cas2-and-delius-context-map.d2 b/projects/cas2-and-delius/tech-docs/diag/cas2-and-delius-context-map.d2 new file mode 100644 index 0000000000..792eb45a49 --- /dev/null +++ b/projects/cas2-and-delius/tech-docs/diag/cas2-and-delius-context-map.d2 @@ -0,0 +1,28 @@ + +style { ...@../../../../script/style.style } +vars { ...@../../../../script/style.vars } +** { ...@../../../../script/style.all-style } + +context-cas2: CAS2 Context { + entities: Entities { + grid-columns: 2 + pop: Person on Probation + referral: Accommodation Referral + } +} + +context-delius: Delius Context { + + interface: CAS2 and Delius { + type: Anti-Corruption\nLayer + } + + entities: Entities { + grid-columns: 2 + pop: Person on Probation + contact: Contact + manager: Offender Manager + } +} + +context-cas2--context-delius.interface: Upstream\n\n\nDownstream diff --git a/projects/cas2-and-delius/tech-docs/diag/cas2-and-delius-workflow-application-update.d2 b/projects/cas2-and-delius/tech-docs/diag/cas2-and-delius-workflow-application-update.d2 new file mode 100644 index 0000000000..2082c48ac4 --- /dev/null +++ b/projects/cas2-and-delius/tech-docs/diag/cas2-and-delius-workflow-application-update.d2 @@ -0,0 +1,42 @@ +# CAS2 Workflow: Referral Application Status Update + +style { ...@../../../../script/style.style } +vars { ...@../../../../script/style.vars } +** { ...@../../../../script/style.all-style } + +direction: right + +# What triggers the workflow? +cas2: CAS2 { + style.font-size: 24 + + explanation: |md + ## Referral Application Workflow + Updates to referral applications raise domain events + | + + application_updated: Application Updated +} + +domain_event_1: "applications.cas2\n.application.status-updated" { + style.font-size: 12 + shape: queue +} + +# What happens in Delius? +delius: Delius { + style.font-size: 24 + + explanation: |md + ## Delius Workflow + Referral application status contact is created\ + or updated Delius to reflect referral application changes + | + + d_contact_create: Create Contact + d_contact_update: Update Contact +} + +cas2 -> domain_event_1 + +domain_event_1 -> delius diff --git a/projects/cas2-and-delius/tech-docs/diag/cas2-and-delius-workflow-application.d2 b/projects/cas2-and-delius/tech-docs/diag/cas2-and-delius-workflow-application.d2 new file mode 100644 index 0000000000..9cca491b38 --- /dev/null +++ b/projects/cas2-and-delius/tech-docs/diag/cas2-and-delius-workflow-application.d2 @@ -0,0 +1,41 @@ +# CAS2 Workflow: Referral Application + +style { ...@../../../../script/style.style } +vars { ...@../../../../script/style.vars } +** { ...@../../../../script/style.all-style } + +direction: right + +# What triggers the workflow? +cas2: CAS2 { + style.font-size: 24 + + explanation: |md + ## Referral Application Workflow + Referral application actions raise domain events + | + + application_submitted: Application Submitted +} + +domain_event_1: "applications.cas2\n.application.submitted" { + style.font-size: 12 + shape: queue +} + +# What happens in Delius? +delius: Delius { + style.font-size: 24 + + explanation: |md + ## Delius Workflow + Contact is added to Delius \ + to indicate referral application creation + | + + d_contact: Create Contact +} + +cas2 -> domain_event_1 + +domain_event_1 -> delius diff --git a/projects/cas2-and-delius/tech-docs/source/img/cas2-and-delius-context-map.svg b/projects/cas2-and-delius/tech-docs/source/img/cas2-and-delius-context-map.svg new file mode 100644 index 0000000000..8f83541c80 --- /dev/null +++ b/projects/cas2-and-delius/tech-docs/source/img/cas2-and-delius-context-map.svg @@ -0,0 +1,120 @@ +CAS2 ContextDelius ContextEntitiesCAS2 and DeliusEntitiesPerson on ProbationAccommodation ReferralAnti-CorruptionLayerPerson on ProbationContactOffender ManagerUpstream Downstream + + + + + + + + + + + + + + diff --git a/projects/cas2-and-delius/tech-docs/source/img/cas2-and-delius-workflow-application-update.svg b/projects/cas2-and-delius/tech-docs/source/img/cas2-and-delius-workflow-application-update.svg new file mode 100644 index 0000000000..5698de4da6 --- /dev/null +++ b/projects/cas2-and-delius/tech-docs/source/img/cas2-and-delius-workflow-application-update.svg @@ -0,0 +1,854 @@ +CAS2applications.cas2.application.status-updatedDelius

Referral Application Workflow

+

Updates to referral applications raise domain events

+
Application Updated

Delius Workflow

+

Referral application status contact is created
+or updated Delius to reflect referral application changes

+
Create ContactUpdate Contact + + + + + + + + + +
diff --git a/projects/cas2-and-delius/tech-docs/source/img/cas2-and-delius-workflow-application.svg b/projects/cas2-and-delius/tech-docs/source/img/cas2-and-delius-workflow-application.svg new file mode 100644 index 0000000000..ff3edef46f --- /dev/null +++ b/projects/cas2-and-delius/tech-docs/source/img/cas2-and-delius-workflow-application.svg @@ -0,0 +1,853 @@ +CAS2applications.cas2.application.submittedDelius

Referral Application Workflow

+

Referral application actions raise domain events

+
Application Submitted

Delius Workflow

+

Contact is added to Delius
+to indicate referral application creation

+
Create Contact + + + + + + + + +
diff --git a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/Registration.kt b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/Registration.kt index 5f23e62b8f..9f3cc15061 100644 --- a/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/Registration.kt +++ b/projects/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/Registration.kt @@ -1,9 +1,12 @@ package uk.gov.justice.digital.hmpps.model +import io.swagger.v3.oas.annotations.media.Schema import java.time.LocalDate data class Registration( + @Schema(example = "RCCO") val code: String, + @Schema(example = "Child Concerns") val description: String, val startDate: LocalDate, val reviewDate: LocalDate?, diff --git a/script/style.d2 b/script/style.d2 new file mode 100644 index 0000000000..1d94a61d05 --- /dev/null +++ b/script/style.d2 @@ -0,0 +1,21 @@ +style { + fill: "#ffffff" + stroke: "#000000" + stroke-width: 2 +} + +all-style { + style { + border-radius: 10 + stroke-width: 2 + } +} + +vars: { + d2-config: { + pad: 25 + center: true + layout-engine: elk + theme-id: 8 + } +}