forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchart_tracker.php
224 lines (197 loc) · 8.38 KB
/
chart_tracker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
/**
* The Chart Tracker feature facilitates the old traditional paper charts updates.
* This feature requires a new list:
* <pre>
* INSERT INTO list_options VALUES ('lists','chartloc','Chart Storage Locations',51,0,0);
* </pre>
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Rod Roark <[email protected]>
* @author Brady Miller <[email protected]>
* @author Roberto Vasquez <[email protected]>
* @Copyright (C) 2008-2012 Rod Roark <[email protected]>
* @Copyright (C) 2011-2018 Brady Miller <[email protected]>
* @Copyright (C) 2017 Roberto Vasquez <[email protected]>
*/
require_once("../interface/globals.php");
require_once("$srcdir/acl.inc");
require_once("$srcdir/options.inc.php");
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Core\Header;
use OpenEMR\Entities\ChartTracker;
use OpenEMR\Services\ChartTrackerService;
use OpenEMR\Services\UserService;
$form_newid = isset($_POST['form_newid' ]) ? trim($_POST['form_newid' ]) : '';
$form_curpid = isset($_POST['form_curpid' ]) ? trim($_POST['form_curpid' ]) : '';
$form_curid = isset($_POST['form_curid' ]) ? trim($_POST['form_curid' ]) : '';
$form_newloc = isset($_POST['form_newloc' ]) ? trim($_POST['form_newloc' ]) : '';
$form_newuser = isset($_POST['form_newuser']) ? trim($_POST['form_newuser']) : '';
if ($form_newuser) {
$form_newloc = '';
} else {
$form_newuser = 0;
}
?>
<html>
<head>
<?php Header::setupHeader(); ?>
<title><?php echo xlt('Chart Tracker'); ?></title>
<script language="JavaScript">
function locationSelect() {
var f = document.forms[0];
var i = f.form_newloc.selectedIndex;
if (i > 0) {
f.form_newuser.selectedIndex = 0;
}
}
function userSelect() {
var f = document.forms[0];
var i = f.form_newuser.selectedIndex;
if (i > 0) {
f.form_newloc.selectedIndex = 0;
}
}
</script>
</head>
<body class="body_top">
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="page-header">
<h1><?php echo xlt('Chart Tracker'); ?></h1>
</div>
</div>
</div>
<form method='post' action='chart_tracker.php' class='form-horizontal' onsubmit='return top.restoreSession()'>
<input type="hidden" name="csrf_token_form" value="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
<?php
// This is the place for status messages.
if ($form_newloc || $form_newuser) {
if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
CsrfUtils::csrfNotVerified();
}
$tracker = new ChartTracker();
$tracker->setPid($form_curpid);
$tracker->setWhen(new \DateTime(date('Y-m-d H:i:s')));
$tracker->setUserId($form_newuser);
$tracker->setLocation($form_newloc);
$chartTrackerService = new ChartTrackerService();
$chartTrackerService->trackPatientLocation($tracker);
echo "<div class='alert alert-success'>" . xlt('Save Successful for chart ID') . " " . "'" . text($form_curid) . "'.</div>";
}
$row = array();
if ($form_newid) {
if (!CsrfUtils::verifyCsrfToken($_POST["csrf_token_form"])) {
CsrfUtils::csrfNotVerified();
}
// Find out where the chart is now.
$query = "SELECT pd.pid, pd.pubpid, pd.fname, pd.mname, pd.lname, " .
"pd.ss, pd.DOB, ct.ct_userid, ct.ct_location, ct.ct_when " .
"FROM patient_data AS pd " .
"LEFT OUTER JOIN chart_tracker AS ct ON ct.ct_pid = pd.pid " .
"WHERE pd.pubpid = ? " .
"ORDER BY pd.pid ASC, ct.ct_when DESC LIMIT 1";
$row = sqlQuery($query, array($form_newid));
if (empty($row)) {
echo "<div class='alert alert-danger'>" . xlt('Chart ID') . " " . "'" . text($form_newid) . "' " . xlt('not found') . "!</div>";
}
}
?>
<?php
if (!empty($row)) {
$userService = new UserService();
$ct_userid = $row['ct_userid'];
$ct_location = $row['ct_location'];
$current_location = xlt('Unassigned');
if ($ct_userid) {
$user = $userService->getUser($ct_userid);
$current_location = text($user->getLname() . ", " . $user->getFname() . " " . $user->getMname() . " " . oeFormatDateTime($row['ct_when'], "global", true));
} else if ($ct_location) {
$current_location = generate_display_field(array('data_type'=>'1','list_id'=>'chartloc'), $ct_location);
}
?>
<div class="row">
<div class="col-sm-6 well">
<div class="form-group">
<label for="form_pat_id" class='control-label col-sm-3'><?php echo xlt('Patient ID') . ":"; ?></label>
<div class='col-sm-9'>
<p class="form-control-static"><?php echo text($row['pid']) ?></p>
<input type='hidden' name='form_curpid' value='<?php echo attr($row['pid']); ?>' />
<input type='hidden' name='form_curid' value='<?php echo attr($row['pubpid']); ?>' />
</div>
</div>
<div class="form-group">
<label for="form_pat_id" class='control-label col-sm-3'><?php echo xlt('Name') . ":"; ?></label>
<div class='col-sm-9'>
<p class="form-control-static"><?php echo text($row['lname'] . ", " . $row['fname'] . " " . $row['mname']) ?></p>
</div>
</div>
<div class="form-group">
<label for="form_pat_id" class='control-label col-sm-3'><?php echo xlt('DOB') . ":"; ?></label>
<div class='col-sm-9'>
<p class="form-control-static"><?php echo text(oeFormatShortDate($row['DOB'])) ?></p>
</div>
</div>
<div class="form-group">
<label for="form_pat_id" class='control-label col-sm-3'><?php echo xlt('SSN') . ":"; ?></label>
<div class='col-sm-9'>
<p class="form-control-static"><?php echo text($row['ss']) ?></p>
</div>
</div>
<div class="form-group">
<label for="form_pat_id" class='control-label col-sm-3'><?php echo xlt('Current Location') . ":"; ?></label>
<div class='col-sm-9'>
<p class="form-control-static"><?php echo text($current_location) ?></p>
</div>
</div>
<div class="form-group">
<label for="form_curr_loc" class='control-label col-sm-3'><?php echo xlt('Check In To') . ":"; ?></label>
<div class='col-sm-9'>
<?php generate_form_field(array('data_type'=>1,'field_id'=>'newloc','list_id'=>'chartloc','empty_title'=>''), ''); ?>
</div>
</div>
<div class="form-group">
<label for="form_out_to" class='control-label col-sm-3'><?php echo xlt('Our Out To') . ":"; ?></label>
<div class='col-sm-9'>
<select name='form_newuser' class='form-control' onchange='userSelect()'>
<option value=''></option>
<?php
$users = $userService->getActiveUsers();
foreach ($users as $activeUser) {
echo " <option value='" . attr($activeUser->getId()) . "'";
echo ">" . text($activeUser->getLname()) . ', ' . text($activeUser->getFname()) . ' ' . text($activeUser->getMname()) .
"</option>\n";
}
?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type='submit' class='btn btn-default btn-save' name='form_save'><?php echo xlt("Save"); ?></button>
</div>
</div>
</div>
<?php
}
?>
<div class="row">
<div class="col-sm-6 well">
<div class="form-group">
<label for='form_newid' class='control-label col-sm-3'><?php echo xlt('New Patient ID') . ":"; ?></label>
<div class='col-sm-9'>
<input type='text' name='form_newid' id='form_newid' class='form-control' title='<?php echo xla('Type or scan the patient identifier here'); ?>'>
</div>
</div>
<div class="form-group">
<div class='col-sm-offset-3 col-sm-9'>
<button type='submit' class='btn btn-default btn-search' name='form_lookup'><?php echo xlt("Look Up"); ?></button>
</div>
</div>
</div>
</form>
</div>
</body>
</html>