Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started