Skip to content

Commit a2c5159

Browse files
committed
[update] integration with scheduler updated
1 parent e34e9ae commit a2c5159

1 file changed

Lines changed: 27 additions & 46 deletions

File tree

docs/guides/integration-with-widgets.md

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,39 @@ The integration primarily focuses on converting the Scheduler data into Booking
1919
So what you actually need is to generate booking slots from the schedule (the [snippet below](#example) shows how to generate booking slots from the doctor's schedule using JSON data).
2020

2121
- **Recurring events limitation:**
22-
- Booking supports only weekly recurring events (defined as INTERVAL=1;FREQ=WEEKLY in the Scheduler).
23-
- Scheduler can handle any recurring pattern
22+
- Booking supports only weekly recurring events (defined as INTERVAL=1;FREQ=WEEKLY in Scheduler).
23+
- Scheduler can handle any recurring pattern so you will need to limit creating other recurring events in Scheduler config
2424

2525
- **Timezone handling:**
2626
- Booking interprets timestamps in the local timezone.
27-
- You need to convert timestamps between global and local timezones before sending them to Booking (and vice versa).
27+
- If you use global timestamps, you need to convert them to local timezones before sending them to Booking (and vice versa before saving the data back).
28+
For conversion instructions, refer to [Working with UTC data](/guides/configuration/saving-reservations/#working-with-utc-data).
2829

29-
- **Slot creation strategy:**
30-
- Use the `slots` and `usedSlots` properties to build the schedule, ensuring that used slots are excluded.
30+
- **Booking slot strategies:**
31+
- Use `slots` and `usedSlots` to build the schedule, ensuring that used slots are excluded (we'll focus on this strategy)
32+
- Use only `availableSlots`, which is suitable for events without recurrences.
3133

34+
## Example
3235

33-
## Main steps for integration and rules for generating events
36+
The snippet below demonstrates how to integrate Booking with the Scheduler widget by converting doctors' schedules into booking slots. Key data endpoints used for integration:
3437

35-
We will show how to generate booking slots from the doctor's schedule using JSON data.
38+
- `/doctors/worktime` - Scheduler data (doctor schedules) that includes recurring and single-time events. These events are used to create time slots for the Booking system.
39+
- `/units` - final Booking slots generated from the Scheduler `worktime` data. The slots are generated on the server-side. Please, also refer to [backend](https://github.com/DHTMLX/scheduler-booking-go).
40+
- `/doctors/reservations` - an auxiliary collection used to visualize `usedSlots` in the timeline view. This data comes from the Booking form, containing information about already reserved slots for doctors.
41+
- `/doctors` - contains all doctors, including their names and IDs. It is used for displaying doctor information in both the Scheduler and Booking widgets.
3642

37-
**Step 1. Retrieve the doctor's schedule data (e.g., /doctors/worktime), which may contain both recurring and single events.**
43+
Converting Scheduler events to Booking slots is the major part of integration and the rules for handling the events and converting them to slots are described in the [section below](#rules-for-converting-scheduler-events-to-booking-slots).
3844

39-
Scheduler data example:
45+
We also ensure that the timestamps are converted correctly. When global (UTC) timestamps are used, they need to be converted to local time before loading them into the system (**l2g** function in the example). Similarly, before saving the data back, the timestamps should be converted from local time to global (UTC) time (**g2l** function in the example).
4046

41-
~~~json
42-
[
43-
{
44-
"doctor_id": 1,
45-
"start_date": "2025-03-18 02:00:00",
46-
"end_date": "2025-03-18 06:00:00"
47-
},
48-
{
49-
"doctor_id": 1,
50-
"start_date": "2025-03-13 09:00:00",
51-
"end_date": "9999-02-01 00:00:00",
52-
"rrule": "INTERVAL=1;FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR",
53-
"duration": 28800
54-
},
55-
{
56-
"doctor_id": 2,
57-
"start_date": "2025-03-13 20:00:00",
58-
"end_date": "9999-02-01 00:00:00",
59-
"rrule": "INTERVAL=1;FREQ=WEEKLY;BYDAY=SA",
60-
"duration": 28800
61-
}
62-
]
63-
~~~
47+
<iframe src="https://snippet.dhtmlx.com/d5zbq3g3?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="800"></iframe>
48+
49+
50+
## Rules for converting Scheduler events to Booking slots
6451

65-
**Step 2. Convert Scheduler events to Booking slots following the next rules.**
52+
We will show how to generate booking slots from the doctor's schedule using JSON data.
6653

67-
**Rule 1:** Single event slot creation.
54+
**Rule 1. Single event slot creation.**
6855

6956
For each single event in the schedule, convert the start and end times to Booking slots by creating an entry in the slots array, including the corresponding date (dates).
7057

@@ -97,7 +84,7 @@ Booking slot:
9784
}
9885
~~~
9986

100-
**Rule 2:** Recurring events.
87+
**Rule 2. Recurring events.**
10188

10289
For recurring events, we use a weekly pattern. The start and end dates must be the same for each occurrence, as Booking only supports weekly recurring slots.
10390

@@ -130,7 +117,7 @@ Booking Slots: In Booking, the weekly schedule is represented as a single rule,
130117
}
131118
~~~
132119

133-
**Rule 3:** Scheduling an event that spans multiple days.
120+
**Rule 3. Scheduling an event that spans multiple days.**
134121

135122
If an event spans across multiple days (e.g., starts at 8 PM and ends at 4 AM), it should be split into two slots — one for each day.
136123

@@ -170,7 +157,7 @@ Booking slot:
170157
}
171158
~~~
172159

173-
**Rule 4:** Additional single events added to recurring events.
160+
**Rule 4. Additional single events added to recurring events.**
174161

175162
In this case, a single event is added to a recurring schedule. The Booking slots are generated for both the recurring and the single events. The single event dates are added to the recurring event's dates array.
176163

@@ -237,7 +224,7 @@ Booking slots:
237224
}
238225
~~~
239226

240-
**Rule 5:** Modifying a single instance of an recurring event.
227+
**Rule 5. Modifying a single instance of an recurring event.**
241228

242229
If a single instance of a recurring event is edited (e.g., time change for a specific date), generate a new slot with the updated time and date in the dates array, overriding the days array.
243230

@@ -286,7 +273,7 @@ Booking slot:
286273
}
287274
~~~
288275

289-
**Rule 6:** Deleting a single instance of a recurring event
276+
**Rule 6. Deleting a single instance of a recurring event.**
290277

291278
When a single occurrence is removed from a recurring event in Scheduler, we need to update Booking rules to reflect this removal. This is done by creating a special rule for the removed date, using an empty time interval and the dates property (which has higher priority than days).
292279

@@ -329,7 +316,7 @@ Booking slot:
329316
}
330317
~~~
331318

332-
**Rule 7:** Events starting later than Booking start date
319+
**Rule 7. Events starting later than Booking start date.**
333320

334321
If a recurring event starts after the Booking start date (default is today), create rules with empty time intervals for the dates prior to the event's start date. This simulates the dates being "removed" from the recurrence.
335322

@@ -360,16 +347,10 @@ Booking slots:
360347
}
361348
~~~
362349

363-
**Step 3. Timezone Conversion**
364-
365-
Ensure that the timestamps are converted from global time to the local time of the user's timezone before sending them to Booking. This ensures correct slot display in the Booking widget.
366350

367351

368-
## Example
369352

370-
The snippet below demonstrates how to convert doctor schedules into booking slots. The doctors' schedules that include recurring and single-time events are fetched from the Scheduler widget via the `/doctors/worktime` URL, while the final booking slots generated from the scheduler data are provided by the `/units` URL. The slots are generated on the server-side. Please, also refer to [backend](https://github.com/DHTMLX/scheduler-booking-go).
371353

372-
<iframe src="https://snippet.dhtmlx.com/d5zbq3g3?mode=result" frameborder="0" class="snippet_iframe" width="100%" height="800"></iframe>
373354

374355

375356

0 commit comments

Comments
 (0)