Scheduling & Appointment Matrix
Scheduling systems need to manage availability across days and time slots. Creating these grids manually is time-consuming and prone to errors.
The Problem
Section titled “The Problem”A medical clinic needs to manage appointments:
- 5 weekdays: Monday through Friday
- 9 time slots: 9 AM to 5 PM (hourly)
- Different pricing: Peak hours cost more
That’s 45 time slots to configure. Traditional JSON requires manual entry:
{ "schedule": [ { "day": "Mon", "hour": 9, "slot": "Mon-9h", "available": true, "price": 100 }, { "day": "Mon", "hour": 10, "slot": "Mon-10h", "available": true, "price": 100 }, { "day": "Mon", "hour": 11, "slot": "Mon-11h", "available": true, "price": 100 } // ... 42 more slots 😰 ]}Problems:
- ❌ Repetitive and boring
- ❌ Easy to miss slots
- ❌ Hard to update pricing rules
- ❌ Difficult to add/remove days
The JSSON Solution
Section titled “The JSSON Solution”With nested maps (v0.0.5), generate the entire schedule automatically:
schedule = (["Mon", "Tue", "Wed", "Thu", "Fri"] map (day) = (9..17 map (hour) = { day = day hour = hour slot = day + "-" + hour + "h" available = true price = hour >= 12 && hour <= 14 ? 150 : 100}))That’s it! 7 lines generate all 45 time slots with dynamic pricing.
Output
Section titled “Output”{"schedule": [ [ { "day": "Mon", "hour": 9, "slot": "Mon-9h", "available": true, "price": 100 }, { "day": "Mon", "hour": 10, "slot": "Mon-10h", "available": true, "price": 100 }, { "day": "Mon", "hour": 11, "slot": "Mon-11h", "available": true, "price": 100 }, { "day": "Mon", "hour": 12, "slot": "Mon-12h", "available": true, "price": 150 }, { "day": "Mon", "hour": 13, "slot": "Mon-13h", "available": true, "price": 150 }, { "day": "Mon", "hour": 14, "slot": "Mon-14h", "available": true, "price": 150 }, { "day": "Mon", "hour": 15, "slot": "Mon-15h", "available": true, "price": 100 }, { "day": "Mon", "hour": 16, "slot": "Mon-16h", "available": true, "price": 100 }, { "day": "Mon", "hour": 17, "slot": "Mon-17h", "available": true, "price": 100 } ], // ... Tue, Wed, Thu, Fri (45 slots total)]}Advanced: Full Week with Weekends
Section titled “Advanced: Full Week with Weekends”Include weekends with different availability and pricing:
schedule = (["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] map (day) = (9..17 map (hour) = { day = day hour = hour slot = day + "-" + hour + "h"
// Weekends have limited availability isWeekend := day == "Sat" || day == "Sun" available = isWeekend ? hour >= 10 && hour <= 16 : true
// Dynamic pricing isPeakHour := hour >= 12 && hour <= 14 weekendSurcharge := isWeekend ? 50 : 0 peakSurcharge := isPeakHour ? 50 : 0
price = 100 + weekendSurcharge + peakSurcharge}))
// Generates 63 slots (7 days × 9 hours)Multi-Room Scheduling
Section titled “Multi-Room Scheduling”Generate schedules for multiple rooms or providers:
// Clinic with 3 roomsclinicSchedule = (["Room-A", "Room-B", "Room-C"] map (room) = (["Mon", "Tue", "Wed", "Thu", "Fri"] map (day) = ( 9..17 map (hour) = { room = room day = day hour = hour slotId = room + "-" + day + "-" + hour + "h" available = true capacity = room == "Room-A" ? 2 : 1 })))
// Generates 135 slots (3 rooms × 5 days × 9 hours)Appointment Slots with Intervals
Section titled “Appointment Slots with Intervals”Generate 30-minute intervals instead of hourly:
// 30-minute slots from 9:00 to 17:00slots = (9..16 map (hour) = ([0, 30] map (minute) = { hour = hour minute = minute time = hour + ":" + (minute == 0 ? "00" : minute) slotId = "slot-" + hour + "-" + minute available = true duration = 30}))
// Generates 16 slots per day (8 hours × 2 slots/hour)Blocked Time Slots
Section titled “Blocked Time Slots”Mark certain slots as unavailable:
schedule = (["Mon", "Tue", "Wed", "Thu", "Fri"] map (day) = (9..17 map (hour) = { day = day hour = hour slot = day + "-" + hour + "h"
// Lunch break: 12-13h unavailable isLunchBreak := hour == 12
// Wednesday afternoons: staff meeting isStaffMeeting := day == "Wed" && hour >= 14
available = !isLunchBreak && !isStaffMeeting price = 100}))Key Features Used
Section titled “Key Features Used”- Nested Maps — Days × Hours for complete schedule grid
- Universal Ranges —
9..17for time slots - Conditional Logic — Dynamic pricing and availability
- Computed Fields — Generate slot IDs, calculate prices
Real-World Applications
Section titled “Real-World Applications”This pattern is perfect for:
- Medical Clinics — Doctor appointments and room scheduling
- Fitness Studios — Class schedules across days and times
- Meeting Rooms — Corporate booking systems
- Service Businesses — Barber shops, salons, repair services
- Event Venues — Availability grids for bookings
- Tutoring Platforms — Teacher availability matrices
Benefits
Section titled “Benefits”95% less code — 7 lines vs 150+ lines of JSON
Consistent logic — Pricing rules in one place
Easy updates — Change hours/days instantly
No gaps — Automatic generation prevents missing slots
Flexible — Add rooms, days, or intervals easily