Skip to content

Commit

Permalink
PI-2698 Add RoSH summary answers to registration notes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl committed Dec 18, 2024
1 parent 3775e37 commit cf2ab82
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"assessments": [
{
"whoAtRisk": "Known adults - Joe Bloggs",
"natureOfRisk": "Physical harm - Physical assault, shown willingness to use a weapon"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ 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

interface OrdsClient {
@GetExchange
fun getAssessmentSummary(uri: URI): AssessmentSummaries

@GetExchange(url = "/ass/sectionroshsumm/ALLOW/{assessmentPk}")
fun getRoshSummary(@PathVariable("assessmentPk") assessmentPk: Long): RoshSummary?
}

data class AssessmentSummary(
Expand Down Expand Up @@ -151,3 +155,12 @@ data class BasicSentencePlanArea(
val bspAreaLinked: String?,
val bspAreaLinkedDesc: String?
)

data class RoshSummary(
val assessments: List<RoshSummaryAssessment>
)

data class RoshSummaryAssessment(
val whoAtRisk: String? = null,
val natureOfRisk: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cf2ab82

Please sign in to comment.