Skip to content

missing clock in/out notifications

overview

If a doctor has not clocked in within 3 minutes after their scheduled shift starts, the doctor will receive an SMS notification to the mobile number on file on the doctor’s profile, indicating that they need to clock in.

If a doctor has clocked in to a shift, but has not clocked out within 3 minutes after their scheduled shift end, the doctor will receive an SMS notification to the mobile number on file on the doctor’s profile, indicating that they need to clock out.

notes

The users table has a new ‘mobile_number’ field added to it, to support sms notifications to that specified number.

Regular users can edit this in their ‘my profile’ screen from the main application.

Doctor users can edit this in their ‘profile’ screen in the vet portal.

There is currently also a ‘phone number’ field - the ‘mobile number’ is an explicitly separate field to allow users to decide whether or not to receive mobile notifications, and at which device.

Merging these two may be something we could attempt in future, but it will require more messaging, testing and dev work than having an explicitly separate ‘mobile’ field at this stage.

testing

A separate testing UI tool was built for non-production environments to allow fine-grained setting of a shift’s start/end times. This will help testing.

In the ‘tools’ screen, a ‘Update shift start/end’ button is available. Enter a shift’s ID string, then you can edit the start/end times. The system will show the wall time of the shift’s start/end times, and give you a sample date/time string to copy to overwrite the times with.

If it’s currently 2021-12-05 09:07:00 in the shift’s America/New_York timezone, this means it’s also … 7 past some hour now (whatever POV we’re using to view this).

The screen will provide 2021-12-05 09:05:00 as a sample to copy/paste as the start time.

Every minute, the system will check for assigned non-deleted shifts that are 3 minutes behind ‘now’, and will send a notification to the mobile number of the assigned user. In the example above, at 8 past the hour, the system will look for shifts started 3 minutes ago, which would match the time you would have just updated the shift start time to. The assigned doctor would get a text message to the ‘mobile_number’ on file.

12/21/21

twilio credentials and webhook handler added

for non-prod environments, you can hit

/setsmsurl?url=http://pr-1010.k8s.indevets.com/inbound/sms

and this will point the SMS inbound handler for one shared phone number to a configurable path for testing. For local dev, you will probably need to use ngrok or similar tool as a publicly available URL.

Calling /setsmsurl without any param will attempt to default to the base url plus /inbound/sms, but the override param is available.

There will need to be two phone numbers - one for ‘prod’ and one for testing. The ‘testing’ phone number will need it’s PN SID grabbed and added to environment as TWILIO_PHONE_SID

Currently my twilio credentials are hardcoded in for testing - had asked Nafis how we might have per-PR ‘secrets’ (which, looking back, we might not specifically have needed) and he didn’t have an answer he was comfortable with at that time.

To go to production, we’ll need real credentials to override via env vars (k8s secrets someplace?).

Inbound

Inbound SMS will be configured to hit InboundSMSController::incoming.

Incoming message will be parse for known commands/input.

Unknown input will be responded to with text from options table related to Options::SMS_REPLY_TEXT_UNSUPPORTED key.

Commands

3 commands are in ‘early working’ stages.

clockin

This will look for the next available shift to clock in to, looking back several hours to catch late clockins.

clockout

This will look for the currently clocked in shift and clock out.

status

This will show either the currently clocked in shift along with the clock in time, or it will show the next upcoming shift date/time/location.

1/20/22

This behaviour (notifications and clockin/out) are behind two feature flags:

ENABLE_CLOCK_IN_OUT_NOTIFICATIONS and ENABLE_CLOCK_IN_OUT_BY_SMS