-
Notifications
You must be signed in to change notification settings - Fork 1
API Walkthroughs 17.2 Police to Hospital move without PNC
-
[FRONTEND] The initial move record is created in a
requested
state with a specific move date by a PECS Police user via the frontend. A new profile is assigned to the move.It is not expected that suppliers would create the initial record. For the purposes of testing however, frontend requests can be simulated with the following calls:
# get the gender reference data with: curl --request GET \ --url http://server/api/reference/genders \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX' # get the ethnicities reference data with: curl --request GET \ --url http://server/api/reference/ethnicities \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX' # create a new person record using the gender and ethnicity reference data curl --request POST \ --url http://server/api/people \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX' \ --header 'content-type: application/json' \ --header 'idempotency-key: ec74fd04-e2a9-44ca-aeb7-ebe7d57d6693' \ --data '{ "data": { "type": "people", "attributes": { "first_names": "Bob", "last_name": "Roberts", "date_of_birth": "1980-03-04", "gender_additional_information": null, "prison_number": null, "police_national_computer": null, "criminal_records_office": null }, "relationships": { "gender": { "data": { "type": "genders", "id": "ffac6763-26d6-4425-8005-6e5d052aed88" } }, "ethnicity": { "data": { "type": "ethnicities", "id": "f480eeff-848c-4fcc-bd75-9f61850fa5bf" } } } } }' # get the assessment questions reference data with: curl --request GET \ --url http://server/api/reference/assessment_questions \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX' # create a new profile record curl --request POST \ --url http://server/api/people/9d8a3f81-f7ae-4c52-ad1f-9ae3fd64e89e/profiles \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX' \ --header 'content-type: application/json' \ --header 'idempotency-key: 31e1bcbf-7c41-47ef-a88b-c3f511edbe51' \ --data '{ "data": { "type": "profiles", "attributes": { "assessment_answers": [ { "key": "violent", "category": "risk", "title": "Violent", "comments": "does not like marmite", "assessment_question_id": "af8cfc67-757c-4019-9d5e-618017de1617", "imported_from_nomis": false }, { "key": "escape", "category": "risk", "title": "Escape", "comments": "good at climbing fences", "assessment_question_id": "f2db9a8f-a5a9-40cf-875b-d1f5f62b2497", "imported_from_nomis": false }, { "key": "hold_separately", "category": "risk", "title": "Must be held separately", "comments": "must be held separately", "assessment_question_id": "8f38efb0-36c1-4a56-8c66-3b72c9525f92", "imported_from_nomis": false }, { "key": "special_diet_or_allergy", "category": "health", "title": "Special diet or allergy", "comments": "peanut allergy", "assessment_question_id": "e6faaf20-3072-4a65-91f7-93d52b16260f", "imported_from_nomis": false } ] } } }' # create a Police to Hospital hospital move using the new profile curl --request POST \ --url http://server/api/moves \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX' \ --header 'content-type: application/json' \ --header 'idempotency-key: f6aabfba-19b9-4945-926f-3e4e15bf1e0d' \ --data '{ "data": { "type": "moves", "attributes": { "date": "2020-08-07", "status": "requested", "additional_information": "example Police to Hospital move: Guildford Custody Suite to St Marys Hospital", "move_type": "hospital" }, "relationships": { "profile": { "data": { "type": "profiles", "id": "af23ecc6-77b8-4ef5-8a91-97e0e61b47c2" } }, "from_location": { "data": { "type": "locations", "id": "8fadb516-f10a-45b1-91b7-a256196829f9" } }, "to_location": { "data": { "type": "locations", "id": "0a4f6c97-1757-452a-8c0b-9db422f6e7d7" } } } } }'
This returns the new move record:
{ "data": { "id": "9e2a81fb-1d1d-4170-a967-ac2461cda5c0", "type": "moves", "attributes": { "additional_information": "example Police to Hospital move: Guildford Custody Suite to St Marys Hospital", "cancellation_reason": null, "cancellation_reason_comment": null, "created_at": "2020-08-05T14:49:53+01:00", "date": "2020-08-07", "date_from": null, "date_to": null, "move_agreed": null, "move_agreed_by": null, "move_type": "hospital", "reference": "YCK6925P", "rejection_reason": null, "status": "requested", "time_due": null, "updated_at": "2020-08-05T14:49:53+01:00" }, "relationships": { "profile": { "data": { "id": "af23ecc6-77b8-4ef5-8a91-97e0e61b47c2", "type": "profiles" } }, "from_location": { "data": { "id": "8fadb516-f10a-45b1-91b7-a256196829f9", "type": "locations" } }, "to_location": { "data": { "id": "0a4f6c97-1757-452a-8c0b-9db422f6e7d7", "type": "locations" } }, "prison_transfer_reason": { "data": null }, "court_hearings": { "data": [] }, "allocation": { "data": null }, "original_move": { "data": null } } } }
-
Suppliers can retrieve a list of requested moves for specific dates by calling the get moves endpoint with appropriate filters:
curl --request GET \ --url 'http://server/api/moves?filter%5Bdate_from%5D=2020-08-07&filter%5Bdate_to%5D=2020-08-07&filter%5Bstatus%5D=requested&include=profile.person%2Cfrom_location%2Cto_location' \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX'
This returns the following JSON:
{ "data": [ { "id": "9e2a81fb-1d1d-4170-a967-ac2461cda5c0", "type": "moves", "attributes": { "additional_information": "example Police to Hospital move: Guildford Custody Suite to St Marys Hospital", "cancellation_reason": null, "cancellation_reason_comment": null, "created_at": "2020-08-05T14:49:53+01:00", "date": "2020-08-07", "date_from": null, "date_to": null, "move_agreed": null, "move_agreed_by": null, "move_type": "hospital", "reference": "YCK6925P", "rejection_reason": null, "status": "requested", "time_due": null, "updated_at": "2020-08-05T14:49:53+01:00" }, "relationships": { "profile": { "data": { "id": "af23ecc6-77b8-4ef5-8a91-97e0e61b47c2", "type": "profiles" } }, "from_location": { "data": { "id": "8fadb516-f10a-45b1-91b7-a256196829f9", "type": "locations" } }, "to_location": { "data": { "id": "0a4f6c97-1757-452a-8c0b-9db422f6e7d7", "type": "locations" } }, "prison_transfer_reason": { "data": null }, "court_hearings": { "data": [] }, "allocation": { "data": null }, "original_move": { "data": null } } } ], "included": [ { "id": "af23ecc6-77b8-4ef5-8a91-97e0e61b47c2", "type": "profiles", "attributes": { "assessment_answers": [ { "title": "Violent", "comments": "does not like marmite", "created_at": "2020-08-05", "expires_at": null, "assessment_question_id": "af8cfc67-757c-4019-9d5e-618017de1617", "category": "risk", "key": "violent", "nomis_alert_type": null, "nomis_alert_code": null, "nomis_alert_type_description": null, "nomis_alert_description": null, "imported_from_nomis": false }, { "title": "Escape", "comments": "good at climbing fences", "created_at": "2020-08-05", "expires_at": null, "assessment_question_id": "f2db9a8f-a5a9-40cf-875b-d1f5f62b2497", "category": "risk", "key": "escape", "nomis_alert_type": null, "nomis_alert_code": null, "nomis_alert_type_description": null, "nomis_alert_description": null, "imported_from_nomis": false }, { "title": "Must be held separately", "comments": "must be held separately", "created_at": "2020-08-05", "expires_at": null, "assessment_question_id": "8f38efb0-36c1-4a56-8c66-3b72c9525f92", "category": "risk", "key": "hold_separately", "nomis_alert_type": null, "nomis_alert_code": null, "nomis_alert_type_description": null, "nomis_alert_description": null, "imported_from_nomis": false }, { "title": "Special diet or allergy", "comments": "peanut allergy", "created_at": "2020-08-05", "expires_at": null, "assessment_question_id": "e6faaf20-3072-4a65-91f7-93d52b16260f", "category": "health", "key": "special_diet_or_allergy", "nomis_alert_type": null, "nomis_alert_code": null, "nomis_alert_type_description": null, "nomis_alert_description": null, "imported_from_nomis": false } ] }, "relationships": { "person": { "data": { "id": "9d8a3f81-f7ae-4c52-ad1f-9ae3fd64e89e", "type": "people" } }, "documents": { "data": [] }, "person_escort_record": { "data": null } } }, { "id": "9d8a3f81-f7ae-4c52-ad1f-9ae3fd64e89e", "type": "people", "attributes": { "first_names": "Bob", "last_name": "Roberts", "date_of_birth": "1980-03-04", "gender_additional_information": null, "prison_number": null, "criminal_records_office": null, "police_national_computer": null }, "relationships": { "ethnicity": { "data": { "id": "f480eeff-848c-4fcc-bd75-9f61850fa5bf", "type": "ethnicities" } }, "gender": { "data": { "id": "ffac6763-26d6-4425-8005-6e5d052aed88", "type": "genders" } }, "profiles": { "data": [ { "id": "af23ecc6-77b8-4ef5-8a91-97e0e61b47c2", "type": "profiles" } ] } } }, { "id": "8fadb516-f10a-45b1-91b7-a256196829f9", "type": "locations", "attributes": { "key": "sry016", "title": "Guildford Custody Suite", "location_type": "police", "nomis_agency_id": "SRY016", "can_upload_documents": false, "disabled_at": null }, "relationships": { "suppliers": { "data": [ { "id": "bccf4d77-984d-560c-9ffd-9badbb9157ca", "type": "suppliers" } ] } } }, { "id": "0a4f6c97-1757-452a-8c0b-9db422f6e7d7", "type": "locations", "attributes": { "key": "stmryl", "title": "St Mary's Hospital (London)", "location_type": "high_security_hospital", "nomis_agency_id": "STMRYL", "can_upload_documents": false, "disabled_at": null }, "relationships": { "suppliers": { "data": [] } } } ], "links": { "self": "http://localhost:5001/api/moves?filter%5Bdate_from%5D=2020-08-07&filter%5Bdate_to%5D=2020-08-07&filter%5Bstatus%5D=requested&include=profile.person%2Cfrom_location%2Cto_location&page%5Bnumber%5D=1&page%5Bsize%5D=20", "first": "http://localhost:5001/api/moves?filter%5Bdate_from%5D=2020-08-07&filter%5Bdate_to%5D=2020-08-07&filter%5Bstatus%5D=requested&include=profile.person%2Cfrom_location%2Cto_location&page%5Bnumber%5D=1&page%5Bsize%5D=20", "prev": null, "next": null, "last": "http://localhost:5001/api/moves?filter%5Bdate_from%5D=2020-08-07&filter%5Bdate_to%5D=2020-08-07&filter%5Bstatus%5D=requested&include=profile.person%2Cfrom_location%2Cto_location&page%5Bnumber%5D=1&page%5Bsize%5D=20" }, "meta": { "pagination": { "per_page": 20, "total_pages": 1, "total_objects": 1, "links": { "first": "/api/moves?filter%5Bdate_from%5D=2020-08-07&filter%5Bdate_to%5D=2020-08-07&filter%5Bstatus%5D=requested&include=profile.person%2Cfrom_location%2Cto_location&page=1", "last": "/api/moves?filter%5Bdate_from%5D=2020-08-07&filter%5Bdate_to%5D=2020-08-07&filter%5Bstatus%5D=requested&include=profile.person%2Cfrom_location%2Cto_location&page=1" } } } }
-
The new move can then be accepted changing its status from "requested" to "booked" by calling the
accept
endpoint:curl --request POST \ --url http://server/api/moves/9e2a81fb-1d1d-4170-a967-ac2461cda5c0/accept \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX' \ --header 'content-type: application/json' \ --header 'idempotency-key: 1ef34ae8-1cfe-4d54-8372-4fa73f7970f1' \ --data '{ "data": { "type": "accepts", "attributes": { "timestamp": "2020-08-05T13:52:00.351Z" } } }'
This will return a 204 No Content response.
-
Journeys should be added to move: please see the separate Journey API walkthrough document.
-
The move can be started, changing its status from "booked" to "in_transit" by calling the
start
endpoint:curl --request POST \ --url http://server/api/moves/9e2a81fb-1d1d-4170-a967-ac2461cda5c0/start \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX' \ --header 'content-type: application/json' \ --header 'idempotency-key: e4a934c2-a5fa-494c-a061-148f14cce52e' \ --data '{ "data": { "type": "starts", "attributes": { "timestamp": "2020-08-05T13:52:15.162Z", "notes": "van on the way" } } }'
This will return a 204 No Content response.
-
Finally, the move can be completed, changing its status from "in_transit" to "completed" by posting to the
complete
endpoint:curl --request POST \ --url http://server/api/moves/9e2a81fb-1d1d-4170-a967-ac2461cda5c0/complete \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX' \ --header 'content-type: application/json' \ --header 'idempotency-key: af7f224b-d29b-4726-a745-d41346786251' \ --data '{ "data": { "type": "completes", "attributes": { "timestamp": "2020-08-05T13:52:29.632Z", "notes": "all is well" } } }'
This will return a 204 No Content response.
-
Optionally, the current move record can be inspected at any time by calling the
GET move
endpoint, using an?include
parameter as required to return the full person, profile or location records:curl --request GET \ --url 'http://server/api/moves/9e2a81fb-1d1d-4170-a967-ac2461cda5c0?include=profile.person%2Cfrom_location%2Cto_location' \ --header 'accept: application/vnd.api+json; version=2' \ --header 'authorization: Bearer XXX'
Which returns:
{ "data": { "id": "9e2a81fb-1d1d-4170-a967-ac2461cda5c0", "type": "moves", "attributes": { "additional_information": "example Police to Hospital move: Guildford Custody Suite to St Marys Hospital", "cancellation_reason": null, "cancellation_reason_comment": null, "created_at": "2020-08-05T14:49:53+01:00", "date": "2020-08-07", "date_from": null, "date_to": null, "move_agreed": null, "move_agreed_by": null, "move_type": "hospital", "reference": "YCK6925P", "rejection_reason": null, "status": "completed", "time_due": null, "updated_at": "2020-08-05T14:50:22+01:00" }, "relationships": { "profile": { "data": { "id": "af23ecc6-77b8-4ef5-8a91-97e0e61b47c2", "type": "profiles" } }, "from_location": { "data": { "id": "8fadb516-f10a-45b1-91b7-a256196829f9", "type": "locations" } }, "to_location": { "data": { "id": "0a4f6c97-1757-452a-8c0b-9db422f6e7d7", "type": "locations" } }, "prison_transfer_reason": { "data": null }, "court_hearings": { "data": [] }, "allocation": { "data": null }, "original_move": { "data": null } } }, "included": [ { "id": "af23ecc6-77b8-4ef5-8a91-97e0e61b47c2", "type": "profiles", "attributes": { "assessment_answers": [ { "title": "Violent", "comments": "does not like marmite", "created_at": "2020-08-05", "expires_at": null, "assessment_question_id": "af8cfc67-757c-4019-9d5e-618017de1617", "category": "risk", "key": "violent", "nomis_alert_type": null, "nomis_alert_code": null, "nomis_alert_type_description": null, "nomis_alert_description": null, "imported_from_nomis": false }, { "title": "Escape", "comments": "good at climbing fences", "created_at": "2020-08-05", "expires_at": null, "assessment_question_id": "f2db9a8f-a5a9-40cf-875b-d1f5f62b2497", "category": "risk", "key": "escape", "nomis_alert_type": null, "nomis_alert_code": null, "nomis_alert_type_description": null, "nomis_alert_description": null, "imported_from_nomis": false }, { "title": "Must be held separately", "comments": "must be held separately", "created_at": "2020-08-05", "expires_at": null, "assessment_question_id": "8f38efb0-36c1-4a56-8c66-3b72c9525f92", "category": "risk", "key": "hold_separately", "nomis_alert_type": null, "nomis_alert_code": null, "nomis_alert_type_description": null, "nomis_alert_description": null, "imported_from_nomis": false }, { "title": "Special diet or allergy", "comments": "peanut allergy", "created_at": "2020-08-05", "expires_at": null, "assessment_question_id": "e6faaf20-3072-4a65-91f7-93d52b16260f", "category": "health", "key": "special_diet_or_allergy", "nomis_alert_type": null, "nomis_alert_code": null, "nomis_alert_type_description": null, "nomis_alert_description": null, "imported_from_nomis": false } ] }, "relationships": { "person": { "data": { "id": "9d8a3f81-f7ae-4c52-ad1f-9ae3fd64e89e", "type": "people" } }, "documents": { "data": [] }, "person_escort_record": { "data": null } } }, { "id": "9d8a3f81-f7ae-4c52-ad1f-9ae3fd64e89e", "type": "people", "attributes": { "first_names": "Bob", "last_name": "Roberts", "date_of_birth": "1980-03-04", "gender_additional_information": null, "prison_number": null, "criminal_records_office": null, "police_national_computer": null }, "relationships": { "ethnicity": { "data": { "id": "f480eeff-848c-4fcc-bd75-9f61850fa5bf", "type": "ethnicities" } }, "gender": { "data": { "id": "ffac6763-26d6-4425-8005-6e5d052aed88", "type": "genders" } }, "profiles": { "data": [ { "id": "af23ecc6-77b8-4ef5-8a91-97e0e61b47c2", "type": "profiles" } ] } } }, { "id": "8fadb516-f10a-45b1-91b7-a256196829f9", "type": "locations", "attributes": { "key": "sry016", "title": "Guildford Custody Suite", "location_type": "police", "nomis_agency_id": "SRY016", "can_upload_documents": false, "disabled_at": null }, "relationships": { "suppliers": { "data": [ { "id": "bccf4d77-984d-560c-9ffd-9badbb9157ca", "type": "suppliers" } ] } } }, { "id": "0a4f6c97-1757-452a-8c0b-9db422f6e7d7", "type": "locations", "attributes": { "key": "stmryl", "title": "St Mary's Hospital (London)", "location_type": "high_security_hospital", "nomis_agency_id": "STMRYL", "can_upload_documents": false, "disabled_at": null }, "relationships": { "suppliers": { "data": [] } } } ] }
- API Guide
- Version 2
- Asked Questions
- Webhook & Email notifications
- Walkthroughs
- Deployment
- Useful Queries
- Data quality improvements
-
Journeys and Payment Related Calls
- Single journey move
- Redirection before move commences
- Redirection after move commences
- Lockouts and Lodgings
- Assessments
- Event Documentation
- GPS Track a move