+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/prisoner_profile_and_delius.xml b/.idea/runConfigurations/prisoner_profile_and_delius.xml
deleted file mode 100644
index 89dbef33ac..0000000000
--- a/.idea/runConfigurations/prisoner_profile_and_delius.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/probation_search_and_delius.run.xml b/.idea/runConfigurations/probation_search_and_delius.run.xml
new file mode 100644
index 0000000000..cec87429f9
--- /dev/null
+++ b/.idea/runConfigurations/probation_search_and_delius.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/probation_search_and_delius.xml b/.idea/runConfigurations/probation_search_and_delius.xml
deleted file mode 100644
index 40c7012df7..0000000000
--- a/.idea/runConfigurations/probation_search_and_delius.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/refer_and_monitor_and_delius.run.xml b/.idea/runConfigurations/refer_and_monitor_and_delius.run.xml
new file mode 100644
index 0000000000..92b961f7aa
--- /dev/null
+++ b/.idea/runConfigurations/refer_and_monitor_and_delius.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/refer_and_monitor_and_delius.xml b/.idea/runConfigurations/refer_and_monitor_and_delius.xml
deleted file mode 100644
index 772e36dba9..0000000000
--- a/.idea/runConfigurations/refer_and_monitor_and_delius.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/resettlement_passport_and_delius.run.xml b/.idea/runConfigurations/resettlement_passport_and_delius.run.xml
new file mode 100644
index 0000000000..5b5ea06437
--- /dev/null
+++ b/.idea/runConfigurations/resettlement_passport_and_delius.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/resettlement_passport_and_delius.xml b/.idea/runConfigurations/resettlement_passport_and_delius.xml
deleted file mode 100644
index 8d17d90b84..0000000000
--- a/.idea/runConfigurations/resettlement_passport_and_delius.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/risk_assessment_scores_to_delius.run.xml b/.idea/runConfigurations/risk_assessment_scores_to_delius.run.xml
new file mode 100644
index 0000000000..58728c3325
--- /dev/null
+++ b/.idea/runConfigurations/risk_assessment_scores_to_delius.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/risk_assessment_scores_to_delius.xml b/.idea/runConfigurations/risk_assessment_scores_to_delius.xml
deleted file mode 100644
index 0b42735976..0000000000
--- a/.idea/runConfigurations/risk_assessment_scores_to_delius.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/sentence_plan_and_delius.run.xml b/.idea/runConfigurations/sentence_plan_and_delius.run.xml
new file mode 100644
index 0000000000..48d60bb7ad
--- /dev/null
+++ b/.idea/runConfigurations/sentence_plan_and_delius.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/sentence_plan_and_delius.xml b/.idea/runConfigurations/sentence_plan_and_delius.xml
deleted file mode 100644
index c1629b5f9b..0000000000
--- a/.idea/runConfigurations/sentence_plan_and_delius.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/sentence_plan_and_oasys.run.xml b/.idea/runConfigurations/sentence_plan_and_oasys.run.xml
new file mode 100644
index 0000000000..c7e58f08d5
--- /dev/null
+++ b/.idea/runConfigurations/sentence_plan_and_oasys.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/sentence_plan_and_oasys.xml b/.idea/runConfigurations/sentence_plan_and_oasys.xml
deleted file mode 100644
index e38500dd25..0000000000
--- a/.idea/runConfigurations/sentence_plan_and_oasys.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/soc_and_delius.run.xml b/.idea/runConfigurations/soc_and_delius.run.xml
new file mode 100644
index 0000000000..b6d911b0a1
--- /dev/null
+++ b/.idea/runConfigurations/soc_and_delius.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/soc_and_delius.xml b/.idea/runConfigurations/soc_and_delius.xml
deleted file mode 100644
index 0a7556eb6e..0000000000
--- a/.idea/runConfigurations/soc_and_delius.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/subject_access_requests_and_delius.run.xml b/.idea/runConfigurations/subject_access_requests_and_delius.run.xml
new file mode 100644
index 0000000000..1136ecbc65
--- /dev/null
+++ b/.idea/runConfigurations/subject_access_requests_and_delius.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/subject_access_requests_and_delius.xml b/.idea/runConfigurations/subject_access_requests_and_delius.xml
deleted file mode 100644
index 5f2829d727..0000000000
--- a/.idea/runConfigurations/subject_access_requests_and_delius.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/tier_to_delius.run.xml b/.idea/runConfigurations/tier_to_delius.run.xml
new file mode 100644
index 0000000000..d9b97282d3
--- /dev/null
+++ b/.idea/runConfigurations/tier_to_delius.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/tier_to_delius.xml b/.idea/runConfigurations/tier_to_delius.xml
deleted file mode 100644
index 0a1157475d..0000000000
--- a/.idea/runConfigurations/tier_to_delius.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/unpaid_work_and_delius.run.xml b/.idea/runConfigurations/unpaid_work_and_delius.run.xml
new file mode 100644
index 0000000000..20fbe345a8
--- /dev/null
+++ b/.idea/runConfigurations/unpaid_work_and_delius.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/unpaid_work_and_delius.xml b/.idea/runConfigurations/unpaid_work_and_delius.xml
deleted file mode 100644
index 16b361cf2e..0000000000
--- a/.idea/runConfigurations/unpaid_work_and_delius.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/runConfigurations/workforce_allocations_to_delius.run.xml b/.idea/runConfigurations/workforce_allocations_to_delius.run.xml
new file mode 100644
index 0000000000..b627aac06c
--- /dev/null
+++ b/.idea/runConfigurations/workforce_allocations_to_delius.run.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/workforce_allocations_to_delius.xml b/.idea/runConfigurations/workforce_allocations_to_delius.xml
deleted file mode 100644
index 8b01a2480e..0000000000
--- a/.idea/runConfigurations/workforce_allocations_to_delius.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/projects/appointment-reminders-and-delius/README.md b/projects/appointment-reminders-and-delius/README.md
index 4515740f75..a4550237e2 100644
--- a/projects/appointment-reminders-and-delius/README.md
+++ b/projects/appointment-reminders-and-delius/README.md
@@ -1,3 +1,35 @@
-# appointment-reminders-and-delius
+# Appointment Reminders and Delius
-// TODO Describe the service
\ No newline at end of file
+## Business Need
+
+- Sending appointment reminders to people on probation to help improve compliance with supervision activities
+- Providing a method of automating the sending of SMS messages via GOV.UK Notify
+- Standardising the process of sending SMS appointment reminders across regions
+
+## Workflows
+
+### Sending SMS Reminders Based on Delius Data
+
+The service will send appointment reminders to people on probation by combining the data in _Delius_ and the [GOV.UK Notify](https://www.notifications.service.gov.uk/) service. Data is gathered from Delius, validated and templated SMS messages are sent using the GOV.UK Notify API.
+
+![Workflow Map](./tech-docs/source/img/east-of-england-upw-reminders.svg)
+
+### Downloading CSV Data
+
+A CSV file of the appointment reminders that the service will send on a particular day can be accessed via an API endpoint
+
+## Interfaces
+
+### Scheduled Job
+
+- SMS messages are send via a scheduled job
+- Telemetry is send to Application Insights for each SMS message sent
+
+### API Access Control
+
+API endpoints are secured by roles supplied by the HMPPS Auth client used in
+the requests
+
+| API Endpoint | Required Role |
+|-----------------------|--------------------------------------------------|
+| /upw-appointments.csv | PROBATION\_API\_\_REMINDERS\_\_UPW\_APPOINTMENTS |
diff --git a/projects/appointment-reminders-and-delius/deploy/values-prod.yml b/projects/appointment-reminders-and-delius/deploy/values-prod.yml
index 60c56efbf9..3b5628ba8d 100644
--- a/projects/appointment-reminders-and-delius/deploy/values-prod.yml
+++ b/projects/appointment-reminders-and-delius/deploy/values-prod.yml
@@ -11,4 +11,4 @@ generic-service:
jobs:
unpaid-work-appointment-reminders:
dry-run: true
- schedule: '0 18 * * *' # 6:00pm UTC every day
\ No newline at end of file
+ schedule: '30 18 * * *' # 6:30pm UTC every day
\ No newline at end of file
diff --git a/projects/appointment-reminders-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/UnpaidWorkAppointmentsService.kt b/projects/appointment-reminders-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/UnpaidWorkAppointmentsService.kt
index 2b08245809..71481ec84c 100644
--- a/projects/appointment-reminders-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/UnpaidWorkAppointmentsService.kt
+++ b/projects/appointment-reminders-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/UnpaidWorkAppointmentsService.kt
@@ -15,7 +15,7 @@ class UnpaidWorkAppointmentsService(
@Value("\${govuk-notify.templates.upw-appointment-reminder}") private val templateId: String,
) {
fun sendUnpaidWorkAppointmentReminders(providerCode: String, dryRun: Boolean = false) {
- upwAppointmentRepository.getUnpaidWorkAppointments(LocalDate.now().plusDays(2), providerCode)
+ upwAppointmentRepository.getUnpaidWorkAppointments(LocalDate.now().plusDays(3), providerCode)
.forEach {
notificationClient.sendSms(
templateId,
diff --git a/projects/appointment-reminders-and-delius/tech-docs/diag/east-of-england-upw-reminders.d2 b/projects/appointment-reminders-and-delius/tech-docs/diag/east-of-england-upw-reminders.d2
new file mode 100644
index 0000000000..eae41899e9
--- /dev/null
+++ b/projects/appointment-reminders-and-delius/tech-docs/diag/east-of-england-upw-reminders.d2
@@ -0,0 +1,79 @@
+# Appointment SMS Flow
+
+direction: down
+
+style { ...@../../../../script/style.style }
+vars { ...@../../../../script/style.vars }
+** { ...@../../../../script/style.all-style }
+
+data: Delius Data {
+ "" {
+ explanation: |md
+ Name, mobile number and appointment date
+ |
+ }
+}
+
+deduplicate: Deduplication {
+ "" {
+ explanation: |md
+ Where there are multiple appointments for a mobile number\
+ only send a single reminder
+ |
+ }
+}
+
+validate: Validation {
+ validate_person: Person Validation {
+ explanation: |md
+ - The person is not in custody or on remand
+ - The person is not unlawfully at large
+ - The person is not Limited Access
+ |
+ }
+
+ validate_comms: Communication Validation {
+ explanation: |md
+ - The mobile number is formatted correctly
+ - The person has not opted out of SMS contacts
+ |
+ }
+
+ validate_activity: Activity Validation {
+ explanation: |md
+ - The person has an active unpaid work requirement
+ - The unpaid work requirement is not related to\
+ Education, Training and Employment
+ - There is time remaining on the unpaid work requirement
+ - The appointment does not have an outcome
+ |
+ }
+}
+
+ok: Validation OK
+fail: Validation Fail
+
+send: Send SMS {
+ notify: GOV.UK Notify {
+ explanation: |md
+ Send SMS appointment reminder to person on probation
+ |
+ }
+}
+
+end1: End {
+ shape: circle
+}
+
+end2: End {
+ shape: circle
+}
+
+data -> validate
+validate -> ok: OK
+validate -> fail: Fail
+
+ok -> deduplicate
+deduplicate -> send
+send -> end1
+fail -> end2
diff --git a/projects/appointment-reminders-and-delius/tech-docs/source/img/east-of-england-upw-reminders.svg b/projects/appointment-reminders-and-delius/tech-docs/source/img/east-of-england-upw-reminders.svg
new file mode 100644
index 0000000000..77b7928bf6
--- /dev/null
+++ b/projects/appointment-reminders-and-delius/tech-docs/source/img/east-of-england-upw-reminders.svg
@@ -0,0 +1,888 @@
+
diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ProbationCaseDataLoader.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ProbationCaseDataLoader.kt
index 56deb3a926..2194d12f44 100644
--- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ProbationCaseDataLoader.kt
+++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/ProbationCaseDataLoader.kt
@@ -14,6 +14,7 @@ import uk.gov.justice.digital.hmpps.entity.LimitedAccessPerson
import uk.gov.justice.digital.hmpps.entity.Restriction
import uk.gov.justice.digital.hmpps.integrations.delius.approvedpremises.referral.entity.EventRepository
import uk.gov.justice.digital.hmpps.integrations.delius.person.Ldu
+import uk.gov.justice.digital.hmpps.integrations.delius.person.ProbationCase
import uk.gov.justice.digital.hmpps.integrations.delius.person.ProbationCaseRepository
import uk.gov.justice.digital.hmpps.integrations.delius.person.manager.probation.PersonManagerRepository
import uk.gov.justice.digital.hmpps.integrations.delius.person.offence.entity.AdditionalOffence
@@ -100,9 +101,34 @@ class ProbationCaseDataLoader(
)
)
+ listOf(
+ ProbationCaseGenerator.CASE_COMPLEX,
+ ProbationCaseGenerator.CASE_X320741,
+ ProbationCaseGenerator.CASE_LAO_RESTRICTED,
+ ProbationCaseGenerator.CASE_LAO_EXCLUSION,
+ ).forEach {
+ generateEventAndAddOffences(probationCase = it)
+ }
+
+ personalCircumstanceTypeRepository.saveAll(PersonalCircumstanceGenerator.PC_TYPES)
+ personalCircumstanceSubTypeRepository.saveAll(PersonalCircumstanceGenerator.PC_SUB_TYPES)
+ personalCircumstanceRepository.save(
+ PersonalCircumstanceGenerator.generate(
+ ProbationCaseGenerator.CASE_COMPLEX.id,
+ PersonalCircumstanceGenerator.PC_TYPES.first { it.code == PersonalCircumstanceType.Code.VETERAN.value },
+ PersonalCircumstanceGenerator.PC_SUB_TYPES.first { it.description == PersonalCircumstanceType.Code.VETERAN.value + "SUB" }
+ ))
+
+ mutableLimitedAccessPersonRepository.save(RESTRICTED_CASE)
+ mutableLimitedAccessPersonRepository.save(EXCLUDED_CASE)
+ restrictionRepository.save(LimitedAccessGenerator.generateRestriction(RESTRICTED_CASE.toLimitedAccessPerson()))
+ exclusionRepository.save(LimitedAccessGenerator.generateExclusion(EXCLUDED_CASE.toLimitedAccessPerson()))
+ }
+
+ private fun generateEventAndAddOffences(probationCase: ProbationCase) {
val event = PersonGenerator.generateEvent(
"1",
- ProbationCaseGenerator.CASE_COMPLEX.id
+ probationCase.id
).apply(eventRepository::save)
mainOffenceRepository.save(
@@ -120,20 +146,6 @@ class ProbationCaseDataLoader(
LocalDate.now().minusDays(5)
)
)
-
- personalCircumstanceTypeRepository.saveAll(PersonalCircumstanceGenerator.PC_TYPES)
- personalCircumstanceSubTypeRepository.saveAll(PersonalCircumstanceGenerator.PC_SUB_TYPES)
- personalCircumstanceRepository.save(
- PersonalCircumstanceGenerator.generate(
- ProbationCaseGenerator.CASE_COMPLEX.id,
- PersonalCircumstanceGenerator.PC_TYPES.first { it.code == PersonalCircumstanceType.Code.VETERAN.value },
- PersonalCircumstanceGenerator.PC_SUB_TYPES.first { it.description == PersonalCircumstanceType.Code.VETERAN.value + "SUB" }
- ))
-
- mutableLimitedAccessPersonRepository.save(RESTRICTED_CASE)
- mutableLimitedAccessPersonRepository.save(EXCLUDED_CASE)
- restrictionRepository.save(LimitedAccessGenerator.generateRestriction(RESTRICTED_CASE.toLimitedAccessPerson()))
- exclusionRepository.save(LimitedAccessGenerator.generateExclusion(EXCLUDED_CASE.toLimitedAccessPerson()))
}
}
diff --git a/templates/runConfiguration.xml b/templates/runConfiguration.xml
index 7ac101736d..75a9d1e251 100644
--- a/templates/runConfiguration.xml
+++ b/templates/runConfiguration.xml
@@ -1,12 +1,29 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+ false
+
\ No newline at end of file