PHP Classes

File: examples/case-studies/health/appointments/appointment_scheduler.md

Recommend this page to a friend!
  Packages of Christos Drogidis   Ascoos OS   examples/case-studies/health/appointments/appointment_scheduler.md   Download  
File: examples/case-studies/health/appointments/appointment_scheduler.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Ascoos OS
A PHP Web 5.0 Kernel for decentralized web and IoT
Author: By
Last change: Update of examples/case-studies/health/appointments/appointment_scheduler.md
Date: 8 months ago
Size: 2,970 bytes
 

Contents

Class file image Download

Smart Appointment Scheduler

This case study demonstrates how Ascoos OS can be used to validate and schedule appointments with intelligent conflict detection. The example validates the request data, checks time slot availability, and logs the result as an event.

Purpose

This example uses the following Ascoos OS classes: - TDatesHandler: Manages date and time operations. - TXValidationHandler: Validates appointment request using rules. - TEventHandler: Logs events (conflict or confirmation).

Structure

The case study is implemented in a single PHP file: - appointment_scheduler.php: Includes validation, availability check, and event logging.

Prerequisites

  1. Install Ascoos OS (main repository). If you're using Ascoos Web Extended Studio 26, it's already preinstalled.
  2. Write permissions for the `$AOS_LOGS_PATH` directory.
  3. Global variables (`$conf`, `$AOS_TMP_DATA_PATH`, `$AOS_LOGS_PATH`) are automatically set by Ascoos OS.
  4. The phpBCL8 library is preinstalled and auto-loaded.

Getting Started

  1. Run the script via a web server:
    https://localhost/aos/examples/case-studies/health/appointments/appointment_scheduler.php
    

Example Usage

// Validation rules
$rules = [
    'patient_id' => 'required|string|min:5|max:10',
    'name' => 'required|string|max:100',
    'requested_date' => 'required|date',
    'requested_time' => 'required|string|regex:/^\d{2}:\d{2}$/'
];
if (!$validator->validate($request, $rules)) {
    $eventHandler->trigger('appointments', 'conflict', ['errors' => $validator->getErrors()]);
    exit("Validation failed.");
}

// Availability check
$requestedSlot = $request['requested_date'] . ' ' . $request['requested_time'];
if (in_array($requestedSlot, $existingAppointments)) {
    $eventHandler->trigger('appointments', 'conflict', ['slot' => $requestedSlot]);
    exit("Time slot unavailable.");
}

Expected Output

The script returns a JSON object with the confirmed appointment details. Example output:

{
    "patient_id": "P1001",
    "name": "Maria Papadopoulou",
    "requested_date": "2025-09-01",
    "requested_time": "10:00",
    "confirmed": true,
    "scheduled_at": "2025-08-28 22:22:00"
}

Resources

Contributing

Want to contribute to this case study? Fork the repository, modify or extend appointment_scheduler.php, and submit a pull request. See CONTRIBUTING.md for guidelines.

License

This case study is licensed under the Ascoos General License (AGL). See LICENSE.