Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PI-2742 Add tech docs for court case and Delius #4590

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions projects/court-case-and-delius/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
# court-case-and-delius
# Court Case and Delius

// TODO Describe the service
This service listens for domain events containing case notes. The notes are merged with an existing case note or a new case note is created if one does not exist. If a case note arrives out of order, a warning will be logged and it will be ignored.

This service also provides a read-only API for authorised users to get information about a **Court case** and the **Conviction**.

# Business need

The consumer is used to update the Delius system when a case note is published for a Court case. The Delius system is used to inform practitioners, who manage cases, when there has been an update to the case notes.

The service also provides an API which is used by the Prepare a Case for Sentence service to get Court case details.

# Data dependencies
This service enables adding or updating data for case notes (contact entity in Delius) only. It provides read-only access relating to a **Person on Probation**, the **Event** (convictions, offences and Court appearances outcomes) and the **Court case** details.

## Context Map - Court Case data

![Context Map](./tech-docs/source/img/court-case-context-map.svg)

# Workflows
## Court case notes submitted
The notes are merged with an existing case note or a new case note is created if one does not exist. If a case note arrives out of order, a warning will be logged and it will be ignored.

| Business Event | Message Event Type / Filter |
| ------------------------- | ---------------------------- |
| Court case note published | court-case.comment.published |

![Context Map](./tech-docs/source/img/court-case-notes-submitted-workflow.svg)

# Interface
## Message formats

The service responds to HMPPS Domain Event messages via the
[Court Case and Delius Queue](https://github.com/ministryofjustice/cloud-platform-environments/blob/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-probation-integration-services-prod/resources/court-case-and-delius-queue.tf).
The events are raised by TODO.

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/main/namespaces/live.cloud-platform.service.justice.gov.uk/hmpps-probation-integration-services-prod/resources/court-case-and-delius-queue.tf)

# API Access Control

API endpoints are secured by roles supplied by the HMPPS Auth client used in
the requests

| API Endpoint | Required Role |
| ---------------------- | ----------------------------------------- |
| /secure/offenders/ | PROBATION_API_\_COURT_CASE_\_CASE_DETAILS |
| /probation-case/{urn}/ | PROBATION_API_\_COURT_CASE_\_CASE_DETAILS |
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

style { ...@../../../../script/style.style }
vars { ...@../../../../script/style.vars }
** { ...@../../../../script/style.all-style }

context-cc: Court Case Context {
entities: Entities {
grid-columns: 4
pop: Person on Probation
pm: Person manager
conviction: Conviction
attendances: Attendances
registrations: Registrations
court-reports: Court reports
probation-record: Probation record
document: Document
status: Sentence status
lc: Licence conditions
cr: Conviction requirements
pr: PSS requirements
nsi: NSI details
}
}

context-delius: Delius Context {

interface: Court Case\n and Delius {
type: Anti-Corruption\nLayer
}

entities: Entities {
grid-columns: 5
person: Person on Probation
person-manager: Person manager
prison-manager: Prison manager
order-manager: Order manager
report-manager: Report manager
staff: Staff
contact: Contact
event: Event
offence: Offence
registration: Registration
deregistration: Deregistration
probation-area: Probation area
institution: Institution
court: Court
court-attendance: Court appearance
court-report: Court report
cr: Conviction requirement
pr: PSS requirement
lc: Licence condition
requirement: Requirement
attendance: Attendance
disposal: Disposal
release: Release
provision: Provision
as: Additional sentence
document: Document
nsi: NSI
}
}

context-cc--context-delius.interface: Upstream\n\n\nDownstream
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Court Case Workflow: Case Note Published

direction: right

style { ...@../../../../script/style.style }
vars { ...@../../../../script/style.vars }
** { ...@../../../../script/style.all-style }

# What triggers the workflow?
case-notes-published: Court Case Note Published {
style.font-size: 24

explanation: |md
## Court Case Note Published
- A Court case note is\
published
|

case_note_published: Court Case Note Published
}

domain_event: "court-case-and-delius\n.court-case.comment.published" {
style.font-size: 12
shape: queue
}

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

d_check_date: Check date of note
d_merge_notes: Add/Merge case note

d_check_date -> d_merge_notes

explanation: |md
## Merge case notes
- Check whether the notes have\
arrived out of order. If so,\
log a warning and ignore notes
- If case notes exist, merge the\
case notes
- Otherwise, add new case notes
|

}

case-notes-published -> domain_event -> delius
Loading
Loading