3 * The Chart Tracker feature facilitates the old traditional paper charts updates.
4 * This feature requires a new list:
6 * INSERT INTO list_options VALUES ('lists','chartloc','Chart Storage Locations',51,0,0);
10 * @link http://www.open-emr.org
11 * @author Rod Roark <rod@sunsetsystems.com>
12 * @author Brady Miller <brady.g.miller@gmail.com>
13 * @author Roberto Vasquez <robertogagliotta@gmail.com>
14 * @Copyright (C) 2008-2012 Rod Roark <rod@sunsetsystems.com>
15 * @Copyright (C) 2011-2018 Brady Miller <brady.g.miller@gmail.com>
16 * @Copyright (C) 2017 Roberto Vasquez <robertogagliotta@gmail.com>
20 require_once("../interface/globals.php");
21 require_once("$srcdir/acl.inc");
22 require_once("$srcdir/options.inc.php");
24 use OpenEMR\Common\Csrf\CsrfUtils
;
25 use OpenEMR\Core\Header
;
26 use OpenEMR\Entities\ChartTracker
;
27 use OpenEMR\Services\ChartTrackerService
;
28 use OpenEMR\Services\UserService
;
30 $form_newid = isset($_POST['form_newid' ]) ?
trim($_POST['form_newid' ]) : '';
31 $form_curpid = isset($_POST['form_curpid' ]) ?
trim($_POST['form_curpid' ]) : '';
32 $form_curid = isset($_POST['form_curid' ]) ?
trim($_POST['form_curid' ]) : '';
33 $form_newloc = isset($_POST['form_newloc' ]) ?
trim($_POST['form_newloc' ]) : '';
34 $form_newuser = isset($_POST['form_newuser']) ?
trim($_POST['form_newuser']) : '';
45 <?php Header
::setupHeader(); ?
>
46 <title
><?php
echo xlt('Chart Tracker'); ?
></title
>
48 <script language
="JavaScript">
50 function locationSelect() {
51 var f
= document
.forms
[0];
52 var i
= f
.form_newloc
.selectedIndex
;
54 f
.form_newuser
.selectedIndex
= 0;
58 function userSelect() {
59 var f
= document
.forms
[0];
60 var i
= f
.form_newuser
.selectedIndex
;
62 f
.form_newloc
.selectedIndex
= 0;
70 <body
class="body_top">
71 <div
class="container">
74 <div
class="col-xs-12">
75 <div
class="page-header">
76 <h1
><?php
echo xlt('Chart Tracker'); ?
></h1
>
81 <form method
='post' action
='chart_tracker.php' class='form-horizontal' onsubmit
='return top.restoreSession()'>
82 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
85 // This is the place for status messages.
87 if ($form_newloc ||
$form_newuser) {
88 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
89 CsrfUtils
::csrfNotVerified();
92 $tracker = new ChartTracker();
93 $tracker->setPid($form_curpid);
94 $tracker->setWhen(new \
DateTime(date('Y-m-d H:i:s')));
95 $tracker->setUserId($form_newuser);
96 $tracker->setLocation($form_newloc);
97 $chartTrackerService = new ChartTrackerService();
98 $chartTrackerService->trackPatientLocation($tracker);
99 echo "<div class='alert alert-success'>" . xlt('Save Successful for chart ID') . " " . "'" . text($form_curid) . "'.</div>";
105 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
106 CsrfUtils
::csrfNotVerified();
109 // Find out where the chart is now.
110 $query = "SELECT pd.pid, pd.pubpid, pd.fname, pd.mname, pd.lname, " .
111 "pd.ss, pd.DOB, ct.ct_userid, ct.ct_location, ct.ct_when " .
112 "FROM patient_data AS pd " .
113 "LEFT OUTER JOIN chart_tracker AS ct ON ct.ct_pid = pd.pid " .
114 "WHERE pd.pubpid = ? " .
115 "ORDER BY pd.pid ASC, ct.ct_when DESC LIMIT 1";
116 $row = sqlQuery($query, array($form_newid));
118 echo "<div class='alert alert-danger'>" . xlt('Chart ID') . " " . "'" . text($form_newid) . "' " . xlt('not found') . "!</div>";
125 $userService = new UserService();
126 $ct_userid = $row['ct_userid'];
127 $ct_location = $row['ct_location'];
128 $current_location = xlt('Unassigned');
130 $user = $userService->getUser($ct_userid);
131 $current_location = text($user->getLname() . ", " . $user->getFname() . " " . $user->getMname() . " " . oeFormatDateTime($row['ct_when'], "global", true));
132 } else if ($ct_location) {
133 $current_location = generate_display_field(array('data_type'=>'1','list_id'=>'chartloc'), $ct_location);
138 <div
class="col-sm-6 well">
139 <div
class="form-group">
140 <label
for="form_pat_id" class='control-label col-sm-3'><?php
echo xlt('Patient ID') . ":"; ?
></label
>
141 <div
class='col-sm-9'>
142 <p
class="form-control-static"><?php
echo text($row['pid']) ?
></p
>
143 <input type
='hidden' name
='form_curpid' value
='<?php echo attr($row['pid
']); ?>' />
144 <input type
='hidden' name
='form_curid' value
='<?php echo attr($row['pubpid
']); ?>' />
147 <div
class="form-group">
148 <label
for="form_pat_id" class='control-label col-sm-3'><?php
echo xlt('Name') . ":"; ?
></label
>
149 <div
class='col-sm-9'>
150 <p
class="form-control-static"><?php
echo text($row['lname'] . ", " . $row['fname'] . " " . $row['mname']) ?
></p
>
153 <div
class="form-group">
154 <label
for="form_pat_id" class='control-label col-sm-3'><?php
echo xlt('DOB') . ":"; ?
></label
>
155 <div
class='col-sm-9'>
156 <p
class="form-control-static"><?php
echo text(oeFormatShortDate($row['DOB'])) ?
></p
>
159 <div
class="form-group">
160 <label
for="form_pat_id" class='control-label col-sm-3'><?php
echo xlt('SSN') . ":"; ?
></label
>
161 <div
class='col-sm-9'>
162 <p
class="form-control-static"><?php
echo text($row['ss']) ?
></p
>
165 <div
class="form-group">
166 <label
for="form_pat_id" class='control-label col-sm-3'><?php
echo xlt('Current Location') . ":"; ?
></label
>
167 <div
class='col-sm-9'>
168 <p
class="form-control-static"><?php
echo text($current_location) ?
></p
>
171 <div
class="form-group">
172 <label
for="form_curr_loc" class='control-label col-sm-3'><?php
echo xlt('Check In To') . ":"; ?
></label
>
173 <div
class='col-sm-9'>
174 <?php
generate_form_field(array('data_type'=>1,'field_id'=>'newloc','list_id'=>'chartloc','empty_title'=>''), ''); ?
>
177 <div
class="form-group">
178 <label
for="form_out_to" class='control-label col-sm-3'><?php
echo xlt('Our Out To') . ":"; ?
></label
>
179 <div
class='col-sm-9'>
180 <select name
='form_newuser' class='form-control' onchange
='userSelect()'>
181 <option value
=''></option
>
183 $users = $userService->getActiveUsers();
185 foreach ($users as $activeUser) {
186 echo " <option value='" . attr($activeUser->getId()) . "'";
187 echo ">" . text($activeUser->getLname()) . ', ' . text($activeUser->getFname()) . ' ' . text($activeUser->getMname()) .
194 <div
class="form-group">
195 <div
class="col-sm-offset-3 col-sm-9">
196 <button type
='submit' class='btn btn-default btn-save' name
='form_save'><?php
echo xlt("Save"); ?
></button
>
206 <div
class="col-sm-6 well">
207 <div
class="form-group">
208 <label
for='form_newid' class='control-label col-sm-3'><?php
echo xlt('New Patient ID') . ":"; ?
></label
>
209 <div
class='col-sm-9'>
210 <input type
='text' name
='form_newid' id
='form_newid' class='form-control' title
='<?php echo xla('Type
or scan the patient identifier here
'); ?>'>
213 <div
class="form-group">
214 <div
class='col-sm-offset-3 col-sm-9'>
215 <button type
='submit' class='btn btn-default btn-search' name
='form_lookup'><?php
echo xlt("Look Up"); ?
></button
>