Skip to content

Commit

Permalink
PI-2470 Truncate long assessor name by initialising first name(s) (#4194
Browse files Browse the repository at this point in the history
)
  • Loading branch information
marcus-bcl authored Aug 23, 2024
1 parent e2c6e56 commit 3f85ef8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"totWeightedScore": 88,
"pOAssessment": "270",
"pOAssessmentDesc": "Review",
"assessorName": "LevelTwo CentralSupport",
"assessorName": "Reeeeeeeeeeaaaaaaaaaally Loooooooooooooooooong Name",
"ogrs1Year": 43,
"ogrs2Year": 61,
"reviewTerm": "N",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ internal class IntegrationTest {
val assessment = oasysAssessmentRepository.findByOasysId("100835871")
assertThat(assessment?.court?.code, equalTo("LVRPCC"))
assertThat(assessment?.offence?.code, equalTo("00857"))
assertThat(assessment?.assessedBy, equalTo("LevelTwo CentralSupport"))
assertThat(assessment?.assessedBy, equalTo("R. L. Name"))
assertThat(assessment?.date, equalTo(LocalDate.parse("2023-12-15")))
assertThat(assessment?.totalScore, equalTo(88))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class AssessmentService(
?.let { offenceRepository.findByCode(it.offenceCode + it.offenceSubcode) },
totalScore = furtherInformation.totWeightedScore,
description = furtherInformation.pOAssessmentDesc,
assessedBy = furtherInformation.assessorName,
assessedBy = furtherInformation.assessorName?.let { if (it.length > 35) initialiseName(it) else it },
riskFlags = riskFlags.joinToString(","),
concernFlags = concernFlags.joinToString(","),
dateCreated = initiationDate,
Expand All @@ -86,6 +86,12 @@ class AssessmentService(
?.forEach { assessment.withSentencePlan(it) }
return assessment
}

private fun initialiseName(name: String): String {
val names = name.split(Regex("\\s+")).toMutableList()
for (i in 0 until names.size - 1) names[i] = "${names[i].first()}."
return names.joinToString(" ")
}
}

private fun AssessmentSummary.contactDetail(contactDate: LocalDate) =
Expand Down

0 comments on commit 3f85ef8

Please sign in to comment.