Skip to content

Commit

Permalink
PI-1723: Update Prison Custody Status to Delius Docs (#2896)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxco86 authored Dec 12, 2023
1 parent 2a0099f commit 310bdd8
Show file tree
Hide file tree
Showing 8 changed files with 2,059 additions and 22 deletions.
70 changes: 49 additions & 21 deletions projects/prison-custody-status-to-delius/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,53 @@
Inbound service that responds to events raised when the custody status of a
person in prison changes. The service is notified when a person is released
from prison or a person is recalled to prison. The information about the
specific type of custody status is contained in the notification message. This
is used to add and update `Custody` and `Event` records in Delius to ensure
the correct case history is maintained and the person's current location is
accurately recorded. We also create any necessary `Contact`s, terminate
`LicenceCondition`s and allocate the person to a `ResponsibleOfficer` as
needed. We also add the necessary audit logs and IAPS events.
specific type of custody status is contained in the notification message.
Thisa is used to add and update **Custody** records in Delius to ensure the
correct case history is maintained and the person's current location is
accurately recorded. We also create any necessary **Contacts**, terminate
**Licence Conditions** as needed. The necessary audit logs and IAPS events are
also added

## Probation Business Need
## Business Need

Removing the need for Probation Practitioners to manually update Delius with
Removes the need for Probation Practitioners to manually update Delius with
the custody status of a person as they move in and out of prison.

## Context Map
## Data Dependencies

![Context Map](tech-docs/source/img/prison-custody-status-to-delius-context-map.png)
_Delius_ depends on _NOMIS_ to inform when a **Person on Probation** has been released from custody. To do this the
_Delius_ record must have been previously matched with a _NOMIS_ record and the **NOMS Number** must have been added to
the _Delius_ record. The custody status processing may depend on the _NOMIS_ **Movement Reason Code** to determine the type of release. The _NOMIS_ **Institution** that the person is leaving is added to the _Delius_ **Release** record based on the
_NOMIS_ **Institution CDE Code**. If the message also contains an **Institution CDE Code** for the institution that the person
is being released to, as in the case of a release to a secure hospital or IRC, then this will be used to update the person's current location.

### Context Map

![Context Map](./tech-docs/source/img/prison-custody-status-to-delius-context-map.svg)

## Workflows

_Delius_ custody status workflows are triggered in real time by notification messages from _NOMIS_

### Release from Custody

Custody release messages are processed when a person's release is recorded in _NOMIS_

| Business Event | Event Type / Filter |
|----------------------|------------------------------------------|
| Release from Custody | prison-offender-events.prisoner.released |

![Release Workflow](./tech-docs/source/img/prison-custody-status-to-delius-workflow-release.svg)

### Recall to Custody

Custody received messages are processed when a person's arrival at a custody location is recorded in _NOMIS_

| Business Event | Event Type / Filter |
|-------------------|------------------------------------------|
| Recall to Custody | prison-offender-events.prisoner.received |

![Release Workflow](./tech-docs/source/img/prison-custody-status-to-delius-workflow-recall.svg)

## Interfaces

Expand All @@ -32,24 +64,20 @@ Example [messages](./src/dev/resources/messages/) are in the development source

Incoming messages are filtered on the `eventType` attribute by the [SQS queue policy](https://github.com/ministryofjustice/cloud-platform-environments/blob/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-domain-events-prod/resources/hmpps-prison-custody-status-to-delius-queue.tf#L6-L10).

## Event Triggers

| Business Event | Message Class | Message Event Type / Filter |
|---------------------|--------------------|------------------------------------------|
| Release from Prison | HMPPS Domain Event | prison-offender-events.prisoner.released |
| Recall to Prison | HMPPS Domain Event | prison-offender-events.prisoner.received |

### Custody Status Details

As we are not able to process all types of custody activity we use the details
in the `additionalInformation` field to determine whether the specific
notification is suitable to be ingested into Delius. Currently we are able to
process the following custody change types:

| Custody Change | Type | Reason Code |
|----------------|--------------------------------------------|-------------|
| Release | Released on Adult Licence | RELEASED |
| Recall | Recall Notified by Custodial Establishment | ADMISSION |
| Custody Change | Type | Reason Code |
|----------------|---------------------------------------------|----------------------------|
| Release | Released on Adult Licence / Secure Hospital | RELEASED |
| Release | Released to a Secure Hospital | RELEASED\_TO\_HOSPITAL |
| Recall | Recall to Custodial Establishment | ADMISSION |
| Recall | Recall - End of Temporary Licence | TEMPORARY\_ABSENCE\_RETURN |
| Recall | Transfer from Other Establishment | TRANSFERRED |

## End-to-End Test

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

style {
fill: "#ffffff"
}

context-nomis: NOMIS/DPS Context {
entities: Entities {
grid-columns: 3
prison-release: Prison Release
prison-receive: Prison Receive
location: Location
}
}

context-delius: Delius Context {
style.stroke-width: 8

interface: Prison Custody Status to Delius {
type: Anti-Corruption Layer
}

entities: Entities {
grid-columns: 3
pop: Person on Probation
event: Event
custody: Custody
release: Release
recall: Recall
staff: Staff
team: Team
transfer: Transfer
contact: Contact
institution: Institution
}
}

context-nomis--context-delius.interface: Upstream\n\n\nDownstream

*.style.border-radius: 10
*.*.style.border-radius: 10
*.*.style.stroke-width: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Custody Status Workflow: Prison Recall

direction: right

style {
fill: "#ffffff"
}

# What triggers the workflow?
nomis: NOMIS {
style.font-size: 24

explanation: |md
## Prison Release
User receives a person via NOMIS. \
This action raises a domain event
|

received: Prisoner Received
}

domain_event: "prison-offender-events\n.prisoner.received" {
style.font-size: 12
shape: queue
}

# What happens in Delius?
delius: Delius {
style.font-size: 24

explanation: |md
## Delius Throughcare Updates
Custody status is updated in Delius based on \
the status, movement reason and location \
in the domain event message
|

d_recall: Add Recall Record
d_location: Update\nCurrent Institution
d_custody: Update Custody Status
d_licence: Terminate\nLicence Conditions
d_contact: Create Contact

d_recall -> d_location -> d_custody
d_licence -> d_contact
}

nomis -> domain_event -> delius


# Styles

style {
fill: "#ffffff"
}

** {
style {
border-radius: 10
stroke-width: 2
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Custody Status Workflow: Prison Release

direction: right

style {
fill: "#ffffff"
}

# What triggers the workflow?
nomis: NOMIS {
style.font-size: 24

explanation: |md
## Prison Release
User releases person via NOMIS. \
This action raises a domain event
|

release: Prisoner Released
}

domain_event: "prison-offender-events\n.prisoner.released" {
style.font-size: 12
shape: queue
}

# What happens in Delius?
delius: Delius {
style.font-size: 24

explanation: |md
## Delius Throughcare Updates
Custody status is updated in Delius based on \
the status, movement reason and location \
in the domain event message
|

d_release: Add\nRelease Record
d_location: Update\nCurrent Institution
d_custody: Update\nCustody Status
d_contact: Create Contact

d_release -> d_location
d_custody -> d_contact
}

nomis -> domain_event -> delius


# Styles

style {
fill: "#ffffff"
}

** {
style {
border-radius: 10
stroke-width: 2
}
}
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-se
weight: 10
---

<%= URI.open('https://raw.githubusercontent.com/ministryofjustice/hmpps-probation-integration-services/main/projects/prison-custody-status-to-delius/README.md').read.gsub(/tech-docs\/source\//, "./") %>
<%= URI.open('https://raw.githubusercontent.com/ministryofjustice/hmpps-probation-integration-services/main/projects/prison-custody-status-to-delius/README.md').read.gsub(/tech-docs\/source\//, "./") %>

0 comments on commit 310bdd8

Please sign in to comment.