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

APS-1813 new cas1 placement requests endpoint #2299

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions server/@types/shared/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type { ApprovedPremisesApplicationSummary } from './models/ApprovedPremis
export type { ApprovedPremisesAssessment } from './models/ApprovedPremisesAssessment';
export type { ApprovedPremisesAssessmentStatus } from './models/ApprovedPremisesAssessmentStatus';
export type { ApprovedPremisesAssessmentSummary } from './models/ApprovedPremisesAssessmentSummary';
export type { ApprovedPremisesBedSearchResult } from './models/ApprovedPremisesBedSearchResult';
export type { ApprovedPremisesSummary } from './models/ApprovedPremisesSummary';
export type { ApprovedPremisesUser } from './models/ApprovedPremisesUser';
export type { ApprovedPremisesUserPermission } from './models/ApprovedPremisesUserPermission';
Expand All @@ -40,12 +39,11 @@ export type { AssessmentTask } from './models/AssessmentTask';
export type { Bed } from './models/Bed';
export type { BedDetail } from './models/BedDetail';
export type { BedSearchAttributes } from './models/BedSearchAttributes';
export type { BedSearchParameters } from './models/BedSearchParameters';
export type { BedSearchResult } from './models/BedSearchResult';
export type { BedSearchResultBedSummary } from './models/BedSearchResultBedSummary';
export type { BedSearchResultPremisesSummary } from './models/BedSearchResultPremisesSummary';
export type { BedSearchResultRoomSummary } from './models/BedSearchResultRoomSummary';
export type { BedSearchResults } from './models/BedSearchResults';
export type { BedspaceFilters } from './models/BedspaceFilters';
export type { BedStatus } from './models/BedStatus';
export type { BedSummary } from './models/BedSummary';
export type { Booking } from './models/Booking';
Expand Down Expand Up @@ -136,6 +134,7 @@ export type { Characteristic } from './models/Characteristic';
export type { CharacteristicPair } from './models/CharacteristicPair';
export type { ClarificationNote } from './models/ClarificationNote';
export type { Confirmation } from './models/Confirmation';
export type { DashboardPlacementRequest } from './models/DashboardPlacementRequest';
export type { DateCapacity } from './models/DateCapacity';
export type { DateChange } from './models/DateChange';
export type { DatePeriod } from './models/DatePeriod';
Expand Down Expand Up @@ -230,6 +229,7 @@ export type { PlacementRequirements } from './models/PlacementRequirements';
export type { PlacementType } from './models/PlacementType';
export type { Premises } from './models/Premises';
export type { PremisesBooking } from './models/PremisesBooking';
export type { PremisesFilters } from './models/PremisesFilters';
export type { PremisesSummary } from './models/PremisesSummary';
export type { PrisonCaseNote } from './models/PrisonCaseNote';
export type { ProbationDeliveryUnit } from './models/ProbationDeliveryUnit';
Expand Down
16 changes: 0 additions & 16 deletions server/@types/shared/models/ApprovedPremisesBedSearchResult.ts

This file was deleted.

