From c19a44e36d060a55183bd4a74f14653464db0e5d Mon Sep 17 00:00:00 2001 From: Paul McPhee Date: Wed, 7 Aug 2024 16:27:22 +0100 Subject: [PATCH] PI-2106: Fixes to align with com api --- .../integrations/delius/contact/entity/Attendance.kt | 2 +- .../digital/hmpps/integrations/delius/event/nsi/Nsi.kt | 9 ++++----- .../integrations/delius/service/InterventionService.kt | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Attendance.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Attendance.kt index 39f5e1f6b9..6fe4a68dcd 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Attendance.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/contact/entity/Attendance.kt @@ -89,7 +89,7 @@ interface AttendanceRepository : JpaRepository { WHERE contact.offenderId = :personId AND contact.eventId = :eventId AND contact.date <= :contactDate - AND (contact.enforcementContact = true OR contact.outcome != null) + AND (contact.enforcementContact = true OR contact.outcome is not null) AND contact.type.attendanceContact = true AND contact.type.nationalStandards = true """ diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/nsi/Nsi.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/nsi/Nsi.kt index 3c885f085f..874af095cd 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/nsi/Nsi.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/event/nsi/Nsi.kt @@ -175,15 +175,14 @@ interface NsiRepository : JpaRepository { @Query( """ select nsi from Nsi nsi - where nsi.id = :nsiId and nsi.eventId = :eventId + where nsi.id = :nsiId """ - ) - fun findByNsiId(nsiId: Long, eventId: Long): Nsi? + fun findByNsiId(nsiId: Long): Nsi? fun findByPersonIdAndEventIdAndTypeCodeIn(personId: Long, eventId: Long, codes: List): List } -fun NsiRepository.getByNsiId(nsiId: Long, eventId: Long) = - findByNsiId(nsiId, eventId) ?: throw NotFoundException("NSI with id $nsiId not found") +fun NsiRepository.getByNsiId(nsiId: Long) = + findByNsiId(nsiId) ?: throw NotFoundException("NSI with id $nsiId not found") diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/service/InterventionService.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/service/InterventionService.kt index 1a264d37c8..238fb039f0 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/service/InterventionService.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/service/InterventionService.kt @@ -31,8 +31,8 @@ class InterventionService( fun getNsiByNsiId(crn: String, convictionId: Long, nsiId: Long): Nsi { val person = personRepository.getPerson(crn) - val event = eventRepository.getByPersonAndEventNumber(person, convictionId) - return nsiRepository.getByNsiId(nsiId, event.id).toNsi() + eventRepository.getByPersonAndEventNumber(person, convictionId) + return nsiRepository.getByNsiId(nsiId).toNsi() } }