typo fixes from joe holzer
[openemr.git] / custom / chart_tracker.php
blobcb137945b6c97259eb03ec9a44dd2e2fd044a072
1 <?php
2 // Copyright (C) 2008 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This feature requires a new list:
11 // INSERT INTO list_options VALUES ('lists','chartloc','Chart Storage Locations',51,0,0);
13 require_once("../interface/globals.php");
14 require_once("$srcdir/acl.inc");
16 $form_newid = isset($_POST['form_newid' ]) ? trim($_POST['form_newid' ]) : '';
17 $form_curpid = isset($_POST['form_curpid' ]) ? trim($_POST['form_curpid' ]) : '';
18 $form_curid = isset($_POST['form_curid' ]) ? trim($_POST['form_curid' ]) : '';
19 $form_newloc = isset($_POST['form_newloc' ]) ? trim($_POST['form_newloc' ]) : '';
20 $form_newuser = isset($_POST['form_newuser']) ? trim($_POST['form_newuser']) : '';
22 if ($form_newuser) $form_newloc = ''; else $form_newuser = 0;
24 <html>
26 <head>
27 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
28 <title><?php xl('Chart Tracker','e'); ?></title>
30 <script language="JavaScript">
32 function locationSelect() {
33 var f = document.forms[0];
34 var i = f.form_newloc.selectedIndex;
35 if (i > 0) {
36 f.form_newuser.selectedIndex = 0;
40 function userSelect() {
41 var f = document.forms[0];
42 var i = f.form_newuser.selectedIndex;
43 if (i > 0) {
44 f.form_newloc.selectedIndex = 0;
48 </script>
50 </head>
52 <body class="body_top">
53 <center>
54 &nbsp;<br />
55 <form method='post' action='chart_tracker.php'>
57 <?php
58 // This is the place for status messages.
60 if ($form_newloc || $form_newuser) {
61 $query = "INSERT INTO chart_tracker ( " .
62 "ct_pid, ct_when, ct_userid, ct_location " .
63 ") VALUES ( " .
64 "'$form_curpid', " .
65 "'" . date('Y-m-d H:i:s') . "', " .
66 "'$form_newuser', " .
67 "'$form_newloc' " .
68 ")";
69 sqlInsert($query);
70 echo "<font color='green'>Save Successful for chart ID '$form_curid'.</font><br />";
73 $row = array();
75 if ($form_newid) {
76 // Find out where the chart is now.
77 $query = "SELECT pd.pid, pd.pubpid, pd.fname, pd.mname, pd.lname, " .
78 "pd.ss, pd.DOB, ct.ct_userid, ct.ct_location, ct.ct_when " .
79 "FROM patient_data AS pd " .
80 "LEFT OUTER JOIN chart_tracker AS ct ON ct.ct_pid = pd.pid " .
81 "WHERE pd.pubpid = '$form_newid' " .
82 "ORDER BY pd.pid ASC, ct.ct_when DESC LIMIT 1";
83 $row = sqlQuery($query);
84 if (empty($row)) {
85 echo "<font color='red'>Chart ID '$form_newid' not found!</font><br />";
90 <table>
92 <?php
93 if (!empty($row)) {
94 $ct_userid = $row['ct_userid'];
95 $ct_location = $row['ct_location'];
96 $current_location = xl('Unassigned');
97 if ($ct_userid) {
98 $urow = sqlQuery("SELECT fname, mname, lname FROM users WHERE id = '$ct_userid'");
99 $current_location = $urow['lname'] . ", " . $urow['fname'] . " " . $urow['mname'] .
100 " " . $row['ct_when'];
102 else if ($ct_location) {
103 $lrow = sqlQuery("SELECT title FROM list_options WHERE " .
104 "list_id = 'chartloc' AND option_id = '$ct_location'");
105 $current_location = $lrow['title'];
108 echo " <tr>\n";
109 echo " <td class='bold'>" . xl('Patient ID') . ":</td>\n";
110 echo " <td class='text'>" . $row['pubpid'] .
111 "<input type='hidden' name='form_curpid' value='" . $row['pid'] . "' />" .
112 "<input type='hidden' name='form_curid' value='" . $row['pubpid'] . "' /></td>\n";
113 echo " </tr>\n";
115 echo " <tr>\n";
116 echo " <td class='bold'>Name:</td>\n";
117 echo " <td class='text'>" . $row['lname'] . ", " . $row['fname'] . " " . $row['mname'] . "</td>\n";
118 echo " </tr>\n";
120 echo " <tr>\n";
121 echo " <td class='bold'>DOB:</td>\n";
122 echo " <td class='text'>" . $row['DOB'] . "</td>\n";
123 echo " </tr>\n";
125 echo " <tr>\n";
126 echo " <td class='bold'>SSN:</td>\n";
127 echo " <td class='text'>" . $row['ss'] . "</td>\n";
128 echo " </tr>\n";
130 echo " <tr>\n";
131 echo " <td class='bold'>Current Location:</td>\n";
132 echo " <td class='text'>$current_location</td>\n";
133 echo " </tr>\n";
135 echo " <tr>\n";
136 echo " <td class='bold'>Check In To:</td>\n";
137 echo " <td class='text'><select name='form_newloc' onchange='locationSelect()'>\n";
138 echo " <option value=''></option>";
139 $ores = sqlStatement("SELECT option_id, title FROM list_options " .
140 "WHERE list_id = 'chartloc' ORDER BY seq, title");
141 while ($orow = sqlFetchArray($ores)) {
142 echo " <option value='" . $orow['option_id'] . "'";
143 echo ">" . $orow['title'] . "</option>\n";
145 echo " </select></td>\n";
146 echo " </tr>\n";
148 echo " <tr>\n";
149 echo " <td class='bold'>Or Out To:</td>\n";
150 echo " <td class='text'><select name='form_newuser' onchange='userSelect()'>\n";
151 echo " <option value=''></option>";
152 $ures = sqlStatement("SELECT id, fname, mname, lname FROM users " .
153 "WHERE username != '' AND active = 1 ORDER BY lname, fname, mname");
154 while ($urow = sqlFetchArray($ures)) {
155 echo " <option value='" . $urow['id'] . "'";
156 echo ">" . $urow['lname'] . ', ' . $urow['fname'] . ' ' . $urow['mname'] .
157 "</option>\n";
159 echo " </select></td>\n";
160 echo " </tr>\n";
162 echo " <tr>\n";
163 echo " <td>&nbsp;</td>\n";
164 echo " <td class='text'><input type='submit' name='form_save' value='Save' /></td>\n";
165 echo " </tr>\n";
167 echo " <tr>\n";
168 echo " <td class='text' colspan='2'>&nbsp;</td>\n";
169 echo " </tr>\n";
173 <tr>
174 <td class='bold'>
175 <?php xl('New Patient ID','e'); ?>: &nbsp;
176 </td>
177 <td class='text'>
178 <input type='text' name='form_newid' size='10' value=''
179 class='inputtext' title='<?php xl("Type or scan the patient identifier here","e") ?>' />
180 </td>
181 </tr>
183 <tr>
184 <td class='bold'>&nbsp;</td>
185 <td class='text'>
186 <input type='submit' class='button' name='form_lookup' value='<?php xl("Look Up","e"); ?>' />
187 </td>
188 </tr>
190 </table>
192 </form>
193 </center>
194 </body>
195 </html>