Skip to content

julienbornstein/doctolib-php

Repository files navigation

Doctolib PHP Client

Latest Release Software License GitHub Workflow Status Codecov Total Downloads

Note: This is an UNOFFICIAL Doctolib PHP Client.

This is a PHP client for Doctolib. It includes the following:

  • Helper methods for REST endpoints:
    • Search Profiles (Doctor) by Speciality and Location, and get Booking and Availability information.
    • Get Patient, Profile, Appointment.
    • Create, Confirm, Delete an Appointment.
    • Authentication. broken
  • PSR-4 autoloading support.

Requirements

Installation

Install it using Composer:

$ composer require julienbornstein/doctolib-php

Usage

$doctolib = new Doctolib\Client(
    new Symfony\Component\HttpClient\HttpClient(), 
    SerializerFactory::create()
);

$searchResults = $doctolib->search('dentiste');
$speciality = $searchResults['specialities'][0];

$profiles = $doctolib->searchProfilesBySpecialityAndLocation('dentiste', '75009-paris'); // = https://www.doctolib.fr/dentiste/75009-paris
$profiles = $doctolib->searchProfilesBySpecialityAndLocation('dentiste', '75009-paris', [
    'latitude' => 48.8785328,
    'longitude' => 2.3377854,
]);

$booking = $doctolib->getBooking('cabinet-dentaire-haussmann-saint-lazare');
$agendas = $booking->getAgendas();
$visitMotives = Agenda::getVisitMotivesForAgendas($agendas);

$tomorrow = new DateTime('tomorrow');
$visitMotive = $visitMotives[0];
$availabilities = $doctolib->getAvailabilities($agendas, $tomorrow, $visitMotive->getRefVisitMotiveId());

$firstAvailability = $availabilities[0];
$firstSlot = $firstAvailability->getSlots()[0];

$doctolib->setSessionId('YOUR_SESSION_ID');

$patient = $doctolib->getMasterPatient();

$appointment = $doctolib->createAppointment($booking, $visitMotive, $firstSlot);
$appointment = $doctolib->confirmAppointment($appointment, $patient);

$upcomingAppointments = $doctolib->getUpcomingAppointments();
$appointment = $doctolib->getAppointment('APPOINTMENT_ID');
$doctolib->deleteAppointment('APPOINTMENT_ID');

Framework integrations

Symfony

Add this block in your services.yaml file to register the Client as a service.

    Doctolib\Client:
      arguments:
        $serializer: '@doctolib.serializer'

    doctolib.serializer:
      class: Symfony\Component\Serializer\SerializerInterface
      factory: ['Doctolib\SerializerFactory', 'create']

Examples

You can find some examples in the examples directory.

You can also check this project julienbornstein/doctolib-autobooking

Testing

$ make test

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Doctolib PHP Client

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors