Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for fixes for HMAI-167, HMAI-168 ,HMAI-177 #585

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class InductionScheduleDeserializer : JsonDeserializer<InductionSchedule>() {
val inductionPerformedBy = node["inductionPerformedBy"]?.takeUnless { it.isNull }?.asText()
val inductionPerformedAt = node["inductionPerformedAt"]?.takeUnless { it.isNull }?.asText()?.let { LocalDate.parse(it) }
val version = node["version"]?.asInt()
val exemptionReason = node["exemptionReason"]?.asText()
val exemptionReason = node["exemptionReason"]?.takeUnless { it.isNull }?.asText()

return InductionSchedule(
deadlineDate = deadlineDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class GetInductionScheduleForPersonService(
fun execute(hmppsId: String): Response<InductionSchedule> {
val response = getPersonService.getNomisNumber(hmppsId = hmppsId)

// not a valid person
if (response.errors.isNotEmpty()) {
return Response(InductionSchedule(), response.errors)
}

response.data?.nomisNumber?.let {
return plpGateway.getInductionSchedule(it)
}
Expand All @@ -23,10 +28,15 @@ class GetInductionScheduleForPersonService(

fun getHistory(hmppsId: String): Response<InductionSchedules> {
val response = getPersonService.getNomisNumber(hmppsId = hmppsId)

// not a valid person
if (response.errors.isNotEmpty()) {
return Response(InductionSchedules(listOf()), response.errors)
}
// found data will return it
response.data?.nomisNumber?.let {
return plpGateway.getInductionScheduleHistory(it)
}
// no data found return an empty list
return Response(InductionSchedules(listOf()), response.errors)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ class GetPersonService(
*/
fun getNomisNumber(hmppsId: String): Response<NomisNumber?> =
when (identifyHmppsId(hmppsId)) {
IdentifierType.NOMS -> Response(data = NomisNumber(hmppsId))
IdentifierType.NOMS -> {
val prisonerResponse = getPersonFromNomis(hmppsId.uppercase())
val nomisNumber = prisonerResponse.data?.prisonerNumber
Response(
data = NomisNumber(nomisNumber),
errors = prisonerResponse.errors,
)
}

IdentifierType.CRN -> {
val personFromProbationOffenderSearch = probationOffenderSearchGateway.getPerson(id = hmppsId)
Expand Down
Loading