2 // Copyright (C) 2008 Rod Roark <rod@sunsetsystems.com>
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;
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
;
36 f
.form_newuser
.selectedIndex
= 0;
40 function userSelect() {
41 var f
= document
.forms
[0];
42 var i
= f
.form_newuser
.selectedIndex
;
44 f
.form_newloc
.selectedIndex
= 0;
52 <body
class="body_top">
55 <form method
='post' action
='chart_tracker.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 " .
65 "'" . date('Y-m-d H:i:s') . "', " .
70 echo "<font color='green'>Save Successful for chart ID '$form_curid'.</font><br />";
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);
85 echo "<font color='red'>Chart ID '$form_newid' not found!</font><br />";
94 $ct_userid = $row['ct_userid'];
95 $ct_location = $row['ct_location'];
96 $current_location = xl('Unassigned');
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'];
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";
116 echo " <td class='bold'>Name:</td>\n";
117 echo " <td class='text'>" . $row['lname'] . ", " . $row['fname'] . " " . $row['mname'] . "</td>\n";
121 echo " <td class='bold'>DOB:</td>\n";
122 echo " <td class='text'>" . $row['DOB'] . "</td>\n";
126 echo " <td class='bold'>SSN:</td>\n";
127 echo " <td class='text'>" . $row['ss'] . "</td>\n";
131 echo " <td class='bold'>Current Location:</td>\n";
132 echo " <td class='text'>$current_location</td>\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";
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'] .
159 echo " </select></td>\n";
163 echo " <td> </td>\n";
164 echo " <td class='text'><input type='submit' name='form_save' value='Save' /></td>\n";
168 echo " <td class='text' colspan='2'> </td>\n";
175 <?php
xl('New Patient ID','e'); ?
>:  
;
178 <input type
='text' name
='form_newid' size
='10' value
=''
179 class='inputtext' title
='<?php xl("Type or scan the patient identifier here","e") ?>' />
184 <td
class='bold'> 
;</td
>
186 <input type
='submit' class='button' name
='form_lookup' value
='<?php xl("Look Up","e"); ?>' />