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

PI-2558 Add support for "Rescheduled - PoP request" outcome #4279

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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 @@ -37,7 +37,7 @@ object ContactGenerator {
compliantAcceptable = false
)

ContactOutcome.Code.RESCHEDULED_SERVICE_REQUEST -> generateOutcome(
ContactOutcome.Code.RESCHEDULED_SERVICE_REQUEST, ContactOutcome.Code.RESCHEDULED_POP_REQUEST -> generateOutcome(
it.value,
attendance = false,
compliantAcceptable = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ internal class MergeAppointmentIntegrationTest {
null,
null,
null,
null
null,
null,
)
val result = status().isOk
makeRequest(person, referralId, mergeAppointment, result)
Expand Down Expand Up @@ -103,7 +104,8 @@ internal class MergeAppointmentIntegrationTest {
null,
null,
null,
null
null,
null,
)

makeRequest(person, referralId, mergeAppointment, status().isConflict)
Expand Down Expand Up @@ -134,15 +136,16 @@ internal class MergeAppointmentIntegrationTest {
null,
null,
appointmentId,
null
null,
"Joe Bloggs",
)
val result = status().isOk

makeRequest(person, referralId, mergeAppointment, result)

val existing =
contactRepository.findByPersonCrnAndExternalReference(person.crn, mergeAppointment.previousUrn!!)!!
assertThat(existing.outcome?.code, equalTo(ContactOutcome.Code.RESCHEDULED_SERVICE_REQUEST.value))
assertThat(existing.outcome?.code, equalTo(ContactOutcome.Code.RESCHEDULED_POP_REQUEST.value))
assertFalse(existing.attended!!)
assertThat(existing.rarActivity, equalTo(false))

Expand Down Expand Up @@ -184,7 +187,8 @@ internal class MergeAppointmentIntegrationTest {
Outcome(Attended.YES, true, null, false),
null,
appointmentId,
null
null,
"Service Provider",
)
val result = status().isOk

Expand Down Expand Up @@ -229,7 +233,8 @@ internal class MergeAppointmentIntegrationTest {
null,
null,
null,
null
null,
null,
)

makeRequest(person, referralId, mergeAppointment, status().isBadRequest)
Expand All @@ -253,7 +258,8 @@ internal class MergeAppointmentIntegrationTest {
Outcome(Attended.LATE, false, NoSessionReasonType.POP_UNACCEPTABLE, true),
null,
null,
null
null,
null,
)
val result = status().isOk

Expand Down Expand Up @@ -292,7 +298,8 @@ internal class MergeAppointmentIntegrationTest {
null,
null,
null,
null
null,
null,
)

makeRequest(person, referralId, mergeAppointment, status().isNotFound)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.justice.digital.hmpps.api.model

import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactOutcome.Code
import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactType
import uk.gov.justice.digital.hmpps.service.Outcome
import java.time.ZonedDateTime
Expand All @@ -17,7 +18,8 @@ data class MergeAppointment(
val outcome: Outcome?,
val sentenceId: Long?,
val previousId: UUID?,
val deliusId: Long?
val deliusId: Long?,
val rescheduleRequestedBy: String?,
) {
val referralUrn
get() = "urn:hmpps:interventions-referral:$referralId"
Expand All @@ -31,4 +33,10 @@ data class MergeAppointment(
get() = if (countsTowardsRar) ContactType.Code.CRSAPT else ContactType.Code.CRSSAA

val end: ZonedDateTime = start.plusMinutes(durationInMinutes)

val rescheduleOutcome
get() = when (rescheduleRequestedBy) {
null, "Service Provider" -> Code.RESCHEDULED_SERVICE_REQUEST.value
else -> Code.RESCHEDULED_POP_REQUEST.value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class ContactOutcome(
FAILED_TO_COMPLY("AFTC"),
FAILED_TO_ATTEND("AFTA"),
RESCHEDULED_SERVICE_REQUEST("RSSR"),
RESCHEDULED_POP_REQUEST("RSOF"),
SENT_HOME("ATSS"),
WITHDRAWN("APPW")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ class AppointmentService(
mergeAppointment.start,
mergeAppointment.end,
mergeAppointment.countsTowardsRar
)?.addNotes(mergeAppointment.notes)
replacement?.also {
appointment.outcome = outcomeRepository.getByCode(Code.RESCHEDULED_SERVICE_REQUEST.value)
)?.also {
it.addNotes(mergeAppointment.notes)
appointment.outcome = outcomeRepository.getByCode(mergeAppointment.rescheduleOutcome)
appointment.rarActivity = false
contactRepository.save(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ internal class ReferralResourceTest {
null,
null,
null,
null
null,
null,
)
val ex = assertThrows<ResponseStatusException> {
referralResource.mergeAppointment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ internal class AppointmentServiceTest {
null,
53L,
null,
9562746271
9562746271,
null,
)
val nsi = NsiGenerator.generate(
NsiGenerator.TYPES.values.first(),
Expand Down
Loading