feat: Improved spacing of additional code buttons on fee sheet (#6790)
[openemr.git] / library / appointment_status.inc.php
blobddee37b43efed36ee15a4a9d36c3c04552dc9f71
1 <?php
3 // Copyright (C) 2011, 2016 Rod Roark <rod@sunsetsystems.com>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This is called to update the appointment status for a specified patient
11 // with an encounter on the specified date. It does nothing unless the
12 // feature to auto-update appointment statuses is enabled.
14 // See sample code in: interface/patient_tracker/patient_tracker_status.php
15 // This updates the patient tracker board as well as the appointment.
17 require_once(dirname(__FILE__) . '/patient_tracker.inc.php');
19 function updateAppointmentStatus($pid, $encdate, $newstatus)
21 if (empty($GLOBALS['gbl_auto_update_appt_status'])) {
22 return;
25 $query = "SELECT pc_eid, pc_aid, pc_catid, pc_apptstatus, pc_eventDate, pc_startTime, " .
26 "pc_hometext, pc_facility, pc_billing_location, pc_room " .
27 "FROM openemr_postcalendar_events WHERE " .
28 "pc_pid = ? AND pc_recurrtype = 0 AND pc_eventDate = ? " .
29 "ORDER BY pc_startTime DESC, pc_eid DESC LIMIT 1";
30 $tmp = sqlQuery($query, array($pid, $encdate));
31 if (!empty($tmp['pc_eid'])) {
32 $appt_eid = $tmp['pc_eid'];
33 $appt_status = $tmp['pc_apptstatus'];
34 // Some tests for illogical changes.
35 if ($appt_status == '$') {
36 return;
39 if ($newstatus == '<' && $appt_status == '>') {
40 return;
43 $encounter = todaysEncounterCheck(
44 $pid,
45 $tmp['pc_eventDate'],
46 $tmp['pc_hometext'],
47 $tmp['pc_facility'],
48 $tmp['pc_billing_location'],
49 $tmp['pc_aid'],
50 $tmp['pc_catid'],
51 false
53 manage_tracker_status(
54 $tmp['pc_eventDate'],
55 $tmp['pc_startTime'],
56 $appt_eid,
57 $pid,
58 $_SESSION["authUser"],
59 $newstatus,
60 $tmp['pc_room'],
61 $encounter