Medical Appointments API

AppointmentService
in package

A class service for working with the logic business of appointments.

Tags
author

Luis Graciano contacto@luisgraciano.dev

Table of Contents

$appointmentRepository  : AppointmentRepository
$medicalCenterService  : MedicalCenterService
$scheduleService  : ScheduleService
$scheduleTimeSlotService  : ScheduleTimeSlotService
$timeZoneService  : TimeZoneService
__construct()  : mixed
AppointmentService constructor.
cancel()  : void
Cancel a reserved appointment by unique ID.
cancelByScheduleTimeSlotId()  : void
findAvailableSlots()  : array<string|int, AppointmentTimeIntervalDomain>
Find available time slots for a given schedule and date.
save()  : AppointmentDomain
Save new appointment.
getAvailableAppointments()  : array<string|int, AppointmentTimeIntervalDomain>
Get available appointments for a given schedule time slot and date.
getSecondsFromTime()  : int
Calculate the seconds from a time string in the format "HH:MM".
getTimeSlotsByDate()  : array<string|int, AppointmentTimeIntervalDomain>
Get the available time slots around a given date.
mapAppointmentDomainToEntity()  : AppointmentEntity
Map an appointment domain to an appointment entity.
mapAppointmentEntityToDomain()  : AppointmentDomain
Map an appointment entity to an appointment domain.
validateAppointment()  : void
Apply business rules to validate an appointment.

Properties

Methods

__construct()

AppointmentService constructor.

public __construct(AppointmentRepository $appointmentRepository, ScheduleService $scheduleService, MedicalCenterService $medicalCenterService, TimeZoneService $timeZoneService, ScheduleTimeSlotService $scheduleTimeSlotService) : mixed
Parameters
$appointmentRepository : AppointmentRepository

The appointment repository.

$scheduleService : ScheduleService

The schedule service.

$medicalCenterService : MedicalCenterService

The medical center service.

$timeZoneService : TimeZoneService

The time zone service.

$scheduleTimeSlotService : ScheduleTimeSlotService

The schedule time slot service.

Return values
mixed

cancelByScheduleTimeSlotId()

public cancelByScheduleTimeSlotId(int $scheduleTimeSlotId) : void
Parameters
$scheduleTimeSlotId : int
Tags
throws
UnhandledException
Return values
void

findAvailableSlots()

Find available time slots for a given schedule and date.

public findAvailableSlots(int $scheduleId, string $dateString) : array<string|int, AppointmentTimeIntervalDomain>
Parameters
$scheduleId : int
$dateString : string
Tags
throws
BusinessValidationException

If the schedule is not found or the medical center is not found.

throws
NotFoundException

If the schedule is not found or the medical center is not found.

throws
UnhandledException

If an error occurs while finding the available slots.

Return values
array<string|int, AppointmentTimeIntervalDomain>

The available time slots.

getAvailableAppointments()

Get available appointments for a given schedule time slot and date.

private getAvailableAppointments(ScheduleTimeSlotDomain $scheduleTimeSlotDomain, int $utcDate, int $appointmentDuration) : array<string|int, AppointmentTimeIntervalDomain>
Parameters
$scheduleTimeSlotDomain : ScheduleTimeSlotDomain

The schedule time slot to get the available appointments for.

$utcDate : int

The date in UTC.

$appointmentDuration : int

The appointment duration in minutes.

Return values
array<string|int, AppointmentTimeIntervalDomain>

The available appointments.

getSecondsFromTime()

Calculate the seconds from a time string in the format "HH:MM".

private getSecondsFromTime(string $time) : int
Parameters
$time : string

The time string.

Return values
int

The seconds.

getTimeSlotsByDate()

Get the available time slots around a given date.

private getTimeSlotsByDate(array<string|int, ScheduleTimeSlotDomain$scheduleTimeSlotDomains, DateTime $dateTime, int $appointmentDuration) : array<string|int, AppointmentTimeIntervalDomain>
Parameters
$scheduleTimeSlotDomains : array<string|int, ScheduleTimeSlotDomain>

The schedule time slots to get the available time slots.

$dateTime : DateTime

The date.

$appointmentDuration : int

The appointment duration in minutes.

Return values
array<string|int, AppointmentTimeIntervalDomain>

The available time slots.

validateAppointment()

Apply business rules to validate an appointment.

private validateAppointment(AppointmentDomain $appointmentDomain) : void
Parameters
$appointmentDomain : AppointmentDomain
Tags
throws
UnhandledException

If an error occurs while validating the appointment.

throws
BusinessValidationException

If the appointment is not valid.

throws
NotFoundException

If the schedule time slot is not found or the schedule is not found or the medical center is not found.

throws
Exception

If an error occurs while validating the appointment.

Return values
void

Search results