diff --git a/projects/prison-custody-status-to-delius/README.md b/projects/prison-custody-status-to-delius/README.md index 6a3ef897ae..ce89680b1a 100644 --- a/projects/prison-custody-status-to-delius/README.md +++ b/projects/prison-custody-status-to-delius/README.md @@ -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 @@ -32,13 +64,6 @@ 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 @@ -46,10 +71,13 @@ 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 diff --git a/projects/prison-custody-status-to-delius/tech-docs/diag/prison-custody-status-to-delius-context-map.d2 b/projects/prison-custody-status-to-delius/tech-docs/diag/prison-custody-status-to-delius-context-map.d2 new file mode 100644 index 0000000000..2c95fe77d6 --- /dev/null +++ b/projects/prison-custody-status-to-delius/tech-docs/diag/prison-custody-status-to-delius-context-map.d2 @@ -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 diff --git a/projects/prison-custody-status-to-delius/tech-docs/diag/prison-custody-status-to-delius-workflow-recall.d2 b/projects/prison-custody-status-to-delius/tech-docs/diag/prison-custody-status-to-delius-workflow-recall.d2 new file mode 100644 index 0000000000..a518d110bf --- /dev/null +++ b/projects/prison-custody-status-to-delius/tech-docs/diag/prison-custody-status-to-delius-workflow-recall.d2 @@ -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 + } +} diff --git a/projects/prison-custody-status-to-delius/tech-docs/diag/prison-custody-status-to-delius-workflow-release.d2 b/projects/prison-custody-status-to-delius/tech-docs/diag/prison-custody-status-to-delius-workflow-release.d2 new file mode 100644 index 0000000000..9dde15a5b1 --- /dev/null +++ b/projects/prison-custody-status-to-delius/tech-docs/diag/prison-custody-status-to-delius-workflow-release.d2 @@ -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 + } +} diff --git a/projects/prison-custody-status-to-delius/tech-docs/source/img/prison-custody-status-to-delius-context-map.svg b/projects/prison-custody-status-to-delius/tech-docs/source/img/prison-custody-status-to-delius-context-map.svg new file mode 100644 index 0000000000..ff1bf8bb39 --- /dev/null +++ b/projects/prison-custody-status-to-delius/tech-docs/source/img/prison-custody-status-to-delius-context-map.svg @@ -0,0 +1,128 @@ +NOMIS/DPS ContextDelius ContextEntitiesPrison Custody Status to DeliusEntitiesPrison ReleasePrison ReceiveLocationAnti-Corruption LayerPerson on ProbationEventCustodyReleaseRecallStaffTeamTransferContactInstitutionUpstream Downstream + + + + + + + + + + + + + + + + + + + + + + diff --git a/projects/prison-custody-status-to-delius/tech-docs/source/img/prison-custody-status-to-delius-workflow-recall.svg b/projects/prison-custody-status-to-delius/tech-docs/source/img/prison-custody-status-to-delius-workflow-recall.svg new file mode 100644 index 0000000000..60b74c1a96 --- /dev/null +++ b/projects/prison-custody-status-to-delius/tech-docs/source/img/prison-custody-status-to-delius-workflow-recall.svg @@ -0,0 +1,859 @@ +NOMISprison-offender-events.prisoner.receivedDelius

Prison Release

+

User receives a person via NOMIS.
+This action raises a domain event

+
Prisoner Received

Delius Throughcare Updates

+

Custody status is updated in Delius based on
+the status, movement reason and location
+in the domain event message

+
Add Recall RecordUpdateCurrent InstitutionUpdate Custody StatusTerminateLicence ConditionsCreate Contact + + + + + + + + + + + + +
diff --git a/projects/prison-custody-status-to-delius/tech-docs/source/img/prison-custody-status-to-delius-workflow-release.svg b/projects/prison-custody-status-to-delius/tech-docs/source/img/prison-custody-status-to-delius-workflow-release.svg new file mode 100644 index 0000000000..e12c3251e2 --- /dev/null +++ b/projects/prison-custody-status-to-delius/tech-docs/source/img/prison-custody-status-to-delius-workflow-release.svg @@ -0,0 +1,858 @@ +NOMISprison-offender-events.prisoner.releasedDelius

Prison Release

+

User releases person via NOMIS.
+This action raises a domain event

+
Prisoner Released

Delius Throughcare Updates

+

Custody status is updated in Delius based on
+the status, movement reason and location
+in the domain event message

+
AddRelease RecordUpdateCurrent InstitutionUpdateCustody StatusCreate Contact + + + + + + + + + + + +
diff --git a/projects/prison-custody-status-to-delius/tech-docs/source/index.html.md.erb b/projects/prison-custody-status-to-delius/tech-docs/source/index.html.md.erb index cc02ae7a4a..ab1fd64fde 100644 --- a/projects/prison-custody-status-to-delius/tech-docs/source/index.html.md.erb +++ b/projects/prison-custody-status-to-delius/tech-docs/source/index.html.md.erb @@ -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\//, "./") %> \ No newline at end of file +<%= 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\//, "./") %>