diff --git a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt index fc2ea8e39f..0e3ddfd696 100644 --- a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt +++ b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/NsiService.kt @@ -33,19 +33,19 @@ class NsiService( val type = nsiTypeRepository.getByCode(NsiType.Code.OPD_COMMUNITY_PATHWAY.value) val subType = opdAssessment.result.subTypeCode?.value?.let { nsiSubTypeRepository.nsiSubType(it) } val status = nsiStatusRepository.getByCode(NsiStatus.Code.READY_FOR_SERVICE.value) - val nsi = nsiRepository.save( - Nsi( - com.person, - opdAssessment.date.toLocalDate(), - type, - subType, - status, - opdAssessment.date, - opdAssessment.date, - com.providerId - ) + val nsi = Nsi( + com.person, + opdAssessment.date.toLocalDate(), + type, + subType, + status, + opdAssessment.date, + opdAssessment.date, + com.providerId ) nsi.appendNotes(opdAssessment.notes) + nsiRepository.save(nsi) + nsiManagerRepository.save( NsiManager( nsi, diff --git a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OpdService.kt b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OpdService.kt index 930e6d16e5..d00ef90fe2 100644 --- a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OpdService.kt +++ b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/OpdService.kt @@ -20,7 +20,7 @@ class OpdService( val nsi = nsiService.findOpdNsi(com.person.id) when { - activeEvent && nsi == null -> { + activeEvent && nsi?.active != true -> { nsiService.createNsi(opdAssessment, com) }