Tracing a path from Patrol Runsheets to Checkpoint Tour Sessions

Mobile scheduled patrols that have runsheets can have “Task Site Instructions” that link: account, task type and checkpoint tour information, but Task Site Instructions is only directly linked to base configuration metadata and not sessions or occurrences of things, so you won’t be able to make an all-in-one API call. You’ll need a couple.

You can pick from different starting points, either mobile-schedule-occurrence-logs to come top-down from the Patrols framework, or mobile-runsheet-sessions to come top-down from the Runsheets framework. I find that the mobile-schedule-occurrence-logs endpoint has the most relation lists tied to it, but requires more dot operator hops through relation lists to get to Zone information. The other mobile-runsheet-sessions can link directly to zone information but it doesn’t link to runsheet sessions.

 So in the end, I’m going to recommend mobile-schedule-occurrence-logs as the starting point of making a link between patrol, to runsheets, to task site instructions, to checkpoint tour sessions. But it won’t be a single API call. Some assembly will be required.

 [GET] /mobile-schedule-occurrence-logs?sort=-id&actionDate:after=2023-11-01&include=mobileRunsheetSession,mobileRunsheetSession.mobileRunsheet,mobileScheduleOccurrence,mobileRunsheetSession.mobileRunsheet.zonePosition,mobileRunsheetSession.mobileRunsheet.zone

 This will give you everything except the Checkpoint Tour Session information. To get the Checkpoint Tour Session information, you need to make a second API call and match on events for the account’s id and I guess on the date and and employee id.

 So if I have a mobile-schedule-occurrence-logs record with payload (using my example call above): 

{             "actionDate": "2024-02-07T00:00:00+00:00",             "status": "MISSED",             "lastStatusOn": null,             "lastStatusTime": null,             "onSiteOn": null,             "onSiteTime": null,             "enRouteOn": null,             "enRouteTime": null,             "completedOn": null,             "completedTime": null,             "mobileSchedule": 432,             "employee": 1055,             "report": null,             "id": 6594,             "mobileRunsheetSession": {                 "status": "ENDED_INCOMPLETED",                 "actionDate": "2024-02-07T00:00:00+00:00",                 "periodDate": null,                 "startTime": "2024-02-07T19:43:45+00:00",                 "endTime": "2024-02-13T18:28:40+00:00",                 "employee": 1055,                 "workSession": null,                 "id": 543,                 "mobileRunsheet": {                     "name": "Mobile Patrol Alpha",                     "customId": "",                     "dayOfWeek": "WEDNESDAY",                     "rangeStartTime": "10:00:00",                     "timeRangeStart": "10:00:00",                     "rangeEndTime": "18:00:00",                     "timeRangeEnd": "18:00:00",                     "region": 7,                     "beginDate": "2022-05-26T00:00:00+00:00",                     "endDate": null,                     "id": 411,                     "zone": {                         "name": "Mobile Patrol Alpha",                         "description": "",                         "customId": "769",                         "address": 1488,                         "region": 7,                         "status": "ACTIVE",                         "taxLocation": null,                         "id": 769                     },                     "zonePosition": {                         "name": "Mobile Patrol Officer",                         "description": "",                         "customId": "",                         "status": "ACTIVE",                         "account": 769,                         "contract": null,                         "nonBillable": true,                         "shiftMemo": "",                         "beginDate": null,                         "endDate": null,                         "breakRule": null,                         "taxClass": null,                         "payCodeLabel": null,                         "taxLocation": null,                         "id": 374                     }                 }             },             "mobileScheduleOccurrence": {                 "id": 20240207432,                 "customId": "",                 "dayOfWeekStart": "WEDNESDAY",                 "dayOfWeekEnd": "WEDNESDAY",                 "occurrenceDate": "2024-02-07T00:00:00+00:00",                 "rangeStartTime": "09:00:00",                 "timeRangeStart": "09:00:00",                 "rangeEndTime": "17:00:00",                 "timeRangeEnd": "17:00:00",                 "durationMinutes": 10,                 "beginServiceOn": "1970-01-01T00:33:39+00:00",                 "beginServiceDate": "2019-09-01T00:00:00+00:00",                 "endServiceOn": null,                 "endServiceDate": null,                 "description": "",                 "details": "",                 "timeZone": "America/New_York",                 "rangeStartedDateTime": "2024-02-07T09:00:00-05:00",                 "dateTimeRangeStart": "2024-02-07T09:00:00+00:00",                 "rangeEndedDateTime": "2024-02-07T17:00:00-05:00",                 "dateTimeRangeEnd": "2024-02-07T17:00:00+00:00",                 "taskType": 3,                 "mobileRunsheet": 411,                 "client": 40,                 "priceTier": 67,                 "zonePosition": 5,                 "reportTemplate": null,                 "mobileScheduleOccurrenceLog": 6594             }         }

 You can then make the call to checkpoint-tour-sessions:

 [GET]  /checkpoint-tour-sessions?employee=1055&client=40&startDateTime:after=2024-02-07T19:43:45+00:00&limit=1&sort=id

That can give you information on the event of a checkpoint tour session, that was part of a runsheet. But it’s not so direct. To give it more credibility, you could also validate with Task Site Instructions that the Task Type from mobile-schedule-occurrence-logs and the Checkpoint Tour ID of checkpoint-tour-sessions, by making a call to task-site-instructions:

 [GET] /task-site-instructions?checkpointTour=123&taskType=3&include=taskType,checkPointTour,checkPointTour.account.parentAccount

 Below example payload is not linked to the previous data shared above, but I’m showing you the JSON structure of task-site-instructions just the same for familiarity:

 

{             "site": 37,             "jobInstructions": "AB API TESTING",             "generalInstructions": "",             "priceTier": null,             "dispatchSla": null,             "generalDispatchSla": "",             "id": 159,             "checkPointTour": {                 "name": "Internal Patrols- Morning",                 "specialInstructions": "",                 "details": "",                 "position": null,                 "status": "ACTIVE",                 "active": true,                 "gracePeriod": 10,                 "estimatedDuration": 45,                 "recurrenceType": "WEEKLY",                 "id": 12,                 "account": {                     "name": "Area 10",                     "customId": "CT-9",                     "type": "CLIENT",                     "subType": "SITE",                     "address": 77,                     "region": 7,                     "closedDate": null,                     "taxLocation": null,                     "id": 37,                     "avatar": "https://innovation.staffr.net/rest/v1/avatar/accounts/37/6110a37bd08f60a606b6361ecb3aa430",                     "parentAccount": {                         "name": "NAC Finance Services",                         "customId": "7070",                         "type": "CLIENT",                         "subType": "MULTI",                         "address": 1476,                         "region": 7,                         "closedDate": null,                         "taxLocation": null,                         "id": 763,                         "avatar": "https://innovation.staffr.net/rest/v1/avatar/accounts/763/0fe4ee5a25f28e94b06890137d961885"                     }                 }             },             "taskType": {                 "id": 101,                 "name": "Ariella API tests TT",                 "dispatchable": false,                 "schedulable": true,                 "schedulableSiteTask": true,                 "billable": false,                 "prefix": "ABAPI",                 "active": true,                 "region": 2,                 "reportTemplate": null,                 "billableItem": null,                 "priority": "LOW",                 "dispatchGroup": "ZONE_USERS",                 "details": "",                 "isGlobal": false             }         }

 

Was this article helpful?
0 out of 0 found this helpful

Articles in this section