Skip to content

Commit

Permalink
PI-1772: Introduced COM handover date (#3036)
Browse files Browse the repository at this point in the history
* PI-1772: Introduced COM handover date
  • Loading branch information
pmcphee77 authored Jan 16, 2024
1 parent e4df65b commit 02abe64
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class AllocationDemandIntegrationTest {
NamedCourt("Court One"),
CaseType.CUSTODY,
ProbationStatus(ManagementStatus.CURRENTLY_MANAGED),
Manager("JJ001", Name("Chip", null, "Rockefeller"), "T001", "PO")
Manager("JJ001", Name("Chip", null, "Rockefeller"), "T001", "PO"),
LocalDate.of(2023, 12, 31)
),
AllocationResponse(
"T456789",
Expand All @@ -91,7 +92,8 @@ class AllocationDemandIntegrationTest {
NamedCourt("Court Two"),
CaseType.CUSTODY,
ProbationStatus(ManagementStatus.CURRENTLY_MANAGED),
Manager("JJ001", Name("Chip", null, "Rockefeller"), "T001", "PO")
Manager("JJ001", Name("Chip", null, "Rockefeller"), "T001", "PO"),
null
)
)

Expand All @@ -101,6 +103,8 @@ class AllocationDemandIntegrationTest {
mockMvc.perform(post("/allocation-demand").withToken().withJson(request))
.andExpect(status().is2xxSuccessful)
.andExpect(jsonPath("\$.cases.length()", `is`(2)))
.andExpect(jsonPath("$.cases[0].comHandoverDate").value("2023-12-31"))
.andExpect(jsonPath("$.cases[1].comHandoverDate").doesNotExist())
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package uk.gov.justice.digital.hmpps.api.model

import java.time.LocalDate

data class AllocationResponse(
val crn: String,
val name: Name,
Expand All @@ -9,7 +11,8 @@ data class AllocationResponse(
val court: NamedCourt,
val type: CaseType = CaseType.UNKNOWN,
val probationStatus: ProbationStatus,
val communityPersonManager: Manager?
val communityPersonManager: Manager?,
val comHandoverDate: LocalDate?
)

data class AllocationDemandResponse(val cases: List<AllocationResponse>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class AllocationDemandRepository(val jdbcTemplate: NamedParameterJdbcTemplate) {
rs.getString("community_manager_team_code"),
gradeMap[rs.getString("community_manager_grade")]
)
}
},
rs.getDate("com_handover_date").toLocalDate()
)
}
}
Expand Down Expand Up @@ -234,7 +235,8 @@ SELECT o.CRN crn,
ias.FORENAME ias_forename,
ias.FORENAME2 ias_middle_name,
ias.SURNAME ias_surname,
iasg.CODE_DESCRIPTION ias_grade
iasg.CODE_DESCRIPTION ias_grade,
kd.KEY_DATE com_handover_date
FROM OFFENDER o
JOIN EVENT e ON e.OFFENDER_ID = o.OFFENDER_ID AND e.ACTIVE_FLAG = 1
JOIN OFFENDER_MANAGER cm ON cm.OFFENDER_ID = o.OFFENDER_ID AND cm.ACTIVE_FLAG = 1
Expand All @@ -249,6 +251,12 @@ FROM OFFENDER o
LEFT OUTER JOIN R_STANDARD_REFERENCE_LIST cmsg ON cms.STAFF_GRADE_ID = cmsg.STANDARD_REFERENCE_LIST_ID
LEFT OUTER JOIN R_STANDARD_REFERENCE_LIST du ON du.STANDARD_REFERENCE_LIST_ID = d.ENTRY_LENGTH_UNITS_ID
LEFT OUTER JOIN CUSTODY c ON c.DISPOSAL_ID = d.DISPOSAL_ID AND c.SOFT_DELETED = 0
LEFT OUTER JOIN (SELECT kd.CUSTODY_ID, kd.KEY_DATE
FROM KEY_DATE kd
JOIN R_STANDARD_REFERENCE_LIST srl
ON srl.STANDARD_REFERENCE_LIST_ID = kd.KEY_DATE_TYPE_ID
AND srl.CODE_VALUE = 'POM2'
AND kd.SOFT_DELETED = 0) kd ON kd.CUSTODY_ID = c.CUSTODY_ID
LEFT OUTER JOIN R_STANDARD_REFERENCE_LIST cs ON cs.STANDARD_REFERENCE_LIST_ID = c.CUSTODIAL_STATUS_ID
LEFT OUTER JOIN INITIAL_APPOINTMENT ia ON e.EVENT_ID = ia.EVENT_ID AND ia.ROW_NUM = 1
LEFT OUTER JOIN STAFF ias ON ias.STAFF_ID = ia.STAFF_ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class AllocationDemandMapperTest {
Name("Bob", null, "Smith"),
"Team1",
"PSO"
)
),
LocalDate.now()
)

whenever(resultSet.getString("crn")).thenReturn(expected.crn)
Expand Down Expand Up @@ -88,6 +89,7 @@ class AllocationDemandMapperTest {
whenever(resultSet.getString("ias_middle_name")).thenReturn(expected.initialAppointment?.staff?.name?.middleName)
whenever(resultSet.getString("ias_surname")).thenReturn(expected.initialAppointment?.staff?.name?.surname)
whenever(resultSet.getString("ias_grade")).thenReturn(expected.initialAppointment?.staff?.grade)
whenever(resultSet.getDate("com_handover_date")).thenReturn(Date.valueOf(expected.comHandoverDate))
}

@Test
Expand Down

0 comments on commit 02abe64

Please sign in to comment.