3 * Patient Tracker Status Editor
5 * This allows entry and editing of current status for the patient from within patient tracker and updates the status on the calendar.
6 * Contains a drop down for the Room information driven by the list Patient Flow Board Rooms.
9 * @link http://www.open-emr.org
10 * @author Terry Hill <terry@lillysystems.com>
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2015 Terry Hill <terry@lillysystems.com>
13 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
14 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
18 require_once("../globals.php");
19 require_once("$srcdir/options.inc.php");
20 require_once("$srcdir/forms.inc");
21 require_once("$srcdir/encounter_events.inc.php");
22 require_once("$srcdir/patient_tracker.inc.php");
24 use OpenEMR\Core\Header
;
27 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
32 # Get the information for fields
33 $tracker_id = $_GET['tracker_id'];
34 $trow = sqlQuery("SELECT apptdate, appttime, patient_tracker_element.room AS lastroom, " .
35 "patient_tracker_element.status AS laststatus, eid, random_drug_test, encounter, pid " .
36 "FROM patient_tracker " .
37 "LEFT JOIN patient_tracker_element " .
38 "ON patient_tracker.id = patient_tracker_element.pt_tracker_id " .
39 "AND patient_tracker.lastseq = patient_tracker_element.seq " .
40 "WHERE patient_tracker.id =?", array($_GET['tracker_id']));
42 $tkpid = $trow['pid'];
43 $appttime = $trow['appttime'];
44 $apptdate = $trow['apptdate'];
45 $pceid = $trow['eid'];
51 <?php Header
::setupHeader(['common','opener']); ?
>
55 if ($_POST['statustype'] !='') {
56 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
60 $status = $_POST['statustype'];
61 if (strlen($_POST['roomnum']) != 0) {
62 $theroom = $_POST['roomnum'];
65 # Manage tracker status. Also auto create encounter, if applicable.
67 if ($GLOBALS['auto_create_new_encounters'] && $apptdate == date('Y-m-d') && (is_checkin($status) == '1') && !is_tracker_encounter_exist($apptdate, $appttime, $tkpid, $pceid)) {
68 # Gather information for encounter fields
69 $genenc = sqlQuery("select pc_catid as category, pc_hometext as reason, pc_aid as provider, pc_facility as facility, pc_billing_location as billing_facility " .
70 "from openemr_postcalendar_events where pc_eid =? ", array($pceid));
71 $encounter = todaysEncounterCheck($tkpid, $apptdate, $genenc['reason'], $genenc['facility'], $genenc['billing_facility'], $genenc['provider'], $genenc['category'], false);
72 # Capture the appt status and room number for patient tracker. This will map the encounter to it also.
74 manage_tracker_status($apptdate, $appttime, $pceid, $tkpid, $_SESSION["authUser"], $status, $theroom, $encounter);
77 # Capture the appt status and room number for patient tracker.
79 manage_tracker_status($apptdate, $appttime, $pceid, $tkpid, $_SESSION["authUser"], $status, $theroom);
84 echo "<body>\n<script language='JavaScript'>\n";
85 echo " window.opener.document.flb.submit();\n";
86 echo " dlgclose();\n";
87 echo "</script></body></html>\n";
91 #get the patient name for display
92 $row = sqlQuery("select fname, lname " .
93 "from patient_data where pid =? limit 1", array($tkpid));
96 <body
class="body_top">
97 <div
class="container">
99 <div
class="col-xs-12">
100 <h2
><?php
echo xlt('Change Status for'). " " . text($row['fname']) . " " . text($row['lname']); ?
></h2
>
103 <form id
="form_note" method
="post" action
="patient_tracker_status.php?tracker_id=<?php echo attr_url($tracker_id) ?>&csrf_token_form=<?php echo attr_url(collectCsrfToken()); ?>" enctype
="multipart/form-data" >
104 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(collectCsrfToken()); ?>" />
105 <div
class="form-group">
106 <label
for="statustype"><?php
echo xlt('Status Type'); ?
></label
>
107 <?php
echo generate_select_list('statustype', 'apptstat', $trow['laststatus'], xl('Status Type')); ?
>
109 <div
class="form-group">
110 <label
for="roomnum"><?php
echo xlt('Exam Room Number'); ?
></label
>
111 <?php
echo generate_select_list('roomnum', 'patient_flow_board_rooms', $trow['lastroom'], xl('Exam Room Number')); ?
>
113 <div
class="position-override">
114 <div
class="btn-group oe-opt-btn-group-pinch" role
="group">
115 <a href
='javascript:;' class='btn btn-default btn-save' onclick
='document.getElementById("form_note").submit();'><?php
echo xlt('Save')?
></a
>
116 <a href
='javascript:;' class='btn btn-link btn-cancel oe-opt-btn-separate-left' onclick
="dlgclose();" ><?php
echo xlt('Cancel'); ?
></a
>