Creating an appointment_resource data model that will be persisting all the data needed to create an appnt block as follows

This is a one to one mapping with location data model.
The above gives more detail on the availability of a location/block.
This design assumes the following existing functionality of the module
a) creating an Appointment Block creates a single Time Slot that fills that whole block.
b)Also assumes there is no need to display timeslot to the user since this will clutter the UI, Instead we provide timeslot information such as the number of scheduled patients
With the above design scheduling an appnt workflow would be:
-
Populate the appntment_resource data model with a resource/block availability data ie
start-time and end-time operation time, services offered their (ie appnt types), excluded dates, start-date and end-date range on when the block will be available for scheduling, if weekends should be allowed or not and provider . A resource is subject to updates ie when a provider ships to another block etc
-
Once the resource details are provided, scheduling an appnt will be as follows:
the payload will look like this, some of this value can be retrieved from the user session ie in our case scheduling an appnt is done just before a visit is stopped
“patient”: “b7009090-4015-11e4-8e9b-2939a1809c7e”,
“status”: “SCHEDULED”,
“appointmentType”: “4d85dda4-c437-11e4-a470-82b0ea87e2d8e”,
“location”: “6351fcf4-e311-4a19-90f9-35667d99a8af”,
“date”: “2019-01-01”
The date property is the scheduled date of the appnt.
Once the user makes a POST request, the following is handled from the backend:
a) Use of the date and location from payload to check if the timeslot for that location for that date exists ie
timeslot.appointmentBlock.location=location && timeslot.startDate = date
if it does set it to the appointment object and save
(ie existence of a timeslot means existence of a block)
b) If timeslot doesn’t exist, retrieve the appointment_resource data for that location and create appnt block and timeslot sequentially
appointmentResource.location=location and date in the range of the resource start-date and end-date
(however i’m not really sure if date validation is necessary since we want ability to schedule appointments any day, please advice)
After creating appnt block and timeslot dynamically, Retrieve this timeslot, set it to the appointment object then persist the scheduled appnt
Once the timeslot is created in case (b) above, if a user schedules another appointment with same date and location, case (a) will pass and the scheduled appointment will be persisted, this goes on until the timeslot is full and the timeslot full exception will be thrown
The module can also be designed to accommodate use cases where users want to create multi-timeslots per appnt block so that it can work in both cases ie one where it’s one timeslot per appnt block and multi-timeslots per appnt block in which in this case user intervention will be needed to define timeslot duration or timeslot end time and start time.
However I think most implementers have adopted one where single Time Slot fills the whole block, so I was hoping we could focus on this first.
Design Improvements
Both appnt block and appnt resource data models are designed to store same kind of data ie block/resource availability which follows one resource per location mapping (I believe in the case of multiple timeslots we don’t need to create dublicate blocks but multiple timeslots whose originality can be linked to a block/resource) ie daily timeslots for block A for January makes more sense than daily timeslots and daily block A for January
With this we could chose to reduce the data models into a single table if need be but as at now i’m making use of both of the tables ie This is if this design of dynamic blocks is accepted.
@mogoodrich @ddesimone above is our proposed solution in handling the appnt blocks issues
I soo much looking forward to hearing your opinion concerning this and even more on how best we can solve the block issues.
If this design makes sense i’ll be soo interested in continuing this discussion through a design call too. Also I have a working branch with the above proposed design working, if it will be interesting I could share the link so that you can have a look.
Please consider, Thank you