function getAvailableSlots($from_date, $to_date, $provider_id = null, $facility_id = null) { $appointments = fetchAllEvents($from_date, $to_date, $provider_id, $facility_id); $appointments = sortAppointments($appointments, "date"); $from_datetime = strtotime($from_date . " 00:00:00"); $to_datetime = strtotime($to_date . " 23:59:59"); $availableSlots = array(); $start_time = 0; $date = 0; for ($i = 0; $i < count($appointments); ++$i) { if ($appointments[$i]['pc_catid'] == 2) { // 2 == In Office $start_time = $appointments[$i]['pc_startTime']; $date = $appointments[$i]['pc_eventDate']; $provider_id = $appointments[$i]['uprovider_id']; } else { if ($appointments[$i]['pc_catid'] == 3) { // 3 == Out Of Office continue; } else { $start_time = $appointments[$i]['pc_endTime']; $date = $appointments[$i]['pc_eventDate']; $provider_id = $appointments[$i]['uprovider_id']; } } // find next appointment with the same provider $next_appointment_date = 0; $next_appointment_time = 0; for ($j = $i + 1; $j < count($appointments); ++$j) { if ($appointments[$j]['uprovider_id'] == $provider_id) { $next_appointment_date = $appointments[$j]['pc_eventDate']; $next_appointment_time = $appointments[$j]['pc_startTime']; break; } } $same_day = strtotime($next_appointment_date) == strtotime($date) ? true : false; if ($next_appointment_time && $same_day) { // check the start time of the next appointment $start_datetime = strtotime($date . " " . $start_time); $next_appointment_datetime = strtotime($next_appointment_date . " " . $next_appointment_time); $curr_time = $start_datetime; while ($curr_time < $next_appointment_datetime - getSlotSize() / 2) { //create a new appointment ever 15 minutes $time = date("H:i:s", $curr_time); $available_slot = createAvailableSlot($appointments[$i]['pc_eventDate'], $time, $appointments[$i]['ufname'], $appointments[$i]['ulname'], $appointments[$i]['umname']); $availableSlots[] = $available_slot; $curr_time += getSlotSize(); // add a 15-minute slot } } } return $availableSlots; }
echo " </select>\n"; echo " <br /><span class='bold'>Return to Play:</span><br>\n"; echo " <input type='text' size='10' name='form_userdate1' id='form_userdate1' " . "value='{$form_userdate1}' " . "title='" . htmlspecialchars(xl('yyyy-mm-dd Date of return to play'), ENT_QUOTES) . "' " . "onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" . " <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' " . "id='img_userdate1' border='0' alt='[?]' style='cursor:pointer' " . "title='" . htmlspecialchars(xl('Click here to choose a date'), ENT_QUOTES) . "'>\n"; echo " <input type='hidden' name='form_original_userdate1' value='" . htmlspecialchars($form_userdate1, ENT_QUOTES) . "' />\n"; echo " <input type='hidden' name='form_issue_id' value='' />\n"; echo "<p><input type='submit' name='form_submit' value='Change' /></p>\n"; echo " </form>\n"; } // Show current and upcoming appointments. if (isset($pid) && !$GLOBALS['disable_calendar']) { // $current_date2 = date('Y-m-d'); $events = array(); $events = fetchAppointments($current_date2, null, $pid, null, null, null, null, null, null, false, true); ////// $events = sortAppointments($events); ////// if (acl_check('patients', 'med') && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw'])) { // clinical summary expand collapse widget $widgetTitle = xl("Clinical Reminders"); $widgetLabel = "clinical_reminders"; $widgetButtonLabel = xl("Edit"); $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=" . $pid; $widgetButtonClass = ""; $linkMethod = "html"; $bodyClass = "summary_item small"; $widgetAuth = true; $fixedWidth = false; expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel, $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); echo "<br/>"; echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
xl('Comment', 'e'); ?> </a> </th> </thead> <tbody> <!-- added for better print-ability --> <?php $lastdocname = ""; $appointments = fetchAppointments($from_date, $to_date, $patient, $provider, $facility); if ($show_available_times) { $availableSlots = getAvailableSlots($from_date, $to_date, $provider, $facility); $appointments = array_merge($appointments, $availableSlots); } $appointments = sortAppointments($appointments, $form_orderby); $pid_list = array(); // Initialize list of PIDs for Superbill option foreach ($appointments as $appointment) { array_push($pid_list, $appointment['pid']); $patient_id = $appointment['pid']; $docname = $appointment['ulname'] . ', ' . $appointment['ufname'] . ' ' . $appointment['umname']; $errmsg = ""; ?> <tr bgcolor='<?php echo $bgcolor; ?> '> <td class="detail"> <?php echo $docname == $lastdocname ? "" : $docname;
</td> <?php } ?> </tr> <?php #define variables, future enhancement allow changing the to_date and from_date #to allow picking a date to review $appointments = array(); $from_date = date("Y-m-d"); $to_date = date("Y-m-d"); $datetime = date("Y-m-d H:i:s"); # go get the information and process it $appointments = fetch_Patient_Tracker_Events($from_date, $to_date); $appointments = sortAppointments($appointments, 'time'); foreach ($appointments as $appointment) { # Collect appt date and set up squashed date for use below $date_appt = $appointment['pc_eventDate']; $date_squash = str_replace("-", "", $date_appt); # Collect variables and do some processing $docname = $appointment['ulname'] . ', ' . $appointment['ufname'] . ' ' . $appointment['umname']; if (strlen($docname) <= 3) { continue; } $ptname = $appointment['lname'] . ', ' . $appointment['fname'] . ' ' . $appointment['mname']; $appt_enc = $appointment['encounter']; $appt_eid = !empty($appointment['eid']) ? $appointment['eid'] : $appointment['pc_eid']; $appt_pid = !empty($appointment['pid']) ? $appointment['pid'] : $appointment['pc_pid']; if ($appt_pid == 0) { continue;