adding ubuntu cvs development package scripts with other pieces
[openemr.git] / custom / chart_tracker.php
blobddc09af6733b8571593d73d0e182919bda82d41f
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 = $urow['lname'] . ", " . $urow['fname'] . " " . $urow['mname'] .
106 " " . $row['ct_when'];
108 else if ($ct_location) {
109 $current_location = generate_display_field(array('data_type'=>'1','list_id'=>'chartloc'),$ct_location);
112 echo " <tr>\n";
113 echo " <td class='bold'>" . xl('Patient ID') . ":</td>\n";
114 echo " <td class='text'>" . $row['pubpid'] .
115 "<input type='hidden' name='form_curpid' value='" . $row['pid'] . "' />" .
116 "<input type='hidden' name='form_curid' value='" . $row['pubpid'] . "' /></td>\n";
117 echo " </tr>\n";
119 echo " <tr>\n";
120 echo " <td class='bold'>" . xl('Name') . ":</td>\n";
121 echo " <td class='text'>" . $row['lname'] . ", " . $row['fname'] . " " . $row['mname'] . "</td>\n";
122 echo " </tr>\n";
124 echo " <tr>\n";
125 echo " <td class='bold'>" . xl('DOB') . ":</td>\n";
126 echo " <td class='text'>" . $row['DOB'] . "</td>\n";
127 echo " </tr>\n";
129 echo " <tr>\n";
130 echo " <td class='bold'>" . xl('SSN') . ":</td>\n";
131 echo " <td class='text'>" . $row['ss'] . "</td>\n";
132 echo " </tr>\n";
134 echo " <tr>\n";
135 echo " <td class='bold'>" . xl('Current Location') . ":</td>\n";
136 echo " <td class='text'>$current_location</td>\n";
137 echo " </tr>\n";
139 echo " <tr>\n";
140 echo " <td class='bold'>" . xl('Check In To') . ":</td>\n";
141 echo " <td class='text'>";
142 generate_form_field(array('data_type'=>1,'field_id'=>'newloc','list_id'=>'chartloc','empty_title'=>''), '');
143 echo " </td>\n";
144 echo " </tr>\n";
146 echo " <tr>\n";
147 echo " <td class='bold'>" . xl('Or Out To') . ":</td>\n";
148 echo " <td class='text'><select name='form_newuser' onchange='userSelect()'>\n";
149 echo " <option value=''></option>";
150 $ures = sqlStatement("SELECT id, fname, mname, lname FROM users " .
151 "WHERE username != '' AND active = 1 ORDER BY lname, fname, mname");
152 while ($urow = sqlFetchArray($ures)) {
153 echo " <option value='" . $urow['id'] . "'";
154 echo ">" . $urow['lname'] . ', ' . $urow['fname'] . ' ' . $urow['mname'] .
155 "</option>\n";
157 echo " </select></td>\n";
158 echo " </tr>\n";
160 echo " <tr>\n";
161 echo " <td>&nbsp;</td>\n";
162 echo " <td class='text'><input type='submit' name='form_save' value=" . xl('Save','','\'','\'') . " /></td>\n";
163 echo " </tr>\n";
165 echo " <tr>\n";
166 echo " <td class='text' colspan='2'>&nbsp;</td>\n";
167 echo " </tr>\n";
171 <tr>
172 <td class='bold'>
173 <?php xl('New Patient ID','e'); ?>: &nbsp;
174 </td>
175 <td class='text'>
176 <input type='text' name='form_newid' size='10' value=''
177 class='inputtext' title='<?php xl("Type or scan the patient identifier here","e") ?>' />
178 </td>
179 </tr>
181 <tr>
182 <td class='bold'>&nbsp;</td>
183 <td class='text'>
184 <input type='submit' class='button' name='form_lookup' value='<?php xl("Look Up","e"); ?>' />
185 </td>
186 </tr>
188 </table>
190 </form>
191 </center>
192 </body>
193 </html>