diff --git a/projects/assessment-summary-and-delius/src/dev/resources/simulations/__files/rosh-summary.json b/projects/assessment-summary-and-delius/src/dev/resources/simulations/__files/rosh-summary.json new file mode 100644 index 0000000000..090c92b718 --- /dev/null +++ b/projects/assessment-summary-and-delius/src/dev/resources/simulations/__files/rosh-summary.json @@ -0,0 +1,8 @@ +{ + "assessments": [ + { + "whoAtRisk": "Known adults - Joe Bloggs", + "natureOfRisk": "Physical harm - Physical assault, shown willingness to use a weapon" + } + ] +} \ No newline at end of file diff --git a/projects/assessment-summary-and-delius/src/dev/resources/simulations/mappings/oasys-mappings.json b/projects/assessment-summary-and-delius/src/dev/resources/simulations/mappings/oasys-mappings.json index 632a65bed9..a043b08677 100644 --- a/projects/assessment-summary-and-delius/src/dev/resources/simulations/mappings/oasys-mappings.json +++ b/projects/assessment-summary-and-delius/src/dev/resources/simulations/mappings/oasys-mappings.json @@ -142,6 +142,19 @@ "status": 200, "bodyFileName": "A000011-multiple-risks.json" } + }, + { + "request": { + "method": "GET", + "urlPattern": "/eor/oasys/ass/sectionroshsumm/ALLOW/.+" + }, + "response": { + "headers": { + "Content-Type": "application/json" + }, + "status": 200, + "bodyFileName": "rosh-summary.json" + } } ] } \ No newline at end of file diff --git a/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt b/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt index 3d7637d021..78ab5ce1b1 100644 --- a/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt +++ b/projects/assessment-summary-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/IntegrationTest.kt @@ -325,7 +325,17 @@ internal class IntegrationTest { assertThat(registration.level?.code, equalTo(RiskLevel.H.code)) assertThat( registration.notes, - equalTo("The OASys assessment of Review on 07/12/2023 identified the Risk to children to be H") + equalTo( + """ + The OASys assessment of Review on 07/12/2023 identified the Risk to children to be H. + + *R10.1 Who is at risk* + Known adults - Joe Bloggs + + *R10.2 What is the nature of the risk* + Physical harm - Physical assault, shown willingness to use a weapon + """.trimIndent() + ) ) assertThat(registration.reviews, hasSize(1)) diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/oasys/OrdsClient.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/oasys/OrdsClient.kt index ada0260b2a..802964df1f 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/oasys/OrdsClient.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/oasys/OrdsClient.kt @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.integrations.oasys import com.fasterxml.jackson.annotation.JsonAlias import com.fasterxml.jackson.annotation.JsonFormat +import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.service.annotation.GetExchange import java.net.URI import java.time.LocalDate @@ -9,6 +10,9 @@ import java.time.LocalDate interface OrdsClient { @GetExchange fun getAssessmentSummary(uri: URI): AssessmentSummaries + + @GetExchange(url = "/ass/sectionroshsumm/ALLOW/{assessmentPk}") + fun getRoshSummary(@PathVariable("assessmentPk") assessmentPk: Long): RoshSummary? } data class AssessmentSummary( @@ -151,3 +155,12 @@ data class BasicSentencePlanArea( val bspAreaLinked: String?, val bspAreaLinkedDesc: String? ) + +data class RoshSummary( + val assessments: List +) + +data class RoshSummaryAssessment( + val whoAtRisk: String? = null, + val natureOfRisk: String? = null, +) diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/RiskService.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/RiskService.kt index a4837d31f9..4f52c8f19c 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/RiskService.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/RiskService.kt @@ -14,6 +14,7 @@ import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.Ref import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceDataRepository import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.registerLevel import uk.gov.justice.digital.hmpps.integrations.oasys.AssessmentSummary +import uk.gov.justice.digital.hmpps.integrations.oasys.OrdsClient import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import java.time.LocalDate @@ -23,6 +24,7 @@ class RiskService( private val registerTypeRepository: RegisterTypeRepository, private val referenceDataRepository: ReferenceDataRepository, private val contactService: ContactService, + private val ordsClient: OrdsClient, private val featureFlags: FeatureFlags ) { fun recordRisk(person: Person, summary: AssessmentSummary) = @@ -75,8 +77,12 @@ class RiskService( if (matchingRegistrations.isEmpty()) { val type = registerTypeRepository.getByCode(riskType.code) val level = referenceDataRepository.registerLevel(riskLevel.code) - val notes = - "The OASys assessment of ${summary.furtherInformation.pOAssessmentDesc} on ${summary.dateCompleted.toDeliusDate()} identified the ${type.description} to be ${level.description}" + val roshSummary = ordsClient.getRoshSummary(summary.assessmentPk)?.assessments?.singleOrNull() + val notes = """ + |The OASys assessment of ${summary.furtherInformation.pOAssessmentDesc} on ${summary.dateCompleted.toDeliusDate()} identified the ${type.description} to be ${level.description}. + |${roshSummary?.whoAtRisk?.let { "\n|*R10.1 Who is at risk*\n|$it" }} + |${roshSummary?.natureOfRisk?.let { "\n|*R10.2 What is the nature of the risk*\n|$it" }} + """.trimMargin() events += registrations.addRegistration(person, type, level, notes).regEvent(person.crn) // Registrations in the type's duplicate group should also be removed