AppointmentService
in package
A class service for working with the logic business of appointments.
Tags
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
$appointmentRepository
private
AppointmentRepository
$appointmentRepository
The appointment repository.
$medicalCenterService
private
MedicalCenterService
$medicalCenterService
The medical center service.
$scheduleService
private
ScheduleService
$scheduleService
The schedule service.
$scheduleTimeSlotService
private
ScheduleTimeSlotService
$scheduleTimeSlotService
The schedule time slot service.
$timeZoneService
private
TimeZoneService
$timeZoneService
The time zone service.
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 —cancel()
Cancel a reserved appointment by unique ID.
public
cancel(int $id) : void
Parameters
- $id : int
-
The ID of the appointment.
Tags
Return values
void —cancelByScheduleTimeSlotId()
public
cancelByScheduleTimeSlotId(int $scheduleTimeSlotId) : void
Parameters
- $scheduleTimeSlotId : int
Tags
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
Return values
array<string|int, AppointmentTimeIntervalDomain> —The available time slots.
save()
Save new appointment.
public
save(AppointmentDomain $appointmentDomain) : AppointmentDomain
Parameters
- $appointmentDomain : AppointmentDomain
Tags
Return values
AppointmentDomain —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.
mapAppointmentDomainToEntity()
Map an appointment domain to an appointment entity.
private
mapAppointmentDomainToEntity(AppointmentDomain $appointmentDomain) : AppointmentEntity
Parameters
- $appointmentDomain : AppointmentDomain
-
The appointment domain.
Tags
Return values
AppointmentEntity —The appointment entity.
mapAppointmentEntityToDomain()
Map an appointment entity to an appointment domain.
private
mapAppointmentEntityToDomain(AppointmentEntity $appointmentEntity) : AppointmentDomain
Parameters
- $appointmentEntity : AppointmentEntity
-
The appointment entity.
Tags
Return values
AppointmentDomain —The appointment domain.
validateAppointment()
Apply business rules to validate an appointment.
private
validateAppointment(AppointmentDomain $appointmentDomain) : void
Parameters
- $appointmentDomain : AppointmentDomain