fix calendar css
[openemr.git] / custom / chart_tracker.php
blob7fe1e5ac2411bb2860fc71540398400ee5fc0395
1 <?php
2 /**
3 * This feature requires a new list:
4 * <pre>
5 * INSERT INTO list_options VALUES ('lists','chartloc','Chart Storage Locations',51,0,0);
6 * </pre>
8 * Copyright (C) 2008-2012 Rod Roark <rod@sunsetsystems.com>
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 2
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 Rod Roark <rod@sunsetsystems.com>
23 * @author Brady Miller <brady@sparmy.com>
24 * @link http://www.open-emr.org
27 $fake_register_globals=false;
28 $sanitize_all_escapes=true;
30 require_once("../interface/globals.php");
31 require_once("$srcdir/acl.inc");
32 require_once("$srcdir/options.inc.php");
34 $form_newid = isset($_POST['form_newid' ]) ? trim($_POST['form_newid' ]) : '';
35 $form_curpid = isset($_POST['form_curpid' ]) ? trim($_POST['form_curpid' ]) : '';
36 $form_curid = isset($_POST['form_curid' ]) ? trim($_POST['form_curid' ]) : '';
37 $form_newloc = isset($_POST['form_newloc' ]) ? trim($_POST['form_newloc' ]) : '';
38 $form_newuser = isset($_POST['form_newuser']) ? trim($_POST['form_newuser']) : '';
40 if ($form_newuser) $form_newloc = ''; else $form_newuser = 0;
42 <html>
44 <head>
45 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
46 <title><?php echo xlt('Chart Tracker'); ?></title>
48 <script language="JavaScript">
50 function locationSelect() {
51 var f = document.forms[0];
52 var i = f.form_newloc.selectedIndex;
53 if (i > 0) {
54 f.form_newuser.selectedIndex = 0;
58 function userSelect() {
59 var f = document.forms[0];
60 var i = f.form_newuser.selectedIndex;
61 if (i > 0) {
62 f.form_newloc.selectedIndex = 0;
66 </script>
68 </head>
70 <body class="body_top">
72 <?php
73 echo "<span class='title'>" . xlt('Chart Tracker') . "</span>\n";
76 <center>
77 &nbsp;<br />
78 <form method='post' action='chart_tracker.php' onsubmit='return top.restoreSession()'>
80 <?php
81 // This is the place for status messages.
83 if ($form_newloc || $form_newuser) {
84 $query = "INSERT INTO chart_tracker ( " .
85 "ct_pid, ct_when, ct_userid, ct_location " .
86 ") VALUES ( " .
87 "?, " .
88 "?, " .
89 "?, " .
90 "? " .
91 ")";
92 sqlInsert($query, array($form_curpid,date('Y-m-d H:i:s'),$form_newuser,$form_newloc) );
93 echo "<font color='green'>" . xlt('Save Successful for chart ID') . " " . "'" . text($form_curid) . "'.</font><br />";
96 $row = array();
98 if ($form_newid) {
99 // Find out where the chart is now.
100 $query = "SELECT pd.pid, pd.pubpid, pd.fname, pd.mname, pd.lname, " .
101 "pd.ss, pd.DOB, ct.ct_userid, ct.ct_location, ct.ct_when " .
102 "FROM patient_data AS pd " .
103 "LEFT OUTER JOIN chart_tracker AS ct ON ct.ct_pid = pd.pid " .
104 "WHERE pd.pubpid = ? " .
105 "ORDER BY pd.pid ASC, ct.ct_when DESC LIMIT 1";
106 $row = sqlQuery($query, array($form_newid) );
107 if (empty($row)) {
108 echo "<font color='red'>" . xlt('Chart ID') . " " . "'" . text($form_newid) . "' " . xlt('not found') . "!</font><br />";
113 <table>
115 <?php
116 if (!empty($row)) {
117 $ct_userid = $row['ct_userid'];
118 $ct_location = $row['ct_location'];
119 $current_location = xlt('Unassigned');
120 if ($ct_userid) {
121 $urow = sqlQuery("SELECT fname, mname, lname FROM users WHERE id = ?", array($ct_userid) );
122 $current_location = text( $urow['lname'] . ", " . $urow['fname'] . " " . $urow['mname'] . " " . $row['ct_when'] );
124 else if ($ct_location) {
125 $current_location = generate_display_field(array('data_type'=>'1','list_id'=>'chartloc'),$ct_location);
128 echo " <tr>\n";
129 echo " <td class='bold'>" . xlt('Patient ID') . ":</td>\n";
130 echo " <td class='text'>" . text($row['pubpid']) .
131 "<input type='hidden' name='form_curpid' value='" . attr($row['pid']) . "' />" .
132 "<input type='hidden' name='form_curid' value='" . attr($row['pubpid']) . "' /></td>\n";
133 echo " </tr>\n";
135 echo " <tr>\n";
136 echo " <td class='bold'>" . xlt('Name') . ":</td>\n";
137 echo " <td class='text'>" . text( $row['lname'] . ", " . $row['fname'] . " " . $row['mname'] ) . "</td>\n";
138 echo " </tr>\n";
140 echo " <tr>\n";
141 echo " <td class='bold'>" . xlt('DOB') . ":</td>\n";
142 echo " <td class='text'>" . text($row['DOB']) . "</td>\n";
143 echo " </tr>\n";
145 echo " <tr>\n";
146 echo " <td class='bold'>" . xlt('SSN') . ":</td>\n";
147 echo " <td class='text'>" . text($row['ss']) . "</td>\n";
148 echo " </tr>\n";
150 echo " <tr>\n";
151 echo " <td class='bold'>" . xlt('Current Location') . ":</td>\n";
152 // Note that $current_location has already been html escaped
153 echo " <td class='text'>$current_location</td>\n";
154 echo " </tr>\n";
156 echo " <tr>\n";
157 echo " <td class='bold'>" . xlt('Check In To') . ":</td>\n";
158 echo " <td class='text'>";
159 generate_form_field(array('data_type'=>1,'field_id'=>'newloc','list_id'=>'chartloc','empty_title'=>''), '');
160 echo " </td>\n";
161 echo " </tr>\n";
163 echo " <tr>\n";
164 echo " <td class='bold'>" . xlt('Or Out To') . ":</td>\n";
165 echo " <td class='text'><select name='form_newuser' onchange='userSelect()'>\n";
166 echo " <option value=''></option>";
167 $ures = sqlStatement("SELECT id, fname, mname, lname FROM users " .
168 "WHERE username != '' AND active = 1 ORDER BY lname, fname, mname");
169 while ($urow = sqlFetchArray($ures)) {
170 echo " <option value='" . attr($urow['id']) . "'";
171 echo ">" . text($urow['lname']) . ', ' . text($urow['fname']) . ' ' . text($urow['mname']) .
172 "</option>\n";
174 echo " </select></td>\n";
175 echo " </tr>\n";
177 echo " <tr>\n";
178 echo " <td>&nbsp;</td>\n";
179 echo " <td class='text'><input type='submit' name='form_save' value='" . xlt('Save') . "' /></td>\n";
180 echo " </tr>\n";
182 echo " <tr>\n";
183 echo " <td class='text' colspan='2'>&nbsp;</td>\n";
184 echo " </tr>\n";
188 <tr>
189 <td class='bold'>
190 <?php echo xlt('New Patient ID'); ?>: &nbsp;
191 </td>
192 <td class='text'>
193 <input type='text' name='form_newid' size='10' value=''
194 class='inputtext' title='<?php echo xla("Type or scan the patient identifier here") ?>' />
195 </td>
196 </tr>
198 <tr>
199 <td class='bold'>&nbsp;</td>
200 <td class='text'>
201 <input type='submit' class='button' name='form_lookup' value='<?php echo xla("Look Up"); ?>' />
202 </td>
203 </tr>
205 </table>
207 </form>
208 </center>
209 </body>
210 </html>