Skip to content

Commit fa9b0c8

Browse files
validate that the nomis number has a real person in prison search
1 parent 782a517 commit fa9b0c8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetPersonService.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ class GetPersonService(
5151
*/
5252
fun getNomisNumber(hmppsId: String): Response<NomisNumber?> =
5353
when (identifyHmppsId(hmppsId)) {
54-
IdentifierType.NOMS -> Response(data = NomisNumber(hmppsId))
54+
IdentifierType.NOMS -> {
55+
val prisoner = prisonerOffenderSearchGateway.getPrisonOffender(hmppsId)
56+
if (prisoner.errors.isNotEmpty()) {
57+
Response(data = null, errors = prisoner.errors)
58+
} else {
59+
Response(data = NomisNumber(hmppsId))
60+
}
61+
}
5562

5663
IdentifierType.CRN -> {
5764
val personFromProbationOffenderSearch = probationOffenderSearchGateway.getPerson(id = hmppsId)

0 commit comments

Comments
 (0)