Fixed bug: https://sourceforge.net/p/openemr/bugs/416/
[openemr.git] / interface / patient_tracker / patient_tracker_status.php
blob3bbac05119332dd15ec086ba83a2e91487e1112b
1 <?php
2 /**
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.
7 *
8 * Copyright (C) 2015 Terry Hill <terry@lillysystems.com>
9 *
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @package OpenEMR
22 * @author Terry Hill <terry@lilysystems.com>
23 * @link http://www.open-emr.org
25 * Please help the overall project by sending changes you make to the author and to the OpenEMR community.
27 */
29 $fake_register_globals=false;
30 $sanitize_all_escapes=true;
32 require_once("../globals.php");
33 require_once("$srcdir/options.inc.php");
34 require_once("$srcdir/forms.inc");
35 require_once("$srcdir/encounter_events.inc.php");
36 require_once("$srcdir/patient_tracker.inc.php");
38 <html>
39 <head>
40 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
41 <link rel="stylesheet" type="text/css" href="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
42 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
43 <script type="text/javascript" src="../../library/js/common.js"></script>
44 <script type="text/javascript" src="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
46 <?php
47 # Get the information for fields
48 $tracker_id = $_GET['tracker_id'];
49 $trow = sqlQuery("SELECT apptdate, appttime, patient_tracker_element.room AS lastroom, " .
50 "patient_tracker_element.status AS laststatus, eid, random_drug_test, encounter, pid " .
51 "FROM patient_tracker " .
52 "LEFT JOIN patient_tracker_element " .
53 "ON patient_tracker.id = patient_tracker_element.pt_tracker_id " .
54 "AND patient_tracker.lastseq = patient_tracker_element.seq " .
55 "WHERE patient_tracker.id =?",array($_GET['tracker_id']));
57 $tkpid = $trow['pid'];
58 $appttime = $trow['appttime'];
59 $apptdate = $trow['apptdate'];
60 $pceid = $trow['eid'];
61 $theroom = '';
63 if ($_POST['statustype'] !='') {
64 $status = $_POST['statustype'];
65 if (strlen($_POST['roomnum']) != 0) {
66 $theroom = $_POST['roomnum'];
69 # Manage tracker status. Also auto create encounter, if applicable.
70 if (!empty($tkpid)) {
71 if ($GLOBALS['auto_create_new_encounters'] && $apptdate == date('Y-m-d') && (is_checkin($status) == '1') && !is_tracker_encounter_exist($apptdate,$appttime,$tkpid,$pceid))
73 # Gather information for encounter fields
74 $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 " .
75 "from openemr_postcalendar_events where pc_eid =? " , array($pceid));
76 $encounter = todaysEncounterCheck($tkpid, $apptdate, $genenc['reason'], $genenc['facility'], $genenc['billing_facility'], $genenc['provider'], $genenc['category'],false);
77 # Capture the appt status and room number for patient tracker. This will map the encounter to it also.
78 if (!empty($pceid)) {
79 manage_tracker_status($apptdate,$appttime,$pceid,$tkpid,$_SESSION["authUser"],$status,$theroom,$encounter);
82 else
84 # Capture the appt status and room number for patient tracker.
85 if (!empty($pceid)) {
86 manage_tracker_status($apptdate,$appttime,$pceid,$tkpid,$_SESSION["authUser"],$status,$theroom);
91 echo "<html>\n<body>\n<script language='JavaScript'>\n";
92 echo " window.opener.pattrk.submit();\n";
93 echo " window.close();\n";
94 echo "</script></body></html>\n";
95 exit();
97 #get the patient name for display
98 $row = sqlQuery("select fname, lname " .
99 "from patient_data where pid =? limit 1" , array($tkpid));
102 </head>
103 <body class="body_top">
104 <center>
105 <form id="form_note" method="post" action="patient_tracker_status.php?tracker_id=<?php echo attr($tracker_id) ?>" enctype="multipart/form-data" >
106 <table>
107 <h2><?php echo xlt('Change Status for'). " " . text($row['fname']) . " " . text($row['lname']); ?></h2>
109 <span class=text><?php echo xlt('Status Type'); ?>: </span><br>
110 <?php
111 # Generate drop down list for status.
112 echo generate_select_list('statustype', 'apptstat',$trow['laststatus'], xl('Status Type'));
114 <br><br>
115 <span class=text><?php echo xlt('Exam Room Number'); ?>: </span><br>
116 <?php
117 # Generate drop down list for room number.
118 echo generate_select_list('roomnum', 'patient_flow_board_rooms',$trow['lastroom'], xl('Exam Room Number'));
120 <br><br>
121 <tr>
122 <td>
123 <a href='javascript:;' class='css_button_small' style='color:gray' onclick='document.getElementById("form_note").submit();'><span><?php echo xla('Save')?></span></a>
124 &nbsp;
125 <a href='javascript:;' class='css_button_small' style='color:gray' onclick="window.close().submit();" ><span><?php echo xla('Cancel'); ?></span></a>
126 </td>
127 </tr>
128 </table>
129 </td>
130 </form>
131 </center>
132 </body>
133 </html>