Skip to content

Commit

Permalink
Merge branch 'main' into feature/PI-2096-get-secure-offenders-crn-crn…
Browse files Browse the repository at this point in the history
…-convictions
  • Loading branch information
achimber-moj authored Jun 20, 2024
2 parents 8ca6dd8 + 4c65efa commit 1886150
Show file tree
Hide file tree
Showing 9 changed files with 2,008 additions and 2 deletions.
48 changes: 46 additions & 2 deletions projects/cas2-and-delius/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
# cas2-and-delius
# CAS2 and Delius

// TODO Describe the service
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)
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1886150

Please sign in to comment.