Question: Need help with this function, gives overlapping times and does not appropriately give times appoitnment for new patients: function calculateAppointmentTime ( $isNewPatient, $desiredStartTime, $desiredEndTime )
Need help with this function, gives overlapping times and does not appropriately give times appoitnment for new patients:
function calculateAppointmentTime$isNewPatient, $desiredStartTime, $desiredEndTime
$startTime strtotime:;
$endTime strtotime:;
$appointmentDuration ;
if $isNewPatient "Yes"
$appointmentDuration ;
$desiredStartTime empty$desiredStartTime $startTime : strtotimedateYmd $desiredStartTime;
$desiredEndTime empty$desiredEndTime $endTime : strtotimedateYmd $desiredEndTime;
if $desiredStartTime $startTime $desiredEndTime $endTime
return Constraints Violated";
$latestEndTime $startTime;
foreach $SESSIONpatients as $patient
$patientEndTime strtotime$patientAppointment Time' $appointmentDuration;
$latestEndTime max$latestEndTime, $patientEndTime;
$driveTime $index calculateDriveTime$SESSIONpatients$index Address Coordinates' $addressc : ;
$appointmentTime max$desiredStartTime, $latestEndTime $driveTime;
while $appointmentTime $desiredEndTime
$isSlotAvailable true;
foreach $SESSIONpatients as $patient
$patientAppointmentTime strtotime$patientAppointment Time';
$patientEndTime $patientAppointmentTime $appointmentDuration;
if
$appointmentTime $patientAppointmentTime && $appointmentTime $patientEndTime
$appointmentTime $appointmentDuration $patientAppointmentTime && $appointmentTime $appointmentDuration $patientEndTime
$isSlotAvailable false;
break;
if $isSlotAvailable
if $appointmentTime $appointmentDuration $desiredEndTime
break;
$appointmentTime $appointmentDuration;
return dateg:i a $appointmentTime;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
