Skip to content

Instantly share code, notes, and snippets.

@dariocravero
Created March 28, 2020 18:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dariocravero/0eb960336b4ca5c2daa0120219e57f94 to your computer and use it in GitHub Desktop.
Save dariocravero/0eb960336b4ca5c2daa0120219e57f94 to your computer and use it in GitHub Desktop.

Description of the models and the APIs: https://docs.google.com/document/d/1xFY6QJJFqMO3c1sZzcQCbAjwKEFzkn3almnnJWOxXNI/edit Heroku app (including data models, permissions and action definitions): https://appointment-booking-hasura.herokuapp.com/console/api-explorer Glitch (nodejs app) for the 2 actions: https://glitch.com/edit/#!/fishy-victorious-bongo?path=index.js:8:0 Some important notes:

  1. Since the client app is going to generate the recurrence rules on the client anyway, it'll have the ability to process the rules. That means that it can fetch the available recurrence rules from the db and render them into the UI by expanding them. Refer to book-appointment.js:L32 to see what this code might look like on the client

  2. We decided to have only 2 actions. One to book an appointment, which validates that times are available that day per the recurrence rules AND this time interval has not been specifically cancelled AND there are no overlapping appointments at this time To see this in action, try loading the database with sample values for clinics, their availability rules etc. And then run queries as a "patient" attempting to make a booking:

mutation book { book_appointment( clinic_id:"c94365c5-c952-4113-86b7-6f7c5174d8dc", start_time:"2020-03-25T14:15:00Z" ) { id appointment{ start_time end_time } } } You'll notice that this query succeeds once, and then twice but fails the third time. Because the clinic has set up 2 overlapping recurring rules for availability You can also change the value of any availability_slot's occupancy. The occupancy value is used to denote the number of simultaneous appointments possible for any slot. If the number of appointments at a given time cross that value, then booking new appointments will fail!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment