4 * Patient Tracker Status Editor
6 * This allows entry and editing of current status for the patient from within patient tracker and updates the status on the calendar.
7 * Contains a drop down for the Room information driven by the list Patient Flow Board Rooms.
10 * @link http://www.open-emr.org
11 * @author Terry Hill <terry@lillysystems.com>
12 * @author Brady Miller <brady.g.miller@gmail.com>
13 * @copyright Copyright (c) 2015 Terry Hill <terry@lillysystems.com>
14 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
15 * @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.php");
21 require_once("$srcdir/encounter_events.inc.php");
22 require_once("$srcdir/patient_tracker.inc.php");
24 use OpenEMR\Common\Csrf\CsrfUtils
;
25 use OpenEMR\Core\Header
;
28 if (!CsrfUtils
::verifyCsrfToken($_GET["csrf_token_form"])) {
29 CsrfUtils
::csrfNotVerified();
33 # Get the information for fields
34 $tracker_id = $_GET['tracker_id'];
35 $trow = sqlQuery("SELECT apptdate, appttime, patient_tracker_element.room AS lastroom, " .
36 "patient_tracker_element.status AS laststatus, eid, random_drug_test, encounter, pid " .
37 "FROM patient_tracker " .
38 "LEFT JOIN patient_tracker_element " .
39 "ON patient_tracker.id = patient_tracker_element.pt_tracker_id " .
40 "AND patient_tracker.lastseq = patient_tracker_element.seq " .
41 "WHERE patient_tracker.id =?", array($_GET['tracker_id']));
43 $tkpid = $trow['pid'];
44 $appttime = $trow['appttime'];
45 $apptdate = $trow['apptdate'];
46 $pceid = $trow['eid'];
52 <?php Header
::setupHeader(['common','opener']); ?
>
56 if (!empty($_POST['statustype'])) {
57 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
58 CsrfUtils
::csrfNotVerified();
61 $status = $_POST['statustype'];
62 if (strlen($_POST['roomnum']) != 0) {
63 $theroom = $_POST['roomnum'];
66 # Manage tracker status. Also auto create encounter, if applicable.
68 // if an encounter is found it is returned to be carried forward with status changes.
69 // otherwise 0 which is table default.
70 $is_tracker = is_tracker_encounter_exist($apptdate, $appttime, $tkpid, $pceid);
71 if ($GLOBALS['auto_create_new_encounters'] && $apptdate == date('Y-m-d') && (is_checkin($status) == '1') && !$is_tracker) {
72 # Gather information for encounter fields
73 $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 " .
74 "from openemr_postcalendar_events where pc_eid =? ", array($pceid));
75 $encounter = todaysEncounterCheck($tkpid, $apptdate, $genenc['reason'], $genenc['facility'], $genenc['billing_facility'], $genenc['provider'], $genenc['category'], false);
76 # Capture the appt status and room number for patient tracker. This will map the encounter to it also.
78 manage_tracker_status($apptdate, $appttime, $pceid, $tkpid, $_SESSION["authUser"], $status, $theroom, $encounter);
81 # Capture the appt status and room number for patient tracker.
83 manage_tracker_status($apptdate, $appttime, $pceid, $tkpid, $_SESSION["authUser"], $status, $theroom, $is_tracker);
88 echo "<body>\n<script>\n";
89 echo " window.opener.document.flb.submit();\n";
90 echo " dlgclose();\n";
91 echo "</script></body></html>\n";
95 #get the patient name for display
96 $row = sqlQuery("select fname, lname " .
97 "from patient_data where pid =? limit 1", array($tkpid));
101 <div
class="container mt-3">
104 <h2
><?php
echo xlt('Change Status for') . " " . text($row['fname']) . " " . text($row['lname']); ?
></h2
>
107 <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(CsrfUtils::collectCsrfToken()); ?>" enctype
="multipart/form-data" >
108 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
109 <div
class="form-group">
110 <label
for="statustype"><?php
echo xlt('Status Type'); ?
></label
>
111 <?php
echo generate_select_list('statustype', 'apptstat', $trow['laststatus'], xl('Status Type')); ?
>
113 <div
class="form-group">
114 <label
for="roomnum"><?php
echo xlt('Exam Room Number'); ?
></label
>
115 <?php
echo generate_select_list('roomnum', 'patient_flow_board_rooms', $trow['lastroom'], xl('Exam Room Number')); ?
>
117 <div
class="position-override">
118 <div
class="btn-group" role
="group">
119 <button type
="button" class='btn btn-primary btn-save btn-sm' onclick
='document.getElementById("form_note").submit();'><?php
echo xlt('Save')?
></button
>
120 <button type
="button" class='btn btn-secondary btn-cancel btn-sm' onclick
="dlgclose();" ><?php
echo xlt('Cancel'); ?
></button
>