minor improvement to tabs style
[openemr.git] / custom / chart_tracker.php
blobeb674ce820697c320cf394352498212d414c3e38
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.g.miller@gmail.com>
24 * @link http://www.open-emr.org
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 $tracker = new \entities\ChartTracker();
85 $tracker->setPid($form_curpid);
86 $tracker->setWhen(new \DateTime(date('Y-m-d H:i:s')));
87 $tracker->setUserId($form_newuser);
88 $tracker->setLocation($form_newloc);
89 $chartTrackerService = new \services\ChartTrackerService();
90 $chartTrackerService->trackPatientLocation($tracker);
91 echo "<font color='green'>" . xlt('Save Successful for chart ID') . " " . "'" . text($form_curid) . "'.</font><br />";
94 $row = array();
96 if ($form_newid) {
97 // Find out where the chart is now.
98 $query = "SELECT pd.pid, pd.pubpid, pd.fname, pd.mname, pd.lname, " .
99 "pd.ss, pd.DOB, ct.ct_userid, ct.ct_location, ct.ct_when " .
100 "FROM patient_data AS pd " .
101 "LEFT OUTER JOIN chart_tracker AS ct ON ct.ct_pid = pd.pid " .
102 "WHERE pd.pubpid = ? " .
103 "ORDER BY pd.pid ASC, ct.ct_when DESC LIMIT 1";
104 $row = sqlQuery($query, array($form_newid) );
105 if (empty($row)) {
106 echo "<font color='red'>" . xlt('Chart ID') . " " . "'" . text($form_newid) . "' " . xlt('not found') . "!</font><br />";
111 <table>
113 <?php
114 if (!empty($row)) {
115 $userService = new \services\UserService();
116 $ct_userid = $row['ct_userid'];
117 $ct_location = $row['ct_location'];
118 $current_location = xlt('Unassigned');
119 if ($ct_userid) {
120 $user = $userService->getUser($ct_userid);
121 $current_location = text( $user->getLname() . ", " . $user->getFname() . " " . $user->getMname() . " " . $row['ct_when'] );
123 else if ($ct_location) {
124 $current_location = generate_display_field(array('data_type'=>'1','list_id'=>'chartloc'),$ct_location);
127 echo " <tr>\n";
128 echo " <td class='bold'>" . xlt('Patient ID') . ":</td>\n";
129 echo " <td class='text'>" . text($row['pubpid']) .
130 "<input type='hidden' name='form_curpid' value='" . attr($row['pid']) . "' />" .
131 "<input type='hidden' name='form_curid' value='" . attr($row['pubpid']) . "' /></td>\n";
132 echo " </tr>\n";
134 echo " <tr>\n";
135 echo " <td class='bold'>" . xlt('Name') . ":</td>\n";
136 echo " <td class='text'>" . text( $row['lname'] . ", " . $row['fname'] . " " . $row['mname'] ) . "</td>\n";
137 echo " </tr>\n";
139 echo " <tr>\n";
140 echo " <td class='bold'>" . xlt('DOB') . ":</td>\n";
141 echo " <td class='text'>" . text($row['DOB']) . "</td>\n";
142 echo " </tr>\n";
144 echo " <tr>\n";
145 echo " <td class='bold'>" . xlt('SSN') . ":</td>\n";
146 echo " <td class='text'>" . text($row['ss']) . "</td>\n";
147 echo " </tr>\n";
149 echo " <tr>\n";
150 echo " <td class='bold'>" . xlt('Current Location') . ":</td>\n";
151 // Note that $current_location has already been html escaped
152 echo " <td class='text'>$current_location</td>\n";
153 echo " </tr>\n";
155 echo " <tr>\n";
156 echo " <td class='bold'>" . xlt('Check In To') . ":</td>\n";
157 echo " <td class='text'>";
158 generate_form_field(array('data_type'=>1,'field_id'=>'newloc','list_id'=>'chartloc','empty_title'=>''), '');
159 echo " </td>\n";
160 echo " </tr>\n";
162 echo " <tr>\n";
163 echo " <td class='bold'>" . xlt('Or Out To') . ":</td>\n";
164 echo " <td class='text'><select name='form_newuser' onchange='userSelect()'>\n";
165 echo " <option value=''></option>";
167 $users = $userService->getActiveUsers();
169 foreach($users as $activeUser) {
170 echo " <option value='" . attr($activeUser->getId()) . "'";
171 echo ">" . text($activeUser->getLname()) . ', ' . text($activeUser->getFname()) . ' ' . text($activeUser->getMname()) .
172 "</option>\n";
175 echo " </select></td>\n";
176 echo " </tr>\n";
178 echo " <tr>\n";
179 echo " <td>&nbsp;</td>\n";
180 echo " <td class='text'><input type='submit' name='form_save' value='" . xlt('Save') . "' /></td>\n";
181 echo " </tr>\n";
183 echo " <tr>\n";
184 echo " <td class='text' colspan='2'>&nbsp;</td>\n";
185 echo " </tr>\n";
189 <tr>
190 <td class='bold'>
191 <?php echo xlt('New Patient ID'); ?>: &nbsp;
192 </td>
193 <td class='text'>
194 <input type='text' name='form_newid' size='10' value=''
195 class='inputtext' title='<?php echo xla("Type or scan the patient identifier here") ?>' />
196 </td>
197 </tr>
199 <tr>
200 <td class='bold'>&nbsp;</td>
201 <td class='text'>
202 <input type='submit' class='button' name='form_lookup' value='<?php echo xla("Look Up"); ?>' />
203 </td>
204 </tr>
206 </table>
208 </form>
209 </center>
210 </body>
211 </html>