incremented patch version 1
[openemr.git] / custom / chart_tracker.php
blob1121ff36d3cb3b17c96f7bcf13730c49d3102b38
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");
15 require_once("$srcdir/options.inc.php");
17 $form_newid = isset($_POST['form_newid' ]) ? trim($_POST['form_newid' ]) : '';
18 $form_curpid = isset($_POST['form_curpid' ]) ? trim($_POST['form_curpid' ]) : '';
19 $form_curid = isset($_POST['form_curid' ]) ? trim($_POST['form_curid' ]) : '';
20 $form_newloc = isset($_POST['form_newloc' ]) ? trim($_POST['form_newloc' ]) : '';
21 $form_newuser = isset($_POST['form_newuser']) ? trim($_POST['form_newuser']) : '';
23 if ($form_newuser) $form_newloc = ''; else $form_newuser = 0;
25 <html>
27 <head>
28 <link rel="stylesheet" href='<?php echo $css_header ?>' type='text/css'>
29 <title><?php xl('Chart Tracker','e'); ?></title>
31 <script language="JavaScript">
33 function locationSelect() {
34 var f = document.forms[0];
35 var i = f.form_newloc.selectedIndex;
36 if (i > 0) {
37 f.form_newuser.selectedIndex = 0;
41 function userSelect() {
42 var f = document.forms[0];
43 var i = f.form_newuser.selectedIndex;
44 if (i > 0) {
45 f.form_newloc.selectedIndex = 0;
49 </script>
51 </head>
53 <body class="body_top">
55 <?php
56 echo "<span class='title'>" . xl('Chart Tracker') . "</span>\n";
59 <center>
60 &nbsp;<br />
61 <form method='post' action='chart_tracker.php'>
63 <?php
64 // This is the place for status messages.
66 if ($form_newloc || $form_newuser) {
67 $query = "INSERT INTO chart_tracker ( " .
68 "ct_pid, ct_when, ct_userid, ct_location " .
69 ") VALUES ( " .
70 "'$form_curpid', " .
71 "'" . date('Y-m-d H:i:s') . "', " .
72 "'$form_newuser', " .
73 "'$form_newloc' " .
74 ")";
75 sqlInsert($query);
76 echo "<font color='green'>" . xl('Save Successful for chart ID','','',' ') . "'$form_curid'.</font><br />";
79 $row = array();
81 if ($form_newid) {
82 // Find out where the chart is now.
83 $query = "SELECT pd.pid, pd.pubpid, pd.fname, pd.mname, pd.lname, " .
84 "pd.ss, pd.DOB, ct.ct_userid, ct.ct_location, ct.ct_when " .
85 "FROM patient_data AS pd " .
86 "LEFT OUTER JOIN chart_tracker AS ct ON ct.ct_pid = pd.pid " .
87 "WHERE pd.pubpid = '$form_newid' " .
88 "ORDER BY pd.pid ASC, ct.ct_when DESC LIMIT 1";
89 $row = sqlQuery($query);
90 if (empty($row)) {
91 echo "<font color='red'>" . xl('Chart ID','','',' ') . "'$form_newid'" . xl('not found','',' ','') . "!</font><br />";
96 <table>
98 <?php
99 if (!empty($row)) {
100 $ct_userid = $row['ct_userid'];
101 $ct_location = $row['ct_location'];
102 $current_location = xl('Unassigned');
103 if ($ct_userid) {
104 $urow = sqlQuery("SELECT fname, mname, lname FROM users WHERE id = '$ct_userid'");
105 $current_location = htmlspecialchars( $urow['lname'] . ", " . $urow['fname'] . " " . $urow['mname'] . " " . $row['ct_when'] );
107 else if ($ct_location) {
108 $current_location = generate_display_field(array('data_type'=>'1','list_id'=>'chartloc'),$ct_location);
111 echo " <tr>\n";
112 echo " <td class='bold'>" . xl('Patient ID') . ":</td>\n";
113 echo " <td class='text'>" . $row['pubpid'] .
114 "<input type='hidden' name='form_curpid' value='" . $row['pid'] . "' />" .
115 "<input type='hidden' name='form_curid' value='" . $row['pubpid'] . "' /></td>\n";
116 echo " </tr>\n";
118 echo " <tr>\n";
119 echo " <td class='bold'>" . xl('Name') . ":</td>\n";
120 echo " <td class='text'>" . htmlspecialchars( $row['lname'] . ", " . $row['fname'] . " " . $row['mname'] ) . "</td>\n";
121 echo " </tr>\n";
123 echo " <tr>\n";
124 echo " <td class='bold'>" . xl('DOB') . ":</td>\n";
125 echo " <td class='text'>" . $row['DOB'] . "</td>\n";
126 echo " </tr>\n";
128 echo " <tr>\n";
129 echo " <td class='bold'>" . xl('SSN') . ":</td>\n";
130 echo " <td class='text'>" . $row['ss'] . "</td>\n";
131 echo " </tr>\n";
133 echo " <tr>\n";
134 echo " <td class='bold'>" . xl('Current Location') . ":</td>\n";
135 echo " <td class='text'>$current_location</td>\n";
136 echo " </tr>\n";
138 echo " <tr>\n";
139 echo " <td class='bold'>" . xl('Check In To') . ":</td>\n";
140 echo " <td class='text'>";
141 generate_form_field(array('data_type'=>1,'field_id'=>'newloc','list_id'=>'chartloc','empty_title'=>''), '');
142 echo " </td>\n";
143 echo " </tr>\n";
145 echo " <tr>\n";
146 echo " <td class='bold'>" . xl('Or Out To') . ":</td>\n";
147 echo " <td class='text'><select name='form_newuser' onchange='userSelect()'>\n";
148 echo " <option value=''></option>";
149 $ures = sqlStatement("SELECT id, fname, mname, lname FROM users " .
150 "WHERE username != '' AND active = 1 ORDER BY lname, fname, mname");
151 while ($urow = sqlFetchArray($ures)) {
152 echo " <option value='" . $urow['id'] . "'";
153 echo ">" . $urow['lname'] . ', ' . $urow['fname'] . ' ' . $urow['mname'] .
154 "</option>\n";
156 echo " </select></td>\n";
157 echo " </tr>\n";
159 echo " <tr>\n";
160 echo " <td>&nbsp;</td>\n";
161 echo " <td class='text'><input type='submit' name='form_save' value=" . xl('Save','','\'','\'') . " /></td>\n";
162 echo " </tr>\n";
164 echo " <tr>\n";
165 echo " <td class='text' colspan='2'>&nbsp;</td>\n";
166 echo " </tr>\n";
170 <tr>
171 <td class='bold'>
172 <?php xl('New Patient ID','e'); ?>: &nbsp;
173 </td>
174 <td class='text'>
175 <input type='text' name='form_newid' size='10' value=''
176 class='inputtext' title='<?php xl("Type or scan the patient identifier here","e") ?>' />
177 </td>
178 </tr>
180 <tr>
181 <td class='bold'>&nbsp;</td>
182 <td class='text'>
183 <input type='submit' class='button' name='form_lookup' value='<?php xl("Look Up","e"); ?>' />
184 </td>
185 </tr>
187 </table>
189 </form>
190 </center>
191 </body>
192 </html>