2 changes: 0 additions & 2 deletions server/@types/shared/models/Assessment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/* eslint-disable */
import type { AssessmentDecision } from './AssessmentDecision';
import type { ClarificationNote } from './ClarificationNote';
import type { ReferralHistoryNote } from './ReferralHistoryNote';
import type { Unit } from './Unit';
export type Assessment = {
service: string;
Expand All @@ -18,6 +17,5 @@ export type Assessment = {
rejectionRationale?: string;
data?: Unit;
clarificationNotes: Array<ClarificationNote>;
referralHistoryNotes?: Array<ReferralHistoryNote>;
};

16 changes: 0 additions & 16 deletions server/@types/shared/models/BedSearchParameters.ts

This file was deleted.

15 changes: 0 additions & 15 deletions server/@types/shared/models/BedSearchResult.ts

This file was deleted.

4 changes: 2 additions & 2 deletions server/@types/shared/models/BedSearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { BedSearchResult } from './BedSearchResult';
import type { TemporaryAccommodationBedSearchResult } from './TemporaryAccommodationBedSearchResult';
export type BedSearchResults = {
/**
* How many distinct Rooms the Beds in the results belong to
Expand All @@ -16,6 +16,6 @@ export type BedSearchResults = {
* How many Beds are in the results
*/
resultsBedCount: number;
results: Array<BedSearchResult>;
results: Array<TemporaryAccommodationBedSearchResult>;
};

9 changes: 9 additions & 0 deletions server/@types/shared/models/BedspaceFilters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type BedspaceFilters = {
includedCharacteristicIds?: Array<string>;
excludedCharacteristicIds?: Array<string>;
};

4 changes: 2 additions & 2 deletions server/@types/shared/models/Cas1SpaceBookingDaySummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { Cas1SpaceBookingCharacteristic } from './Cas1SpaceBookingCharacteristic';
import type { Cas1SpaceCharacteristic } from './Cas1SpaceCharacteristic';
import type { PersonSummary } from './PersonSummary';
export type Cas1SpaceBookingDaySummary = {
id: string;
Expand All @@ -20,6 +20,6 @@ export type Cas1SpaceBookingDaySummary = {
*/
tier?: string;
releaseType?: string;
essentialCharacteristics: Array<Cas1SpaceBookingCharacteristic>;
essentialCharacteristics: Array<Cas1SpaceCharacteristic>;
};

21 changes: 21 additions & 0 deletions server/@types/shared/models/DashboardPlacementRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { BookingSummary } from './BookingSummary';
import type { Person } from './Person';
import type { PersonRisks } from './PersonRisks';
import type { PlacementDates } from './PlacementDates';
import type { PlacementRequestStatus } from './PlacementRequestStatus';
import type { PlacementRequirements } from './PlacementRequirements';
export type DashboardPlacementRequest = (PlacementRequirements & PlacementDates & {
id: string;
person: Person;
risks: PersonRisks;
applicationId: string;
status: PlacementRequestStatus;
applicationDate: string;
isParole: boolean;
booking?: BookingSummary;
});

2 changes: 1 addition & 1 deletion server/@types/shared/models/MigrationJobType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type MigrationJobType = 'update_all_users_from_community_api' | 'update_sentence_type_and_situation' | 'update_booking_status' | 'update_task_due_dates' | 'update_users_pdu_by_api' | 'update_cas2_applications_with_assessments' | 'update_cas2_status_updates_with_assessments' | 'update_cas2_notes_with_assessments' | 'update_cas1_fix_placement_app_links' | 'update_cas1_notice_types' | 'update_cas1_backfill_user_ap_area' | 'update_cas3_application_offender_name' | 'update_cas3_domain_event_type_for_person_departed_updated' | 'update_cas1_applications_licence_expiry_date';
export type MigrationJobType = 'update_all_users_from_community_api' | 'update_sentence_type_and_situation' | 'update_booking_status' | 'update_task_due_dates' | 'update_users_pdu_by_api' | 'update_cas2_applications_with_assessments' | 'update_cas2_status_updates_with_assessments' | 'update_cas2_notes_with_assessments' | 'update_cas1_fix_placement_app_links' | 'update_cas1_notice_types' | 'update_cas1_backfill_user_ap_area' | 'update_cas3_application_offender_name' | 'update_cas3_domain_event_type_for_person_departed_updated' | 'update_cas1_applications_licence_expiry_date' | 'update_cas1_backfill_offline_application_name';
3 changes: 3 additions & 0 deletions server/@types/shared/models/PlacementRequirements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import type { PlacementCriteria } from './PlacementCriteria';
export type PlacementRequirements = {
gender: Gender;
type: ApType;
/**
* Postcode outcode
*/
location: string;
radius: number;
essentialCriteria: Array<PlacementCriteria>;
Expand Down
9 changes: 9 additions & 0 deletions server/@types/shared/models/PremisesFilters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do not edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type PremisesFilters = {
includedCharacteristicIds?: Array<string>;
excludedCharacteristicIds?: Array<string>;
};

2 changes: 1 addition & 1 deletion server/@types/shared/models/SeedFileType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export type SeedFileType = 'approved_premises' | 'approved_premises_rooms' | 'temporary_accommodation_premises' | 'temporary_accommodation_bedspace' | 'user' | 'nomis_users' | 'external_users' | 'cas2_applications' | 'temporary_accommodation_users' | 'approved_premises_users' | 'characteristics' | 'update_noms_number' | 'update_users_from_api' | 'approved_premises_ap_staff_users' | 'approved_premises_cancel_bookings' | 'approved_premises_assessment_more_info_bug_fix' | 'approved_premises_redact_assessment_details' | 'approved_premises_booking_to_space_booking' | 'approved_premises_withdraw_placement_request' | 'approved_premises_replay_domain_events' | 'approved_premises_duplicate_application' | 'approved_premises_update_event_number' | 'approved_premises_link_booking_to_placement_request' | 'approved_premises_out_of_service_beds' | 'approved_premises_cru_management_areas' | 'approved_premises_space_planning_dry_run' | 'approved_premises_import_delius_referrals' | 'approved_premises_update_space_booking' | 'approved_premises_backfill_active_space_bookings_created_in_delius' | 'temporary_accommodation_referral_rejection';
export type SeedFileType = 'approved_premises' | 'approved_premises_rooms' | 'temporary_accommodation_premises' | 'temporary_accommodation_bedspace' | 'user' | 'nomis_users' | 'external_users' | 'cas2_applications' | 'temporary_accommodation_users' | 'approved_premises_users' | 'characteristics' | 'update_noms_number' | 'update_users_from_api' | 'approved_premises_ap_staff_users' | 'approved_premises_cancel_bookings' | 'approved_premises_assessment_more_info_bug_fix' | 'approved_premises_redact_assessment_details' | 'approved_premises_booking_to_space_booking' | 'approved_premises_withdraw_placement_request' | 'approved_premises_replay_domain_events' | 'approved_premises_duplicate_application' | 'approved_premises_update_event_number' | 'approved_premises_link_booking_to_placement_request' | 'approved_premises_out_of_service_beds' | 'approved_premises_cru_management_areas' | 'approved_premises_space_planning_dry_run' | 'approved_premises_import_delius_referrals' | 'approved_premises_update_space_booking' | 'approved_premises_backfill_active_space_bookings_created_in_delius' | 'approved_premises_create_test_applications' | 'approved_premises_delete_application_timeline_notes' | 'temporary_accommodation_referral_rejection';
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,24 @@
/* tslint:disable */
/* eslint-disable */
import type { BedSearchAttributes } from './BedSearchAttributes';
import type { BedSearchParameters } from './BedSearchParameters';
export type TemporaryAccommodationBedSearchParameters = (BedSearchParameters & {
import type { BedspaceFilters } from './BedspaceFilters';
import type { PremisesFilters } from './PremisesFilters';
export type TemporaryAccommodationBedSearchParameters = {
serviceName?: string;
startDate: string;
/**
* The number of days the Bed will need to be free from the start_date until
*/
durationDays: number;
/**
* The list of pdus Ids to search within
*/
probationDeliveryUnits: Array<string>;
premisesFilters?: PremisesFilters;
bedspaceFilters?: BedspaceFilters;
/**
* Bedspace and property attributes to filter on
*/
attributes?: Array<BedSearchAttributes>;
});
};

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { BedSearchResult } from './BedSearchResult';
import type { BedSearchResultBedSummary } from './BedSearchResultBedSummary';
import type { BedSearchResultPremisesSummary } from './BedSearchResultPremisesSummary';
import type { BedSearchResultRoomSummary } from './BedSearchResultRoomSummary';
import type { TemporaryAccommodationBedSearchResultOverlap } from './TemporaryAccommodationBedSearchResultOverlap';
export type TemporaryAccommodationBedSearchResult = (BedSearchResult & {
export type TemporaryAccommodationBedSearchResult = {
premises: BedSearchResultPremisesSummary;
room: BedSearchResultRoomSummary;
bed: BedSearchResultBedSummary;
overlaps: Array<TemporaryAccommodationBedSearchResultOverlap>;
});
};

5 changes: 3 additions & 2 deletions server/data/placementRequestClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BookingNotMade,
Cas1CruManagementArea,
DashboardPlacementRequest,
NewBookingNotMade,
NewPlacementRequestBooking,
NewPlacementRequestBookingConfirmation,
Expand Down Expand Up @@ -48,7 +49,7 @@ export default class PlacementRequestClient {
page = 1,
sortBy: PlacementRequestSortField = 'created_at',
sortDirection: SortDirection = 'asc',
): Promise<PaginatedResponse<PlacementRequest>> {
): Promise<PaginatedResponse<DashboardPlacementRequest>> {
const params: DashboardQueryParams = {}

Object.keys(allParams).forEach(key => {
Expand All @@ -61,7 +62,7 @@ export default class PlacementRequestClient {
params.crnOrName = normaliseCrn(allParams.crnOrName)
}

return this.restClient.getPaginatedResponse<PlacementRequest>({
return this.restClient.getPaginatedResponse<DashboardPlacementRequest>({
path: paths.placementRequests.dashboard.pattern,
page: page.toString(),
query: { ...params, sortBy, sortDirection },
Expand Down
6 changes: 3 additions & 3 deletions server/services/placementRequestService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PaginatedResponse, PlacementRequestDashboardSearchOptions } from '@approved-premises/ui'
import {
DashboardPlacementRequest,
NewBookingNotMade,
NewPlacementRequestBooking,
NewPlacementRequestBookingConfirmation,
PlacementRequest,
PlacementRequestDetail,
PlacementRequestSortField,
SortDirection,
Expand All @@ -21,7 +21,7 @@ export default class PlacementRequestService {
page: number = 1,
sortBy: PlacementRequestSortField = 'created_at',
sortDirection: SortDirection = 'asc',
): Promise<PaginatedResponse<PlacementRequest>> {
): Promise<PaginatedResponse<DashboardPlacementRequest>> {
const placementRequestClient = this.placementRequestClientFactory(token)

return placementRequestClient.dashboard(filters, page, sortBy, sortDirection)
Expand All @@ -33,7 +33,7 @@ export default class PlacementRequestService {
page: number = 1,
sortBy: PlacementRequestSortField = 'created_at',
sortDirection: SortDirection = 'asc',
): Promise<PaginatedResponse<PlacementRequest>> {
): Promise<PaginatedResponse<DashboardPlacementRequest>> {
const placementRequestClient = this.placementRequestClientFactory(token)

return placementRequestClient.dashboard(searchParams, page, sortBy, sortDirection)
Expand Down
22 changes: 11 additions & 11 deletions server/utils/placementRequests/table.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addDays } from 'date-fns'
import {
PlacementRequest,
DashboardPlacementRequest,
PlacementRequestSortField,
PlacementRequestStatus,
PlacementRequestTask,
Expand Down Expand Up @@ -33,10 +33,10 @@ export const tableRows = (tasks: Array<PlacementRequestTask>): Array<TableRow> =
}

export const dashboardTableRows = (
placementRequests: Array<PlacementRequest>,
placementRequests: Array<DashboardPlacementRequest>,
status: PlacementRequestStatus | undefined,
): Array<TableRow> => {
return placementRequests.map((placementRequest: PlacementRequest) => {
return placementRequests.map((placementRequest: DashboardPlacementRequest) => {
return [
nameCell(placementRequest),
tierCell(placementRequest.risks),
Expand All @@ -50,25 +50,25 @@ export const dashboardTableRows = (
})
}

export const statusCell = (placementRequest: PlacementRequest): TableCell => {
export const statusCell = (placementRequest: DashboardPlacementRequest): TableCell => {
return {
text: placementRequestStatus[placementRequest.status],
}
}

export const requestTypeCell = (placementRequest: PlacementRequest): TableCell => {
export const requestTypeCell = (placementRequest: DashboardPlacementRequest): TableCell => {
return {
text: placementRequest.isParole ? 'Parole' : 'Standard release',
}
}

export const premisesNameCell = (placementRequest: PlacementRequest): TableCell => {
export const premisesNameCell = (placementRequest: DashboardPlacementRequest): TableCell => {
return {
text: placementRequest.booking?.premisesName,
}
}

export const durationCell = (placementRequest: PlacementRequest): TableCell => {
export const durationCell = (placementRequest: DashboardPlacementRequest): TableCell => {
return { text: DateFormats.formatDuration(daysToWeeksAndDays(placementRequest.duration), ['weeks', 'days']) }
}

Expand All @@ -84,21 +84,21 @@ export const dueDateCell = (task: PlacementRequestTask, differenceBetweenDueDate
}

export const expectedArrivalDateCell = (
item: PlacementRequestTask | PlacementRequest,
item: PlacementRequestTask | DashboardPlacementRequest,
format: 'short' | 'long' = 'long',
): TableCell => ({
text: DateFormats.isoDateToUIDate(item.expectedArrival, { format }),
})

export const actualArrivalDateCell = (item: PlacementRequest): TableCell => ({
export const actualArrivalDateCell = (item: DashboardPlacementRequest): TableCell => ({
text: item.booking?.arrivalDate ? DateFormats.isoDateToUIDate(item.booking?.arrivalDate, { format: 'short' }) : 'N/A',
})

export const applicationDateCell = (item: PlacementRequest): TableCell => ({
export const applicationDateCell = (item: DashboardPlacementRequest): TableCell => ({
text: DateFormats.isoDateToUIDate(item.applicationDate, { format: 'short' }),
})

export const nameCell = (item: PlacementRequestTask | PlacementRequest): TableCell => {
export const nameCell = (item: PlacementRequestTask | DashboardPlacementRequest): TableCell => {
if ('personName' in item && item.personName) {
return {
html: linkTo(matchPaths.placementRequests.show({ id: item.id }), {
Expand Down
Loading