From 7397e34e226727f6ec91b6e98c57b44355b96cc1 Mon Sep 17 00:00:00 2001 From: pmcphee77 <150798161+pmcphee77@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:15:57 +0100 Subject: [PATCH] PI-2063: Fixed order of sentences and added rarActivity flag (#3609) --- .../uk/gov/justice/digital/hmpps/ComplianceIntegrationTest.kt | 2 +- .../gov/justice/digital/hmpps/api/model/activity/Activity.kt | 1 + .../hmpps/integrations/delius/overview/entity/Contact.kt | 2 +- .../digital/hmpps/integrations/delius/overview/entity/Event.kt | 3 ++- .../uk/gov/justice/digital/hmpps/service/ScheduleService.kt | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ComplianceIntegrationTest.kt b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ComplianceIntegrationTest.kt index 5e3fe49a37..5239704469 100644 --- a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ComplianceIntegrationTest.kt +++ b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/ComplianceIntegrationTest.kt @@ -43,7 +43,7 @@ internal class ComplianceIntegrationTest { assertThat(res.currentSentences[0].activity.compliedAppointmentsCount, equalTo(2)) assertThat(res.currentSentences[0].activity.outcomeNotRecordedCount, equalTo(3)) assertThat(res.currentSentences[0].activity.acceptableAbsenceCount, equalTo(1)) - assertThat(res.previousOrders.orders[0].status, equalTo(TERMINATION_REASON.description)) + assertThat(res.previousOrders.orders[1].status, equalTo(TERMINATION_REASON.description)) } @Test diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/activity/Activity.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/activity/Activity.kt index 81b38b62ba..31017c0ecf 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/activity/Activity.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/activity/Activity.kt @@ -42,6 +42,7 @@ data class Activity( val isEmailOrTextToPop: Boolean? = false, val isPhoneCallToPop: Boolean? = false, val isPastAppointment: Boolean = (isAppointment && ZonedDateTime.now() > startDateTime), + val countsTowardsRAR: Boolean?, val lastUpdated: ZonedDateTime, val lastUpdatedBy: Name ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt index 0a5a7a7efd..25a6fa477f 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt @@ -246,7 +246,7 @@ interface ContactRepository : JpaRepository { and (to_char(c.contact_date, 'YYYY-MM-DD') < :dateNow or (to_char(c.contact_date, 'YYYY-MM-DD') = :dateNow and to_char(c.contact_start_time, 'HH24:MI') < :timeNow)) and c.soft_deleted = 0 - order by c.contact_date, c.contact_start_time asc + order by c.contact_date, c.contact_start_time desc """, nativeQuery = true ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Event.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Event.kt index 6edc38573e..01a5c37750 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Event.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Event.kt @@ -63,7 +63,8 @@ interface EventRepository : JpaRepository { "LEFT JOIN FETCH e.additionalOffences ao " + "LEFT JOIN FETCH m.offence mo " + "LEFT JOIN FETCH ao.offence aoo " + - "WHERE e.personId = :personId" + "WHERE e.personId = :personId " + + "ORDER BY e.eventNumber DESC" ) fun findByPersonId(personId: Long): List } diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ScheduleService.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ScheduleService.kt index 88d1a95c3b..75e5345d35 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ScheduleService.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ScheduleService.kt @@ -83,6 +83,7 @@ fun Contact.toActivity() = Activity( officerName = staff?.forename?.let { Name(forename = it, surname = staff.surname) }, rarCategory = requirement?.mainCategory?.description, rarToolKit = requirement?.mainCategory?.description, + countsTowardsRAR = rarActivity, rescheduled = rescheduledPop(), rescheduledStaff = rescheduledPop() || rescheduledStaff(), rescheduledPop = rescheduledPop(),