Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-britton-moj authored Feb 21, 2024
1 parent 11e3223 commit a67eb4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Referral(

@Column(name = "event_id")
val eventId: Long,
val approvedPremisesId: Long,
val approvedPremisesId: Long?,

val referralDate: LocalDate,
var expectedArrivalDate: LocalDate?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,23 @@ class ReferralService(
return ExistingReferrals(person.crn, referrals)
}

fun getReferral(person: Person, externalReference: String) =
referralRepository.findByPersonIdAndCreatedByUserIdAndReferralNotesContains(
fun getReferral(person: Person, externalReference: String): Referral {
val referral: Referral = referralRepository.findByPersonIdAndCreatedByUserIdAndReferralNotesContains(
person.id,
ServiceContext.servicePrincipal()!!.userId,
externalReference
) ?: throw IgnorableMessageException(
"Referral Not Found",
mapOf("crn" to person.crn, "externalReference" to externalReference)
)
if (referral.approvedPremisesId == null) {
throw IgnorableMessageException(
"Approved Premises unlinked from Referral",
mapOf("crn" to person.crn, "externalReference" to externalReference)
)
}
return referral
}

private fun BookingMade.referral(
person: Person,
Expand Down

0 comments on commit a67eb4c

Please sign in to comment.